コード例 #1
0
ファイル: Dispatcher.cpp プロジェクト: aboleab/ArangoDB
bool Dispatcher::addJob (Job* job) {
  RequestStatisticsAgentSetQueueStart(job);

  // do not start new jobs if we are already shutting down
  if (_stopping != 0) {
    return false;
  }

  // try to find a suitable queue
  DispatcherQueue* queue = lookupQueue(job->queue());

  if (queue == 0) {
    LOGGER_WARNING("unknown queue '" << job->queue() << "'");
    return false;
  }

  // log success, but do this BEFORE the real add, because the addJob might execute
  // and delete the job before we have a chance to log something
  LOGGER_TRACE("added job " << job << " to queue " << job->queue());

  // add the job to the list of ready jobs
  queue->addJob(job);

  // indicate success, BUT never access job after it has been added to the queue
  return true;
}
コード例 #2
0
int Dispatcher::addJob (Job* job) {
  RequestStatisticsAgentSetQueueStart(job);

  // do not start new jobs if we are already shutting down
  if (_stopping != 0) {
    return TRI_ERROR_DISPATCHER_IS_STOPPING;
  }

  // try to find a suitable queue
  string const& name = job->queue();
  DispatcherQueue* queue = lookupQueue(name);

  if (queue == nullptr) {
    LOG_DEBUG("unknown queue '%s'", name.c_str());
    return TRI_ERROR_QUEUE_UNKNOWN;
  }

  // log success, but do this BEFORE the real add, because the addJob might execute
  // and delete the job before we have a chance to log something
  LOG_TRACE("added job %p to queue '%s'", (void*) job, name.c_str());

  // add the job to the list of ready jobs
  if (! queue->addJob(job)) {
    return TRI_ERROR_QUEUE_FULL; // queue full etc.
  }

  // indicate success, BUT never access job after it has been added to the queue
  return TRI_ERROR_NO_ERROR;
}
コード例 #3
0
ファイル: Dispatcher.cpp プロジェクト: CedarLogic/arangodb
int Dispatcher::addJob (Job* job) {
  RequestStatisticsAgentSetQueueStart(job);

  // do not start new jobs if we are already shutting down
  if (_stopping.load(memory_order_relaxed)) {
    return TRI_ERROR_DISPATCHER_IS_STOPPING;
  }

  // try to find a suitable queue
  size_t qnr = job->queue();
  DispatcherQueue* queue;

  if (qnr >= _queues.size() || (queue = _queues[qnr]) == nullptr) {
    LOG_WARNING("unknown queue '%lu'", (unsigned long) qnr);
    return TRI_ERROR_QUEUE_UNKNOWN;
  }

  // log success, but do this BEFORE the real add, because the addJob might execute
  // and delete the job before we have a chance to log something
  LOG_TRACE("added job %p to queue '%lu'", (void*) job, (unsigned long) qnr);

  // add the job to the list of ready jobs
  return queue->addJob(job);
}