if (config.getMaxConnections() > -1 && (maxConnections.get() + 1) > config.getMaxConnections()) { throw new IOException(String.format("Too many connections %s", config.getMaxConnections()));
tooManyConnections = buildStaticIOException(String.format("Too many connections %s", config.getMaxConnections())); tooManyConnectionsPerHost = buildStaticIOException(String.format("Too many connections per host %s", config.getMaxConnectionsPerHost())); poolAlreadyClosed = buildStaticIOException("Pool is already closed"); maxTotalConnectionsEnabled = config.getMaxConnections() > 0; maxConnectionsPerHostEnabled = config.getMaxConnectionsPerHost() > 0; freeChannels = new Semaphore(config.getMaxConnections()); } else { openChannels = new CleanupChannelGroup("asyncHttpClient");
connectionTTL = prototype.getConnectionTTL(); maxRedirects = prototype.getMaxRedirects(); maxConnections = prototype.getMaxConnections(); proxyServerSelector = prototype.getProxyServerSelector(); realm = prototype.getRealm();
fc = handleIoException(fc); } catch (FilterException e) { if (config.getMaxConnections() != -1) { maxConnections.decrementAndGet(); } finally { if (terminate) { if (config.getMaxConnections() != -1) { maxConnections.decrementAndGet();
.connectTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .asyncPollTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .maxConnectionsTotal(config.getMaxConnections()) .maxConnectionsPerEndpoint(config.getMaxConnectionsPerHost()) .keepAliveTimeout(config.getPooledConnectionIdleTimeout(), TimeUnit.MILLISECONDS) .connectTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .asyncPollTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .maxConnectionsTotal(config.getMaxConnections()) .maxConnectionsPerEndpoint(config.getMaxConnectionsPerHost()) .keepAliveTimeout(0, TimeUnit.MILLISECONDS) // no pool
public boolean preemptChannel(AsyncHandler<?> asyncHandler, String poolKey) throws IOException { boolean channelPreempted = false; if (channelManager.preemptChannel(poolKey)) { channelPreempted = true; } else { IOException ex = new IOException(String.format("Too many connections %s", config.getMaxConnections())); try { asyncHandler.onThrowable(ex); } catch (Exception e) { LOGGER.warn("asyncHandler.onThrowable crashed", e); } throw ex; } return channelPreempted; }
public GrizzlyConnectionPool(final AsyncHttpClientConfig config) { cacheSSLConnections = config.isAllowPoolingSslConnections(); timeout = config.getPooledConnectionIdleTimeout(); maxConnectionLifeTime = config.getConnectionTTL(); maxConnectionsPerHost = config.getMaxConnectionsPerHost(); maxConnections = config.getMaxConnections(); unlimitedConnections = (maxConnections == -1); delayedExecutor = new DelayedExecutor(Executors.newSingleThreadExecutor(), this); delayedExecutor.start(); ownsDelayedExecutor = true; }
if (config.getMaxConnections() > -1 && (maxConnections.get() + 1) > config.getMaxConnections()) { throw new IOException(String.format("Too many connections %s", config.getMaxConnections()));
log.debug("read timeout: {}", config.getReadTimeout()); log.debug("request timeout: {}", config.getRequestTimeout()); log.debug("max connections: {}", config.getMaxConnections()); log.debug("max connections per host: {}", config.getMaxConnectionsPerHost()); log.debug("enabled cipher suites: {}", Arrays.toString(config.getEnabledCipherSuites()));
if (config.getMaxConnections() > -1 && (maxConnections.get() + 1) > config.getMaxConnections()) { throw new IOException(String.format("Too many connections %s", config.getMaxConnections()));
maxTotalConnectionsEnabled = config.getMaxConnections() > 0; maxConnectionsPerHostEnabled = config.getMaxConnectionsPerHost() > 0; freeChannels = new Semaphore(config.getMaxConnections()); } else { openChannels = new CleanupChannelGroup("asyncHttpClient");
ConnectionManager(final GrizzlyAsyncHttpProvider provider, final TCPNIOTransport transport, final GrizzlyAsyncHttpProviderConfig providerConfig) { ConnectionPool connectionPool; this.provider = provider; final AsyncHttpClientConfig config = provider.clientConfig; if (config.isAllowPoolingConnections()) { ConnectionPool pool = providerConfig != null ? providerConfig.getConnectionPool() : null; if (pool != null) { connectionPool = pool; } else { connectionPool = new GrizzlyConnectionPool((config)); } } else { connectionPool = new NonCachingPool(); } pool = connectionPool; connectionHandler = TCPNIOConnectorHandler.builder(transport).build(); final int maxConns = provider.clientConfig.getMaxConnections(); connectionMonitor = new ConnectionMonitor(maxConns); }
connectionTTL = prototype.getConnectionTTL(); maxRedirects = prototype.getMaxRedirects(); maxConnections = prototype.getMaxConnections(); proxyServerSelector = prototype.getProxyServerSelector(); realm = prototype.getRealm();
fc = handleIoException(fc); } catch (FilterException e) { if (config.getMaxConnections() != -1) { maxConnections.decrementAndGet(); if (config.getMaxConnections() != -1) { maxConnections.decrementAndGet();
connectionTTL = prototype.getConnectionTTL(); maxRedirects = prototype.getMaxRedirects(); maxConnections = prototype.getMaxConnections(); proxyServerSelector = prototype.getProxyServerSelector(); realm = prototype.getRealm();
fc = handleIoException(fc); } catch (FilterException e) { if (config.getMaxConnections() != -1) { maxConnections.decrementAndGet(); if (config.getMaxConnections() != -1) { maxConnections.decrementAndGet();
connectionTTL = prototype.getConnectionTTL(); maxRedirects = prototype.getMaxRedirects(); maxConnections = prototype.getMaxConnections(); proxyServerSelector = prototype.getProxyServerSelector(); realm = prototype.getRealm();
.connectTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .asyncPollTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .maxConnectionsTotal(config.getMaxConnections()) .maxConnectionsPerEndpoint(config.getMaxConnectionsPerHost()) .keepAliveTimeout(config.getPooledConnectionIdleTimeout(), TimeUnit.MILLISECONDS) .connectTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .asyncPollTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .maxConnectionsTotal(config.getMaxConnections()) .maxConnectionsPerEndpoint(config.getMaxConnectionsPerHost()) .keepAliveTimeout(0, TimeUnit.MILLISECONDS) // no pool
.connectTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .asyncPollTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .maxConnectionsTotal(config.getMaxConnections()) .maxConnectionsPerEndpoint(config.getMaxConnectionsPerHost()) .keepAliveTimeout(config.getPooledConnectionIdleTimeout(), TimeUnit.MILLISECONDS) .connectTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .asyncPollTimeout(config.getConnectTimeout(), TimeUnit.MILLISECONDS) .maxConnectionsTotal(config.getMaxConnections()) .maxConnectionsPerEndpoint(config.getMaxConnectionsPerHost()) .keepAliveTimeout(0, TimeUnit.MILLISECONDS) // no pool