Пример #1
0
int ObMergerRequest::remove_invalid_event_in_finish_queue(const int64_t timeout)
{
  int ret = OB_SUCCESS;
  int64_t remainder = timeout;
  int64_t size = finish_queue_.size();
  bool is_valid = false;
  ObMergerRpcEvent * event = NULL;
  while (remainder > 0 && size > 0)
  {
    if (OB_SUCCESS == (ret = finish_queue_.pop(remainder, (void *&)event)))
    {
      if (NULL != event && OB_SUCCESS == event->get_result_code()
          && event->get_session_id() >  ObCommonRpcEvent::INVALID_SESSION_ID)
      {
        terminate_remote_session(event->get_server(), event->get_session_id());
        TBSYS_LOG(INFO,"end finished but not process session [client:%ld, session_id:%lu, event_id:%ld]",
            event->get_client_id(), event->get_session_id(), event->get_event_id());
      }
      remove_wait_queue(event, is_valid);
      destroy_rpc_event(event);
    }
    else
    {
      TBSYS_LOG(WARN, "pop result from finish queue failed:request[%lu], event[%p], ret[%d]",
          request_id_, event, ret);
    }
    size = finish_queue_.size();
  }
  return ret;
}
Пример #2
0
// by the tbnet thread so lightweight
int ObMergerRequest::signal(ObMergerRpcEvent & event)
{
  // only push to the finish_queue not check request id or in wait queue
  int ret = OB_SUCCESS;
  if (request_id_ != event.get_client_id())
  {
    TBSYS_LOG(INFO , "the event we do not expect from server, "
        "event[%ld], client[%ld], current client[%ld], session id[%ld], rcode[%d]",
        event.get_event_id(), event.get_client_id(), request_id_,
        event.get_session_id(), event.get_result_code());
    ret = OB_INVALID_ERROR;
  }
  else
  {
    ret = finish_queue_.push(&event);
  }

  if (ret != OB_SUCCESS)
  {
    if (OB_INVALID_ERROR != ret)
    {
      TBSYS_LOG(ERROR, "push to finish queue failed:client[%lu], event[%lu], "
          "request[%lu], finish_size[%ld], ret[%d]", event.get_client_id(), event.get_event_id(),
          request_id_, finish_queue_.size(), ret);
    }
    else if (OB_INVALID_ERROR == ret && OB_SUCCESS == event.get_result_code()
        && event.get_session_id() >  ObCommonRpcEvent::INVALID_SESSION_ID)
    {
      terminate_remote_session(event.get_server(), event.get_session_id());
      TBSYS_LOG(INFO,"end unexpect session [client:%ld, session_id:%lu]",
          event.get_client_id(), event.get_session_id());
    }
    bool is_valid = false;
    remove_wait_queue(&event, is_valid);
    destroy_rpc_event(&event);
  }
  else
  {
    TBSYS_LOG(DEBUG, "push to finish queue succ:client[%lu], event[%lu], request[%lu]",
        event.get_client_id(), event.get_event_id(), request_id_);
  }
  return ret;
}
Пример #3
0
int ObGetRequestEvent::setup_new_request(const bool retry, const ObGetParam & get_param)
{
  int ret = OB_SUCCESS;
  ObMergerRpcEvent * event = NULL;
  // step 1. create new rpc event and add to the waiting queue
  if (false == check_inner_stat())
  {
    ret = OB_INNER_STAT_ERROR;
    TBSYS_LOG(WARN, "check inner stat failed");
  }
  else
  {
    ret = ObMergerRequestEvent::create(&event);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "add new rpc event failed:request[%lu], ret[%d]", get_request_id(), ret);
    }
  }
  
  // TODO check retry with other cs
  UNUSED(retry);
  ObMergerTabletLocationList list;
  // step 3. select the right cs for request
  if ((OB_SUCCESS == ret)) // && (false == retry))
  {
    ret = get_cache_proxy()->get_tablet_location(get_param[0]->table_id_, get_param[0]->row_key_, list);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(WARN, "get tablet location failed:client[%lu], event[%lu], request[%lu], ret[%d]",
          event->get_client_id(), event->get_event_id(), get_request_id(), ret);
    }
  }
  
  // step 4. send reqeust for get
  if (OB_SUCCESS == ret)
  {
    // TODO access list[0]
    event->set_server(list[0].server_.chunkserver_);
    ret = get_rpc()->get(get_timeout(), list[0].server_.chunkserver_, get_param, *event);
    if (ret != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "check async rpc stub failed:client[%lu], event[%lu], request[%lu], ret[%d]",
        event->get_client_id(), event->get_event_id(), get_request_id(), ret);
    }
    else
    {
      TBSYS_LOG(DEBUG, "send get param to server succ:client[%lu], event[%lu], request[%lu], "
          "get_cell[%ld]", event->get_client_id(), event->get_event_id(), get_request_id(),
          get_param.get_cell_size());
    }
  }
  
  /// if not send succ
  if ((event != NULL) && (ret != OB_SUCCESS))
  {
    uint64_t client_id = event->get_client_id();
    uint64_t event_id = event->get_event_id();
    int err = ObMergerRequestEvent::destroy(event);
    if (err != OB_SUCCESS)
    {
      TBSYS_LOG(ERROR, "destroy the event failed when rpc send failed:client[%lu], event[%lu], "
          "request[%lu], ret[%d], err[%d]", client_id, event_id, get_request_id(), ret, err);
    }
    else
    {
      TBSYS_LOG(INFO, "destroy directly succ:client[%lu], event[%lu], request[%lu], ret[%d]",
          client_id, event_id, get_request_id(), ret);
    }
  }
  return ret;
}