コード例 #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
void Dispatcher::setProcessorAffinity (size_t id, std::vector<size_t> const& cores) {
  DispatcherQueue* queue;

  if (id >= _queues.size() || (queue = _queues[id]) == nullptr) {
    return;
  }

  queue->setProcessorAffinity(cores);
}
コード例 #4
0
ファイル: Dispatcher.cpp プロジェクト: CedarLogic/arangodb
void Dispatcher::shutdown () {
  LOG_DEBUG("shutting down the dispatcher");

  for (size_t i = 0;  i < _queues.size();  ++i) {
    DispatcherQueue* queue = _queues[i];

    if (queue != nullptr) {
      queue->shutdown();
    }
  }
}
コード例 #5
0
ファイル: Dispatcher.cpp プロジェクト: CedarLogic/arangodb
bool Dispatcher::cancelJob (uint64_t jobId) {
  bool done = false;

  for (size_t i = 0;  ! done && i < _queues.size();  ++i) {
    DispatcherQueue* queue = _queues[i];

    if (queue != nullptr) {
      done = queue->cancelJob(jobId);
    }
  }

  return done;
}
コード例 #6
0
bool Dispatcher::cancelJob (uint64_t jobId) {
  bool done = false;

  MUTEX_LOCKER(_accessDispatcher);

  for (map<string, DispatcherQueue*>::iterator i = _queues.begin();  i != _queues.end() && ! done;  ++i) {
    DispatcherQueue* q = i->second;

    done = q->cancelJob(jobId);
  }

  return done;
}
コード例 #7
0
ファイル: Dispatcher.cpp プロジェクト: CedarLogic/arangodb
void Dispatcher::beginShutdown () {
  if (_stopping) {
    return;
  }

  LOG_DEBUG("beginning shutdown sequence of dispatcher");

  _stopping = true;

  for (size_t i = 0;  i < _queues.size();  ++i) {
    DispatcherQueue* queue = _queues[i];

    if (queue != nullptr) {
      queue->beginShutdown();
    }
  }
}
コード例 #8
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);
}