本文整理汇总了C++中ObPacket::get_session_id方法的典型用法代码示例。如果您正苦于以下问题:C++ ObPacket::get_session_id方法的具体用法?C++ ObPacket::get_session_id怎么用?C++ ObPacket::get_session_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObPacket
的用法示例。
在下文中一共展示了ObPacket::get_session_id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send_request
int ObClientManager::send_request(const ObServer& server, const int32_t pcode, const int32_t version,
const int64_t timeout, ObDataBuffer& in_buffer, ObDataBuffer& out_buffer, int64_t& session_id) const
{
int rc = OB_SUCCESS;
ObPacket* response = NULL;
rc = do_send_request(server, pcode, version, timeout, in_buffer, response);
// deserialize response packet to out_buffer
if (OB_SUCCESS == rc && NULL != response)
{
session_id = response->get_session_id() ; // TODO
// copy response's inner_buffer to out_buffer.
int64_t data_length = response->get_data_length();
ObDataBuffer* response_buffer = response->get_buffer();
if (out_buffer.get_remain() < data_length)
{
TBSYS_LOG(ERROR, "insufficient memory in out_buffer, remain:%ld, length=%ld",
out_buffer.get_remain(), data_length);
rc = OB_ERROR;
}
else
{
memcpy(out_buffer.get_data() + out_buffer.get_position(),
response_buffer->get_data() + response_buffer->get_position(),
data_length);
out_buffer.get_position() += data_length;
}
}
return rc;
}
示例2: deserialize_packet
int ObMsSqlRpcEvent::deserialize_packet(ObPacket & packet, ObNewScanner & result)
{
ObDataBuffer * data_buff = NULL;
int ret = packet.deserialize();
if (ret != OB_SUCCESS)
{
TBSYS_LOG(WARN, "deserialize the packet failed:ret[%d]", ret);
}
else
{
data_buff = packet.get_buffer();
if (NULL == data_buff)
{
ret = OB_INNER_STAT_ERROR;
TBSYS_LOG(WARN, "check packet data buff failed:buff[%p]", data_buff);
}
if (packet.get_packet_code() == OB_SESSION_END)
{
/// when session end, set session id to 0
set_session_end();
}
else
{
set_session_id(packet.get_session_id());
}
}
ObResultCode code;
if (OB_SUCCESS == ret)
{
ret = code.deserialize(data_buff->get_data(), data_buff->get_capacity(),
data_buff->get_position());
if (OB_SUCCESS != ret)
{
TBSYS_LOG(ERROR, "deserialize result failed:pos[%ld], ret[%d]",
data_buff->get_position(), ret);
}
else
{
ObCommonSqlRpcEvent::set_result_code(code.result_code_);
}
}
///
result.clear();
if ((OB_SUCCESS == ret) && (OB_SUCCESS == code.result_code_))
{
ret = result.deserialize(data_buff->get_data(), data_buff->get_capacity(),
data_buff->get_position());
if (ret != OB_SUCCESS)
{
TBSYS_LOG(WARN, "deserialize scanner failed:pos[%ld], ret[%d]",
data_buff->get_position(), ret);
}
}
return ret;
}
示例3: handle_packet
int ObMsSqlRpcEvent::handle_packet(ObPacket * packet, void * args)
{
int ret = OB_SUCCESS;
if (ObMergeServerMain::get_instance()->get_merge_server().is_stoped())
{
TBSYS_LOG(WARN, "server stoped, cannot handle anything.");
ret = OB_ERROR;
}
else
{
/// stat event process time
this->end();
/// parse the packet for get result code and result scanner
ret = parse_packet(packet, args);
if (ret != OB_SUCCESS)
{
TBSYS_LOG(WARN, "parse packet from server[%s] failed, request_id[%lu], event_id[%lu], rpc_event[%p]",
server_.to_cstring(), client_request_id_, get_event_id(), this);
/// set result code, maybe timeout packet, connection errors.
if (NULL != args && 1 == reinterpret_cast<easy_connection_t*>(args)->conn_has_error)
{
ObCommonSqlRpcEvent::set_result_code(OB_CONN_ERROR);
}
else
{
ObCommonSqlRpcEvent::set_result_code(ret);
}
}
ObPacket* obpacket = packet;
if (NULL != obpacket)
{
TBSYS_LOG(DEBUG, "get packet from server[%s] success, event_id[%lu], time_used[%ld],"
"result code=%d, packet code=%d, session_id=%ld",
server_.to_cstring(), get_event_id(), get_time_used(), get_result_code(),
obpacket->get_packet_code(), obpacket->get_session_id());
}
//lock_.lock();
if (client_request_ == NULL)
{
TBSYS_LOG(WARN, "rpc event(%p) unknown status, destroy myself, event_id[%lu] "
"request_id[%lu], req_type[%d]",
this, this->get_event_id(), this->get_client_id(), this->get_req_type());
this->~ObMsSqlRpcEvent();
ob_tc_free(this);
}
else
{
/// no matter parse succ or failed push to finish queue
/// not check the event valid only push to the finish queue
if (OB_SUCCESS != (ret = client_request_->signal(*this)))
{
TBSYS_LOG(WARN, "failed to push event to finish queue, destroy myself, req_type[%s], request_id[%lu], ret=%d",
(this->get_req_type() == SCAN_RPC) ? "SCAN":"GET", this->get_client_id(), ret);
OB_ASSERT(magic_ == 0x1234abcd);
this->~ObMsSqlRpcEvent();
ob_tc_free(this);
}
else
{
//OB_ASSERT(magic_ == 0x1234abcd);
//lock_.unlock();
}
}
}
return ret;
}