예제 #1
0
int BalanceTestRpc::push_migrate_msg(const common::ObServer& src_cs, const common::ObServer& dest_cs, const common::ObRange& range, bool keep_src)
{
  int ret = OB_SUCCESS;
  MigrateMsg* msg = new_migrate_msg(src_cs, dest_cs, range, keep_src);
  assert(msg);
  assert(msg->next_ == NULL);
  char addr_buf1[OB_IP_STR_BUFF];
  char addr_buf2[OB_IP_STR_BUFF];
  static char range_buf[OB_MAX_ROW_KEY_LENGTH * 2];
  src_cs.to_string(addr_buf1, OB_IP_STR_BUFF);
  dest_cs.to_string(addr_buf2, OB_IP_STR_BUFF);

  tbsys::CThreadGuard guard(&migrate_msg_mutex_);
  if (NULL == msg_head_)
  {
    msg_head_ = msg;
  }
  else
  {
    msg->next_ = msg_head_;
    msg_head_ = msg;
  }
  msg_count_++;
  msg->range_.to_string(range_buf, OB_MAX_ROW_KEY_LENGTH*2);
  TBSYS_LOG(DEBUG, "push migrate msg, src=%s dest=%s range=%s",
            addr_buf1, addr_buf2, range_buf);
  return ret;
}
예제 #2
0
int ObRootRpcStub::switch_schema(const common::ObServer& ups, const common::ObSchemaManagerV2& schema_manager, 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 = schema_manager.serialize(msgbuf.get_data(), msgbuf.get_capacity(), msgbuf.get_position())))
  {
    TBSYS_LOG(ERROR, "failed to serialize schema, err=%d", ret);
  }
  else if (OB_SUCCESS != (ret = client_mgr_->send_request(ups, OB_SWITCH_SCHEMA, 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 switch schema, err=%d", result.result_code_);
      ret = result.result_code_;
    }
    else
    {
      char server_buf[OB_IP_STR_BUFF];
      ups.to_string(server_buf, OB_IP_STR_BUFF);
      TBSYS_LOG(INFO, "send up_switch_schema, ups=%s schema_version=%ld", server_buf, schema_manager.get_version());
    }
  }
  return ret;
}