本文整理汇总了C++中ObRootServer2类的典型用法代码示例。如果您正苦于以下问题:C++ ObRootServer2类的具体用法?C++ ObRootServer2怎么用?C++ ObRootServer2使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObRootServer2类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(ObRootServer2LogTest, do_server_down)
{
int32_t port = 1001;
ObServer server(ObServer::IPV4, "10.10.10.1", port);
int32_t status = 1;
int64_t ts = 123456;
ObRootServer2 master;
ObRootWorkerForTest master_worker;
ASSERT_TRUE(master.init("./root_server.conf", 100, &master_worker));
ObRootServer2 slave;
ObRootWorkerForTest slave_worker;
ASSERT_TRUE(slave.init("./root_server.conf", 100, &slave_worker));
ObRootServerTester wrapper(&slave);
wrapper.stop_thread();
int ret = master.regist_server(server, false, status, ts);
ASSERT_EQ(OB_SUCCESS, ret);
ObRootLogWorker log_worker = wrapper.get_log_worker();
log_worker.do_cs_regist(server, ts); // up server
ObChunkServerManager& server_manager = wrapper.get_server_manager();
ObChunkServerManager::iterator it = server_manager.find_by_ip(server);
ASSERT_TRUE(it != server_manager.end());
ASSERT_NE(ObServerStatus::STATUS_DEAD, it->status_);
log_worker.do_server_down(server, ts); // down server
it = server_manager.find_by_ip(server);
ASSERT_TRUE(it != server_manager.end());
ASSERT_EQ(ObServerStatus::STATUS_DEAD, it->status_);
}
示例2: TEST
TEST(ObRootServer2Test2, migrate_over2_1)
{
MigrateTestEnv env;
env.setup();
ObRootServer2* rs = env.worker_.get_root_server();
ObRootServerTester tester(rs);
ObChunkServerManager& csmgr = tester.get_server_manager();
ObRootTable2* roottable = tester.get_root_table_for_query();
/// case 1
// 4. target cs2 down
ObChunkServerManager::iterator it = csmgr.find_by_ip(env.cs2_);
ASSERT_TRUE(csmgr.end() != it);
csmgr.set_server_down(it);
int64_t now = tbsys::CTimeUtil::getTime();
roottable->server_off_line(it - csmgr.begin(), now);
// 5. report migrate over
rs->migrate_over(env.info1_.range_, env.cs1_, env.cs2_, true, env.tablet_version_);
// 6. verify
ObRootTable2::const_iterator it1, it2;
ASSERT_EQ(OB_SUCCESS, roottable->find_range(env.info1_.range_, it1, it2));
ASSERT_EQ(it1, it2);
ASSERT_EQ(0, it1->server_info_indexes_[0]);
ASSERT_EQ(OB_INVALID_INDEX, it1->server_info_indexes_[1]);
ASSERT_EQ(OB_INVALID_INDEX, it1->server_info_indexes_[2]);
rs->stop_threads();
}
示例3: setup
void MigrateTestEnv::setup()
{
// 1. init
ObRootServer2* rs = worker_.get_root_server();
ASSERT_TRUE(rs->init("./root_server.conf", 100, &worker_));
rs->start_threads();
sleep(1);
// 2. cs register
int status;
ASSERT_EQ(OB_SUCCESS, rs->regist_server(cs1_, false, status));
ASSERT_EQ(OB_SUCCESS, rs->regist_server(cs2_, false, status));
// 3. cs1 report tablets replicas
ObTabletReportInfoList report_list1;
ObTabletReportInfoList report_list2;
ObTabletReportInfo report_info;
ObTabletLocation location;
location.tablet_version_ = tablet_version_;
info1_.range_.table_id_ = 10001;
info1_.range_.border_flag_.set_inclusive_end();
info1_.range_.border_flag_.unset_inclusive_start();
info1_.range_.border_flag_.set_min_value();
info1_.range_.border_flag_.unset_max_value();
info1_.range_.start_key_.assign_buffer(buf1[0], 30);
info1_.range_.end_key_.assign_buffer(buf2[0], 30);
info1_.range_.start_key_.write("aa1", 3);
info1_.range_.end_key_.write("ba1", 3);
location.chunkserver_ = cs1_;
report_info.tablet_info_ = info1_;
report_info.tablet_location_ = location;
report_list1.add_tablet(report_info);
info1_.range_.border_flag_.unset_min_value();
info1_.range_.border_flag_.set_max_value();
info1_.range_.start_key_.assign_buffer(buf1[1], 30);
info1_.range_.end_key_.assign_buffer(buf2[1], 30);
info1_.range_.start_key_.write("ba1", 3);
info1_.range_.end_key_.write("ca1", 3);
report_info.tablet_info_ = info1_;
report_info.tablet_location_ = location;
report_list1.add_tablet(report_info);
int64_t now = tbsys::CTimeUtil::getTime();
ASSERT_EQ(OB_SUCCESS, rs->report_tablets(cs1_, report_list1, now));
ASSERT_EQ(OB_SUCCESS, rs->report_tablets(cs2_, report_list2, now));
// wait init finish
sleep(5);
}
示例4: heartbeat_cs
void ObDeleteReplicasTest::heartbeat_cs(int32_t cs_num)
{
for (int i = 0; i < cs_num; ++i)
{
ASSERT_EQ(OB_SUCCESS, server_->receive_hb(get_addr(i), 0, false, OB_CHUNKSERVER));
}
}
示例5: heartbeat_cs
void ObBalanceTest::heartbeat_cs(int32_t cs_num)
{
for (int i = 0; i < cs_num; ++i)
{
ASSERT_EQ(OB_SUCCESS, server_->receive_hb(get_addr(i), OB_CHUNKSERVER));
}
}
示例6: register_cs
void ObDeleteReplicasTest::register_cs(int32_t cs_num)
{
for (int i = 0; i < cs_num; ++i)
{
int32_t status = 0;
ASSERT_EQ(OB_SUCCESS, server_->regist_chunk_server(get_addr(i), "0.4.1.2", status));
TBSYS_LOG(INFO, "register cs, id=%d status=%d", i, status);
}
}
示例7: register_cs
void ObBalanceTest::register_cs(int32_t cs_num)
{
for (int i = 0; i < cs_num; ++i)
{
int32_t status = 0;
ASSERT_EQ(OB_SUCCESS, server_->regist_server(get_addr(i), false, status));
TBSYS_LOG(INFO, "register cs, id=%d status=%d", i, status);
}
}
示例8: TearDown
void ObBalanceTest::TearDown()
{
sleep(1);
worker_.get_test_stub().stop();
worker_.get_test_stub().wait();
server_->stop_threads();
// test after balance thread stopped
ASSERT_EQ(0, worker_.get_test_stub().get_migrate_msg_count());
ASSERT_TRUE(server_->balancer_->nb_is_all_tables_balanced(balance_except_cs_));
}
示例9: SetUp
void ObBalanceTest::SetUp()
{
server_ = worker_.get_root_server();
worker_.set_config_file_name("ob_new_balance_test.conf");
ASSERT_EQ(OB_SUCCESS, worker_.initialize());
server_->config_.flag_migrate_wait_seconds_.set(20);
server_->config_.flag_enable_rereplication_.set(0); // disable
server_->start_threads();
sleep(1);
worker_.get_role_manager()->set_role(ObRoleMgr::STANDALONE); // for testing
worker_.get_test_stub().set_server(server_);
worker_.get_test_stub().start();
}
示例10: SetUp
void ObDeleteReplicasTest::SetUp()
{
server_ = worker_.get_root_server();
common::ObSystemConfig sys_config;
sys_config.init();
//worker_.set_config_file_name("ob_delete_replicas_test.conf");
worker_.rs_config_.init(sys_config);
worker_.rs_config_.port = 1110;
worker_.rs_config_.io_thread_count = 2;
worker_.create_eio();
worker_.rs_config_.read_queue_size = 2;
worker_.rs_config_.root_server_ip.set_value("10.232.35.40");
worker_.rs_config_.schema_filename.set_value("ob_delete_replicas_test_schema.ini");
ASSERT_EQ(OB_SUCCESS, worker_.initialize());
worker_.get_role_manager()->set_role(ObRoleMgr::STANDALONE); // for testing
server_->start_threads();
sleep(5);
}
示例11: run
void BalanceTestRpc::run(tbsys::CThread *thread, void *arg)
{
UNUSED(thread);
UNUSED(arg);
TBSYS_LOG(INFO, "balance test rpc thread begin");
while(!_stop)
{
TBSYS_LOG(DEBUG, "balance test rpc thread running");
MigrateMsg *msg = NULL;
int ret = pop_migrate_msg(msg);
if (OB_SUCCESS == ret)
{
assert(server_);
if (blocked_cs_ == msg->src_cs_)
{
char addr_buf1[OB_IP_STR_BUFF];
blocked_cs_.to_string(addr_buf1, OB_IP_STR_BUFF);
TBSYS_LOG(DEBUG, "drop migrate msg, src_cs=%s", addr_buf1);
}
else if (blocked_dest_cs_ == msg->dest_cs_)
{
char addr_buf1[OB_IP_STR_BUFF];
blocked_dest_cs_.to_string(addr_buf1, OB_IP_STR_BUFF);
TBSYS_LOG(DEBUG, "drop migrate msg, dest_cs=%s", addr_buf1);
}
else
{
server_->migrate_over(msg->range_, msg->src_cs_, msg->dest_cs_, msg->keep_src_, 2);
}
delete_migrate_msg(msg);
}
else
{
usleep(500*1000);
}
}
TBSYS_LOG(INFO, "balance test rpc thread finished");
}
示例12: TearDown
void ObDeleteReplicasTest::TearDown()
{
server_->stop_threads();
}
示例13: new
// 每个tablet两个复本,每个CS上均匀分布
void ObBalanceTest::report_tablets_2replicas(BalanceTestParams ¶ms)
{
ObTabletReportInfoList* report_lists = new (std::nothrow) ObTabletReportInfoList[params.cs_num_];
ASSERT_TRUE(NULL != report_lists);
int64_t *tablets_per_cs = new(std::nothrow) int64_t[params.cs_num_];
ASSERT_TRUE(NULL != tablets_per_cs);
ObTabletReportInfo tablet;
for (int i = 0; i < params.table_num_; ++i)
{
int32_t sstables_count = params.sstables_per_table_[i];
TBSYS_LOG(INFO, "table_id=%lu sstables=%d\n", get_table_id(i), sstables_count);
for (int j = 0; j < params.cs_num_; ++j)
{
TBSYS_LOG(INFO, "sstables dist per cs, %d", params.sstables_dist[i][j]);
reset_report_info_list(report_lists[j]);
tablets_per_cs[j] = 0;
}
int k = 0;
for (int j = 0; j < sstables_count; ++j)
{
int replicas = 0;
while (replicas < 2)
{
if (0 < params.sstables_dist[i][k])
{
get_report_tablet(tablet, sstables_count, i, j, k, params.sstable_size_);
int ret2 = report_lists[k].add_tablet(tablet);
if (OB_ARRAY_OUT_OF_RANGE == ret2)
{
// report
int ret = server_->report_tablets(get_addr(k), report_lists[k], 1);
ASSERT_EQ(OB_SUCCESS, ret);
TBSYS_LOG(INFO, "report tablets, cs=%d count=%ld", k, report_lists[k].get_tablet_size());
reset_report_info_list(report_lists[k]);
ret2 = report_lists[k].add_tablet(tablet);
}
ASSERT_EQ(OB_SUCCESS, ret2);
tablets_per_cs[k]++;
++replicas;
}
k++;
if (k >= params.cs_num_)
{
k = 0;
}
}
}
for (int k = 0; k < params.cs_num_; ++k)
{
if (0 < report_lists[k].get_tablet_size())
{
int ret = server_->report_tablets(get_addr(k), report_lists[k], 1);
ASSERT_EQ(OB_SUCCESS, ret);
TBSYS_LOG(INFO, "report tablets, cs=%d count=%ld", k, report_lists[k].get_tablet_size());
}
}
for (int k = 0; k < params.cs_num_; ++k)
{
TBSYS_LOG(INFO, "reported tablets, table=%lu cs_idx=%d tablets=%ld",
get_table_id(i), k, tablets_per_cs[k]);
}
} // end for each table
if (NULL != tablets_per_cs)
{
delete [] tablets_per_cs;
tablets_per_cs = NULL;
}
if (NULL != report_lists)
{
delete [] report_lists;
}
}