本文整理汇总了C++中ObServer::set_ipv4_addr方法的典型用法代码示例。如果您正苦于以下问题:C++ ObServer::set_ipv4_addr方法的具体用法?C++ ObServer::set_ipv4_addr怎么用?C++ ObServer::set_ipv4_addr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObServer
的用法示例。
在下文中一共展示了ObServer::set_ipv4_addr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST_F(TestTabletLocationItem, test_valid)
{
ObMergerTabletLocationList list;
ObTabletLocation temp_server;
ObServer chunkserver;
for (int32_t i = 0; i < ObMergerTabletLocationList::MAX_REPLICA_COUNT; ++i)
{
chunkserver.set_ipv4_addr(i + 300000, i + 1024);
temp_server.tablet_version_ = i;
temp_server.chunkserver_ = chunkserver;
EXPECT_TRUE(OB_SUCCESS == list.add(temp_server));
}
// all invalid
ObMergerTabletLocation server;
for (int32_t i = 0; i < ObMergerTabletLocationList::MAX_REPLICA_COUNT; ++i)
{
chunkserver.set_ipv4_addr(i + 300000, i + 1024);
server.server_.chunkserver_ = chunkserver;
server.server_.tablet_version_ = i;
EXPECT_TRUE(OB_SUCCESS == list.set_item_invalid(server));
EXPECT_TRUE(list[i].err_times_ == ObMergerTabletLocation::MAX_ERR_TIMES);
}
list.set_item_valid(1100);
EXPECT_TRUE(list.get_timestamp() == 1100);
for (int64_t i = 0; i < ObMergerTabletLocationList::MAX_REPLICA_COUNT; ++i)
{
EXPECT_TRUE(list[i].err_times_ == 0);
}
}
示例2: main
int main(int argc, char* argv[])
{
ObServer cs;
cs.set_ipv4_addr("localhost", 3500);
BaseClient client;
client.initialize();
ObServer root;
root.set_ipv4_addr("10.232.35.40", 2500);
ThreadSpecificBuffer buffer;
ObRootServerRpcStub server;
do
{
int ret = server.init(root, client.get_rpc());
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "init failed");
break;
}
int64_t timeout = 2000;
int64_t timestamp = 0;
// heartbeat
ret = server.renew_heartbeat(timeout, cs, timestamp);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "renew heartbeat failed:ret[%d]", ret);
break;
}
else
{
printf("get new lease time[%ld]\n", timestamp);
}
sleep(1);
// fetch schema
timestamp = 1282900503726484;
ObSchemaManager schema;
ret = server.fetch_schema(timeout, timestamp, schema);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "fetch schema failed:ret[%d]", ret);
break;
}
else
{
printf("fetch schema succ:appname[%s]\n", schema.get_app_name());
schema.print_info();
}
} while(0);
client.destory();
return 0;
}
示例3: srand
TEST_F(TestTabletLocationItem, test_sort)
{
ObMergerTabletLocationList list;
ObServer root_server;
const char * addr = "localhost";
root_server.set_ipv4_addr(addr, 8888);
int32_t server_ip = root_server.get_ipv4();
// one server
ObTabletLocation location;
srand(100);
ObServer temp;
temp.set_ipv4_addr(rand() % 10245, 1023);
//location.tablet_id_ = 1;
location.chunkserver_ = temp;
list.add(location);
EXPECT_TRUE(OB_SUCCESS == list.sort(root_server));
int64_t count = list.size();
for (int64_t i = 0; i < count - 1; ++i)
{
EXPECT_TRUE(abs(list[i].server_.chunkserver_.get_ipv4() - server_ip)
<= abs(list[i+1].server_.chunkserver_.get_ipv4() - server_ip));
}
// two server
temp.set_ipv4_addr(rand() % 10245, 1024);
location.chunkserver_ = temp;
list.add(location);
EXPECT_TRUE(OB_SUCCESS == list.sort(root_server));
count = list.size();
for (int64_t i = 0; i < count - 1; ++i)
{
EXPECT_TRUE(abs(list[i].server_.chunkserver_.get_ipv4() - server_ip)
<= abs(list[i+1].server_.chunkserver_.get_ipv4() - server_ip));
}
// three server
location.chunkserver_ = root_server;
list.add(location);
EXPECT_TRUE(OB_SUCCESS == list.sort(root_server));
count = list.size();
for (int64_t i = 0; i < count - 1; ++i)
{
EXPECT_TRUE(abs(list[i].server_.chunkserver_.get_ipv4() - server_ip)
<= abs(list[i+1].server_.chunkserver_.get_ipv4() - server_ip));
}
}
示例4: handle_get_updater
int MockRootServer::handle_get_updater(ObPacket * ob_packet)
{
int ret = OB_SUCCESS;
ObDataBuffer* data = ob_packet->get_buffer();
if (NULL == data)
{
ret = OB_ERROR;
}
tbnet::Connection* connection = ob_packet->get_connection();
ThreadSpecificBuffer::Buffer* thread_buffer = response_packet_buffer_.get_buffer();
if (NULL == thread_buffer)
{
ret = OB_ERROR;
}
else
{
thread_buffer->reset();
ObDataBuffer out_buffer(thread_buffer->current(), thread_buffer->remain());
ObResultCode result_msg;
result_msg.result_code_ = ret;
ret = result_msg.serialize(out_buffer.get_data(), out_buffer.get_capacity(), out_buffer.get_position());
// new version
int32_t channel_id = ob_packet->getChannelId();
ObServer server;
server.set_ipv4_addr("localhost", MockUpdateServer::UPDATE_SERVER_PORT);
ret = server.serialize(out_buffer.get_data(), out_buffer.get_capacity(), out_buffer.get_position());
ret = send_response(OB_REPORT_TABLETS_RESPONSE, 1, out_buffer, connection, channel_id);
}
return ret;
}
示例5: select_master
int ObMonitor::select_master(node_list_type *pnodelist, ObServer &new_master)
{
int err = OB_ERROR;
if(pnodelist == NULL)
{
TBSYS_LOG(WARN, "invalid argument");
err = OB_INVALID_ARGUMENT;
}
if(OB_ERROR == err)
{
node_list_type::iterator it = (*pnodelist).begin();
while(it != (*pnodelist).end())
{
if((*it)->status == SLAVE_SYNC)
{
new_master.set_ipv4_addr((*it)->node_server.get_ipv4(), (*it)->node_server.get_port());
(*it)->status = MASTER_ACTIVE;
err = OB_SUCCESS;
break;
}
it ++;
}
}
return err;
}
示例6: snprintf
ObServer &ObDeleteReplicasTest::get_addr(int32_t idx)
{
char buff[128];
snprintf(buff, 128, "10.10.10.%d", idx);
int port = 26666;
addr_.set_ipv4_addr(buff, port);
return addr_;
}
示例7: run_migrate_test_case
void run_migrate_test_case(ParamSet& param, char * cmd)
{
bool print_help = parse_param(param,cmd);
if ( true == print_help )
printhelp();
else
{
printParam(param);
ObServer cs;
cs.set_ipv4_addr(param.server_ip, param.port);
ObServer ds;
ds.set_ipv4_addr(param.dest_ip, param.dest_port);
BaseClient client;
if (OB_SUCCESS != client.initialize())
{
TBSYS_LOG(ERROR, "initialize client failed.");
}
migrate_test_case(client, cs, ds, param.table_id, param.user_id, param.item_type);
client.destory();
printf("================MIGRATE TEST DONE================\n");
}
}
示例8: ObServerStats
ObAppStats::ObAppStats(ObClientRpcStub &stub, const ObRole server_type, const char* config_file_name)
: ObServerStats(stub, server_type)
{
root_server_array_.init(MAX_SERVER_NUM, root_servers_, 0);
tbsys::CConfig config;
if(config.load(config_file_name))
{
fprintf(stderr, "load file %s error\n", config_file_name);
}
else
{
master_index_ = -1;
int count = config.getInt(SERVER_SECTION, "cluster_count", 0);
if (count <= 0)
{
fprintf(stderr, "cluster_count %d cannot < 0\n", count);
}
else
{
const int MAX_LEN = 64;
char ipname[MAX_LEN];
char portname[MAX_LEN];
char ip[MAX_LEN];
char mastername[MAX_LEN];
int32_t port = 0;
int is_master = 0;
ObServer server;
for (int i = 0; i < count ; ++i)
{
snprintf(ipname, MAX_LEN, "rs%d_ip", i);
snprintf(portname, MAX_LEN, "rs%d_port", i);
snprintf(mastername, MAX_LEN, "rs%d_is_master", i);
if (OB_SUCCESS != load_string(config, ip, MAX_LEN, SERVER_SECTION, ipname, true))
{
fprintf(stderr, "%s is null\n", ipname);
break;
}
port = config.getInt(SERVER_SECTION, portname, 0);
if (port <= 0)
{
fprintf(stderr, "%s is 0\n", portname);
break;
}
is_master = config.getInt(SERVER_SECTION, mastername, 0);
if (is_master > 0) master_index_ = i;
server.set_ipv4_addr(ip, port);
root_server_array_.push_back(server);
}
}
}
}
示例9: parse_obsql_options
int parse_obsql_options(int argc, char *argv[], ObServer &root_server)
{
int ret = 0;
const char *addr = NULL;
int32_t port = 0;
static struct option longopts[] =
{
{"hostip", required_argument, NULL, 'h'},
{"port", required_argument, NULL, 'p'},
{"quiet", required_argument, NULL, 'q'},
{"help", no_argument, NULL, '?'},
{NULL, 0, NULL, 0}
};
while((ret = getopt_long(argc, argv,"h:p:q?", longopts, NULL)) != -1)
{
switch(ret)
{
case 'h':
addr = optarg;
break;
case 'p':
port = atoi(optarg);
break;
case 'q':
TBSYS_LOGGER.setLogLevel("ERROR");
break;
case '?':
if (strcmp(argv[optind - 1], "-?") == 0 || strcmp(argv[optind - 1], "--help") == 0)
usage();
break;
default:
fprintf(stderr, "%s is not identified\n",optarg);
usage();
exit(1);
break;
};
}
ret = root_server.set_ipv4_addr(addr, port);
if (!ret)
{
fprintf(stderr, "root_server addr invalid, addr=%s, port=%d\n", addr, port);
return OB_ERROR;
}
return OB_SUCCESS;
}
示例10:
TEST_F(TestBlackList, init)
{
ObMergerServerBlackList list;
ObUpsList ups_list;
EXPECT_TRUE(OB_SUCCESS != list.init(10, 10000, MERGE_SERVER, ups_list));
ObUpsInfo info;
ObServer server;
for (int i = 0; i < MAX_COUNT; ++i)
{
server.set_ipv4_addr(i+1024, i+2048);
info.addr_ = server;
info.ms_read_percentage_ = 10;
ups_list.ups_count_ = i + 1;
ups_list.ups_array_[i] = info;
}
EXPECT_TRUE(OB_SUCCESS == list.init(10, 10000, MERGE_SERVER, ups_list));
}
示例11: thread_run
void* thread_run(void* arg)
{
ParamSet *param = reinterpret_cast<ParamSet*>(arg);
ObServer cs;
cs.set_ipv4_addr(param->server_ip, param->port);
BaseClient client;
if (OB_SUCCESS != client.initialize())
{
TBSYS_LOG(ERROR, "initialize client failed.");
//return OB_ERROR;
}
// get_test_case(client, cs, param->table_id, param->user_id, param->item_type, param->item_id);
//scan_test_case(client, cs, param->table_id, param->user_id, param->item_type, param->column_count);
// create_test_case(client, cs, param->table_id,param->user_id,param->item_type);
// migrate_test_case();
// merge_test_case();
return (void *)0;
}
示例12: run_drop_test_case
void run_drop_test_case(ParamSet& param, char * cmd)
{
bool print_help = parse_param(param,cmd);
if ( true == print_help )
printhelp();
else
{
printParam(param);
ObServer cs;
cs.set_ipv4_addr(param.server_ip, param.port);
BaseClient client;
if (OB_SUCCESS != client.initialize())
{
TBSYS_LOG(ERROR, "initialize client failed.");
}
drop_test_case(client, cs, param.memtable_frozen_version);
client.destory();
printf("==============DROP TEST DONE==================\n");
}
}
示例13: run_scan_test_case
void run_scan_test_case(ParamSet& param, char * cmd)
{
bool print_help = parse_param(param,cmd);
if ( true == print_help )
printhelp();
else
{
printParam(param);
ObServer cs;
cs.set_ipv4_addr(param.server_ip, param.port);
BaseClient client;
if (OB_SUCCESS != client.initialize())
{
TBSYS_LOG(ERROR, "initialize client failed.");
}
scan_test_case(client, cs, param.table_id, param.user_id, static_cast<int8_t>(param.item_type), static_cast<int32_t>(param.column_count));
client.destory();
printf("================SCAN TEST DONE===============\n");
}
}
示例14: run_get_test_case_common
void run_get_test_case_common(ParamSet& param, char * cmd)
{
bool print_help = parse_param(param,cmd);
if ( true == print_help )
printhelp();
else
{
printParam(param);
ObServer cs;
cs.set_ipv4_addr(param.server_ip, param.port);
BaseClient client;
if (OB_SUCCESS != client.initialize())
{
TBSYS_LOG(ERROR, "initialize client failed.");
}
get_test_case_common(client, cs, param.table_id, param.start_key, param.column_count);
client.destory();
printf("===============GET TEST DONE==============\n");
}
}
示例15: run_merge_scan_case
void run_merge_scan_case(ParamSet& param, char * cmd)
{
bool print_help = parse_param(param,cmd);
if ( true == print_help )
printhelp();
else
{
printParam(param);
ObServer cs;
cs.set_ipv4_addr(param.server_ip, param.port);
BaseClient client;
if (OB_SUCCESS != client.initialize())
{
TBSYS_LOG(ERROR, "initialize client failed.");
}
merge_scan_case(client, cs, param.table_name, param.start_key, param.end_key, param.key_size, param.is_hex_key);
client.destory();
printf("===============GET TEST DONE==============\n");
}
}