Is the pool task limit exceeded?
@param poolName name of the pool
@param type type of the task to be check
@return true if the limit is exceeded
961437
public boolean isMaxTasks(String poolName, TaskType type) {
    return getRunningTasks(poolName, type ) >= getMaxSlots(poolName, type);
  }
1136133
public void incRunningTasks(String poolName, TaskType type, int inc) {
    Map<String, Integer> runningMap = (type == TaskType.MAP ?
                                       poolRunningMaps : poolRunningReduces);
    if (!runningMap.containsKey(poolName)) {
      runningMap.put(poolName, 0);
    }
    int runningTasks = runningMap.get(poolName) + inc;
    runningMap.put(poolName, runningTasks);
  }
1289071
function(opt_maxPoolSize) {
  /**
   * The max pool size as configured.
   *
   * @private {number}
   */
  this.maxPoolSizeConfigured_ =
      opt_maxPoolSize || ForwardChannelRequestPool.MAX_POOL_SIZE_;

  /**
   * The current size limit of the request pool. This limit is meant to be
   * read-only after the channel is fully opened.
   *
   * If SPDY or HTTP2 is enabled, set it to the max pool size, which is also
   * configurable.
   *
   * @private {number}
   */
  this.maxSize_ = ForwardChannelRequestPool.isSpdyOrHttp2Enabled_() ?
      this.maxPoolSizeConfigured_ :
      1;

  /**
   * The container for all the pending request objects.
   *
   * @private {Set<ChannelRequest>}
   */
  this.requestPool_ = null;

  if (this.maxSize_ > 1) {
    this.requestPool_ = new Set();
  }

  /**
   * The single request object when the pool size is limited to one.
   *
   * @private {ChannelRequest}
   */
  this.request_ = null;

  /**
   * Saved pending messages when the pool is cancelled.
   *
   * @private {!Array<Wire.QueuedMap>}
   */
  this.pendingMessages_ = [];
}
436633
def _pool_put(pool_semaphore, tasks, put_to_pool_in, pool_size, id_self, \
                  is_stopping):
        
        log.debug('NuMap(%s) started pool_putter.' % id_self)
        last_tasks = {}
        for task in xrange(tasks.lenght):
            last_tasks[task] = -1
        stop_tasks = []
        while True:
            # are we stopping the Weaver?
            if is_stopping():
                log.debug('NuMap(%s) pool_putter has been told to stop.' % \
                           id_self)
                tasks.stop()
            # try to get a task
            try:
                log.debug('NuMap(%s) pool_putter waits for next task.' % \
                           id_self)
                task = tasks.next()
                log.debug('NuMap(%s) pool_putter received next task.' % id_self)
            except StopIteration:
                # Weaver raised a StopIteration
                stop_task = tasks.i # current task
                log.debug('NuMap(%s) pool_putter caught StopIteration from task %s.' % \
                                                                  (id_self, stop_task))
                if stop_task not in stop_tasks:
                    # task raised stop for the first time.
                    log.debug('NuMap(%s) pool_putter task %s first-time finished.' % \
                                                           (id_self, stop_task))
                    stop_tasks.append(stop_task)
                    pool_semaphore.acquire()
                    log.debug('NuMap(%s) pool_putter sends a sentinel for task %s.' % \
                                                           (id_self, stop_task))
                    put_to_pool_in((stop_task, None, last_tasks[stop_task]))
                if len(stop_tasks) == tasks.lenght:
                    log.debug('NuMap(%s) pool_putter sent sentinels for all tasks.' % \
                                                                        id_self)
                    # all tasks have been stopped
                    for _worker in xrange(pool_size):
                        put_to_pool_in(None)
                    log.debug('NuMap(%s) pool_putter sent sentinel for %s workers' % \
                                                           (id_self, pool_size))
                    # this kills the pool_putter
                    break
                # multiple StopIterations for a tasks are ignored. 
                # This is for stride.
                continue

            # got task
            last_tasks[tasks.i] = task[-1][0] # last valid result
            log.debug('NuMap(%s) pool_putter waits for semaphore for task %s' % \
                       (id_self, task))
            pool_semaphore.acquire()
            log.debug('NuMap(%s) pool_putter gets semaphore for task %s' % \
                       (id_self, task))
            #gc.disable()
            put_to_pool_in(task)
            #gc.enable()
            log.debug('NuMap(%s) pool_putter submits task %s to worker.' % \
                       (id_self, task))
        log.debug('NuMap(%s) pool_putter returns' % id_self)
593856
public static boolean isPopulatable(final Type type) {
        return !isWildcardType(type) && !isTypeVariable(type) && !isCollectionType(type) && !isParameterizedType(type);
    }
1024648
boolean isProcessTreeOverLimit(ProcfsBasedProcessTree pTree, 
                                    String tId, long limit) {
    long currentMemUsage = pTree.getCumulativeVmem();
    // as processes begin with an age 1, we want to see if there are processes
    // more than 1 iteration old.
    long curMemUsageOfAgedProcesses = pTree.getCumulativeVmem(1);
    return isProcessTreeOverLimit(tId, currentMemUsage, 
                                  curMemUsageOfAgedProcesses, limit);
  }
1102703
public synchronized boolean addPool(HostConnectionPool<CL> pool) {
        if (this.pools.add(pool)) {
            refresh();
            return true;
        }
        return false;
    }
327753
public boolean containsLong(long value) {
		for (int i = 1; i < maxPoolSize; i++) {
			if (types[i] == LONG && readLong(i) == value) return true;
		}
		return false;
	}
191900
public V put(ResourceType type, PoolInfo poolInfo, V value) {
    Map<PoolInfo, V> poolInfoMap = typePoolInfoMap.get(type);
    if (poolInfoMap == null) {
      poolInfoMap = new HashMap<PoolInfo, V>();
      typePoolInfoMap.put(type, poolInfoMap);
    }
    return poolInfoMap.put(poolInfo, value);
  }
587590
private boolean isQueue(DestinationType type)
    {
        boolean isQueue = false;
        if (type == DestinationType.QUEUE ||
            type == DestinationType.PORT)
            //  type == DestinationType.SERVICE)
            isQueue = true;

        return isQueue;
    }
818515
public void deltaTotalPoolTime(long delta)
   {
      if (enabled.get() && delta > 0)
      {
         totalPoolTime.addAndGet(delta);
         totalPoolTimeInvocations.incrementAndGet();

         if (delta > maxPoolTime.get())
            maxPoolTime.set(delta);
      }
   }
457011
public synchronized void incrementLoad(ResourceType type) {
    Integer load = typeToTotalLoad.get(type);
    assert(load != null);
    typeToTotalLoad.put(type, load + 1);
  }
516790
public boolean checkMinimumSlotsAvailable(
      ClusterStatus clusterStatus, TaskType type) {
    Map<String, Integer> poolToMinSlots = (type == TaskType.MAP) ?
        mapAllocs : reduceAllocs;
    int totalSlots = (type == TaskType.MAP) ?
        clusterStatus.getMaxMapTasks() : clusterStatus.getMaxReduceTasks();
    int totalMinSlots = 0;
    for (int minSlots : poolToMinSlots.values()) {
      totalMinSlots += minSlots;
    }
    if (totalMinSlots > totalSlots) {
      LOG.warn(String.format(
          "Bad minimum %s slot configuration. cluster:%s totalMinSlots:%s",
          type, totalSlots, totalMinSlots));
      return false;
    }
    LOG.info(String.format(
        "Minimum %s slots checked. cluster:%s totalMinSlots:%s",
        type, totalSlots, totalSlots));
    return true;
  }
1349320
public V get(ResourceType type, String poolGroupName) {
    Map<String, V> poolGroupNameMap = typePoolGroupNameMap.get(type);
    if (poolGroupNameMap == null) {
      return null;
    }
    return poolGroupNameMap.get(poolGroupName);
  }
727217
protected function stopWorkerPool(string $poolName) : bool
    {
        if (empty($this->processes[$poolName])) {
            return true;
        }
        foreach ($this->processes[$poolName] as $process) {
            /** @var Process $process */
            $process->terminate();
        }
        return true;
    }
43988
static boolean isSafeReturnType(Class<?> type) { 
        return !ConnectionPoolDataSource.class.isAssignableFrom(type)
               && !CommonDataSource.class.isAssignableFrom(type) 
               && !XADataSource.class.isAssignableFrom(type)
               && !DataSource.class.isAssignableFrom(type)
               && !PooledConnection.class.isAssignableFrom(type) // implies XAConnection
               && !Connection.class.isAssignableFrom(type)
               && !DatabaseMetaData.class.isAssignableFrom(type)
               && !Statement.class.isAssignableFrom(type) // implies prepared & callable
               && !ResultSet.class.isAssignableFrom(type)
               && !XAResource.class.isAssignableFrom(type);
    }
299134
public function checkCreation(
        $type,
        ResourceNode $node,
        TokenInterface $token,
        Workspace $workspace
    )
    {
        $errors = array();

        //even the workspace manager can't break the file limit.
        $workspace = $node->getWorkspace();
        $isLimitExceeded = $this->resourceManager
            ->checkResourceLimitExceeded($workspace);

        if ($isLimitExceeded) {
            $currentCount = $this->workspaceManager->countResources($workspace);
            $errors[] = $this->translator
                ->trans(
                    'resource_limit_exceeded',
                    array('%current%' => $currentCount, '%max%' => $workspace->getMaxUploadResources()),
                    'platform'
                );
        }

        //if I am the manager, I can do whatever I want
        if ($this->isWorkspaceManager($workspace, $token)) {
            return $errors;
        }

        //otherwise we need to check
        $rightsCreation = $this->repository->findCreationRights($this->ut->getRoles($token), $node);

        if (!$this->canCreate($rightsCreation, $type)) {
            $errors[] = $this->translator
                ->trans(
                    'resource_creation_wrong_type',
                    array(
                        '%path%' => $node->getPathForDisplay(),
                        '%type%' => $this->translator->trans(
                            strtolower($type), array(), 'resource'
                        )
                    ),
                    'platform'
                );
        }

        return $errors;
    }