当前位置: 首页>>代码示例>>C++>>正文


C++ ObResultCode类代码示例

本文整理汇总了C++中ObResultCode的典型用法代码示例。如果您正苦于以下问题:C++ ObResultCode类的具体用法?C++ ObResultCode怎么用?C++ ObResultCode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ObResultCode类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: handle_grant_lease

          int handle_grant_lease(ObPacket* ob_packet)
          {
            int ret = OB_SUCCESS;

            ObDataBuffer* data_buffer = ob_packet->get_buffer();
            if (NULL == data_buffer)
            {
              TBSYS_LOG(ERROR, "data_buffer is NUll should not reach this");
              ret = OB_ERROR;
            }
            else
            {
              tbnet::Connection* connection = ob_packet->get_connection();
              char buf[10 * 1024];
              ObDataBuffer out_buffer(buf, sizeof(buf));
              ObLease lease;
              ret = lease.deserialize(data_buffer->get_data(), data_buffer->get_capacity(),
                 data_buffer->get_position());
              TBSYS_LOG(DEBUG, "recv grant lease request, lease_time=%ld, lease_interval=%ld, "
                  "ret=%d", lease.lease_time, lease.lease_interval, ret);

              ObResultCode response;
              response.result_code_ = OB_SUCCESS;
              response.serialize(out_buffer.get_data(), out_buffer.get_capacity(),
                  out_buffer.get_position());

              int32_t version = 1;
              int32_t channel_id = ob_packet->getChannelId();
              ret = send_response(OB_GRANT_LEASE_RESPONSE, version, out_buffer, connection, channel_id);
              TBSYS_LOG(DEBUG, "send grant lease response, ret=%d", ret);
            }

            return ret;
          }
开发者ID:CCoder123,项目名称:pproj,代码行数:34,代码来源:mock_server.cpp

示例2: ms_scan

int MockMergeServer::ms_scan(const int64_t start_time,const int32_t version,const int32_t channel_id,tbnet::Connection* connection,common::ObDataBuffer& in_buffer,common::ObDataBuffer& out_buffer,const int64_t timeout_us)
{
  ObResultCode rc;
  rc.result_code_ = OB_SUCCESS;
  int ret = OB_SUCCESS;
  const int32_t MS_SCAN_VERSION = 1;
  ret = rc.serialize(out_buffer.get_data(), out_buffer.get_capacity(), out_buffer.get_position());
  if (OB_SUCCESS == ret)
  {
    ObScanner result_scanner;
    ObCellInfo cell;
    cell.table_name_.assign((char*)"table1", 6);
    //TODO
    char rowkey[30 * 1024];
    cell.row_key_.assign(rowkey, 30 * 1024);
    cell.column_name_.assign((char*)"column1", 7);
    cell.value_.set_int(0xff);
    ret = result_scanner.add_cell(cell);
    result_scanner.set_is_req_fullfilled(true, 1);
    if (OB_SUCCESS == ret)
    {
      ret = result_scanner.serialize(out_buffer.get_data(),out_buffer.get_capacity(), out_buffer.get_position());
    }
    if (OB_SUCCESS == ret)
    {
      ret = this->send_response(OB_SCAN_RESPONSE, MS_SCAN_VERSION, out_buffer, connection, channel_id, 0);
    }

  }
  return ret;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:31,代码来源:mock_merge_server.cpp

示例3: handle_send_log

          int handle_send_log(ObPacket* ob_packet)
          {
            int ret = OB_SUCCESS;

            ObDataBuffer* data_buffer = ob_packet->get_buffer();
            if (NULL == data_buffer)
            {
              TBSYS_LOG(ERROR, "data_buffer is NUll should not reach this");
              ret = OB_ERROR;
            }
            else
            {
              tbnet::Connection* connection = ob_packet->get_connection();
              char buf[10 * 1024];
              ObDataBuffer out_buffer(buf, sizeof(buf));

              ObResultCode response;
              response.result_code_ = OB_SUCCESS;
              response.serialize(out_buffer.get_data(), out_buffer.get_capacity(),
                  out_buffer.get_position());
              TBSYS_LOG(DEBUG, "recv send log request, ret=%d", ret);

              int32_t version = 1;
              int32_t channel_id = ob_packet->getChannelId();
              ret = send_response(OB_SEND_LOG_RES, version, out_buffer, connection, channel_id);
              TBSYS_LOG(DEBUG, "send log response, ret=%d", ret);
            }

            return ret;
          }
开发者ID:CCoder123,项目名称:pproj,代码行数:30,代码来源:mock_server.cpp

示例4: rpc_cs_drop

int rpc_cs_drop(ObClientManager& cp,
                const ObServer& cs,
                int64_t memtable_frozen_version)
{
  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 = encode_i64(ob_inout_buffer.get_data(),
                   ob_inout_buffer.get_capacity(), ob_inout_buffer.get_position(),memtable_frozen_version);
  if (OB_SUCCESS != ret)
  {
    fprintf(stderr,"serialize memtable_frozen_version into buffer failed\n");
    goto exit;
  }

  // send request;
  start = tbsys::CTimeUtil::getTime();
  ret = cp.send_request(cs, OB_DROP_OLD_TABLETS, 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;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:59,代码来源:test_client.cpp

示例5: TBSYS_LOG

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;
}
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:56,代码来源:ob_ms_sql_rpc_event.cpp

示例6: TBSYS_LOG

int ObRootRpcStub::migrate_tablet(const common::ObServer& src_cs, const common::ObServer& dest_cs, const common::ObRange& range, bool keey_src, const int64_t timeout_us)
{
  int ret = OB_SUCCESS;
  ObDataBuffer msgbuf;

  if (NULL == client_mgr_)
  {
    TBSYS_LOG(ERROR, "client_mgr_=NULL");
    ret = OB_ERROR;
  }
  else if (OB_SUCCESS != (ret = get_thread_buffer_(msgbuf)))
  {
    TBSYS_LOG(ERROR, "failed to get thread buffer, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = range.serialize(msgbuf.get_data(), msgbuf.get_capacity(), msgbuf.get_position())))
  {
    TBSYS_LOG(ERROR, "failed to serialize rage, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = dest_cs.serialize(msgbuf.get_data(), msgbuf.get_capacity(), msgbuf.get_position())))
  {
    TBSYS_LOG(ERROR, "failed to serialize dest_cs, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = common::serialization::encode_bool(msgbuf.get_data(), msgbuf.get_capacity(), msgbuf.get_position(), keey_src)))
  {
    TBSYS_LOG(ERROR, "failed to serialize keey_src, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = client_mgr_->send_request(src_cs, OB_CS_MIGRATE, DEFAULT_VERSION, timeout_us, msgbuf)))
  {
    TBSYS_LOG(WARN, "failed to send request, err=%d", ret);
  }
  else
  {
    ObResultCode result;
    int64_t pos = 0;
    if (OB_SUCCESS != (ret = result.deserialize(msgbuf.get_data(), msgbuf.get_position(), pos)))
    {
      TBSYS_LOG(ERROR, "failed to deserialize response, err=%d", ret);
    }
    else if (OB_SUCCESS != result.result_code_)
    {
      TBSYS_LOG(WARN, "failed to migrate tablet, err=%d", result.result_code_);
      ret = result.result_code_;
    }
    else
    {
    }
  }
  return ret;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:49,代码来源:ob_root_rpc_stub.cpp

示例7: deserialize_result_0

 int deserialize_result_0(const ObDataBuffer & data_buffer, int64_t & pos, ObResultCode & rc)
 {
   int ret = OB_SUCCESS;
   if (OB_SUCCESS != (ret = rc.deserialize(data_buffer.get_data(), data_buffer.get_position(), pos)))
   {
     TBSYS_LOG(WARN, "deserialize result code failed. ret:%d, buffer length:%ld, pos:%ld",
         ret, data_buffer.get_position(), pos);
   }
   else
   {
     ret = rc.result_code_;
   }
   return ret;
 }
开发者ID:Alibaba-boonya,项目名称:oceanbase,代码行数:14,代码来源:ob_rpc_stub.cpp

示例8: handle_renew_lease

          int handle_renew_lease(ObPacket* ob_packet)
          {
            int ret = OB_SUCCESS;

            ObDataBuffer* data_buffer = ob_packet->get_buffer();
            if (NULL == data_buffer)
            {
              TBSYS_LOG(ERROR, "data_buffer is NUll should not reach this");
              ret = OB_ERROR;
            }
            else
            {
              ObServer slave_addr;
              char addr_buf[1024];
              ret = slave_addr.deserialize(data_buffer->get_data(), data_buffer->get_capacity(),
                 data_buffer->get_position());
              slave_addr.to_string(addr_buf, sizeof(addr_buf));
              addr_buf[sizeof(addr_buf) - 1] = '\0';
              TBSYS_LOG(DEBUG, "recv renew lease request, slave_addr=%s, ret=%d", addr_buf, ret);
              tbnet::Connection* connection = ob_packet->get_connection();
              char buf[10 * 1024];
              ObDataBuffer out_buffer(buf, sizeof(buf));

              ObResultCode response;
              response.result_code_ = OB_SUCCESS;
              response.serialize(out_buffer.get_data(), out_buffer.get_capacity(),
                  out_buffer.get_position());

              int32_t version = 1;
              int32_t channel_id = ob_packet->getChannelId();
              ret = send_response(OB_RENEW_LEASE_RESPONSE, version, out_buffer, connection, channel_id);
              TBSYS_LOG(DEBUG, "send renew lease response, ret=%d", ret);
            }

            return ret;
          }
开发者ID:CCoder123,项目名称:pproj,代码行数:36,代码来源:mock_server.cpp

示例9: snprintf

int ObFileService::receive_file_end(ObString& file_path, ObString& tmp_file_path,
                                    const int64_t file_size, easy_request_t* request, ObDataBuffer& out_buffer,
                                    int32_t& response_cid, const int64_t session_id)
{
    int ret = OB_SUCCESS;

    struct stat file_stat;
    char tmp_path_buf[OB_MAX_FILE_NAME_LENGTH];
    char path_buf[OB_MAX_FILE_NAME_LENGTH];
    int n = snprintf(tmp_path_buf, OB_MAX_FILE_NAME_LENGTH, "%.*s",
                     tmp_file_path.length(), tmp_file_path.ptr());
    if (n<0 || n>=OB_MAX_FILE_NAME_LENGTH)
    {
        TBSYS_LOG(ERROR, "failed to get tmp_file_path length[%d] [%.*s]",
                  n, tmp_file_path.length(), tmp_file_path.ptr());
        ret = OB_SIZE_OVERFLOW;
    }
    else if (stat(tmp_path_buf, &file_stat) != 0)
    {
        TBSYS_LOG(ERROR, "stat tmp_file_path[%s] failed: %s",
                  tmp_path_buf, strerror(errno));
        ret = OB_IO_ERROR;
    }

    n = snprintf(path_buf, OB_MAX_FILE_NAME_LENGTH, "%.*s",
                 file_path.length(), file_path.ptr());
    if (OB_SUCCESS == ret && (n<0 || n>=OB_MAX_FILE_NAME_LENGTH))
    {
        TBSYS_LOG(ERROR, "failed to get path_buf length[%d] [%.*s]",
                  n, file_path.length(), file_path.ptr());
        ret = OB_SIZE_OVERFLOW;
    }

    if (OB_SUCCESS == ret && file_stat.st_size != file_size)
    {
        TBSYS_LOG(ERROR, "The size of received tmp file size[%ld], "
                  "remote file size[%ld]", file_stat.st_size, file_size);
        ret = OB_INVALID_DATA;
    }
    if (OB_SUCCESS == ret && 0 != rename(tmp_path_buf, path_buf))
    {
        TBSYS_LOG(ERROR, "Rename [%s] to path[%s] failed: errno[%d] %s",
                  tmp_path_buf, path_buf, errno, strerror(errno));
        ret = OB_IO_ERROR;
    }

    int err = OB_SUCCESS;
    ObResultCode rc;
    rc.result_code_ = ret;
    err = rc.serialize(out_buffer.get_data(), out_buffer.get_capacity(),
                       out_buffer.get_position());
    if (OB_SUCCESS != err)
    {
        TBSYS_LOG(WARN, "Encode result code failed:ret=[%d]", err);
    }
    if (OB_SUCCESS == err)
    {
        err = server_->send_response(OB_SEND_FILE_REQUEST_RESPONSE, DEFAULT_VERSION,
                                     out_buffer, request, response_cid, session_id);
        if (OB_SUCCESS != err)
        {
            TBSYS_LOG(WARN, "Send send_file_end_response failed:ret[%d]", err);
        }
    }

    if (OB_SUCCESS == ret && OB_SUCCESS != err)
    {
        ret = err;
    }

    return ret;
}
开发者ID:cuiwm,项目名称:oceanbase,代码行数:72,代码来源:ob_file_service.cpp

示例10: receive_file_loop

int ObFileService::receive_file_loop(ObString& file_path, ObString& tmp_file_path,
                                     const int64_t file_size, ObFileAppender& file_appender,
                                     easy_request_t* request, ObDataBuffer& out_buffer,
                                     int32_t& response_cid, const int64_t session_id)
{
    int ret = OB_SUCCESS;
    ObResultCode rc;
    ObPacket *next_request = NULL;

    if (!file_appender.is_opened())
    {
        ret = OB_ERR_UNEXPECTED;
        TBSYS_LOG(WARN, "File appender is not opened yet in receive_file_loop");
    }

    //generate block_buf
    char *block_buf = NULL;
    if (OB_SUCCESS == ret)
    {
        block_buf = reinterpret_cast<char *>(ob_malloc(block_size_, ObModIds::OB_FILE_CLIENT));
        if(NULL == block_buf)
        {
            ret = OB_ALLOCATE_MEMORY_FAILED;
            TBSYS_LOG(WARN, "Allocate memory for block buffer in receive_file_loop"
                      " failed:err[%d]", ret);
        }
    }
    // do receive file loop
    ObDataBuffer *in_buffer = NULL;
    while(OB_SUCCESS == ret)
    {
        ret = queue_thread_->wait_for_next_request(session_id, next_request,
                network_timeout_);
        if (OB_SUCCESS != ret)
        {
            TBSYS_LOG(WARN, "wait for next request fail:ret[%d] "
                      "network_timeout_[%ld]", ret, network_timeout_);
        }

        if (OB_SUCCESS == ret)
        {
            response_cid = next_request->get_channel_id();
            request = next_request->get_request();
            ret = next_request->deserialize();
            if (OB_SUCCESS != ret)
            {
                TBSYS_LOG(WARN, "Deserialize next request failed:ret[%d]", ret);
            }
        }

        if (OB_SUCCESS == ret)
        {
            in_buffer = next_request->get_buffer();
            if (NULL == in_buffer)
            {
                ret = OB_INNER_STAT_ERROR;
                TBSYS_LOG(WARN, "Get buffer for next request failed");
            }
        }

        if (OB_SUCCESS == ret)
        {
            ret = rc.deserialize(in_buffer->get_data(), in_buffer->get_capacity(),
                                 in_buffer->get_position());
            if (OB_SUCCESS != ret)
            {
                TBSYS_LOG(WARN, "Decode result code failed: ret=[%d]", ret);
            }
        }

        if (OB_SUCCESS == ret)
        {
            if (OB_SUCCESS == rc.result_code_) // receive file block
            {
                ret = receive_file_block(file_appender, block_buf, request,
                                         *in_buffer, out_buffer, response_cid, session_id);
                if (OB_SUCCESS != ret)
                {
                    TBSYS_LOG(ERROR, "failed to receive_file_block");
                }
                //FILL_TRACE_LOG("receive_file_block ");
            }
            else if (OB_ITER_END == rc.result_code_) // the whole file is received
            {
                if (file_appender.is_opened())
                {
                    file_appender.close();
                }
                //FILL_TRACE_LOG("receive_file_end");
                ret = receive_file_end(file_path, tmp_file_path, file_size,
                                       request, out_buffer, response_cid, session_id);
                if (OB_SUCCESS != ret)
                {
                    TBSYS_LOG(ERROR, "failed to send receive_file_end");
                }
                break;// end the receive loop
            }
        }
    }
    if (NULL != block_buf)
//.........这里部分代码省略.........
开发者ID:cuiwm,项目名称:oceanbase,代码行数:101,代码来源:ob_file_service.cpp

示例11: TBSYS_LOG

int ObFileService::handle_send_file_request(
    const int32_t version,
    const int32_t channel_id,
    easy_request_t* request,
    common::ObDataBuffer& in_buffer,
    common::ObDataBuffer& out_buffer)
{
    int ret = OB_SUCCESS;
    bool inc_concurrency_count_flag = false;
    int32_t response_cid = channel_id;
    int64_t session_id = queue_thread_->generate_session_id();
    const char* src_ip;

    //FILL_TRACE_LOG("handle_send_file_request");
    if (!inited_)
    {
        ret = OB_NOT_INIT;
        TBSYS_LOG(ERROR, "ob file client is not inited yet.");
    }

    if (OB_SUCCESS == ret && NULL == request)
    {
        ret = OB_INVALID_ARGUMENT;
        TBSYS_LOG(WARN, "Connection param in receive_file_loop should not be null");
    }

    if (request != NULL && request->ms != NULL && request->ms->c != NULL)
    {
        src_ip  = get_peer_ip(request);
    }
    else
    {
        src_ip = "";
        TBSYS_LOG(WARN, "can't get src ip for send_file_request");
    }

    if (DEFAULT_VERSION != version)
    {
        ret = OB_ERROR_FUNC_VERSION;
        TBSYS_LOG(ERROR, "Can'd handle send_file_request in different version:"
                  "Server version:%d, Packet version:%d", DEFAULT_VERSION, version);
        // send back error message
        ObResultCode rc;
        rc.result_code_ = OB_ERROR_FUNC_VERSION;
        int err = OB_SUCCESS;
        out_buffer.get_position() = 0;
        err = rc.serialize(out_buffer.get_data(), out_buffer.get_capacity(),
                           out_buffer.get_position());
        if (OB_SUCCESS != err)
        {
            TBSYS_LOG(WARN, "Encode result code failed:ret=[%d]", err);
        }
        else
        {
            err = server_->send_response(OB_SEND_FILE_REQUEST_RESPONSE,
                                         DEFAULT_VERSION, out_buffer, request, response_cid, session_id);
            if (OB_SUCCESS != err)
            {
                TBSYS_LOG(WARN, "Send error message for OB_SEND_FILE_REQUEST failed:"
                          "ret[%d]", err);
            }
        }
    }

    if (OB_SUCCESS == ret)
    {
        ret = inc_concurrency_count();
        if(OB_SUCCESS == ret)
        {
            inc_concurrency_count_flag = true;
        }
        else
        {
            // send back error message
            ObResultCode rc;
            int err = OB_SUCCESS;
            rc.result_code_ = ret;
            out_buffer.get_position() = 0;
            err = rc.serialize(out_buffer.get_data(), out_buffer.get_capacity(),
                               out_buffer.get_position());
            if (OB_SUCCESS != err)
            {
                TBSYS_LOG(WARN, "Encode result code failed:ret=[%d]", err);
            }
            else
            {
                err = server_->send_response(OB_SEND_FILE_REQUEST_RESPONSE,
                                             DEFAULT_VERSION, out_buffer, request, response_cid, session_id);
                if (OB_SUCCESS != err)
                {
                    TBSYS_LOG(WARN, "Send error message for OB_SEND_FILE_REQUEST failed:"
                              "ret[%d]", err);
                }
            }
        }
    }

    // handle...
    ObFileAppender file_appender;
    int64_t file_size;
//.........这里部分代码省略.........
开发者ID:cuiwm,项目名称:oceanbase,代码行数:101,代码来源:ob_file_service.cpp

示例12: 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;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:77,代码来源:test_client.cpp

示例13: rpc_cs_get

int rpc_cs_get(ObClientManager& cp,
               const ObServer& cs,
               const ObGetParam& get_param,
               ObScanner& scanner)
{
  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 = get_param.serialize(ob_inout_buffer.get_data(),
                            ob_inout_buffer.get_capacity(), ob_inout_buffer.get_position());
  if (OB_SUCCESS != ret)
  {
    fprintf(stderr,"serialize get_param into buffer failed\n");
    goto exit;
  }

  // send request;
  start = tbsys::CTimeUtil::getTime();
  ret = cp.send_request(cs, OB_GET_REQUEST, 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 obscanner 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());

  // deserialize output
  ret = scanner.deserialize(ob_inout_buffer.get_data(),
                            ob_inout_buffer.get_position(), return_start_pos);
  if (OB_SUCCESS != ret)
  {
    fprintf(stderr,"deserialize obscanner failed\n");
    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;
}
开发者ID:Abioy,项目名称:oceanbase,代码行数:70,代码来源:test_client.cpp


注:本文中的ObResultCode类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。