本文整理汇总了C++中ObServer::get_ipv4方法的典型用法代码示例。如果您正苦于以下问题:C++ ObServer::get_ipv4方法的具体用法?C++ ObServer::get_ipv4怎么用?C++ ObServer::get_ipv4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObServer
的用法示例。
在下文中一共展示了ObServer::get_ipv4方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mutate
int ObScanHelperImpl::mutate(ObMutator& mutator)
{
int ret = OB_SUCCESS;
if (!check_inner_stat())
{
ret = OB_NOT_INIT;
TBSYS_LOG(ERROR, "scan help not init");
}
else
{
ObServer ups;
if (OB_SUCCESS != (ret = ups_provider_->get_ups(ups)))
{
TBSYS_LOG(WARN, "failed to get ups, err=%d", ret);
}
else if (0 == ups.get_port() || 0 == ups.get_ipv4())
{
ret = OB_INVALID_ARGUMENT;
TBSYS_LOG(WARN, "invalid update server address");
}
else if (OB_SUCCESS != (ret = rpc_stub_->mutate(ups, mutator, mutate_timeout_us_)))
{
TBSYS_LOG(WARN, "failed to mutate, mutate_timeout_us_=%ld, ups=%s, err=%d",
mutate_timeout_us_, to_cstring(ups), ret);
}
else
{
TBSYS_LOG(DEBUG, "ups mutate succ, ups=%s", to_cstring(ups));
}
}
return ret;
}
示例2: report_slave_failure
int ObMonitor::report_slave_failure(const int64_t timeout, const int64_t retry_times, const ObServer slave, const ObServer master)
{
int err = OB_ERROR;
for(int64_t i = 0; (i < retry_times) && (err != OB_SUCCESS); i++)
{
int64_t timeu = tbsys::CTimeUtil::getMonotonicTime();
err = report_slave_failure_(timeout, slave, master);
timeu = tbsys::CTimeUtil::getMonotonicTime() - timeu;
if(OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "%ldth, report slave failure fail. err =%d", i, err);
}
else
{
TBSYS_LOG(INFO, "report slave failure to master succ!");
}
}
if(OB_SUCCESS != err)
{
TBSYS_LOG(ERROR, "can't report failure to master node. master addr =%d", master.get_ipv4());
err = OB_ERROR;
}
return err;
}
示例3: get_ms
int ObSchemaServiceMsProvider::get_ms(const ObScanParam &scan_param, const int64_t retry_num, ObServer &ms)
{
int ret = OB_SUCCESS;
UNUSED(scan_param);
if (0 < retry_num
&& 0 != ms.get_port()
&& 0 != ms.get_ipv4())
{
update_ms_retry(ms);
}
if (did_need_reset())
{
if (OB_SUCCESS != (ret = reset()))
{
TBSYS_LOG(WARN, "failed to init schema service ms provider, err=%d", ret);
}
}
if (OB_SUCCESS == ret)
{
if (retry_num >= count_)
{
TBSYS_LOG(DEBUG, "no more ms for scan, retry=%ld count=%ld", retry_num, count_);
ret = OB_MS_ITER_END;
}
else
{
tbsys::CRLockGuard guard(rwlock_);
ms = ms_carray_[retry_num].ms_;
}
}
return ret;
}
示例4:
MockNodeServer::MockNodeServer(int32_t port, int64_t retry_time, int64_t timeout, ObServer monitor, char* app_name, char* instance_name, char* hostname)
{
port_ = port;
retry_times_ = retry_time;
timeout_ = timeout;
monitor_.set_ipv4_addr(monitor.get_ipv4(), monitor.get_port());
app_name_ = app_name;
instance_name_ = instance_name;
hostname_ = hostname;
status_ = UNKNOWN;
}
示例5: fetch_update_server
int ObMergerRpcStub::fetch_update_server(
const int64_t timeout, const ObServer & root_server,
ObServer & update_server, bool for_merge) const
{
int ret = OB_SUCCESS;
ObDataBuffer data_buff;
ret = get_rpc_buffer(data_buff);
// step 1. send get update server info request
if (OB_SUCCESS == ret)
{
ret = rpc_frame_->send_request(root_server,
for_merge ? OB_GET_UPDATE_SERVER_INFO_FOR_MERGE : OB_GET_UPDATE_SERVER_INFO,
DEFAULT_VERSION, timeout, data_buff);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(WARN, "send request to root server for find update server failed:ret[%d]", ret);
}
}
// step 2. deserialize restult code
int64_t pos = 0;
if (OB_SUCCESS == ret)
{
ObResultCode result_code;
ret = result_code.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "deserialize result_code failed:pos[%ld], ret[%d]", pos, ret);
}
else
{
ret = result_code.result_code_;
}
}
// step 3. deserialize update server addr
if (OB_SUCCESS == ret)
{
ret = update_server.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(WARN, "deserialize server failed:pos[%ld], ret[%d]", pos, ret);
}
else
{
TBSYS_LOG(DEBUG, "find update server succ:addr[%d], port[%d]", update_server.get_ipv4(),
update_server.get_port());
}
}
return ret;
}
示例6: change_master
int ObMonitor::change_master(const int64_t timeout, const int64_t retry_times, const ObServer &new_master)
{
int err = OB_ERROR;
for(int64_t i = 0; (i < retry_times) && (err != OB_SUCCESS); i++)
{
err = change_master_(timeout, new_master);
if(OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "%ldth, report change master fail. err =%d", i, err);
}
else
{
TBSYS_LOG(INFO, "report change master to master succ!");
}
}
if(OB_SUCCESS != err)
{
TBSYS_LOG(ERROR, "can't report to master node. master addr =%d, err=%d", new_master.get_ipv4(), err);
}
return err;
}
示例7: scan
int ObScanHelperImpl::scan(const ObScanParam& scan_param, ObScanner &out) const
{
int ret = OB_SUCCESS;
if (!check_inner_stat())
{
ret = OB_NOT_INIT;
TBSYS_LOG(ERROR, "scan help not init");
}
else
{
ObServer ms;
for (int64_t i = 0; i < scan_retry_times_; ++i)
{
if (OB_SUCCESS != (ret = ms_provider_->get_ms(scan_param, i, ms)))
{
TBSYS_LOG(WARN, "failed to get one mergeserver, err=%d", ret);
}
else if (0 == ms.get_port() || 0 == ms.get_ipv4())
{
TBSYS_LOG(WARN, "invalid merge server address, i=%ld", i);
ret = OB_INVALID_ARGUMENT;
}
else if (OB_SUCCESS == (ret = rpc_stub_->scan(ms, scan_param, out, scan_timeout_us_)))
{
TBSYS_LOG(DEBUG, "scan from ms=%s", to_cstring(ms));
break;
}
else
{
TBSYS_LOG(WARN, "scan ms timeout, scan_timeout_us_=%ld, ms=%s, retry=%ld",
scan_timeout_us_, to_cstring(ms), i);
}
} // end for
}
return ret;
}
示例8: get_table_tablet
//.........这里部分代码省略.........
++count;
}
list.clear();
start_key = end_key;
end_key.assign(cell->row_key_.ptr(), cell->row_key_.length());
}
else
{
end_key.assign(cell->row_key_.ptr(), cell->row_key_.length());
if ((cell->column_name_.compare("1_ms_port") == 0)
|| (cell->column_name_.compare("2_ms_port") == 0)
|| (cell->column_name_.compare("3_ms_port") == 0))
{
ret = cell->value_.get_int(port);
}
else if ((cell->column_name_.compare("1_ipv4") == 0)
|| (cell->column_name_.compare("2_ipv4") == 0)
|| (cell->column_name_.compare("3_ipv4") == 0))
{
ret = cell->value_.get_int(ip);
}
else if ((cell->column_name_.compare("1_tablet_version") == 0)
|| (cell->column_name_.compare("2_tablet_version") == 0)
|| (cell->column_name_.compare("3_tablet_version") == 0))
{
ret = cell->value_.get_int(version);
if (OB_SUCCESS == ret)
{
if (0 == port || port == 0)
{
TBSYS_LOG(WARN, "%s", "check port or ip failed");
}
else
{
server.set_ipv4_addr(ip, port);
ObTabletLocation addr(version, server);
if (OB_SUCCESS != (ret = list.add(addr)))
{
TBSYS_LOG(ERROR, "add addr failed:server[%d], port[%d], ret[%d]",
server.get_ipv4(), server.get_port(), ret);
}
else
{
server.to_string(server_addr, MAX_SERVER_ADDR_SIZE);
TBSYS_LOG(DEBUG, "add addr succ:server[%s], version:%ld", server_addr, version);
}
}
ip = port = version = 0;
}
}
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "check get value failed:ret[%d]", ret);
break;
}
}
}
// for the last row
if ((OB_SUCCESS == ret) && (start_key != end_key))
{
ret = init_new_task(name, start_key, end_key, scan_param, task);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "init new task failed:ret[%d]", ret);
}
else
{
ret = insert_new_task(list, task);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "insert new task failed:ret[%d]", ret);
}
++count;
}
if (OB_SUCCESS == ret)
{
// modify last row key for next get root table
uint64_t len = end_key.length();
if (MAX_LEN > len + 1)
{
memcpy(last_tablet_rowkey, end_key.ptr(), len);
last_tablet_rowkey[len] = 0;
row_key.assign(last_tablet_rowkey, len + 1);
}
else
{
TBSYS_LOG(ERROR, "check end key failed:len[%lu]", len);
}
}
}
list.clear();
}
}
}
return ret;
}
示例9: heartbeat
int ObMonitor::heartbeat(const int64_t timeout, const ObServer &master, const ObServer &node, MMS_Status &status)
{
int err = OB_SUCCESS;
ObDataBuffer data_buffer;
err = get_rpc_buffer(data_buffer);
if(OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "fail to get rpc buffer. err=%d", err);
}
//step1:serialize lease
ObLease lease;
lease.lease_time = tbsys::CTimeUtil::getTime();
lease.lease_interval = lease_interval_;
lease.renew_interval = renew_interval_;
if(OB_SUCCESS == err)
{
err = lease.serialize(data_buffer.get_data(), data_buffer.get_capacity(), data_buffer.get_position());
if(OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "fail to serialize lease.err=%d", err);
}
}
FILL_TRACE_LOG("1.serailize lease, err= %d", err);
//step2:serialize master server
if(OB_SUCCESS == err)
{
err = master.serialize(data_buffer.get_data(), data_buffer.get_capacity(), data_buffer.get_position());
if(err != OB_SUCCESS)
{
TBSYS_LOG(WARN, "fail to serialize master");
}
}
FILL_TRACE_LOG("2.serialize master server. err=%d", err);
//step3:send request to node
if(OB_SUCCESS == err)
{
err = client_manager_->send_request(node, OB_MMS_HEART_BEAT, MY_VERSION, timeout, data_buffer);
if(err != OB_SUCCESS)
{
TBSYS_LOG(WARN, "fail to send request. err=%d", err);
}
}
FILL_TRACE_LOG("3. send request to node. node ip=%d, err=%d", node.get_ipv4(), err);
//step4:deserizlie the result_code
ObResultCode result_code;
int64_t pos = 0;
if(OB_SUCCESS == err)
{
err = result_code.deserialize(data_buffer.get_data(), data_buffer.get_position(), pos);
if(OB_SUCCESS != err)
{
TBSYS_LOG(WARN, "fail to deserialize result_code");
}
else
{
err = result_code.result_code_;
}
}
FILL_TRACE_LOG("4.deserialize result code. err=%d", err);
//step5: deserializiton the node status
if(OB_SUCCESS == err)
{
err = serialization::decode_vi32(data_buffer.get_data(), data_buffer.get_position(), pos, reinterpret_cast<int32_t*>(&status));
if(err != OB_SUCCESS)
{
TBSYS_LOG(WARN, "fail to decode status.err=%d", err);
}
}
FILL_TRACE_LOG("5.deserializiton the node status, status=%d, err=%d", status, err);
return err;
}
示例10: add_register_node
int ObMonitor::add_register_node(const ObServer &node, const char *app_name, const char *instance_name, const MMS_Status status)
{
int err = OB_SUCCESS;
if(app_name == NULL || instance_name == NULL)
{
TBSYS_LOG(ERROR, "should not be here.");
err = OB_INVALID_ARGUMENT;
}
//node_list_type * pnodelist = NULL;
mms_value *pvalue = NULL;
mms_key key;
key.app_name = const_cast<char*>(app_name);
key.instance_name = const_cast<char *>(instance_name);
if(OB_SUCCESS == err)
{
if(HASH_EXIST == node_map_.get(key, pvalue))
{
node_list_type *pnodelist = &((*pvalue).node_list);
node_list_type::iterator it_server = pnodelist->end();
bool node_exist = if_node_exist(pnodelist, node, it_server);
if(node_exist == true)
{
TBSYS_LOG(DEBUG, "re_register node. reset the node status");
(*it_server)->is_valid = true;
(*it_server)->lease.lease_time = tbsys::CTimeUtil::getTime();
(*it_server)->lease.lease_interval = lease_interval_;
(*it_server)->lease.renew_interval = renew_interval_;
}
else
{
TBSYS_LOG(DEBUG, "already have register node in the list, add node_info");
node_info *node_server = new(std::nothrow) node_info;
if(node_server == NULL)
{
TBSYS_LOG(WARN, "fail to new node_server.");
err = OB_ALLOCATE_MEMORY_FAILED;
}
else
{
node_server->node_server.set_ipv4_addr(node.get_ipv4(), node.get_port());
node_server->status = status;
node_server->is_valid = true;
node_server->lease.lease_time = tbsys::CTimeUtil::getTime();
node_server->lease.lease_interval = lease_interval_;
node_server->lease.renew_interval = renew_interval_;
pnodelist->push_back(node_server);
}
}
}
else
{
TBSYS_LOG(DEBUG, "a new app+instance node register. add a map pair");
key.app_name = new(std::nothrow)char [OB_MAX_APP_NAME_LENGTH];
key.instance_name = new(std::nothrow)char [OB_MAX_INSTANCE_NAME_LENGTH];
pvalue = new(std::nothrow) mms_value;
node_info *node_server = new(std::nothrow)node_info;
if(key.app_name == NULL || key.instance_name == NULL || node_server == NULL || pvalue == NULL)
{
TBSYS_LOG(WARN, "fail to allocate memory");
err = OB_ALLOCATE_MEMORY_FAILED;
}
else
{
node_list_type *pnodelist = &(pvalue->node_list);
memcpy(key.app_name, app_name, strlen(app_name) + 1);
memcpy(key.instance_name, instance_name, strlen(instance_name) + 1);
node_server->node_server.set_ipv4_addr(node.get_ipv4(), node.get_port());
node_server->status = status;
node_server->is_valid = true;
node_server->lease.lease_time = tbsys::CTimeUtil::getTime();
node_server->lease.lease_interval = lease_interval_;
node_server->lease.renew_interval = renew_interval_;
pnodelist->push_back(node_server);
int hash_err = node_map_.set(key, pvalue);
if(hash_err != HASH_INSERT_SUCC)
{
TBSYS_LOG(WARN, "fail to insert to node_map");
err = OB_ERROR;
}
else
{
TBSYS_LOG(DEBUG, "add map pair succ~!");
}
}
}
}
if(err == OB_SUCCESS && status == MASTER_ACTIVE)
{
pvalue->has_master = true;
pvalue->master.set_ipv4_addr(node.get_ipv4(), node.get_port());
}
return err;
}
示例11: fetch_schema
int ObServerRpc::fetch_schema(const ObServer& root_server,
const int64_t timestap,
ObSchemaManagerV2& schema,
const int64_t timeout)
{
int ret = OB_SUCCESS;
int64_t pos = 0;
ObResultCode result_code;
ObDataBuffer data_buff;
if (root_server.get_ipv4() == 0 || root_server.get_port() == 0
|| timestap < 0 || timeout <= 0)
{
TBSYS_LOG(WARN, "invalid param, ip=%d, port=%d, timestap=%ld, "
"timeout=%ld",
root_server.get_ipv4(), root_server.get_port(),
timestap, timeout);
ret = OB_ERROR;
}
else if (NULL == rpc_frame_)
{
TBSYS_LOG(WARN, "server rpc doesn't init.");
ret = OB_ERROR;
}
if (OB_SUCCESS == ret)
{
ret = get_frame_buffer(data_buff);
}
// step 1. serialize timestap to data_buff
if (OB_SUCCESS == ret)
{
ret = encode_vi64(data_buff.get_data(),
data_buff.get_capacity(),
data_buff.get_position(), timestap);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "serialize timestap failed, timestap=%ld, ret=%d.",
timestap, ret);
}
}
// step 2. send request for fetch new schema
if (OB_SUCCESS == ret)
{
ret = rpc_frame_->send_request(root_server,
OB_FETCH_SCHEMA, DEFAULT_VERSION,
timeout, data_buff);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(WARN, "send request to root server for fetch schema failed, "
"timestap=%ld, ret=%d.", timestap, ret);
}
}
// step 3. deserialize the response code
if (OB_SUCCESS == ret)
{
ret = result_code.deserialize(data_buff.get_data(),
data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "deserialize result_code failed, pos=%ld, ret=%d.",
pos, ret);
}
else
{
ret = result_code.result_code_;
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "get response from root server failed, "
"timeout=%ld, ret=%d.", timeout, ret);
}
}
}
// step 4. deserialize the table schema
if (OB_SUCCESS == ret)
{
ret = schema.deserialize(data_buff.get_data(),
data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "deserialize schema from buffer failed, "
"timestap=%ld, pos=%ld, ret=%d",
timestap, pos, ret);
}
}
return ret;
}
示例12: ups_apply
int ObServerRpc::ups_apply(const ObServer& update_server,
const ObMutator &mutator,
const int64_t timeout)
{
int ret = OB_SUCCESS;
int64_t pos = 0;
ObResultCode result_code;
ObDataBuffer data_buff;
if (update_server.get_ipv4() == 0 || update_server.get_port() == 0
|| timeout <= 0)
{
TBSYS_LOG(WARN, "invalid param, ip=%d, port=%d, timeout=%ld",
update_server.get_ipv4(), update_server.get_port(),
timeout);
ret = OB_ERROR;
}
else if (NULL == rpc_frame_)
{
TBSYS_LOG(WARN, "server rpc doesn't init.");
ret = OB_ERROR;
}
if (NULL == rpc_frame_)
{
TBSYS_LOG(WARN, "server rpc doesn't init.");
ret = OB_ERROR;
}
if (OB_SUCCESS == ret)
{
ret = get_frame_buffer(data_buff);
}
// step 1. serialize mutator to data_buff
if (OB_SUCCESS == ret)
{
ret = mutator.serialize(data_buff.get_data(),
data_buff.get_capacity(),
data_buff.get_position());
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "serialize get_param failed, ret=%d.", ret);
}
}
// step 2. send request for apply
if (OB_SUCCESS == ret)
{
ret = rpc_frame_->send_request(update_server,
OB_WRITE, DEFAULT_VERSION,
timeout, data_buff);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "send request to update server for apply failed, "
"timeout=%ld, ret=%d.", timeout, ret);
}
}
// step 3. deserialize the response code
if (OB_SUCCESS == ret)
{
ret = result_code.deserialize(data_buff.get_data(),
data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "deserialize result_code failed, pos=%ld, ret=%d.",
pos, ret);
}
else
{
ret = result_code.result_code_;
}
}
return ret;
}
示例13: get
int ObServerRpc::get(const ObServer& remote_server,
const ObGetParam& get_param,
ObScanner& scanner,
const int64_t timeout)
{
int ret = OB_SUCCESS;
int64_t pos = 0;
ObResultCode result_code;
ObDataBuffer data_buff;
if (remote_server.get_ipv4() == 0 || remote_server.get_port() == 0
|| timeout <= 0)
{
TBSYS_LOG(WARN, "invalid param, ip=%d, port=%d, timeout=%ld",
remote_server.get_ipv4(), remote_server.get_port(),
timeout);
ret = OB_ERROR;
}
else if (get_param.get_cell_size() <= 0 || get_param.get_row_size() <= 0)
{
TBSYS_LOG(WARN, "invalid param, cell_size=%ld, row_size=%ld",
get_param.get_cell_size(), get_param.get_row_size());
ret = OB_ERROR;
}
else if (NULL == rpc_frame_)
{
TBSYS_LOG(WARN, "server rpc doesn't init.");
ret = OB_ERROR;
}
if (OB_SUCCESS == ret)
{
ret = get_frame_buffer(data_buff);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "get frame buffer failed, ret=%d.", ret);
}
}
// step 1. serialize get param to data_buff
if (OB_SUCCESS == ret)
{
ret = get_param.serialize(data_buff.get_data(),
data_buff.get_capacity(),
data_buff.get_position());
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "serialize get_param failed, ret=%d.", ret);
}
}
// step 2. send request for get
if (OB_SUCCESS == ret)
{
ret = rpc_frame_->send_request(remote_server,
OB_GET_REQUEST, DEFAULT_VERSION,
timeout, data_buff);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "send request to remote server for get failed, "
"ret=%d.", ret);
}
}
// step 3. deserialize the response code
if (OB_SUCCESS == ret)
{
ret = result_code.deserialize(data_buff.get_data(),
data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "deserialize result_code failed,pos=%ld, ret=%d.",
pos, ret);
}
else
{
ret = result_code.result_code_;
if (OB_SUCCESS != ret && OB_DATA_NOT_SERVE != ret)
{
TBSYS_LOG(WARN, "get response from remote server failed, "
"timeout=%ld, ret=%d.", timeout, ret);
}
}
}
// step 4. deserialize the scanner
if (OB_SUCCESS == ret)
{
ret = scanner.deserialize(data_buff.get_data(),
data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "deserialize scanner from buff failed, "
"pos=%ld, ret=%d.", pos, ret);
}
}
return ret;
}
示例14: fetch_update_server
int ObServerRpc::fetch_update_server(const ObServer& root_server,
ObServer& update_server,
const int64_t timeout)
{
int ret = OB_SUCCESS;
int64_t pos = 0;
ObResultCode result_code;
ObDataBuffer data_buff;
if (root_server.get_ipv4() == 0 || root_server.get_port() == 0
|| timeout <= 0)
{
TBSYS_LOG(WARN, "invalid param, ip=%d, port=%d, timeout=%ld",
root_server.get_ipv4(), root_server.get_port(),
timeout);
ret = OB_ERROR;
}
else if (NULL == rpc_frame_)
{
TBSYS_LOG(WARN, "server rpc doesn't init.");
ret = OB_ERROR;
}
if (OB_SUCCESS == ret)
{
ret = get_frame_buffer(data_buff);
}
// step 1. send get update server info request
if (OB_SUCCESS == ret)
{
ret = rpc_frame_->send_request(root_server,
OB_GET_UPDATE_SERVER_INFO,
DEFAULT_VERSION,
timeout, data_buff);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "send request to root server for "
"get update server failed, ret=%d", ret);
}
}
// step 2. deserialize restult code
if (OB_SUCCESS == ret)
{
ret = result_code.deserialize(data_buff.get_data(),
data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(WARN, "deserialize result_code failed, pos=%ld, ret=%d",
pos, ret);
}
else
{
ret = result_code.result_code_;
if (OB_SUCCESS != ret && OB_DATA_NOT_SERVE != ret)
{
TBSYS_LOG(WARN, "get response from root server failed, "
"timeout=%ld, ret=%d.", timeout, ret);
}
}
}
// step 3. deserialize update server addr
if (OB_SUCCESS == ret)
{
ret = update_server.deserialize(data_buff.get_data(),
data_buff.get_position(), pos);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "deserialize update server failed, pos=%ld, ret=%d",
pos, ret);
}
}
return ret;
}
示例15: main
int main(const int argc, char *argv[])
{
int ret = 0;
int exit_flag = 0;
int cmd_type;
char *token = NULL;
ObServer root_server;
ret = parse_obsql_options(argc, argv, root_server);
if ( OB_SUCCESS != ret)
{
usage();
return ret;
}
ret = GFactory::get_instance().initialize(root_server);
if (OB_SUCCESS != ret)
{
fprintf(stderr, "initialize GFactory error, ret=%d\n", ret);
return ret;
}
while ( !exit_flag)
{
char cmdbuf[256];
char *p;
fprintf(stderr, "obsql>");
do
{
fgets(cmdbuf, sizeof(cmdbuf), stdin);
}while (strlen(p = trim(cmdbuf)) == 0);
token = get_token(p);
cmd_type = get_command_type(token);
switch(cmd_type)
{
case CMD_SHOW:
{
/*
const int MAX_SERVER_COUNT = 1000;
ObServer data_holder[MAX_SERVER_COUNT];
common::ObArrayHelper<ObServer> servers(MAX_SERVER_COUNT, data_holder);
*/
ObServer server;
cmd_type = parse_show_command(p, server);
switch(cmd_type)
{
case CMD_SHOW_SCHEMA:
ret = show_schema();
break;
case CMD_SHOW_TABLET:
{
/*
ObTabletShower tablet_shower(GFactory::get_instance().get_rpc_stub(), server);
ret = parse_number_range(p, tablet_shower.get_disks_array());
if (ret != OB_SUCCESS)
{
fprintf(stderr, "parse array numbers error, ret=%d\n", ret);
return ret;
}
tablet_shower.output();
*/
fprintf(stderr, "Cannot support to show tablets now! \n");
break;
}
case CMD_SHOW_STATS_ROOT:
ret = show_server_stats_info(common::ObStatManager::SERVER_TYPE_ROOT,
(server.get_ipv4() != 0) ? &server : NULL,
0);
break;
case CMD_SHOW_STATS_UPDATE:
ret = show_server_stats_info(common::ObStatManager::SERVER_TYPE_UPDATE,
(server.get_ipv4() != 0) ? &server : NULL,
0);
break;
case CMD_SHOW_STATS_CHUNK:
ret = show_server_stats_info(common::ObStatManager::SERVER_TYPE_CHUNK,
(server.get_ipv4() != 0) ? &server : NULL,
0);
break;
case CMD_SHOW_STATS_MERGE:
ret = show_server_stats_info(common::ObStatManager::SERVER_TYPE_MERGE,
(server.get_ipv4() != 0) ? &server : NULL,
0);
break;
case CMD_MIN:
default:
fprintf(stderr, "wrong command. Try \"help\" for more help\n");
break;
}
break;
}
case CMD_HELP:
cmd_usage();
break;
//.........这里部分代码省略.........