提交 64b53b6a 编写于 作者: M mw0 提交者: wangzelin.wzl

patch backup &migrate code to open source

上级 a2c22b06
...@@ -18,10 +18,10 @@ ...@@ -18,10 +18,10 @@
namespace oceanbase { namespace oceanbase {
namespace common { namespace common {
const char* OB_STORAGE_TYPES_STR[] = {"OSS", "FILE", "COS"}; const char *OB_STORAGE_TYPES_STR[] = {"OSS", "FILE", "COS"};
void print_access_storage_log( void print_access_storage_log(
const char* msg, const common::ObString& uri, const int64_t start_ts, const int64_t size, bool* is_slow) const char *msg, const common::ObString &uri, const int64_t start_ts, const int64_t size, bool *is_slow)
{ {
if (NULL != is_slow) { if (NULL != is_slow) {
*is_slow = false; *is_slow = false;
...@@ -48,7 +48,7 @@ void print_access_storage_log( ...@@ -48,7 +48,7 @@ void print_access_storage_log(
} }
} }
int get_storage_type_from_path(const common::ObString& uri, ObStorageType& type) int get_storage_type_from_path(const common::ObString &uri, ObStorageType &type)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
type = OB_STORAGE_MAX_TYPE; type = OB_STORAGE_MAX_TYPE;
...@@ -66,9 +66,9 @@ int get_storage_type_from_path(const common::ObString& uri, ObStorageType& type) ...@@ -66,9 +66,9 @@ int get_storage_type_from_path(const common::ObString& uri, ObStorageType& type)
return ret; return ret;
} }
const char* get_storage_type_str(const ObStorageType& type) const char *get_storage_type_str(const ObStorageType &type)
{ {
const char* str = "UNKNOWN"; const char *str = "UNKNOWN";
STATIC_ASSERT( STATIC_ASSERT(
static_cast<int64_t>(OB_STORAGE_MAX_TYPE) == ARRAYSIZEOF(OB_STORAGE_TYPES_STR), "ObStorageType count mismatch"); static_cast<int64_t>(OB_STORAGE_MAX_TYPE) == ARRAYSIZEOF(OB_STORAGE_TYPES_STR), "ObStorageType count mismatch");
if (type >= 0 && type < OB_STORAGE_MAX_TYPE) { if (type >= 0 && type < OB_STORAGE_MAX_TYPE) {
...@@ -82,7 +82,7 @@ bool is_io_error(const int result) ...@@ -82,7 +82,7 @@ bool is_io_error(const int result)
return OB_IO_ERROR == result || OB_OSS_ERROR == result; return OB_IO_ERROR == result || OB_OSS_ERROR == result;
} }
int get_storage_type_from_name(const char* type_str, ObStorageType& type) int get_storage_type_from_name(const char *type_str, ObStorageType &type)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
type = ObStorageType::OB_STORAGE_MAX_TYPE; type = ObStorageType::OB_STORAGE_MAX_TYPE;
...@@ -131,11 +131,11 @@ ObStorageUtil::ObStorageUtil(const bool need_retry, const int64_t max_retry_dura ...@@ -131,11 +131,11 @@ ObStorageUtil::ObStorageUtil(const bool need_retry, const int64_t max_retry_dura
} }
} }
int ObStorageUtil::is_exist(const common::ObString& uri, const common::ObString& storage_info, bool& exist) int ObStorageUtil::is_exist(const common::ObString &uri, const common::ObString &storage_info, bool &exist)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
exist = false; exist = false;
#ifdef ERRSIM #ifdef ERRSIM
...@@ -156,11 +156,11 @@ int ObStorageUtil::is_exist(const common::ObString& uri, const common::ObString& ...@@ -156,11 +156,11 @@ int ObStorageUtil::is_exist(const common::ObString& uri, const common::ObString&
} }
int ObStorageUtil::get_file_length( int ObStorageUtil::get_file_length(
const common::ObString& uri, const common::ObString& storage_info, int64_t& file_length) const common::ObString &uri, const common::ObString &storage_info, int64_t &file_length)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
file_length = -1; file_length = -1;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -203,11 +203,11 @@ int ObStorageUtil::get_file_length( ...@@ -203,11 +203,11 @@ int ObStorageUtil::get_file_length(
return ret; return ret;
} }
int ObStorageUtil::del_file(const common::ObString& uri, const common::ObString& storage_info) int ObStorageUtil::del_file(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
#ifdef ERRSIM #ifdef ERRSIM
ret = E(EventTable::EN_BACKUP_IO_BEFORE_DEL_FILE) OB_SUCCESS; ret = E(EventTable::EN_BACKUP_IO_BEFORE_DEL_FILE) OB_SUCCESS;
...@@ -252,11 +252,11 @@ int ObStorageUtil::del_file(const common::ObString& uri, const common::ObString& ...@@ -252,11 +252,11 @@ int ObStorageUtil::del_file(const common::ObString& uri, const common::ObString&
return ret; return ret;
} }
int ObStorageUtil::mkdir(const common::ObString& uri, const common::ObString& storage_info) int ObStorageUtil::mkdir(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
STORAGE_LOG(DEBUG, "mkdir", K(uri)); STORAGE_LOG(DEBUG, "mkdir", K(uri));
#ifdef ERRSIM #ifdef ERRSIM
...@@ -280,7 +280,7 @@ int ObStorageUtil::mkdir(const common::ObString& uri, const common::ObString& st ...@@ -280,7 +280,7 @@ int ObStorageUtil::mkdir(const common::ObString& uri, const common::ObString& st
return ret; return ret;
} }
int ObStorageUtil::mk_parent_dir(const common::ObString& uri, const common::ObString& storage_info) int ObStorageUtil::mk_parent_dir(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
char path[OB_MAX_URI_LENGTH]; char path[OB_MAX_URI_LENGTH];
...@@ -318,8 +318,8 @@ int ObStorageUtil::mk_parent_dir(const common::ObString& uri, const common::ObSt ...@@ -318,8 +318,8 @@ int ObStorageUtil::mk_parent_dir(const common::ObString& uri, const common::ObSt
return ret; return ret;
} }
int ObStorageUtil::read_single_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, int ObStorageUtil::read_single_file(const common::ObString &uri, const common::ObString &storage_info, char *buf,
const int64_t buf_size, int64_t& read_size) const int64_t buf_size, int64_t &read_size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
...@@ -354,8 +354,8 @@ int ObStorageUtil::read_single_file(const common::ObString& uri, const common::O ...@@ -354,8 +354,8 @@ int ObStorageUtil::read_single_file(const common::ObString& uri, const common::O
return ret; return ret;
} }
int ObStorageUtil::do_read_single_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, int ObStorageUtil::do_read_single_file(const common::ObString &uri, const common::ObString &storage_info, char *buf,
const int64_t buf_size, int64_t& read_size) const int64_t buf_size, int64_t &read_size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
...@@ -384,7 +384,7 @@ int ObStorageUtil::do_read_single_file(const common::ObString& uri, const common ...@@ -384,7 +384,7 @@ int ObStorageUtil::do_read_single_file(const common::ObString& uri, const common
// has '\0' in the end // has '\0' in the end
int ObStorageUtil::read_single_text_file( int ObStorageUtil::read_single_text_file(
const common::ObString& uri, const common::ObString& storage_info, char* buf, const int64_t buf_size) const common::ObString &uri, const common::ObString &storage_info, char *buf, const int64_t buf_size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int64_t read_size = -1; int64_t read_size = -1;
...@@ -404,11 +404,11 @@ int ObStorageUtil::read_single_text_file( ...@@ -404,11 +404,11 @@ int ObStorageUtil::read_single_text_file(
return ret; return ret;
} }
int ObStorageUtil::update_file_modify_time(const common::ObString& uri, const common::ObString& storage_info) int ObStorageUtil::update_file_modify_time(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -446,12 +446,12 @@ int ObStorageUtil::update_file_modify_time(const common::ObString& uri, const co ...@@ -446,12 +446,12 @@ int ObStorageUtil::update_file_modify_time(const common::ObString& uri, const co
return ret; return ret;
} }
int ObStorageUtil::list_files(const common::ObString& uri, const common::ObString& storage_info, int ObStorageUtil::list_files(const common::ObString &uri, const common::ObString &storage_info,
common::ObIAllocator& allocator, common::ObIArray<common::ObString>& file_names) common::ObIAllocator &allocator, common::ObIArray<common::ObString> &file_names)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -492,11 +492,11 @@ int ObStorageUtil::list_files(const common::ObString& uri, const common::ObStrin ...@@ -492,11 +492,11 @@ int ObStorageUtil::list_files(const common::ObString& uri, const common::ObStrin
} }
int ObStorageUtil::write_single_file( int ObStorageUtil::write_single_file(
const common::ObString& uri, const common::ObString& storage_info, const char* buf, const int64_t size) const common::ObString &uri, const common::ObString &storage_info, const char *buf, const int64_t size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -544,7 +544,7 @@ int ObStorageUtil::write_single_file( ...@@ -544,7 +544,7 @@ int ObStorageUtil::write_single_file(
return ret; return ret;
} }
int ObStorageUtil::get_util(const common::ObString& uri, ObIStorageUtil*& util) int ObStorageUtil::get_util(const common::ObString &uri, ObIStorageUtil *&util)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObStorageType type = OB_STORAGE_MAX_TYPE; ObStorageType type = OB_STORAGE_MAX_TYPE;
...@@ -568,8 +568,8 @@ int ObStorageUtil::get_util(const common::ObString& uri, ObIStorageUtil*& util) ...@@ -568,8 +568,8 @@ int ObStorageUtil::get_util(const common::ObString& uri, ObIStorageUtil*& util)
return ret; return ret;
} }
int ObStorageUtil::read_part_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, int ObStorageUtil::read_part_file(const common::ObString &uri, const common::ObString &storage_info, char *buf,
const int64_t buf_size, const int64_t offset, int64_t& read_size) const int64_t buf_size, const int64_t offset, int64_t &read_size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
...@@ -600,8 +600,8 @@ int ObStorageUtil::read_part_file(const common::ObString& uri, const common::ObS ...@@ -600,8 +600,8 @@ int ObStorageUtil::read_part_file(const common::ObString& uri, const common::ObS
return ret; return ret;
} }
int ObStorageUtil::do_read_part_file(const common::ObString& uri, const common::ObString& storage_info, char* buf, int ObStorageUtil::do_read_part_file(const common::ObString &uri, const common::ObString &storage_info, char *buf,
const int64_t buf_size, const int64_t offset, int64_t& read_size) const int64_t buf_size, const int64_t offset, int64_t &read_size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
...@@ -623,11 +623,11 @@ int ObStorageUtil::do_read_part_file(const common::ObString& uri, const common:: ...@@ -623,11 +623,11 @@ int ObStorageUtil::do_read_part_file(const common::ObString& uri, const common::
return ret; return ret;
} }
int ObStorageUtil::del_dir(const common::ObString& uri, const common::ObString& storage_info) int ObStorageUtil::del_dir(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -657,11 +657,11 @@ int ObStorageUtil::del_dir(const common::ObString& uri, const common::ObString& ...@@ -657,11 +657,11 @@ int ObStorageUtil::del_dir(const common::ObString& uri, const common::ObString&
} }
int ObStorageUtil::get_pkeys_from_dir( int ObStorageUtil::get_pkeys_from_dir(
const common::ObString& uri, const common::ObString& storage_info, common::ObIArray<common::ObPartitionKey>& pkeys) const common::ObString &uri, const common::ObString &storage_info, common::ObIArray<common::ObPartitionKey> &pkeys)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -695,11 +695,11 @@ int ObStorageUtil::get_pkeys_from_dir( ...@@ -695,11 +695,11 @@ int ObStorageUtil::get_pkeys_from_dir(
return ret; return ret;
} }
int ObStorageUtil::delete_tmp_files(const common::ObString& uri, const common::ObString& storage_info) int ObStorageUtil::delete_tmp_files(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -738,7 +738,7 @@ int ObStorageUtil::delete_tmp_files(const common::ObString& uri, const common::O ...@@ -738,7 +738,7 @@ int ObStorageUtil::delete_tmp_files(const common::ObString& uri, const common::O
} }
int ObStorageUtil::check_backup_dest_lifecycle( int ObStorageUtil::check_backup_dest_lifecycle(
const common::ObString& path, const common::ObString& storage_info, bool& is_set_lifecycle) const common::ObString &path, const common::ObString &storage_info, bool &is_set_lifecycle)
{ {
int ret = OB_NOT_SUPPORTED; int ret = OB_NOT_SUPPORTED;
...@@ -785,12 +785,12 @@ int ObStorageUtil::check_backup_dest_lifecycle( ...@@ -785,12 +785,12 @@ int ObStorageUtil::check_backup_dest_lifecycle(
} }
int ObStorageUtil::is_empty_directory( int ObStorageUtil::is_empty_directory(
const common::ObString& uri, const common::ObString& storage_info, bool& is_empty_directory) const common::ObString &uri, const common::ObString &storage_info, bool &is_empty_directory)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
is_empty_directory = false; is_empty_directory = false;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -819,12 +819,12 @@ int ObStorageUtil::is_empty_directory( ...@@ -819,12 +819,12 @@ int ObStorageUtil::is_empty_directory(
return ret; return ret;
} }
int ObStorageUtil::list_directories(const common::ObString& uri, const common::ObString& storage_info, int ObStorageUtil::list_directories(const common::ObString &uri, const common::ObString &storage_info,
common::ObIAllocator& allocator, common::ObIArray<common::ObString>& directory_names) common::ObIAllocator &allocator, common::ObIArray<common::ObString> &directory_names)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
ObIStorageUtil* util = NULL; ObIStorageUtil *util = NULL;
int64_t retry_times = 0; int64_t retry_times = 0;
bool need_retry = true; bool need_retry = true;
...@@ -857,8 +857,7 @@ int ObStorageUtil::list_directories(const common::ObString& uri, const common::O ...@@ -857,8 +857,7 @@ int ObStorageUtil::list_directories(const common::ObString& uri, const common::O
return ret; return ret;
} }
ObStorageReader::ObStorageReader() ObStorageReader::ObStorageReader() : file_length_(-1), reader_(NULL), start_ts_(0)
: file_length_(-1), reader_(NULL), start_ts_(0)
{ {
uri_[0] = '\0'; uri_[0] = '\0';
} }
...@@ -870,7 +869,7 @@ ObStorageReader::~ObStorageReader() ...@@ -870,7 +869,7 @@ ObStorageReader::~ObStorageReader()
} }
} }
int ObStorageReader::open(const common::ObString& uri, const common::ObString& storage_info) int ObStorageReader::open(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
...@@ -921,7 +920,7 @@ int ObStorageReader::open(const common::ObString& uri, const common::ObString& s ...@@ -921,7 +920,7 @@ int ObStorageReader::open(const common::ObString& uri, const common::ObString& s
return ret; return ret;
} }
int ObStorageReader::pread(char* buf, const int64_t buf_size, int64_t offset, int64_t& read_size) int ObStorageReader::pread(char *buf, const int64_t buf_size, int64_t offset, int64_t &read_size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
read_size = 0; read_size = 0;
...@@ -987,7 +986,7 @@ ObStorageWriter::~ObStorageWriter() ...@@ -987,7 +986,7 @@ ObStorageWriter::~ObStorageWriter()
} }
} }
int ObStorageWriter::open(const common::ObString& uri, const common::ObString& storage_info) int ObStorageWriter::open(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
...@@ -1035,7 +1034,7 @@ int ObStorageWriter::open(const common::ObString& uri, const common::ObString& s ...@@ -1035,7 +1034,7 @@ int ObStorageWriter::open(const common::ObString& uri, const common::ObString& s
return ret; return ret;
} }
int ObStorageWriter::write(const char* buf, const int64_t size) int ObStorageWriter::write(const char *buf, const int64_t size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
...@@ -1103,7 +1102,7 @@ ObStorageAppender::~ObStorageAppender() ...@@ -1103,7 +1102,7 @@ ObStorageAppender::~ObStorageAppender()
} }
int ObStorageAppender::open( int ObStorageAppender::open(
const common::ObString& uri, const common::ObString& storage_info, const AppenderParam& param) const common::ObString &uri, const common::ObString &storage_info, const AppenderParam &param)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
...@@ -1156,7 +1155,7 @@ int ObStorageAppender::open( ...@@ -1156,7 +1155,7 @@ int ObStorageAppender::open(
return ret; return ret;
} }
int ObStorageAppender::open_deprecated(const common::ObString& uri, const common::ObString& storage_info) int ObStorageAppender::open_deprecated(const common::ObString &uri, const common::ObString &storage_info)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
int tmp_ret = OB_SUCCESS; int tmp_ret = OB_SUCCESS;
...@@ -1206,7 +1205,7 @@ int ObStorageAppender::open_deprecated(const common::ObString& uri, const common ...@@ -1206,7 +1205,7 @@ int ObStorageAppender::open_deprecated(const common::ObString& uri, const common
return ret; return ret;
} }
int ObStorageAppender::write(const char* buf, const int64_t size) int ObStorageAppender::write(const char *buf, const int64_t size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
...@@ -1235,7 +1234,7 @@ int ObStorageAppender::write(const char* buf, const int64_t size) ...@@ -1235,7 +1234,7 @@ int ObStorageAppender::write(const char* buf, const int64_t size)
return ret; return ret;
} }
int ObStorageAppender::pwrite(const char* buf, const int64_t size, const int64_t offset) int ObStorageAppender::pwrite(const char *buf, const int64_t size, const int64_t offset)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
...@@ -1294,11 +1293,11 @@ ObStorageMetaWrapper::ObStorageMetaWrapper() : file_meta_() ...@@ -1294,11 +1293,11 @@ ObStorageMetaWrapper::ObStorageMetaWrapper() : file_meta_()
ObStorageMetaWrapper::~ObStorageMetaWrapper() ObStorageMetaWrapper::~ObStorageMetaWrapper()
{} {}
int ObStorageMetaWrapper::get(const common::ObString& uri, const common::ObString& storage_info, char* buf, int ObStorageMetaWrapper::get(const common::ObString &uri, const common::ObString &storage_info, char *buf,
const int64_t buf_size, int64_t& read_size) const int64_t buf_size, int64_t &read_size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObIStorageMetaWrapper* meta = NULL; ObIStorageMetaWrapper *meta = NULL;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
if (ObStorageGlobalIns::get_instance().is_io_prohibited()) { if (ObStorageGlobalIns::get_instance().is_io_prohibited()) {
...@@ -1320,10 +1319,10 @@ int ObStorageMetaWrapper::get(const common::ObString& uri, const common::ObStrin ...@@ -1320,10 +1319,10 @@ int ObStorageMetaWrapper::get(const common::ObString& uri, const common::ObStrin
} }
int ObStorageMetaWrapper::set( int ObStorageMetaWrapper::set(
const common::ObString& uri, const common::ObString& storage_info, const char* buf, const int64_t size) const common::ObString &uri, const common::ObString &storage_info, const char *buf, const int64_t size)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObIStorageMetaWrapper* meta = NULL; ObIStorageMetaWrapper *meta = NULL;
const int64_t start_ts = ObTimeUtility::current_time(); const int64_t start_ts = ObTimeUtility::current_time();
if (ObStorageGlobalIns::get_instance().is_io_prohibited()) { if (ObStorageGlobalIns::get_instance().is_io_prohibited()) {
...@@ -1344,7 +1343,7 @@ int ObStorageMetaWrapper::set( ...@@ -1344,7 +1343,7 @@ int ObStorageMetaWrapper::set(
return ret; return ret;
} }
int ObStorageMetaWrapper::get_meta(const common::ObString& uri, ObIStorageMetaWrapper*& meta) int ObStorageMetaWrapper::get_meta(const common::ObString &uri, ObIStorageMetaWrapper *&meta)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
ObStorageType type = OB_STORAGE_MAX_TYPE; ObStorageType type = OB_STORAGE_MAX_TYPE;
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
#define TRACEPOINT_CALL(name, ...) \ #define TRACEPOINT_CALL(name, ...) \
({ \ ({ \
static void** func_ptr = ::oceanbase::common::tracepoint_get(name); \ static void **func_ptr = ::oceanbase::common::tracepoint_get(name); \
(NULL != func_ptr) ? TP_CALL_FUNC(func_ptr, ##__VA_ARGS__) : 0; \ (NULL != func_ptr) ? TP_CALL_FUNC(func_ptr, ##__VA_ARGS__) : 0; \
}) })
...@@ -77,13 +77,13 @@ ...@@ -77,13 +77,13 @@
#define OB_I(...) #define OB_I(...)
#endif #endif
bool& get_tp_switch(); bool &get_tp_switch();
#define TP_SWITCH_GUARD(v) ::oceanbase::lib::ObSwitchGuard<get_tp_switch> osg_##__COUNTER__##_(v) #define TP_SWITCH_GUARD(v) ::oceanbase::lib::ObSwitchGuard<get_tp_switch> osg_##__COUNTER__##_(v)
namespace oceanbase { namespace oceanbase {
namespace lib { namespace lib {
using GetSwitchFunc = bool&(); using GetSwitchFunc = bool &();
template <GetSwitchFunc fn> template <GetSwitchFunc fn>
class ObSwitchGuard { class ObSwitchGuard {
...@@ -130,23 +130,23 @@ private: ...@@ -130,23 +130,23 @@ private:
} }
#define TP_SET(file_name, func_name, key, trace_func) \ #define TP_SET(file_name, func_name, key, trace_func) \
*::oceanbase::common::tracepoint_get(refine_tp_key(file_name, func_name, key)) = (void*)(trace_func) *::oceanbase::common::tracepoint_get(refine_tp_key(file_name, func_name, key)) = (void *)(trace_func)
#define TP_SET_ERROR(file_name, func_name, key, err) \ #define TP_SET_ERROR(file_name, func_name, key, err) \
TP_SET(file_name, func_name, key, (int (*)()) & tp_const_error<(err)>) TP_SET(file_name, func_name, key, (int (*)()) & tp_const_error<(err)>)
namespace oceanbase { namespace oceanbase {
namespace common { namespace common {
inline const char* tp_basename(const char* path) inline const char *tp_basename(const char *path)
{ {
const char* ret = OB_ISNULL(path) ? NULL : strrchr(path, '/'); const char *ret = OB_ISNULL(path) ? NULL : strrchr(path, '/');
return (NULL == ret) ? path : ++ret; return (NULL == ret) ? path : ++ret;
} }
inline const char* refine_tp_key(const char* s1, const char* s2, const char* s3) inline const char *refine_tp_key(const char *s1, const char *s2, const char *s3)
{ {
const int32_t BUFFER_SIZE = 256; const int32_t BUFFER_SIZE = 256;
static RLOCAL(lib::ByteBuf<BUFFER_SIZE>, buffer); static RLOCAL(lib::ByteBuf<BUFFER_SIZE>, buffer);
const char* cret = nullptr; const char *cret = nullptr;
if (OB_ISNULL(s1) || OB_ISNULL(s2) || OB_ISNULL(s3)) { if (OB_ISNULL(s1) || OB_ISNULL(s2) || OB_ISNULL(s3)) {
} else { } else {
s1 = tp_basename(s1); s1 = tp_basename(s1);
...@@ -168,13 +168,13 @@ public: ...@@ -168,13 +168,13 @@ public:
{} {}
~TPSymbolTable() ~TPSymbolTable()
{} {}
void** get(const char* name) void **get(const char *name)
{ {
return (NULL != name) ? do_get(name) : NULL; return (NULL != name) ? do_get(name) : NULL;
} }
private: private:
static uint64_t BKDRHash(const char* str); static uint64_t BKDRHash(const char *str);
enum { SYMBOL_SIZE_LIMIT = 128, SYMBOL_COUNT_LIMIT = 64 * 1024 }; enum { SYMBOL_SIZE_LIMIT = 128, SYMBOL_COUNT_LIMIT = 64 * 1024 };
struct SymbolEntry { struct SymbolEntry {
...@@ -186,19 +186,19 @@ private: ...@@ -186,19 +186,19 @@ private:
~SymbolEntry() ~SymbolEntry()
{} {}
bool find(const char* name); bool find(const char *name);
int lock_; int lock_;
void* value_; void *value_;
char name_[SYMBOL_SIZE_LIMIT]; char name_[SYMBOL_SIZE_LIMIT];
}; };
void** do_get(const char* name); void **do_get(const char *name);
SymbolEntry symbol_table_[SYMBOL_COUNT_LIMIT]; SymbolEntry symbol_table_[SYMBOL_COUNT_LIMIT];
}; };
inline void** tracepoint_get(const char* name) inline void **tracepoint_get(const char *name)
{ {
static TPSymbolTable symbol_table; static TPSymbolTable symbol_table;
return symbol_table.get(name); return symbol_table.get(name);
...@@ -233,7 +233,7 @@ struct EventItem { ...@@ -233,7 +233,7 @@ struct EventItem {
}; };
struct NamedEventItem : public ObDLinkBase<NamedEventItem> { struct NamedEventItem : public ObDLinkBase<NamedEventItem> {
NamedEventItem(const char* name, ObDList<NamedEventItem>& l) : name_(name) NamedEventItem(const char *name, ObDList<NamedEventItem> &l) : name_(name)
{ {
l.add_last(this); l.add_last(this);
} }
...@@ -242,7 +242,7 @@ struct NamedEventItem : public ObDLinkBase<NamedEventItem> { ...@@ -242,7 +242,7 @@ struct NamedEventItem : public ObDLinkBase<NamedEventItem> {
return item_.call(); return item_.call();
} }
const char* name_; const char *name_;
EventItem item_; EventItem item_;
}; };
...@@ -442,6 +442,9 @@ public: ...@@ -442,6 +442,9 @@ public:
EN_BACKUP_AFTER_UPDATE_EXTERNAL_BOTH_PIECE_INFO_FOR_SYS = 180, EN_BACKUP_AFTER_UPDATE_EXTERNAL_BOTH_PIECE_INFO_FOR_SYS = 180,
EN_BACKUP_BACKUPPIECE_FINISH_UPDATE_EXTERN_AND_INNER_INFO = 181, EN_BACKUP_BACKUPPIECE_FINISH_UPDATE_EXTERN_AND_INNER_INFO = 181,
EN_BACKUP_BACKUPPIECE_DO_SCHEDULE = 182, EN_BACKUP_BACKUPPIECE_DO_SCHEDULE = 182,
EN_BACKUP_UPDATE_START_REPLAY_LOG_TS = 183,
EN_BACKUP_BACKUPSET_DO_SCHEDULE = 184,
EN_BACKUP_CHECK_BACKUP_POINT_EXIST = 185,
// 下面请从201开始 // 下面请从201开始
EN_CHECK_STANDBY_CLUSTER_SCHEMA_CONDITION = 201, EN_CHECK_STANDBY_CLUSTER_SCHEMA_CONDITION = 201,
EN_ALLOCATE_LOB_BUF_FAILED = 202, EN_ALLOCATE_LOB_BUF_FAILED = 202,
...@@ -507,14 +510,14 @@ public: ...@@ -507,14 +510,14 @@ public:
} }
/* set an event value */ /* set an event value */
inline void set_event(int64_t index, const EventItem& item) inline void set_event(int64_t index, const EventItem &item)
{ {
if (index >= 0 && index < SIZE_OF_EVENT_TABLE) { if (index >= 0 && index < SIZE_OF_EVENT_TABLE) {
event_table_[index] = item; event_table_[index] = item;
} }
} }
static inline void set_event(const char* name, const EventItem& item) static inline void set_event(const char *name, const EventItem &item)
{ {
DLIST_FOREACH_NORET(i, global_item_list()) DLIST_FOREACH_NORET(i, global_item_list())
{ {
...@@ -524,13 +527,13 @@ public: ...@@ -524,13 +527,13 @@ public:
} }
} }
static ObDList<NamedEventItem>& global_item_list() static ObDList<NamedEventItem> &global_item_list()
{ {
static ObDList<NamedEventItem> g_list; static ObDList<NamedEventItem> g_list;
return g_list; return g_list;
} }
static EventTable& instance() static EventTable &instance()
{ {
static EventTable et; static EventTable et;
return et; return et;
...@@ -545,7 +548,7 @@ private: ...@@ -545,7 +548,7 @@ private:
}; };
inline void event_access(int64_t index, /* tracepoint number */ inline void event_access(int64_t index, /* tracepoint number */
EventItem& item, bool is_get) /* is a 'get' */ EventItem &item, bool is_get) /* is a 'get' */
{ {
if (is_get) if (is_get)
item = EventTable::instance().get_event(index); item = EventTable::instance().get_event(index);
......
...@@ -55,7 +55,7 @@ TEST_F(TestStorageOss, test_del) ...@@ -55,7 +55,7 @@ TEST_F(TestStorageOss, test_del)
databuff_printf( databuff_printf(
storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_)); storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_));
const ObString storage_info(storage_infos); const ObString storage_info(storage_infos);
const char* dir_name = "test"; const char *dir_name = "test";
char test_content[OB_MAX_URI_LENGTH] = "just_for_test"; char test_content[OB_MAX_URI_LENGTH] = "just_for_test";
int64_t read_size = 0; int64_t read_size = 0;
...@@ -79,8 +79,9 @@ TEST_F(TestStorageOss, test_get_pkey_from_path) ...@@ -79,8 +79,9 @@ TEST_F(TestStorageOss, test_get_pkey_from_path)
char storage_infos[OB_MAX_URI_LENGTH]; char storage_infos[OB_MAX_URI_LENGTH];
ObArenaAllocator allocator; ObArenaAllocator allocator;
ASSERT_EQ(OB_SUCCESS, databuff_printf(storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", ASSERT_EQ(OB_SUCCESS,
oss_host_, oss_id_, oss_key_)); databuff_printf(
storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_));
const ObString storage_info(storage_infos); const ObString storage_info(storage_infos);
const char *dir_name = "test/pkeys"; const char *dir_name = "test/pkeys";
char test_content[OB_MAX_URI_LENGTH] = "just_for_test"; char test_content[OB_MAX_URI_LENGTH] = "just_for_test";
...@@ -88,7 +89,14 @@ TEST_F(TestStorageOss, test_get_pkey_from_path) ...@@ -88,7 +89,14 @@ TEST_F(TestStorageOss, test_get_pkey_from_path)
const ObPartitionKey pkey(1100611139403779, 0, 0); const ObPartitionKey pkey(1100611139403779, 0, 0);
ObArray<ObPartitionKey> pkeys; ObArray<ObPartitionKey> pkeys;
ASSERT_EQ(OB_SUCCESS, databuff_printf(uri, sizeof(uri), "%s/%s/%lu/%ld/test_file", test_oss_bucket_, dir_name, pkey.get_table_id(), pkey.get_partition_id())); ASSERT_EQ(OB_SUCCESS,
databuff_printf(uri,
sizeof(uri),
"%s/%s/%lu/%ld/test_file",
test_oss_bucket_,
dir_name,
pkey.get_table_id(),
pkey.get_partition_id()));
ASSERT_EQ(OB_SUCCESS, databuff_printf(dir_uri, sizeof(dir_uri), "%s/%s/", test_oss_bucket_, dir_name)); ASSERT_EQ(OB_SUCCESS, databuff_printf(dir_uri, sizeof(dir_uri), "%s/%s/", test_oss_bucket_, dir_name));
STORAGE_LOG(INFO, "uri and dir uri", K(uri), K(dir_uri)); STORAGE_LOG(INFO, "uri and dir uri", K(uri), K(dir_uri));
...@@ -114,8 +122,9 @@ TEST_F(TestStorageOss, test_get_bucket_lifecycle) ...@@ -114,8 +122,9 @@ TEST_F(TestStorageOss, test_get_bucket_lifecycle)
ObArenaAllocator allocator; ObArenaAllocator allocator;
bool is_set_lifecycle = false; bool is_set_lifecycle = false;
ASSERT_EQ(OB_SUCCESS, databuff_printf(storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", ASSERT_EQ(OB_SUCCESS,
oss_host_, oss_id_, oss_key_)); databuff_printf(
storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_));
const ObString storage_info(storage_infos); const ObString storage_info(storage_infos);
ASSERT_EQ(OB_SUCCESS, databuff_printf(uri, sizeof(uri), "%s/xuanyi_61/hahaha", test_oss_bucket_)); ASSERT_EQ(OB_SUCCESS, databuff_printf(uri, sizeof(uri), "%s/xuanyi_61/hahaha", test_oss_bucket_));
...@@ -123,7 +132,66 @@ TEST_F(TestStorageOss, test_get_bucket_lifecycle) ...@@ -123,7 +132,66 @@ TEST_F(TestStorageOss, test_get_bucket_lifecycle)
ASSERT_EQ(true, is_set_lifecycle); ASSERT_EQ(true, is_set_lifecycle);
} }
TEST_F(TestStorageOss, test_get_pkey_from_path)
{
ObStorageUtil util(false);
char uri[OB_MAX_URI_LENGTH];
char dir_uri[OB_MAX_URI_LENGTH];
char storage_infos[OB_MAX_URI_LENGTH];
ObArenaAllocator allocator;
ASSERT_EQ(OB_SUCCESS,
databuff_printf(
storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_));
const ObString storage_info(storage_infos);
const char *dir_name = "test/pkeys";
char test_content[OB_MAX_URI_LENGTH] = "just_for_test";
int64_t read_size = 0;
const ObPartitionKey pkey(1100611139403779, 0, 0);
ObArray<ObPartitionKey> pkeys;
ASSERT_EQ(OB_SUCCESS,
databuff_printf(uri,
sizeof(uri),
"%s/%s/%lu/%ld/test_file",
test_oss_bucket_,
dir_name,
pkey.get_table_id(),
pkey.get_partition_id()));
ASSERT_EQ(OB_SUCCESS, databuff_printf(dir_uri, sizeof(dir_uri), "%s/%s/", test_oss_bucket_, dir_name));
STORAGE_LOG(INFO, "uri and dir uri", K(uri), K(dir_uri));
ASSERT_EQ(OB_SUCCESS, util.write_single_file(uri, storage_info, test_content, 0));
ASSERT_EQ(OB_SUCCESS, util.get_file_length(uri, storage_info, read_size));
ASSERT_EQ(OB_SUCCESS, util.get_pkeys_from_dir(dir_uri, storage_info, pkeys));
ASSERT_TRUE(!pkeys.empty());
bool found = false;
for (int64_t i = 0; pkeys.count() && !found; ++i) {
const ObPartitionKey &tmp_pkey = pkeys.at(i);
if (tmp_pkey == pkey) {
found = true;
}
}
ASSERT_TRUE(found);
}
TEST_F(TestStorageOss, test_get_bucket_lifecycle)
{
ObStorageUtil util(false);
char uri[OB_MAX_URI_LENGTH];
char storage_infos[OB_MAX_URI_LENGTH];
ObArenaAllocator allocator;
bool is_set_lifecycle = false;
ASSERT_EQ(OB_SUCCESS,
databuff_printf(
storage_infos, sizeof(storage_infos), "host=%s&access_id=%s&access_key=%s", oss_host_, oss_id_, oss_key_));
const ObString storage_info(storage_infos);
ASSERT_EQ(OB_SUCCESS, databuff_printf(uri, sizeof(uri), "%s/xuanyi_61/hahaha", test_oss_bucket_));
ASSERT_EQ(OB_SUCCESS, util.check_bucket_lifecycle(uri, storage_info, is_set_lifecycle));
ASSERT_EQ(true, is_set_lifecycle);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
......
...@@ -207,6 +207,74 @@ int ObServerReloadConfig::operator()() ...@@ -207,6 +207,74 @@ int ObServerReloadConfig::operator()()
} }
} }
// backup zone and region support
{
ObString backup_zone_str = GCONF.backup_zone.get_value_string();
ObString backup_region_str = GCONF.backup_region.get_value_string();
bool prev_io_stat = ObStorageGlobalIns::get_instance().is_io_prohibited();
bool prohibited = true;
LOG_INFO("backup zone and region", K(backup_zone_str), K(backup_region_str));
if (backup_zone_str.empty() && backup_region_str.empty()) {
// Both backup region and zone are not set, IO operation is allowed.
prohibited = false;
} else if (!backup_zone_str.empty() && !backup_region_str.empty()) {
// Both backup region and zone exist, not allowed, something wrong unexpected.
ret = OB_ERR_UNEXPECTED;
LOG_WARN("backup region and zone both are set, which are unexpected.", K(ret), K(backup_zone_str), K(backup_region_str));
} else if (!backup_zone_str.empty()) {
// Backup zone is set.
ObArray<ObBackupZone> backup_zone;
if (OB_FAIL(ObBackupUtils::parse_backup_format_input(backup_zone_str, MAX_ZONE_LENGTH, backup_zone))) {
LOG_WARN("failed to parse backup zone format", K(ret), K(backup_zone_str));
} else if (backup_zone.empty()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("backup zone is empty", K(ret), K(backup_zone_str));
} else {
const ObZone zone = GCONF.zone.str();
LOG_INFO("set backup zone", K(zone), K(backup_zone_str), K(backup_zone));
for (int64_t i = 0; i < backup_zone.count(); i++) {
// I am in black list, IO operations are allowed.
if (zone == backup_zone[i].zone_) {
prohibited = false;
break;
}
}
}
} else {
// Backup region is set.
ObArray<ObBackupRegion> backup_region;
ObRegion region;
if (OB_FAIL(ObBackupUtils::parse_backup_format_input(backup_region_str, MAX_REGION_LENGTH, backup_region))) {
LOG_WARN("failed to parse backup region format", K(ret), K(backup_region_str));
} else if (backup_region.empty()) {
ret = OB_ERR_UNEXPECTED;
LOG_WARN("backup region is empty", K(ret), K(backup_region_str));
} else if (OB_FAIL(ObServer::get_instance().get_partition_service().get_locality_manager()->load_region())) {
LOG_WARN("get local region failed", K(ret), K(backup_region_str));
} else if (OB_FAIL(ObServer::get_instance().get_partition_service().get_locality_manager()->get_local_region(region))) {
LOG_WARN("get local region failed", K(ret), K(backup_region_str));
} else {
LOG_INFO("set backup region", K(region), K(backup_region_str), K(backup_region));
for (int64_t i = 0; i < backup_region.count(); i++) {
// I am in black list, IO operations are allowed.
if (region == backup_region[i].region_) {
prohibited = false;
break;
}
}
}
}
if (OB_SUCC(ret) && prev_io_stat != prohibited) {
ObStorageGlobalIns::get_instance().set_io_prohibited(prohibited);
if (prev_io_stat != prohibited) {
FLOG_WARN("backup set_io_prohibited", K(ret), K(prohibited), K(prev_io_stat));
}
}
}
const int64_t cache_size = GCONF.memory_chunk_cache_size; const int64_t cache_size = GCONF.memory_chunk_cache_size;
const int cache_cnt = cache_size > 0 ? cache_size / INTACT_ACHUNK_SIZE : INT32_MAX; const int cache_cnt = cache_size > 0 ? cache_size / INTACT_ACHUNK_SIZE : INT32_MAX;
lib::AChunkMgr::instance().set_max_chunk_cache_cnt(cache_cnt); lib::AChunkMgr::instance().set_max_chunk_cache_cnt(cache_cnt);
......
...@@ -1916,7 +1916,18 @@ int ObService::migrate_replica_batch(const obrpc::ObMigrateReplicaBatchArg& arg) ...@@ -1916,7 +1916,18 @@ int ObService::migrate_replica_batch(const obrpc::ObMigrateReplicaBatchArg& arg)
int ObService::standby_cutdata_batch_task(const obrpc::ObStandbyCutDataBatchTaskArg& arg) int ObService::standby_cutdata_batch_task(const obrpc::ObStandbyCutDataBatchTaskArg& arg)
{ {
int ret = OB_SUCCESS; int ret = OB_SUCCESS;
LOG_INFO("receive standby_cutdata_batch_task request", K(arg)); LOG_INFO("receive standby cut data batch request", K(arg));
if (!inited_) {
ret = OB_NOT_INIT;
LOG_WARN("ObService not init", K(ret));
} else if (!arg.is_valid()) {
ret = OB_INVALID_ARGUMENT;
LOG_WARN("invalid arg", K(arg), K(ret));
} else if (OB_FAIL(gctx_.par_ser_->standby_cut_data_batch(arg))) {
LOG_WARN("add migrate batch fail", K(arg), K(ret));
} else {
LOG_INFO("standby cut data batch successfully", K(arg));
}
return ret; return ret;
} }
...@@ -3728,3 +3739,4 @@ int ObService::broadcast_locations(const obrpc::ObPartitionBroadcastArg& arg, ob ...@@ -3728,3 +3739,4 @@ int ObService::broadcast_locations(const obrpc::ObPartitionBroadcastArg& arg, ob
} // end namespace observer } // end namespace observer
} // end namespace oceanbase } // end namespace oceanbase
此差异已折叠。
...@@ -2020,7 +2020,8 @@ bool ObTenantBackupTaskItem::is_valid() const ...@@ -2020,7 +2020,8 @@ bool ObTenantBackupTaskItem::is_valid() const
bool ObTenantBackupTaskItem::is_same_task(const ObTenantBackupTaskItem& other) const bool ObTenantBackupTaskItem::is_same_task(const ObTenantBackupTaskItem& other) const
{ {
return tenant_id_ == other.tenant_id_ && backup_set_id_ == other.backup_set_id_ && incarnation_ == other.incarnation_; return tenant_id_ == other.tenant_id_ && backup_set_id_ == other.backup_set_id_ &&
incarnation_ == other.incarnation_ && copy_id_ == other.copy_id_;
} }
bool ObTenantBackupTaskItem::is_result_succeed() const bool ObTenantBackupTaskItem::is_result_succeed() const
...@@ -2067,6 +2068,21 @@ int ObTenantBackupTaskItem::set_backup_task_status(const char* buf) ...@@ -2067,6 +2068,21 @@ int ObTenantBackupTaskItem::set_backup_task_status(const char* buf)
return ret; return ret;
} }
uint64_t ObTenantBackupTaskItem::hash() const
{
uint64_t hash_val = 0;
hash_val = murmurhash(&tenant_id_, sizeof(tenant_id_), hash_val);
hash_val = murmurhash(&incarnation_, sizeof(incarnation_), hash_val);
hash_val = murmurhash(&backup_set_id_, sizeof(backup_set_id_), hash_val);
hash_val = murmurhash(&copy_id_, sizeof(copy_id_), hash_val);
return hash_val;
}
bool ObTenantBackupTaskItem::operator==(const ObTenantBackupTaskItem &other) const
{
return is_same_task(other);
}
ObPGBackupTaskItem::ObPGBackupTaskItem() ObPGBackupTaskItem::ObPGBackupTaskItem()
: tenant_id_(OB_INVALID_ID), : tenant_id_(OB_INVALID_ID),
table_id_(OB_INVALID_ID), table_id_(OB_INVALID_ID),
......
...@@ -949,7 +949,9 @@ public: ...@@ -949,7 +949,9 @@ public:
bool is_same_task(const ObTenantBackupTaskItem& other) const; bool is_same_task(const ObTenantBackupTaskItem& other) const;
bool is_result_succeed() const; bool is_result_succeed() const;
const char* get_backup_task_status_str() const; const char* get_backup_task_status_str() const;
int set_backup_task_status(const char* buf); int set_backup_task_status(const char *buf);
uint64_t hash() const;
bool operator==(const ObTenantBackupTaskItem &other) const;
TO_STRING_KV(K_(tenant_id), K_(backup_set_id), K_(incarnation), K_(snapshot_version), K_(prev_full_backup_set_id), TO_STRING_KV(K_(tenant_id), K_(backup_set_id), K_(incarnation), K_(snapshot_version), K_(prev_full_backup_set_id),
K_(prev_inc_backup_set_id), K_(prev_backup_data_version), K_(pg_count), K_(macro_block_count), K_(prev_inc_backup_set_id), K_(prev_backup_data_version), K_(pg_count), K_(macro_block_count),
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -4739,6 +4739,12 @@ int ObPGStorage::set_restore_flag( ...@@ -4739,6 +4739,12 @@ int ObPGStorage::set_restore_flag(
ObPartitionGroupMeta& next_meta = *next_meta_ptr; ObPartitionGroupMeta& next_meta = *next_meta_ptr;
if (REPLICA_RESTORE_LOG == restore_flag) { if (REPLICA_RESTORE_LOG == restore_flag) {
if (!is_sys_table(pkey_.get_table_id())) { if (!is_sys_table(pkey_.get_table_id())) {
ObRole role;
if (OB_FAIL(pg_->get_role(role))) {
LOG_WARN("failed to get role", K(ret));
} else if (ObRole::FOLLOWER == role) {
DEBUG_SYNC(FOLLOWER_BEFORE_UPDATE_RESTORE_FLAG_RESTORE_LOG);
}
DEBUG_SYNC(BEFORE_UPDATE_RESTORE_FLAG_RESTORE_LOG); DEBUG_SYNC(BEFORE_UPDATE_RESTORE_FLAG_RESTORE_LOG);
} }
} }
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册