CombinedConnectionSemaphore(int maxConnections, int maxConnectionsPerHost, int acquireTimeout) { super(maxConnectionsPerHost, acquireTimeout); this.globalMaxConnectionSemaphore = new MaxConnectionSemaphore(maxConnections, acquireTimeout); }
@Test(timeOut = 1000, invocationCount = NON_DETERMINISTIC__INVOCATION_COUNT, successPercentage = NON_DETERMINISTIC__SUCCESS_PERCENT) public void maxConnectionCheckAcquireTime() { checkAcquireTime(new MaxConnectionSemaphore(CHECK_ACQUIRE_TIME__PERMITS, CHECK_ACQUIRE_TIME__TIMEOUT)); }
@Test(timeOut = 1000) public void maxConnectionCheckRelease() throws IOException { checkRelease(new MaxConnectionSemaphore(1, 0)); }
@Test(timeOut = 1000, dataProvider = "permitsAndRunnersCount") public void maxConnectionCheckPermitCount(int permitCount, int runnerCount) { allSemaphoresCheckPermitCount(new MaxConnectionSemaphore(permitCount, 0), permitCount, runnerCount); }
public ConnectionSemaphore newConnectionSemaphore(AsyncHttpClientConfig config) { int acquireFreeChannelTimeout = Math.max(0, config.getAcquireFreeChannelTimeout()); int maxConnections = config.getMaxConnections(); int maxConnectionsPerHost = config.getMaxConnectionsPerHost(); if (maxConnections > 0 && maxConnectionsPerHost > 0) { return new CombinedConnectionSemaphore(maxConnections, maxConnectionsPerHost, acquireFreeChannelTimeout); } if (maxConnections > 0) { return new MaxConnectionSemaphore(maxConnections, acquireFreeChannelTimeout); } if (maxConnectionsPerHost > 0) { return new CombinedConnectionSemaphore(maxConnections, maxConnectionsPerHost, acquireFreeChannelTimeout); } return new NoopConnectionSemaphore(); } }