示例#1
0
bool ThriftServer::isOverloaded(
    const transport::THeader::StringToStringMap* readHeaders,
    const std::string* method) const {
  if (UNLIKELY(isOverloaded_ && isOverloaded_(readHeaders, method))) {
    return true;
  }

  uint32_t maxRequests = getMaxRequests();
  if (maxRequests > 0) {
    return static_cast<uint32_t>(getActiveRequests()) >= maxRequests;
  }

  return false;
}
示例#2
0
bool ThriftServer::isOverloaded(uint32_t workerActiveRequests) {
  if (UNLIKELY(isOverloaded_())) {
    return true;
  }

  if (maxRequests_ > 0) {
    if (isUnevenLoad_) {
      return globalActiveRequests_ + getPendingCount() >= maxRequests_;
    } else {
      return workerActiveRequests >= maxRequests_ / nWorkers_;
    }
  }

  return false;
}
示例#3
0
bool ThriftServer::isOverloaded(uint32_t workerActiveRequests) {
  if (UNLIKELY(isOverloaded_())) {
    return true;
  }

  if (maxRequests_ > 0) {
    if (isUnevenLoad_) {
      int pendingRequests = 0;
      for (auto& worker: workers_) {
        pendingRequests += worker.worker->getPendingCount();
      }
      return (globalActiveRequests_ + pendingRequests) >= maxRequests_;
    } else {
      return workerActiveRequests >= maxRequests_ / nWorkers_;
    }
  }

  return false;
}