private void shutdownIfNeeded() { Callback<None> shutdown = checkShutdownComplete(); if (shutdown != null) { finishShutdown(shutdown); } }
private boolean objectDestroyed() { return objectDestroyed(1); }
/** * This method is safe to call while holding the lock. * @param num number of objects have been destroyed * @return true if another object creation should be initiated */ private boolean objectDestroyed(int num) { boolean create; synchronized (_lock) { if (_poolSize - num > 0) { _poolSize -= num; } else { _poolSize = 0; } create = shouldCreate(); shutdownIfNeeded(); } return create; }
_statsTracker.sampleMaxCheckedOut(); shutdown = checkShutdownComplete(); trc("dequeued a waiter"); trc("enqueued an idle object"); finishShutdown(shutdown);
@Override public AsyncPool<Channel> getPool(SocketAddress address) { return new AsyncPoolImpl<>(address.toString(), new ChannelPoolLifecycle(address, _bootstrap, _allChannels, _tcpNoDelay), _maxPoolSize, _idleTimeout, _scheduler, _maxPoolWaiterSize, _strategy, _minPoolSize, new ExponentialBackOffRateLimiter(0, ChannelPoolLifecycle.MAX_PERIOD_BEFORE_RETRY_CONNECTIONS, ChannelPoolLifecycle.INITIAL_PERIOD_BEFORE_RETRY_CONNECTIONS, _scheduler, _maxConcurrentConnectionInitializations), SystemClock.instance(), NoopLongTracker.instance() ); } }
@Override public void dispose(T obj) { synchronized (_lock) { _checkedOut--; } destroy(obj, true); }
@Override public void shutdown(Callback<None> callback) { final State state; synchronized (_lock) { state = _state; if (state == State.RUNNING) { _state = State.SHUTTING_DOWN; _shutdownCallback = callback; } } if (state != State.RUNNING) { // Retest state outside the synchronized block, since we don't want to invoke this // callback inside a synchronized block callback.onError(new IllegalStateException(_poolName + " is " + _state)); return; } LOG.info("{}: {}", _poolName, "shutdown requested"); shutdownIfNeeded(); }
@Override public AsyncPool<Channel> getPool(SocketAddress address) { return new AsyncPoolImpl<>(address.toString(), new ChannelPoolLifecycle(address, _bootstrap, _allChannels, false), _maxPoolSize, _idleTimeout, _scheduler, _maxPoolWaiterSize, _strategy, _minPoolSize, new ExponentialBackOffRateLimiter(0, ChannelPoolLifecycle.MAX_PERIOD_BEFORE_RETRY_CONNECTIONS, ChannelPoolLifecycle.INITIAL_PERIOD_BEFORE_RETRY_CONNECTIONS, _scheduler, _maxConcurrentConnectionInitializations), SystemClock.instance(), NoopLongTracker.instance() ); }