Beispiel #1
0
    int ObUpsRpcStub :: report_freeze(const common::ObServer &root_server,
        const common::ObServer &ups_master, const int64_t frozen_version, 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(), frozen_version);
      }

      // step 1. send freeze memtable resp
      if (OB_SUCCESS == err)
      {
        err = client_mgr_->send_request(root_server, 
            OB_UPDATE_SERVER_REPORT_FREEZE, 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;
    }
Beispiel #2
0
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;
}
Beispiel #3
0
    int ObRootRpcStub::slave_register(const common::ObServer& master, const common::ObServer& slave_addr, common::ObFetchParam& fetch_param, const int64_t timeout)
    {
      int err = OB_SUCCESS;
      ObDataBuffer data_buff;

      if (NULL == client_mgr_)
      {
        TBSYS_LOG(WARN, "invalid status, client_mgr_[%p]", client_mgr_);
        err = OB_ERROR;
      }
      else
      {
        err = get_thread_buffer_(data_buff);
      }

      // step 1. serialize slave addr
      if (OB_SUCCESS == err)
      {
        err = slave_addr.serialize(data_buff.get_data(), data_buff.get_capacity(),
            data_buff.get_position());
      }

      // step 2. send request to register
      if (OB_SUCCESS == err)
      {
        err = client_mgr_->send_request(master, 
            OB_SLAVE_REG, DEFAULT_VERSION, timeout, data_buff);
        if (err != OB_SUCCESS)
        {
          TBSYS_LOG(ERROR, "send request to register failed"
              "err[%d].", err);
        }
      }

      // step 3. 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_;
        }
      }

      // step 3. deserialize fetch param
      if (OB_SUCCESS == err)
      {
        err = fetch_param.deserialize(data_buff.get_data(), data_buff.get_position(), pos);
        if (OB_SUCCESS != err)
        {
          TBSYS_LOG(WARN, "deserialize fetch param failed, err[%d]", err);
        }
      }

      return err;
    }
Beispiel #4
0
int ObRootServerRpcStub::migrate_over(
    const common::ObRange &range, 
    const common::ObServer &src_server,
    const common::ObServer &dest_server, 
    const bool keep_src,
    const int64_t tablet_version)
{
  const int64_t timeout = ObChunkServerMain::get_instance()->
    get_chunk_server().get_param().get_network_time_out() ;  // send_request timeout us
  int ret = OB_SUCCESS;
  ObDataBuffer data_buff;
  ret = get_frame_buffer(data_buff);

  // step 1. serialize server to data_buff
  if (OB_SUCCESS == ret)
  {
    ret = range.serialize(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position());
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize range failed[%d]", ret);
    }
  }

  if (OB_SUCCESS == ret)
  {
    ret = src_server.serialize(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position());
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize src_server failed[%d]", ret);
    }
  }

  if (OB_SUCCESS == ret)
  {
    ret = dest_server.serialize(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position());
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize dest_server failed=[%d]", ret);
    }
  }

  if (OB_SUCCESS == ret)
  {
    ret = serialization::encode_bool(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position(), keep_src);
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize keep_src failed=[%d]", ret);
    }
  }

  if (OB_SUCCESS == ret)
  {
    ret = serialization::encode_vi64(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position(), tablet_version);
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize tablet_version failed=[%d]", ret);
    }
  }

  // step 2. send request for report tablet migrate over.
  if (OB_SUCCESS == ret)
  {
    ret = rpc_frame_->send_request(root_server_, 
        OB_MIGRATE_OVER, DEFAULT_VERSION, timeout, data_buff);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "send request to root server for register failed"
          ",ret=[%d].", ret);
    }
  }


  // step 3. deserialize the response 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(ERROR, "deserialize result_code failed:pos[%ld], ret[%d].", pos, ret);
    }
    else
    {
      ret = result_code.result_code_;
    }
  }

  return ret;
}
Beispiel #5
0
int ObRootServerRpcStub::report_capacity_info(const common::ObServer &server, 
    const int64_t capacity, const int64_t used)
{
  const int64_t report_timeout = ObChunkServerMain::get_instance()->
    get_chunk_server().get_param().get_network_time_out() ;  // send_request timeout us
  int ret = OB_SUCCESS;
  ObDataBuffer data_buff;
  ret = get_frame_buffer(data_buff);

  // step 1. serialize server to data_buff
  if (OB_SUCCESS == ret)
  {
    ret = server.serialize(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position());
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize server failed[%d]", ret);
    }
  }

  if (OB_SUCCESS == ret)
  {
    ret = serialization::encode_vi64(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position(), capacity);
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize capacity failed=[%d]", ret);
    }
  }

  if (OB_SUCCESS == ret)
  {
    ret = serialization::encode_vi64(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position(), used);
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize used failed=[%d]", ret);
    }
  }

  // step 2. send request for fetch new schema
  if (OB_SUCCESS == ret)
  {
    ret = rpc_frame_->send_request(root_server_, 
        OB_REPORT_CAPACITY_INFO, DEFAULT_VERSION, report_timeout, data_buff);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "send request to root server for report capacity failed"
          ",ret=[%d].", ret);
    }
  }


  // step 3. deserialize the response 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(ERROR, "deserialize result_code failed:pos[%ld], ret[%d].", pos, ret);
    }
    else
    {
      ret = result_code.result_code_;
    }
  }

  return ret;
}
Beispiel #6
0
int ObRootServerRpcStub::register_server(const common::ObServer & server, 
    const bool is_merge_server, int32_t& status)
{
  const int64_t register_timeout = ObChunkServerMain::get_instance()->
    get_chunk_server().get_param().get_network_time_out() ;  // send_request timeout us
  int ret = OB_SUCCESS;
  ObDataBuffer data_buff;
  ret = get_frame_buffer(data_buff);

  // step 1. serialize server to data_buff
  if (OB_SUCCESS == ret)
  {
    ret = server.serialize(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position());
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize server failed[%d]", ret);
    }
  }

  if (OB_SUCCESS == ret)
  {
    ret = serialization::encode_bool(data_buff.get_data(), data_buff.get_capacity(),
        data_buff.get_position(), is_merge_server);
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "serialize is_merge_server failed=[%d]", ret);
    }
  }

  // step 2. send request for fetch new schema
  if (OB_SUCCESS == ret)
  {
    ret = rpc_frame_->send_request(root_server_, 
        OB_SERVER_REGISTER, DEFAULT_VERSION, register_timeout, data_buff);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "send request to root server for register failed"
          ",ret=[%d].", ret);
    }
  }


  // step 3. deserialize the response 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(ERROR, "deserialize result_code failed:pos[%ld], ret[%d].", pos, ret);
    }
    else
    {
      ret = result_code.result_code_;
    }
  }
  // step 4. deserialize status field
  if (OB_SUCCESS == ret)
  {
    ret = serialization::decode_vi32(data_buff.get_data(), data_buff.get_position(), pos, &status);
    if (OB_SUCCESS != ret)
    {
      TBSYS_LOG(ERROR, "deserialize status from buff failed,"
          "pos[%ld], ret[%d].", pos, ret);
    }
  }

  return ret;
}