We set targetPoolSize last time thru - if pool is not at that size, system may
need more time to create/delete the necessary threads, so skip this interval
If this happens repeatedly, maybe the prior setPoolSize call failed somehow,
so try again
511163
private boolean checkTargetPoolSize(int poolSize) {
        boolean poolSizeCheckFailed = false;

        if (poolSize != targetPoolSize) {
            poolSizeCheckFailed = true;
            if (tc.isEventEnabled()) {
                Tr.event(tc, "targetPoolSize check", (" poolSize " + poolSize + " != targetPoolSize " + targetPoolSize));
            }
            consecutiveTargetPoolSizeWrong++;
            if (consecutiveTargetPoolSizeWrong >= MAX_CONSECUTIVE_TARGET_POOLSIZE_WRONG) {
                if (tc.isEventEnabled()) {
                    Tr.event(tc, "consecutiveTargetPoolSize check", (" consecutiveTargetPoolSizeWrong " + consecutiveTargetPoolSizeWrong +
                                                                     " exceeds threshold " + MAX_CONSECUTIVE_TARGET_POOLSIZE_WRONG + ", calling setPoolSize(targetPoolSize)"));
                }
                setPoolSize(targetPoolSize);
                consecutiveTargetPoolSizeWrong = 0;
            }
        } else {
            consecutiveTargetPoolSizeWrong = 0;
        }

        return poolSizeCheckFailed;
    }
867484
void resetThreadPool() {
        if (threadPool == null)
            return; // if no pool (during shutdown), nothing to retune/reset

        // 8/22/2012: Introduced factor - was hard coded at 2
        final int availableProcessors = NUMBER_CPUS;

        int factor = 2500 * availableProcessors / Math.max(1, (int) previousThroughput);
        factor = Math.min(factor, 4);
        factor = Math.max(factor, 2);
        int newThreads = Math.min(factor * availableProcessors, maxThreads);
        newThreads = Math.max(newThreads, coreThreads);

        targetPoolSize = newThreads;
        setPoolSize(newThreads);

        resetStatistics(true);
    }
656786
protected void initializeExecutorServices() {
        final int downloadPoolSize;
        final int max = settings.getInt(Settings.KEYS.MAX_DOWNLOAD_THREAD_POOL_SIZE, 3);
        if (DOWNLOAD_THREAD_POOL_SIZE > max) {
            downloadPoolSize = max;
        } else {
            downloadPoolSize = DOWNLOAD_THREAD_POOL_SIZE;
        }
        downloadExecutorService = Executors.newFixedThreadPool(downloadPoolSize);
        processingExecutorService = Executors.newFixedThreadPool(PROCESSING_THREAD_POOL_SIZE);
        LOGGER.debug("#download   threads: {}", downloadPoolSize);
        LOGGER.debug("#processing threads: {}", PROCESSING_THREAD_POOL_SIZE);
    }
1048439
def set_limits_for_pool(self, pool, **kw):
        
        pool_limits = {}

        for time_period in ["year", "month", "week", "day", "hour"]:
            if time_period not in kw:
                continue

            limit = kw.pop(time_period)
            if limit is not None and not isinstance(limit, (float, int)):
                raise TypeError("%s must be a float or int or None",
                                time_period)
            pool_limits[time_period] = limit

        if kw:
            raise ValueError("Unknown time periods specified: %s" %
                             ", ".join(kw.keys()))

        self.cache.set("LIMIT:%s" % pool, json_dumps(pool_limits))
        return
1327619
def _ensure_pool_exists(self):
        """"""
        if self.pid not in self._pool_manager:
            self._pool_manager.create(self.pid, self._pool_idle_ttl,
                                      self._pool_max_size, self._ioloop.time)
158146
public void initialisePool()
    {
        Properties loginProperties = createLoginProperties();

        if (logger.isDebugEnabled())
        {
            logger.debug("about to create pool with user-id : " + this.getJdbcUser());
        }

        ConnectionFactory connectionFactory = createConnectionFactory(loginProperties);
        PoolableObjectFactory objectFactoryForConnectionPool = getObjectFactoryForConnectionPool(connectionFactory, connectionPool);

        connectionPool = new ObjectPoolWithThreadAffinity(objectFactoryForConnectionPool, this.getPoolSize(),
                this.getMaxWait(), this.getPoolSize(), this.getInitialSize(), true, false, this.timeBetweenEvictionRunsMillis,
                this.minEvictableIdleTimeMillis, this.softMinEvictableIdleTimeMillis);

        dataSource = createPoolingDataSource(connectionPool);

        if (this.getInitialSize() > 0)
        {
            try // test connection
            {
                this.getConnection().close();
            }
            catch (Exception e)
            {
                logger.error("Error initializing pool " + this, e);
            }
        }
    }
1262786
def shrink(self):
        ""
        if self._size <= 0:
            raise IndexError("pool is already empty")
        self._size -= 1
        self.put(SuicideJob())
728051
private void growThreadPool() {

        if (m_currentThreadCount < m_maxThreadCount) {
            // if maximum number is not reached grow the thread pool
            synchronized (m_nextRunnableLock) {
                m_workers[m_currentThreadCount] = new CmsSchedulerThread(
                    this,
                    m_threadGroup,
                    m_threadNamePrefix + m_currentThreadCount,
                    m_threadPriority,
                    m_makeThreadsDaemons);
                m_workers[m_currentThreadCount].start();
                if (m_inheritLoader) {
                    m_workers[m_currentThreadCount].setContextClassLoader(
                        Thread.currentThread().getContextClassLoader());
                }
                // increas the current size
                m_currentThreadCount++;
                // notify the waiting threads
                m_nextRunnableLock.notifyAll();
            }
        }
    }
1325544
private synchronized void createSystemThreadPool() {
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.entry(tc, "createSystemThreadPool");
        if (_systemThreadPool == null) {
            // 214163 Add a threadpool listener to associate threads in trace
            // with the messaging engine.
            _systemThreadPool = new ThreadPool(
                            "System " + getMessagingEngineName(),
                            1,
                            _customProperties.get_max_system_threadpool_size(),
                            new ThreadPoolListener[] { new ThreadPoolListenerImpl(this) });
            _systemThreadPool.setRequestBufferExpansionLimit(Integer.MAX_VALUE);

            // note that setting this to true means that the MAX_SYSTEM_THREADS
            // value is ignored
            _systemThreadPool.setGrowAsNeeded(true);
        }
        if (TraceComponent.isAnyTracingEnabled()
            && tc.isEntryEnabled())
            SibTr.exit(tc, "createSystemThreadPool");
    }
1311057
private void setEntityManagerPoolSize(String poolSize) {

        setExtProperty(
            CmsDbPoolV11.KEY_DATABASE_POOL + '.' + getPool() + '.' + CmsDbPoolV11.KEY_ENTITY_MANAGER_POOL_SIZE,
            poolSize);
    }
310412
private void throwPoolInitializationException(Throwable t)
   {
      logger.error("{} - Exception during pool initialization.", poolName, t);
      destroyHouseKeepingExecutorService();
      throw new PoolInitializationException(t);
   }
628405
private static void initExceptionThreadPool() {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(tc, "initExceptionThreadPool");

        // Do a synchronous check to ensure once-only creation
        synchronized (exceptionTPCreateSync) {
            if (exceptionThreadPool == null) {
                // Get the maximum size for the thread pool, defaulting if
                // not specified or if the value cannot be parsed
                int maxThreads = Integer.parseInt(ApiJmsConstants.EXCEPTION_MAXTHREADS_DEFAULT_INT);
                String maxThreadsStr = RuntimeInfo.getProperty(ApiJmsConstants.EXCEPTION_MAXTHREADS_NAME_INT,
                                                               ApiJmsConstants.EXCEPTION_MAXTHREADS_DEFAULT_INT);
                try {
                    maxThreads = Integer.parseInt(maxThreadsStr);
                } catch (NumberFormatException e) {
                    // No FFDC code needed, but we will exception this
                    SibTr.exception(tc, e);
                }

                // Trace the value we will use
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                    SibTr.debug(tc, ApiJmsConstants.EXCEPTION_MAXTHREADS_NAME_INT + ": " + Integer.toString(maxThreads));

                // Create the thread pool
                exceptionThreadPool = new ThreadPool(ApiJmsConstants.EXCEPTION_THREADPOOL_NAME_INT, 0, maxThreads);
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(tc, "initExceptionThreadPool");
    }
93245
function(pool) {
    if (
      !connectionInCreation &&
      pool.idleConnections() < opts.minimumIdle &&
      pool.totalConnections() < opts.connectionLimit &&
      !closed
    ) {
      connectionInCreation = true;
      process.nextTick(() => {
        const timeoutEnd = Date.now() + opts.initializationTimeout;
        if (!closed) {
          connectionCreationLoop(pool, 0, timeoutEnd)
            .then(conn => {
              if (closed) {
                return conn.forceEnd().catch(err => {});
              }
              addPoolConnection(pool, conn);
            })
            .catch(err => {
              if (pool.totalConnections() === 0) {
                const task = taskQueue.shift();
                if (task) {
                  firstTaskTimeout = clearTimeout(firstTaskTimeout);
                  process.nextTick(task.reject, err);
                  resetTimeoutToNextTask();
                }
              } else if (!closed) {
                console.error(
                  `pool fail to create connection (${err.message})`
                );
              }

              //delay next try
              setTimeout(() => {
                connectionInCreation = false;
                if (taskQueue.size() > 0) {
                  ensurePoolSize(pool);
                }
              }, 500);
            });
        }
      });
    }
  }
1035717
public void setMaxSize(long maxSize) {
		// if the new maxSize is <= 0, clear keyLRUList
		if (maxSize <= 0) {
			keyLRUList.clear();
		} else if (maxSize > 0 && this.maxSize <= 0) {
			// if the new maxSize > 0 and the old is <= 0, fill in LRU list -
			// order will be meaningless for now
			Iterator keys = cacheLineTable.keySet().iterator();

			while (keys.hasNext()) {
				keyLRUList.add(keys.next());
			}
		}

		// if the new maxSize is less than the current cache size, shrink the
		// cache.
		if (maxSize > 0 && cacheLineTable.size() > maxSize) {
			while (cacheLineTable.size() > maxSize) {
				Object lastKey = keyLRUList.getLast();

				removeObject(lastKey);
			}
		}

		this.maxSize = maxSize;
	}
1102703
public synchronized boolean addPool(HostConnectionPool<CL> pool) {
        if (this.pools.add(pool)) {
            refresh();
            return true;
        }
        return false;
    }
985039
private void internalFillPool(FillRequest fr)
   {
      if (this.threadStarted.compareAndSet(false, true))         
      {
         this.fillerThread.start();
      }
      
      synchronized (pools)
      {
         if (!pools.contains(fr))
         {
            pools.addLast(fr);
            pools.notifyAll();
         }
      }
   }
636148
@Override
    public void setFetchSize(int rows) throws SQLException
    {
        checkClosed();
        if (rows < 0) {
            throw SQLError.get(SQLError.ILLEGAL_ARGUMENT, rows);
        }
        this.fetchSize = rows;
    }