本文整理汇总了C++中ObServer::serialize方法的典型用法代码示例。如果您正苦于以下问题:C++ ObServer::serialize方法的具体用法?C++ ObServer::serialize怎么用?C++ ObServer::serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObServer
的用法示例。
在下文中一共展示了ObServer::serialize方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2:
int ObUpsRpcStub :: send_freeze_memtable_resp(const ObServer& root_server,
const ObServer& ups_master, const int64_t schema_timestamp, const int64_t timeout_us)
{
int err = OB_SUCCESS;
ObDataBuffer data_buff;
ObServer update_server;
if (NULL == client_mgr_)
{
TBSYS_LOG(WARN, "invalid status, client_mgr_[%p]", client_mgr_);
err = OB_ERROR;
}
else
{
err = get_thread_buffer_(data_buff);
}
// serialize ups_master
if (OB_SUCCESS == err)
{
err = ups_master.serialize(data_buff.get_data(), data_buff.get_capacity(),
data_buff.get_position());
}
// serialize timestamp
if (OB_SUCCESS == err)
{
err = common::serialization::encode_vi64(data_buff.get_data(),
data_buff.get_capacity(), data_buff.get_position(), schema_timestamp);
}
// step 1. send freeze memtable resp
if (OB_SUCCESS == err)
{
err = client_mgr_->send_request(root_server,
OB_WAITING_JOB_DONE, DEFAULT_VERSION, timeout_us, data_buff);
if (err != OB_SUCCESS)
{
TBSYS_LOG(ERROR, "send freeze memtable failed, err[%d].", err);
}
}
// step 2. deserialize the response code
int64_t pos = 0;
if (OB_SUCCESS == err)
{
ObResultCode result_code;
err = result_code.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
if (OB_SUCCESS != err)
{
TBSYS_LOG(ERROR, "deserialize result_code failed:pos[%ld], err[%d].", pos, err);
}
else
{
err = result_code.result_code_;
}
}
return err;
}
示例3: async_heartbeat
int ObRootServerRpcStub::async_heartbeat(const ObServer & client)
{
int ret = OB_SUCCESS;
ObDataBuffer data_buff;
ret = get_frame_buffer(data_buff);
// step 1. serialize client server addr to data_buff
if (OB_SUCCESS == ret)
{
ret = client.serialize(data_buff.get_data(),
data_buff.get_capacity(), data_buff.get_position());
if (OB_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "serialize client server addr failed:ret[%d].", ret);
}
}
// step 2. rpc frame send request and receive the response
if (OB_SUCCESS == ret)
{
ret = rpc_frame_->post_request(root_server_,
OB_HEARTBEAT, DEFAULT_VERSION, data_buff);
if (OB_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "post request to root server "
"for heartbeat failed:ret[%d].", ret);
}
}
// step 3. dont care server's response packet.
return ret;
}
示例4: report_slave_failure_
int ObMonitor::report_slave_failure_(const int64_t timeout, const ObServer &slave, const ObServer &master)
{
int err = OB_SUCCESS;
ObDataBuffer data_buffer;
err = get_rpc_buffer(data_buffer);
if(err != OB_SUCCESS)
{
TBSYS_LOG(WARN, "fail to get data buffer. err=%d", err);
}
//step 1:serialize slave node
if(OB_SUCCESS == err)
{
err = slave.serialize(data_buffer.get_data(), data_buffer.get_capacity(), data_buffer.get_position());
if(err != OB_SUCCESS)
{
TBSYS_LOG(WARN, "fail to serialize slave node. err=%d", err);
}
}
//step2: send request
if(OB_SUCCESS == err)
{
err = client_manager_->send_request(master, OB_MMS_SLAVE_DOWN, MY_VERSION, timeout, data_buffer);
if(err != OB_SUCCESS)
{
TBSYS_LOG(WARN, "fail to send request to master. err=%d", err);
}
}
//step3:deserialize the result code
int64_t pos = 0;
if(OB_SUCCESS == err)
{
ObResultCode result_code;
err = result_code.deserialize(data_buffer.get_data(), data_buffer.get_capacity(), pos);
if(err != OB_SUCCESS)
{
TBSYS_LOG(WARN, "fail to deserialize result_code, err=%d", err);
}
else
{
err = result_code.result_code_;
}
}
return err;
}
示例5: regist_self
int MockChunkServer::regist_self()
{
self_.reset_ipv4_10(number_+1);
ThreadSpecificBuffer::Buffer* thread_buffer = response_packet_buffer_.get_buffer();
thread_buffer->reset();
ObDataBuffer thread_buff(thread_buffer->current(),thread_buffer->remain());
ObServer server = self_;
int ret = server.serialize(thread_buff.get_data(),
thread_buff.get_capacity(), thread_buff.get_position());
ret = common::serialization::encode_bool(thread_buff.get_data(), thread_buff.get_capacity(), thread_buff.get_position(), false);
char str[60];
root_server_.to_string(str,60);
if (OB_SUCCESS == ret)
{
do {
TBSYS_LOG(INFO, "root server is %s", str);
ret = client_manager_.send_request(root_server_, OB_SERVER_REGISTER, 1, 50000, thread_buff);
if (OB_SUCCESS != ret) sleep(1);
}while (OB_SUCCESS != ret);
}
ObDataBuffer out_buffer(thread_buff.get_data(), thread_buff.get_position());
if (ret == OB_SUCCESS)
{
common::ObResultCode result_msg;
ret = result_msg.deserialize(out_buffer.get_data(), out_buffer.get_capacity(), out_buffer.get_position());
if (ret == OB_SUCCESS)
{
ret = result_msg.result_code_;
if (ret != OB_SUCCESS)
{
TBSYS_LOG(INFO, "rpc return error code is %d msg is %s", result_msg.result_code_, result_msg.message_.ptr());
}
}
}
thread_buffer->reset();
return 0;
}
示例6: rpc_cs_migrate
int rpc_cs_migrate(ObClientManager& cp,
const ObServer& src,
const ObServer& dest,
const ObRange& range,
bool keep_src)
{
int ret = OB_SUCCESS;
int64_t start = 0, end = 0;
const int32_t BUFFER_SIZE = 2*1024*1024;
char* param_buffer = new char[BUFFER_SIZE];
ObDataBuffer ob_inout_buffer;
ObResultCode rc;
int64_t return_start_pos = 0;
if (NULL == param_buffer)
{
goto exit;
}
ob_inout_buffer.set_data(param_buffer, BUFFER_SIZE);
ret = range.serialize(ob_inout_buffer.get_data(),
ob_inout_buffer.get_capacity(), ob_inout_buffer.get_position());
if (OB_SUCCESS != ret)
{
fprintf(stderr,"serialize migrate range into buffer failed\n");
goto exit;
}
ret = dest.serialize(ob_inout_buffer.get_data(),
ob_inout_buffer.get_capacity(), ob_inout_buffer.get_position());
if (OB_SUCCESS != ret)
{
fprintf(stderr,"serialize dest_server into buffer failed\n");
goto exit;
}
ret = encode_bool(ob_inout_buffer.get_data(),ob_inout_buffer.get_capacity(),ob_inout_buffer.get_position(),keep_src);
if (OB_SUCCESS != ret)
{
fprintf(stderr,"serialize keep_src into buffer failed\n");
goto exit;
}
// send request;
start = tbsys::CTimeUtil::getTime();
ret = cp.send_request(src, OB_CS_MIGRATE, 1, 2000*2000, ob_inout_buffer);
end = tbsys::CTimeUtil::getTime();
fprintf(stderr,"time consume:%ld\n", end - start);
if (OB_SUCCESS != ret)
{
fprintf(stderr,"rpc failed\n");
goto exit;
}
ret = rc.deserialize(ob_inout_buffer.get_data(),
ob_inout_buffer.get_position(), return_start_pos);
if (OB_SUCCESS != ret)
{
fprintf(stderr,"deserialize failed\n");
goto exit;
}
fprintf(stderr,"return rc code:%d, msg:%s\n", rc.result_code_, rc.message_.ptr());
if (OB_SUCCESS != rc.result_code_)
{
goto exit;
}
fprintf(stderr,"return_start_pos:%ld, %ld\n", return_start_pos, ob_inout_buffer.get_position());
exit:
if (param_buffer) delete []param_buffer;
return ret;
}
示例7: 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;
}