[liboblog] support storage work mode

This commit is contained in:
SanmuWangZJU
2022-03-25 18:10:38 +08:00
committed by LINxiansheng
parent 8b88f1f1bd
commit 463064375a
255 changed files with 964 additions and 462 deletions

View File

@ -30,5 +30,5 @@ add_subdirectory(share)
add_subdirectory(rootserver)
add_subdirectory(tools)
if (OB_BUILD_LIBOBLOG)
add_subdirectory(liboblog)
add_subdirectory(obcdc)
endif()

View File

@ -1,34 +0,0 @@
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
link_directories(${DEP_DIR}/lib/mariadb)
function(liboblog_unittest case)
if(ARGC EQUAL 1)
add_executable(${case} ${case}.cpp)
else()
add_executable(${ARGV})
endif()
target_link_libraries(${case} PRIVATE oceanbase oblog gtest gmock)
disable_pch(${case})
target_include_directories(${case}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/unittest ${CMAKE_SOURCE_DIR}/deps/oblib/unittest ${DEP_DIR}/include)
endfunction()
liboblog_unittest(test_log_part_mgr)
liboblog_unittest(test_log_task_pool)
liboblog_unittest(test_small_arena)
#liboblog_unittest(test_log_config) // TODO may core, need fix
liboblog_unittest(test_log_fake_common_config)
liboblog_unittest(test_log_table_matcher)
liboblog_unittest(test_ob_map_queue)
liboblog_unittest(test_ob_map_queue_thread)
liboblog_unittest(test_ob_log_timer)
liboblog_unittest(test_ob_log_dlist)
liboblog_unittest(test_ob_log_part_svr_list)
liboblog_unittest(test_ob_log_all_svr_cache)
liboblog_unittest(test_ob_log_start_log_id_locator)
liboblog_unittest(test_ob_log_heartbeater)
liboblog_unittest(test_log_utils)
liboblog_unittest(test_ob_log_adapt_string)
liboblog_unittest(test_ob_concurrent_seq_queue)
liboblog_unittest(test_ob_seq_thread)
liboblog_unittest(test_ob_log_part_trans_resolver_new)
liboblog_unittest(test_log_svr_blacklist)

View File

@ -0,0 +1,30 @@
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
link_directories(${DEP_DIR}/lib/mariadb)
function(libobcdc_unittest case)
ob_unittest(${ARGV})
target_link_libraries(${case} PRIVATE obcdc)
disable_pch(${case})
target_include_directories(${case}
PRIVATE ${PROJECT_SOURCE_DIR}/tools ${CMAKE_SOURCE_DIR}/unittest ${CMAKE_SOURCE_DIR}/deps/oblib/unittest ${DEP_DIR}/include)
endfunction()
libobcdc_unittest(test_log_part_mgr)
libobcdc_unittest(test_log_task_pool)
libobcdc_unittest(test_small_arena)
libobcdc_unittest(test_log_config)
libobcdc_unittest(test_log_fake_common_config)
libobcdc_unittest(test_log_table_matcher)
libobcdc_unittest(test_ob_map_queue)
libobcdc_unittest(test_ob_map_queue_thread)
libobcdc_unittest(test_ob_log_timer)
libobcdc_unittest(test_ob_log_dlist)
libobcdc_unittest(test_ob_log_part_svr_list)
libobcdc_unittest(test_ob_log_all_svr_cache)
libobcdc_unittest(test_ob_log_start_log_id_locator)
libobcdc_unittest(test_ob_log_heartbeater)
libobcdc_unittest(test_log_utils)
libobcdc_unittest(test_ob_log_adapt_string)
libobcdc_unittest(test_ob_concurrent_seq_queue)
libobcdc_unittest(test_ob_seq_thread)
libobcdc_unittest(test_ob_log_part_trans_resolver_new)
libobcdc_unittest(test_log_svr_blacklist)

View File

@ -92,10 +92,10 @@ void TestLogConfig::SetUp()
ADD_CONFIG_STR(log_level, "INFO");
ADD_CONFIG_STR(cluster_url, "http:://www.test_url.com/abcdefg/");
ADD_CONFIG_STR(cluster_user, "中华人民共和国");
ADD_CONFIG_STR(cluster_password, "阿里巴巴");
ADD_CONFIG_STR(cluster_user, "cdc");
ADD_CONFIG_STR(cluster_password, "V587");
ADD_CONFIG_STR(config_fpath, "/home/abcdefg/hijklmn");
ADD_CONFIG_STR(cluster_appname, "obtest");
ADD_CONFIG_STR(cluster_appname, "obcdc");
ADD_CONFIG_STR(cluster_db_name, "oceanbase");
ADD_CONFIG_STR(timezone, "+8:00");
ADD_CONFIG_STR(tb_white_list, "*.*.*");
@ -108,60 +108,71 @@ void TestLogConfig::SetUp()
TEST_F(TestLogConfig, init)
{
LOG_INFO("sizeof ObLogConfig");
ObLogConfig config;
ObLogConfig *config = new ObLogConfig();
EXPECT_EQ(OB_SUCCESS, config.init());
EXPECT_EQ(OB_SUCCESS, config->init());
// After initialization, the configuration items are not detected by default
EXPECT_NE(OB_SUCCESS, config.check_all());
config.print();
EXPECT_NE(OB_SUCCESS, config->check_all());
config->print();
if (NULL != config) {
delete config;
config = NULL;
}
}
TEST_F(TestLogConfig, load_from_buffer)
{
ObLogConfig config;
EXPECT_EQ(OB_SUCCESS, config.init());
ObLogConfig *config = new ObLogConfig();
EXPECT_EQ(OB_SUCCESS, config->init());
EXPECT_EQ(OB_SUCCESS, config.load_from_buffer(config_buf_, strlen(config_buf_)));
EXPECT_EQ(OB_SUCCESS, config.check_all());
config.print();
EXPECT_EQ(OB_SUCCESS, config->load_from_buffer(config_buf_, strlen(config_buf_)));
EXPECT_EQ(OB_SUCCESS, config->check_all());
config->print();
EXPECT_EQ(dml_parser_thread_num, config.dml_parser_thread_num);
EXPECT_EQ(sequencer_thread_num, config.sequencer_thread_num);
EXPECT_EQ(formatter_thread_num, config.formatter_thread_num);
EXPECT_EQ(0, strcmp(cluster_url, config.cluster_url.str()));
EXPECT_EQ(0, strcmp(log_level, config.log_level.str()));
EXPECT_EQ(0, strcmp(cluster_user, config.cluster_user.str()));
EXPECT_EQ(0, strcmp(cluster_password, config.cluster_password.str()));
EXPECT_EQ(0, strcmp(config_fpath, config.config_fpath.str()));
EXPECT_EQ(dml_parser_thread_num, config->dml_parser_thread_num);
EXPECT_EQ(sequencer_thread_num, config->sequencer_thread_num);
EXPECT_EQ(formatter_thread_num, config->formatter_thread_num);
EXPECT_EQ(0, strcmp(cluster_url, config->cluster_url.str()));
EXPECT_EQ(0, strcmp(log_level, config->log_level.str()));
EXPECT_EQ(0, strcmp(cluster_user, config->cluster_user.str()));
EXPECT_EQ(0, strcmp(cluster_password, config->cluster_password.str()));
EXPECT_EQ(0, strcmp(config_fpath, config->config_fpath.str()));
bool check_name = true;
int64_t version = 0;
EXPECT_NE(OB_SUCCESS,
config.load_from_buffer(config_buf_, strlen(config_buf_), version, check_name));
config->load_from_buffer(config_buf_, strlen(config_buf_), version, check_name));
if (NULL != config) {
delete config;
config = NULL;
}
}
TEST_F(TestLogConfig, load_from_map)
{
ObLogConfig config;
EXPECT_EQ(OB_SUCCESS, config.init());
ObLogConfig *config = new ObLogConfig();
EXPECT_EQ(OB_SUCCESS, config->init());
EXPECT_EQ(OB_SUCCESS, config.load_from_map(config_map_));
EXPECT_EQ(OB_SUCCESS, config.check_all());
config.print();
EXPECT_EQ(OB_SUCCESS, config->load_from_map(config_map_));
EXPECT_EQ(OB_SUCCESS, config->check_all());
config->print();
EXPECT_EQ(dml_parser_thread_num, config.dml_parser_thread_num);
EXPECT_EQ(sequencer_thread_num, config.sequencer_thread_num);
EXPECT_EQ(formatter_thread_num, config.formatter_thread_num);
EXPECT_EQ(0, strcmp(cluster_url, config.cluster_url.str()));
EXPECT_EQ(0, strcmp(log_level, config.log_level.str()));
EXPECT_EQ(0, strcmp(cluster_user, config.cluster_user.str()));
EXPECT_EQ(0, strcmp(cluster_password, config.cluster_password.str()));
EXPECT_EQ(0, strcmp(config_fpath, config.config_fpath.str()));
EXPECT_EQ(dml_parser_thread_num, config->dml_parser_thread_num);
EXPECT_EQ(sequencer_thread_num, config->sequencer_thread_num);
EXPECT_EQ(formatter_thread_num, config->formatter_thread_num);
EXPECT_EQ(0, strcmp(cluster_url, config->cluster_url.str()));
EXPECT_EQ(0, strcmp(log_level, config->log_level.str()));
EXPECT_EQ(0, strcmp(cluster_user, config->cluster_user.str()));
EXPECT_EQ(0, strcmp(cluster_password, config->cluster_password.str()));
EXPECT_EQ(0, strcmp(config_fpath, config->config_fpath.str()));
bool check_name = true;
int64_t version = 0;
EXPECT_NE(OB_SUCCESS, config.load_from_map(config_map_, version, check_name));
EXPECT_NE(OB_SUCCESS, config->load_from_map(config_map_, version, check_name));
if (NULL != config) {
delete config;
config = NULL;
}
}
TEST_F(TestLogConfig, load_from_file)
@ -222,31 +233,35 @@ TEST_F(TestLogConfig, load_from_file)
// default check_all() removes the double quotes from cluster_url
TEST_F(TestLogConfig, format_cluster_url)
{
ObLogConfig config;
EXPECT_EQ(OB_SUCCESS, config.init());
ObLogConfig *config = new ObLogConfig();
EXPECT_EQ(OB_SUCCESS, config->init());
const char *URL = "http://abc.com/def/hijklmn";
char cluster_url[1024];
ASSERT_EQ(OB_SUCCESS, config.load_from_buffer(config_buf_, strlen(config_buf_)));
ASSERT_EQ(OB_SUCCESS, config.check_all());
ASSERT_EQ(OB_SUCCESS, config->load_from_buffer(config_buf_, strlen(config_buf_)));
ASSERT_EQ(OB_SUCCESS, config->check_all());
snprintf(cluster_url, sizeof(cluster_url), "\"");
ASSERT_TRUE(config.cluster_url.set_value(cluster_url));
ASSERT_NE(OB_SUCCESS, config.format_cluster_url());
ASSERT_TRUE(config->cluster_url.set_value(cluster_url));
ASSERT_NE(OB_SUCCESS, config->format_cluster_url());
snprintf(cluster_url, sizeof(cluster_url), "\"\"");
ASSERT_TRUE(config.cluster_url.set_value(cluster_url));
ASSERT_NE(OB_SUCCESS, config.format_cluster_url());
ASSERT_TRUE(config->cluster_url.set_value(cluster_url));
ASSERT_NE(OB_SUCCESS, config->format_cluster_url());
snprintf(cluster_url, sizeof(cluster_url), "\"%s\"", URL);
ASSERT_TRUE(config.cluster_url.set_value(cluster_url));
ASSERT_EQ(OB_SUCCESS, config.format_cluster_url());
EXPECT_EQ(0, strcmp(URL, config.cluster_url.str()));
ASSERT_TRUE(config->cluster_url.set_value(cluster_url));
ASSERT_EQ(OB_SUCCESS, config->format_cluster_url());
EXPECT_EQ(0, strcmp(URL, config->cluster_url.str()));
// No handling of single inverted commas
snprintf(cluster_url, sizeof(cluster_url), "\'\'");
ASSERT_TRUE(config.cluster_url.set_value(cluster_url));
ASSERT_EQ(OB_SUCCESS, config.format_cluster_url());
ASSERT_TRUE(config->cluster_url.set_value(cluster_url));
ASSERT_EQ(OB_SUCCESS, config->format_cluster_url());
if (NULL != config) {
delete config;
config = NULL;
}
}
} // namespace liboblog

View File

@ -17,9 +17,9 @@
#include "lib/allocator/ob_concurrent_fifo_allocator.h"
#include "lib/container/ob_array.h"
#include "liboblog/src/ob_i_log_fetcher.h"
#include "liboblog/src/ob_log_fetcher_utils.h"
#include "liboblog/src/ob_log_fetcher.h"
#include "obcdc/src/ob_i_log_fetcher.h"
#include "obcdc/src/ob_log_fetcher_utils.h"
#include "obcdc/src/ob_log_fetcher.h"
#include "test_log_fetcher_common_utils.h"
@ -162,4 +162,3 @@ int main(int argc, char **argv)
// testing::FLAGS_gtest_filter = "DO_NOT_RUN";
return RUN_ALL_TESTS();
}

View File

@ -18,9 +18,9 @@
#include "storage/ob_storage_log_type.h"
#include "storage/transaction/ob_trans_log.h"
#include "liboblog/src/ob_log_instance.h"
#include "liboblog/src/ob_log_fetcher_stream.h"
#include "liboblog/src/ob_log_fetcher_part_stream.h"
#include "obcdc/src/ob_log_instance.h"
#include "obcdc/src/ob_log_fetcher_stream.h"
#include "obcdc/src/ob_log_fetcher_part_stream.h"
#include "ob_log_utils.h" // get_timestamp

View File

@ -15,7 +15,7 @@
#include "share/ob_define.h"
#include "liboblog/src/ob_log_fetcher_heartbeat_mgr.h"
#include "obcdc/src/ob_log_fetcher_heartbeat_mgr.h"
#include "test_log_fetcher_common_utils.h"
@ -173,7 +173,7 @@ public:
}
};
//////////////////////基本功能测试//////////////////////////////////////////
////////////////////// test basic function //////////////////////////////////////////
/*
* Test HeartbeatRequest
*/

View File

@ -17,7 +17,7 @@
#include "test_log_fetcher_common_utils.h"
#include "liboblog/src/ob_log_fetcher_impl.h"
#include "obcdc/src/ob_log_fetcher_impl.h"
using namespace oceanbase;
using namespace common;

View File

@ -16,7 +16,7 @@
#include "storage/ob_storage_log_type.h"
#include "storage/transaction/ob_trans_log.h"
#include "liboblog/src/ob_log_fetcher_part_stream.h"
#include "obcdc/src/ob_log_fetcher_part_stream.h"
#include "test_log_fetcher_common_utils.h"
using namespace oceanbase;

View File

@ -14,7 +14,7 @@
#include <vector>
#include "share/ob_define.h"
#include "liboblog/src/ob_log_fetcher_start_log_id_locator.h"
#include "obcdc/src/ob_log_fetcher_start_log_id_locator.h"
#include "test_log_fetcher_common_utils.h"

View File

@ -13,7 +13,7 @@
#include <gtest/gtest.h>
#include "share/ob_define.h"
#include "liboblog/src/ob_log_fetcher_stream.h"
#include "obcdc/src/ob_log_fetcher_stream.h"
#include "test_log_fetcher_common_utils.h"

View File

@ -16,7 +16,7 @@
#include "share/ob_define.h"
#include "lib/container/ob_se_array.h"
#include "liboblog/src/ob_log_fetcher_svr_finder.h"
#include "obcdc/src/ob_log_fetcher_svr_finder.h"
#include "test_log_fetcher_common_utils.h"

View File

@ -123,7 +123,7 @@ TEST(MySQLConnector, run)
ret = conn.destroy();
EXPECT_EQ(OB_SUCCESS, ret);
}
}

View File

@ -156,4 +156,3 @@ private:
private:
DISALLOW_COPY_AND_ASSIGN(MockObLogPartMgr);
};

View File

@ -196,7 +196,7 @@ TEST_F(TestLogSQLServerProvider, fetch)
EXPECT_EQ(1, server_provider_.get_server_count());
EXPECT_EQ(OB_SUCCESS, server_provider_.get_server(0, server));
EXPECT_EQ(rs_leader_.server_.get_ipv4(), server.get_ipv4());
EXPECT_EQ(rs_leader_.sql_port_, server.get_port()); // Server的端口应该是SQL端口
EXPECT_EQ(rs_leader_.sql_port_, server.get_port()); // Server SQL port
EXPECT_EQ(OB_ENTRY_NOT_EXIST, server_provider_.get_server(1, server));
EXPECT_EQ(OB_INVALID_ARGUMENT, server_provider_.get_server(-1, server));

View File

@ -13,7 +13,7 @@
#include <gtest/gtest.h>
#include "share/ob_define.h"
#include "lib/oblog/ob_log.h"
#include "liboblog/src/ob_log_svr_blacklist.h"
#include "obcdc/src/ob_log_svr_blacklist.h"
using namespace oceanbase;
using namespace common;

View File

@ -15,7 +15,7 @@
#include "share/ob_define.h"
#include "liboblog/src/ob_log_table_matcher.h"
#include "obcdc/src/ob_log_table_matcher.h"
using namespace oceanbase;
@ -200,6 +200,7 @@ TEST(TableMatcher, BasicTest3)
err = matcher.tablegroup_match("tt1", "alitg2", matched, flag);
EXPECT_TRUE(matched);
err = matcher.tablegroup_match("tt1", "alipaytg", matched, flag);
EXPECT_FALSE(matched);
err = matcher.tablegroup_match("tt2", "alitg1", matched, flag);

View File

@ -16,7 +16,7 @@
#include "lib/allocator/ob_malloc.h"
#include "lib/allocator/ob_concurrent_fifo_allocator.h"
#include "liboblog/src/ob_log_task_pool.h"
#include "obcdc/src/ob_log_task_pool.h"
using namespace oceanbase;
using namespace common;

View File

@ -320,20 +320,20 @@ TEST_F(TransCtxTest, add_participant_not_served)
EXPECT_EQ(OB_SUCCESS, participants.push_back(part_info_1));
part_trans_task_.set_participants(participants);
// prepare一次
// prepare
trans_ctx_.set_state(TransCtx::TRANS_CTX_STATE_INVALID);
EXPECT_EQ(OB_SUCCESS, trans_ctx_.prepare(part_trans_task_, part_mgr_, stop_flag, need_discard));
EXPECT_FALSE(need_discard);
// 构造一个partition key,不在参与者列表里
// construct a pkey which not in participants_list
PartTransTask part_trans_task_new;
part_trans_task_new.set_trans_id(trans_id_);
ObPartitionKey partition_key_new;
partition_key_new.init(1000000000, 2, 3);
part_trans_task_new.set_partition(partition_key_new);
// 当前是prepare状态 但partition不在参与者列表中
// in prepare state but partition not in participants_list
trans_ctx_.set_state(TransCtx::TRANS_CTX_STATE_PREPARED);
EXPECT_EQ(OB_SUCCESS, trans_ctx_.add_participant(part_trans_task_new, is_part_trans_served,
is_all_participants_ready));

View File

@ -355,4 +355,3 @@ int main(int argc, char **argv)
::testing::InitGoogleTest(&argc,argv);
return RUN_ALL_TESTS();
}

View File

@ -12,7 +12,7 @@
#include <gtest/gtest.h>
#include "share/ob_define.h"
#include "liboblog/src/ob_log_utils.h"
#include "obcdc/src/ob_log_utils.h"
using namespace oceanbase;
using namespace common;

View File

@ -44,7 +44,7 @@ TEST_F(TestLogAdaptString, smoke_test)
test_append_str(str, std_str, "");
test_append_str(str, std_str, "I am me ");
test_append_str(str, std_str, "中华人民共和国 ");
test_append_str(str, std_str, "CHINA ");
EXPECT_EQ(OB_SUCCESS, str.append_int64(100));
std_str.append("100");

View File

@ -15,8 +15,8 @@
#include <gtest/gtest.h>
#include "share/ob_define.h"
#define private public
#include "liboblog/src/ob_log_all_svr_cache.h"
#include "liboblog/src/ob_log_systable_helper.h"
#include "obcdc/src/ob_log_all_svr_cache.h"
#include "obcdc/src/ob_log_systable_helper.h"
#include "ob_log_utils.h"
#include "test_ob_log_fetcher_common_utils.h"
#include "lib/atomic/ob_atomic.h"

View File

@ -15,7 +15,7 @@
#include <gtest/gtest.h>
#include "share/ob_define.h"
#define private public
#include "liboblog/src/ob_log_dlist.h"
#include "obcdc/src/ob_log_dlist.h"
#include "ob_log_utils.h"
using namespace oceanbase;

View File

@ -19,7 +19,7 @@
#include "storage/ob_storage_log_type.h"
#include "storage/transaction/ob_trans_log.h"
#include "liboblog/src/ob_log_instance.h"
#include "obcdc/src/ob_log_instance.h"
#include "ob_log_stream_worker.h"
#define private public
#include "ob_log_rpc.h"
@ -114,12 +114,12 @@ public:
rec.end_log_id_ = log_id + 10000;
if (idx < QUERY_CLOG_HISTORY_VALID_COUNT) {
// Insert QUERY_CLOG_HISTORY_VALID_COUNT a valid record
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
"127.0.0.%ld", valid_seed % ALL_SERVER_COUNT);
valid_seed++;
} else {
// Insert QUERY_CLOG_HISTORY_INVALID_COUNT an invalid record
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1, "127.0.0.%ld", invalid_seed);
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1, "127.0.0.%ld", invalid_seed);
invalid_seed++;
}
rec.svr_port_ = 8888;
@ -154,12 +154,12 @@ public:
rec.end_log_id_ = 65536;
if (idx < QUERY_CLOG_HISTORY_VALID_COUNT) {
// Insert QUERY_CLOG_HISTORY_VALID_COUNT a valid record
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
"127.0.0.%ld", valid_seed % ALL_SERVER_COUNT);
valid_seed++;
} else {
// Insert QUERY_CLOG_HISTORY_INVALID_COUNT an invalid record
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1, "127.0.0.%ld", invalid_seed);
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1, "127.0.0.%ld", invalid_seed);
invalid_seed++;
}
rec.svr_port_ = 8888;
@ -190,11 +190,11 @@ public:
rec.reset();
if (idx < QUERY_CLOG_HISTORY_VALID_COUNT) {
// Returns the same server as query_clog_history
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
"127.0.0.%ld", seed % ALL_SERVER_COUNT);
} else {
// Return QUERY_META_INFO_ADD_COUNT additional records
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1,
"127.0.0.%ld", seed % ALL_SERVER_COUNT);
}
rec.svr_port_ = 8888;
@ -296,7 +296,7 @@ public:
rec.reset();
snprintf(rec.svr_ip_, common::MAX_IP_ADDR_LENGTH + 1, "127.0.0.%ld", seed);
rec.svr_port_ = 8888;
if (0 == (idx & 0x01)) {
if (0 == (idx & 0x01)) {
rec.status_ = share::ObServerStatus::DisplayStatus::OB_SERVER_ACTIVE;
} else {
rec.status_ = share::ObServerStatus::DisplayStatus::OB_SERVER_INACTIVE;
@ -428,11 +428,11 @@ public:
if (OB_SUCCESS == res.get_err()) {
ParamArray &param_array = req.get_params();
for (int64_t idx = 0, cnt = param_array.count(); idx < cnt; ++idx) {
for (int64_t idx = 0, cnt = param_array.count(); idx < cnt; ++idx) {
Param &param = param_array[idx];
obrpc::ObLogReqStartLogIdByTsResponseWithBreakpoint::Result result;
result.reset();
result.start_log_id_ = param.pkey_.table_id_;
obrpc::ObLogReqStartLogIdByTsResponseWithBreakpoint::Result result;
result.reset();
result.start_log_id_ = param.pkey_.table_id_;
if (spec_err_) {
result.err_ = part_err_;
@ -444,9 +444,9 @@ public:
result.err_ = (succeed) ? OB_SUCCESS : ((breakrpc) ? OB_EXT_HANDLE_UNFINISH : OB_NEED_RETRY);
}
// Break info is actually not returned.
EXPECT_EQ(OB_SUCCESS, res.append_result(result));
}
// Break info is actually not returned.
EXPECT_EQ(OB_SUCCESS, res.append_result(result));
}
}
return ret;
@ -518,10 +518,10 @@ public:
// Save the request parameters
for (int64_t idx = 0, cnt = param_array.count(); idx < cnt; ++idx) {
const Param &param = param_array[idx];
Param add_param;
add_param.reset(param.pkey_, param.start_tstamp_, param.break_info_);
Param add_param;
add_param.reset(param.pkey_, param.start_tstamp_, param.break_info_);
if (OB_FAIL(request_->append_param(add_param))) {
if (OB_FAIL(request_->append_param(add_param))) {
//LOG_ERROR("append param fail", K(ret), K(idx), K(add_param));
}
}

View File

@ -156,30 +156,30 @@ public:
res.set_err(OB_ERR_UNEXPECTED);
} else {
res.set_err(OB_SUCCESS);
for (int64_t idx = 0, cnt = req.get_params().count(); OB_SUCCESS == ret && idx < cnt; ++idx) {
// 30%.
for (int64_t idx = 0, cnt = req.get_params().count(); OB_SUCCESS == ret && idx < cnt; ++idx) {
// 30%.
seed = get_timestamp();
rand = (idx + seed) % 100;
bool succeed = (rand < 30);
bool not_master = (30 <= rand) && (rand < 60);
bool partition_not_exist = (60 <= rand) && (rand < 90);
bool succeed = (rand < 30);
bool not_master = (30 <= rand) && (rand < 60);
bool partition_not_exist = (60 <= rand) && (rand < 90);
const obrpc::ObLogLeaderHeartbeatReq::Param &param = req.get_params().at(idx);
obrpc::ObLogLeaderHeartbeatResp::Result result;
result.reset();
const obrpc::ObLogLeaderHeartbeatReq::Param &param = req.get_params().at(idx);
obrpc::ObLogLeaderHeartbeatResp::Result result;
result.reset();
if (succeed) {
result.err_ = OB_SUCCESS;
result.err_ = OB_SUCCESS;
} else if (not_master) {
result.err_ = OB_NOT_MASTER;
result.err_ = OB_NOT_MASTER;
} else if (partition_not_exist) {
result.err_ = OB_PARTITION_NOT_EXIST;
result.err_ = OB_PARTITION_NOT_EXIST;
} else {
result.err_ = OB_ERR_UNEXPECTED;
result.err_ = OB_ERR_UNEXPECTED;
}
result.next_served_log_id_ = (succeed || not_master) ? param.next_log_id_ : OB_INVALID_ID;
result.next_served_ts_ = (succeed || not_master) ? FIXED_TIMESTAMP : OB_INVALID_TIMESTAMP;
EXPECT_EQ(OB_SUCCESS, res.append_result(result));
EXPECT_EQ(OB_SUCCESS, res.append_result(result));
// Verify that the partitions correspond to the same request server
common::ObAddr cur_svr;
@ -244,7 +244,7 @@ public:
};
void generate_req(const int64_t all_svr_cnt,
const int64_t req_cnt,
const int64_t req_cnt,
HeartbeatRequest *&request_array,
common::ObLinearHashMap<common::ObPartitionKey, common::ObAddr> &map)
{
@ -256,11 +256,11 @@ void generate_req(const int64_t all_svr_cnt,
request_array = new HeartbeatRequest[req_cnt];
for (int64_t idx = 0, cnt = req_cnt; idx < cnt; ++idx) {
HeartbeatRequest &r = request_array[idx];
r.reset();
HeartbeatRequest &r = request_array[idx];
r.reset();
// set pkey, next_log_id, svr
// next_log_id = pkey.table_id + 1
r.reset(ObPartitionKey((uint64_t)(1000 + idx), 0, 1), 1000 + idx + 1, svrs[idx % all_svr_cnt]);
r.reset(ObPartitionKey((uint64_t)(1000 + idx), 0, 1), 1000 + idx + 1, svrs[idx % all_svr_cnt]);
int ret = OB_SUCCESS;
if (OB_FAIL(map.insert(r.pkey_, svrs[idx % all_svr_cnt]))) {

View File

@ -18,7 +18,7 @@
#include "lib/allocator/page_arena.h"
#include "ob_log_utils.h"
#define private public
#include "liboblog/src/ob_log_part_svr_list.h"
#include "obcdc/src/ob_log_part_svr_list.h"
#include "ob_log_start_log_id_locator.h" // StartLogIdLocateReq
@ -38,7 +38,7 @@ public :
public:
typedef PartSvrList::SvrItem SvrItem;
typedef PartSvrList::LogIdRange LogIdRange;
// 验证svr_item字段的正确性
// verify correctness for svr_item filed
void is_svr_item_correct(PartSvrList &svr_list,
const int64_t svr_item_index,
common::ObAddr &expect_svr,
@ -66,7 +66,7 @@ void TestObLogPartSvrList::TearDown()
void TestObLogPartSvrList::is_svr_item_correct(PartSvrList &svr_list,
const int64_t svr_item_index,
common::ObAddr &expect_svr,
common::ObAddr &expect_svr,
const int64_t expect_range_num,
LogIdRange *expect_log_ranges)
{
@ -87,7 +87,7 @@ void TestObLogPartSvrList::is_svr_item_correct(PartSvrList &svr_list,
// The main test is the insert_range_ function, which calls find_pos_and_merge to find the position, but no log range merge has occurred
TEST_F(TestObLogPartSvrList, add_server_test1)
{
// 声明
// declear
const int64_t svr_idx = 0;
common::ObAddr expect_svr = servers[svr_idx];
int64_t expect_range_num = 0;
@ -292,7 +292,7 @@ TEST_F(TestObLogPartSvrList, next_server)
svr.reset();
EXPECT_EQ(OB_SUCCESS, svr_list.next_server(next_log_id, black_list, svr));
// 请求650
// request log_id 650
next_log_id = 650;
EXPECT_EQ(OB_SUCCESS, svr_list.next_server(next_log_id, black_list, svr));
svr_idx = 0;

View File

@ -20,7 +20,7 @@
#include "ob_log_fetch_stat_info.h"
#define private public
#include "liboblog/src/ob_log_part_trans_resolver.h"
#include "obcdc/src/ob_log_part_trans_resolver.h"
#include "test_trans_log_generator.h"
#include "test_sp_trans_log_generator.h"
@ -608,7 +608,7 @@ TEST(PartTransResolver, BasicTest4)
* For N Sp transactions, half of them commit, half of them abort
* Each Sp transaction has a random redo log
*
* log seqredo, redo, ... redo, commit/abort
* log seq: redo, redo, ... redo, commit/abort
*
* // redo info
* redo_log_cnt
@ -722,7 +722,7 @@ TEST(PartTransResolver, BasicTest5)
* For N Sp transactions, redo and commit in the same log entry
* Each Sp transaction has a random redo log
*
* log seqredo, redo, ... redo, redo-commit
* log seq: redo, redo, ... redo, redo-commit
*
*/
TEST(PartTransResolver, BasicTest6)
@ -904,7 +904,7 @@ TEST(PartTransResolver, BasicTest7)
EXPECT_EQ(OB_SUCCESS, err);
}
// read commit log,发现miss redo log,
// read commit log. found miss redo log,
if (is_normal_trans) {
EXPECT_EQ(OB_SUCCESS, log_gen.next_log_entry_missing_redo(SP_NORMAL_TRAN, log_entry));
} else if (is_redo_with_commit_trans) {

View File

@ -20,7 +20,7 @@
#include "ob_log_fetch_stat_info.h"
#define private public
#include "liboblog/src/ob_log_part_trans_resolver.h"
#include "obcdc/src/ob_log_part_trans_resolver.h"
using namespace oceanbase;
using namespace common;

View File

@ -57,13 +57,13 @@ void generate_req(const int64_t req_cnt, StartLogIdLocateReq *&request_array,
request_array = new StartLogIdLocateReq[req_cnt];
for (int64_t idx = 0, cnt = req_cnt; idx < cnt; ++idx) {
StartLogIdLocateReq &r = request_array[idx];
r.reset();
r.pkey_ = ObPartitionKey((uint64_t)(1000 + idx), 0, 1);
r.start_tstamp_ = start_tstamp;
// Set server list.
for (int64_t idx2 = 0, cnt2 = AllSvrCnt; idx2 < cnt2; ++idx2) {
StartLogIdLocateReq::SvrItem item;
StartLogIdLocateReq &r = request_array[idx];
r.reset();
r.pkey_ = ObPartitionKey((uint64_t)(1000 + idx), 0, 1);
r.start_tstamp_ = start_tstamp;
// Set server list.
for (int64_t idx2 = 0, cnt2 = AllSvrCnt; idx2 < cnt2; ++idx2) {
StartLogIdLocateReq::SvrItem item;
item.reset();
item.svr_ = svrs[idx2];
r.svr_list_.push_back(item);

View File

@ -54,7 +54,7 @@ void generate_part_svr_list(const int64_t count, PartSvrList *&part_svr_list)
// 2. timestamp request
void generate_svr_finder_requset(const int64_t count,
PartSvrList *part_svr_list,
SvrFindReq *&svr_req_array)
SvrFindReq *&svr_req_array)
{
svr_req_array = static_cast<SvrFindReq *>(
ob_malloc(sizeof(SvrFindReq) * count));
@ -64,10 +64,10 @@ void generate_svr_finder_requset(const int64_t count,
const int64_t seed = get_timestamp();
if ((seed % 100) < 50) {
svr_req_array[idx].reset_for_req_by_log_id(part_svr_list[idx], pkey, idx);
svr_req_array[idx].reset_for_req_by_log_id(part_svr_list[idx], pkey, idx);
EXPECT_TRUE(svr_req_array[idx].is_state_idle());
} else {
svr_req_array[idx].reset_for_req_by_tstamp(part_svr_list[idx], pkey, seed);
svr_req_array[idx].reset_for_req_by_tstamp(part_svr_list[idx], pkey, seed);
EXPECT_TRUE(svr_req_array[idx].is_state_idle());
}
}
@ -96,7 +96,7 @@ void wait_svr_finer_req_end(SvrFindReq *svr_req_array,
while (((get_timestamp() - start_test_tstamp) < TEST_TIME_LIMIT)
&& (end_request_cnt < count)) {
for (int64_t idx = 0, cnt = count; idx < cnt; ++idx) {
SvrFindReq &r = svr_req_array[idx];
SvrFindReq &r = svr_req_array[idx];
if (SvrFindReq::DONE == r.get_state()) {
end_request_cnt += 1;
r.set_state_idle();
@ -115,7 +115,7 @@ void wait_leader_finer_req_end(LeaderFindReq *leader_req_array,
while (((get_timestamp() - start_test_tstamp) < TEST_TIME_LIMIT)
&& (end_request_cnt < count)) {
for (int64_t idx = 0, cnt = count; idx < cnt; ++idx) {
LeaderFindReq &r = leader_req_array[idx];
LeaderFindReq &r = leader_req_array[idx];
if (LeaderFindReq::DONE == r.get_state()) {
end_request_cnt += 1;
r.set_state_idle();

View File

@ -14,11 +14,11 @@
#include <gtest/gtest.h>
#include "share/ob_define.h"
#include "liboblog/src/ob_map_queue_thread.h"
#include "obcdc/src/ob_map_queue_thread.h"
#include "ob_log_utils.h"
#define private public
#include "test_ob_log_fetcher_common_utils.h"
#include "liboblog/src/ob_log_timer.h"
#include "obcdc/src/ob_log_timer.h"
using namespace oceanbase;
using namespace common;
@ -83,7 +83,7 @@ public :
static constexpr const int64_t TEST_TIME_LIMIT = 10 * _MIN_;
// ObMapQueue mod_id
static constexpr const char *MOD_ID = "1";
// ObMapQueueThread线程个数
// thread num of ObMapQueueThread
static const int THREAD_NUM = 6;
// max task count
static const int64_t MAX_TASK_COUNT = 10 * 1000;
@ -93,7 +93,7 @@ public:
};
void TestObLogTimer::generate_data(const int64_t count,
QueueThread *host,
QueueThread *host,
int64_t *&process_count,
Type *&datas)
{

View File

@ -14,7 +14,7 @@
#include <gtest/gtest.h>
#include "share/ob_define.h"
#include "liboblog/src/ob_map_queue.h"
#include "obcdc/src/ob_map_queue.h"
#include "ob_log_utils.h"
using namespace oceanbase;
@ -55,7 +55,7 @@ class TestPushWorker : public liboblog::Runnable
public:
enum State
{
IDLE, //
IDLE, //
REQ, // pushing
DONE // push DONE
};
@ -104,7 +104,7 @@ public:
int64_t pop_count_ CACHE_ALIGNED;
// record poped count for all threads
int64_t *end_pop_count_ CACHE_ALIGNED;
// 保存pop出来的数据
// save data poped out
Type *array_;
virtual int routine()
@ -123,7 +123,7 @@ public:
}
if (OB_EAGAIN == ret) {
ret = OB_SUCCESS;
ret = OB_SUCCESS;
}
if (ATOMIC_LOAD(end_pop_count_) == VALUE_COUNT) {
break;

View File

@ -15,7 +15,7 @@
#include <gtest/gtest.h>
#include <vector>
#include "share/ob_define.h"
#include "liboblog/src/ob_map_queue_thread.h"
#include "obcdc/src/ob_map_queue_thread.h"
#include "ob_log_utils.h"
using namespace oceanbase;
@ -89,7 +89,7 @@ class DerivedQueueThread1 : public QueueThread
{
public:
DerivedQueueThread1(vector<vector<Type> > &handle_result) : end_handle_count_(0),
handle_result_(handle_result),
handle_result_(handle_result),
inited_(false) {}
virtual ~DerivedQueueThread1() { destroy(); }
public:
@ -113,7 +113,7 @@ class DerivedQueueThread2 : public QueueThread
{
public:
DerivedQueueThread2(vector<vector<Type> > &handle_result) : end_handle_count_(0),
handle_result_(handle_result),
handle_result_(handle_result),
inited_(false) {}
virtual ~DerivedQueueThread2() { destroy(); }
public:
@ -124,7 +124,7 @@ public:
// Record the number of data that has been processed by the thread
int64_t end_handle_count_ CACHE_ALIGNED;
public:
// Overload run, test the correctness of ObMapQueueThread execution
// Overload run, test the correctness of ObMapQueueThread execution
virtual void run(const int64_t thread_index);
private:
static const int64_t IDLE_WAIT_TIME = 10 * 1000;
@ -161,7 +161,7 @@ void DerivedQueueThread1::destroy()
EXPECT_TRUE(QueueThread::is_stoped());
inited_ = false;
LOG_INFO("DerivedQueueThread1 destory");
LOG_INFO("DerivedQueueThread1 destory");
}
}
@ -237,7 +237,7 @@ void DerivedQueueThread2::destroy()
EXPECT_TRUE(QueueThread::is_stoped());
inited_ = false;
LOG_INFO("DerivedQueueThread2 destory");
LOG_INFO("DerivedQueueThread2 destory");
}
}

View File

@ -18,8 +18,8 @@
#include "storage/ob_storage_log_type.h"
#include "storage/transaction/ob_trans_log.h"
#include "liboblog/src/ob_log_instance.h"
#include "liboblog/src/ob_log_utils.h" // get_timestamp
#include "obcdc/src/ob_log_instance.h"
#include "obcdc/src/ob_log_utils.h" // get_timestamp
using namespace oceanbase;
using namespace common;
@ -186,7 +186,7 @@ public:
// Call next_log_entry to get the number of redo entries in order by specifying the number of redo entries
void next_trans(const int64_t redo_cnt, bool is_commit)
{
// 正常事务日志总条数=redo log count + 1(commit/abort log)
// total log count of normal trans = redo_log_count + 1(commit/abort log)
remain_log_cnt_ = redo_cnt + 1;
is_commit_ = is_commit;
redos_.reset();
@ -348,8 +348,8 @@ protected:
data_len_ = pos;
// Gen entry header.
ObLogEntryHeader header;
// 日志submit timestamp采用SP_PREPARE_TIMESTAMP, 因为对于sp事务,分区任务存储的prepare时间戳
// commit日志的时间戳,用于正确性验证
// submit timestamp use SP_PREPARE_TIMESTAMP, because for sp_trans, prepare ts is stored in PartTransTask
// commit log ts is used for check correctness.
header.generate_header(OB_LOG_SUBMIT, pkey_, commit_log_id, buf_,
data_len_, get_timestamp(), get_timestamp(),
ObProposalID(), SP_PREPARE_TIMESTAMP, ObVersion(0));
@ -380,7 +380,7 @@ protected:
/*
* test missing redo log, When the commit log is read, the missing redo can be detected
*
* two case
* two case:
* 1. redo, redo, redo...redo, commit
* 2. redo, redo, redo...redo, redo-commit
*/

View File

@ -18,11 +18,11 @@
#include "storage/ob_storage_log_type.h"
#include "storage/transaction/ob_trans_log.h"
#include "liboblog/src/ob_log_instance.h"
#include "liboblog/src/ob_log_parser.h"
#include "obcdc/src/ob_log_instance.h"
#include "obcdc/src/ob_log_parser.h"
#include "ob_log_utils.h" // get_timestamp
#include "liboblog/src/ob_map_queue.h"
#include "obcdc/src/ob_map_queue.h"
#include "lib/oblog/ob_log_module.h"
using namespace oceanbase;
@ -207,7 +207,7 @@ public:
// Specify the number of redo entries and call next_log_entry to get them in order
void next_trans(const int64_t redo_cnt, bool is_commit)
{
// 正常事务日志总条数=redo log count + 2(prepare log + commit/abort log)
// total log count of normal trans = redo log count + 2(prepare log + commit/abort log)
remain_log_cnt_ = redo_cnt + 2;
is_commit_ = is_commit;
redos_.reset();
@ -221,12 +221,12 @@ public:
void next_trans_with_redo_prepare(const int64_t redo_cnt, bool is_commit)
{
next_trans(redo_cnt, is_commit);
// redo-prepare在同一个log entrey, remain_log_cnt_重新赋值
// redo and prepare in the same log_entry
remain_log_cnt_ = redo_cnt + 1;
}
// Get next log entry.
// normal trans: 依次获取redo, redo...prepare, commit/abort
// normal trans: get redo, redo...prepare, commit/abort by sequence
int next_log_entry(clog::ObLogEntry &log_entry)
{
int ret = OB_SUCCESS;
@ -434,7 +434,7 @@ const ObAddr TransLogEntryGeneratorBase::SCHEDULER = ObAddr(ObAddr::IPV4, "127.0
/*
* test missing redo log, When the prepare log is read, the missing redo can be detected
*
* two case
* two case:
* 1. redo, redo, redo...prepare, commit/abort
* 2. redo, redo, redo...redo-prepare, commit/abort
*/