예제 #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;
}
int ObMergerGetRequest::get_session_next(const int64_t sub_req_idx,
  ObMergerRpcEvent & prev_rpc, const int64_t timeout_us)
{
  int err = OB_SUCCESS;
  ObMergerRpcEvent *rpc_event = NULL;
  if ((OB_SUCCESS == err) && (OB_SUCCESS != (err = ObMergerRequest::create(&rpc_event))))
  {
    TBSYS_LOG(WARN,"fail to create ObMergerRpcEvent [err:%d]", err);
  }
  if (OB_SUCCESS == err)
  {
    if (OB_SUCCESS != (err = get_rpc()->get_session_next(timeout_us,prev_rpc.get_server(),
            prev_rpc.get_session_id(), prev_rpc.get_req_type(), *rpc_event)))
    {
      TBSYS_LOG(WARN,"fail to send request to server [request_id:%lu,err:%d]", get_request_id(),err);
    }
    else
    {
      sub_requests_[sub_req_idx].set_last_rpc_event(*rpc_event, prev_rpc.get_session_id());
      sub_requests_[sub_req_idx].set_last_svr_ipv4(prev_rpc.get_server().get_ipv4());
      TBSYS_LOG(INFO, "session next [request_id:%lu,prev_rpc:%lu,cur_rpc:%lu]", get_request_id(),
        prev_rpc.get_event_id(), rpc_event->get_event_id());
    }
  }
  return err;
}
예제 #3
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;
}