@Override public void releaseChannelLock(Object partitionKey) { this.globalMaxConnectionSemaphore.releaseChannelLock(partitionKey); super.releaseChannelLock(partitionKey); } }
public void drainChannelAndExecuteNextRequest(final Channel channel, final NettyResponseFuture<?> future, Request nextRequest) { Channels.setAttribute(channel, new OnLastHttpContentCallback(future) { @Override public void call() { sendNextRequest(nextRequest, future); } }); }
public void drainChannelAndOffer(Channel channel, NettyResponseFuture<?> future, boolean keepAlive, Object partitionKey) { Channels.setAttribute(channel, newDrainCallback(future, channel, keepAlive, partitionKey)); }
public void closeChannel(Channel channel) { LOGGER.debug("Closing Channel {} ", channel); Channels.setDiscard(channel); removeAll(channel); Channels.silentlyCloseChannel(channel); }
private void close(Channel channel) { // FIXME pity to have to do this here Channels.setDiscard(channel); Channels.silentlyCloseChannel(channel); }
@Test(timeOut = 3000, dataProvider = "permitsAndRunnersCount") public void combinedCheckPermitCount(int permitCount, int runnerCount) { allSemaphoresCheckPermitCount(new CombinedConnectionSemaphore(permitCount, permitCount, 0), permitCount, runnerCount); allSemaphoresCheckPermitCount(new CombinedConnectionSemaphore(0, permitCount, 0), permitCount, runnerCount); allSemaphoresCheckPermitCount(new CombinedConnectionSemaphore(permitCount, 0, 0), permitCount, runnerCount); }
@Test(timeOut = 1000, invocationCount = NON_DETERMINISTIC__INVOCATION_COUNT, successPercentage = NON_DETERMINISTIC__SUCCESS_PERCENT) public void combinedCheckAcquireTime() { checkAcquireTime(new CombinedConnectionSemaphore(CHECK_ACQUIRE_TIME__PERMITS, CHECK_ACQUIRE_TIME__PERMITS, CHECK_ACQUIRE_TIME__TIMEOUT)); }
@Test(timeOut = 1000, dataProvider = "permitsAndRunnersCount") public void maxConnectionCheckPermitCount(int permitCount, int runnerCount) { allSemaphoresCheckPermitCount(new MaxConnectionSemaphore(permitCount, 0), permitCount, runnerCount); }
@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) public void combinedCheckRelease() throws IOException { checkRelease(new CombinedConnectionSemaphore(1, 1, 0)); }
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 perHostCheckAcquireTime() { checkAcquireTime(new PerHostConnectionSemaphore(CHECK_ACQUIRE_TIME__PERMITS, CHECK_ACQUIRE_TIME__TIMEOUT)); }
@Test(timeOut = 1000) public void perHostCheckRelease() throws IOException { checkRelease(new PerHostConnectionSemaphore(1, 0)); }
protected void releaseGlobal(Object partitionKey) { this.globalMaxConnectionSemaphore.releaseChannelLock(partitionKey); }
@Override public ClientStats getClientStats() { return channelManager.getClientStats(); }
protected long acquireGlobal(Object partitionKey) throws IOException { this.globalMaxConnectionSemaphore.acquireChannelLock(partitionKey); return 0; }
public ChannelPool getChannelPool() { return channelManager.getChannelPool(); }
public EventLoopGroup getEventLoopGroup() { return channelManager.getEventLoopGroup(); }
public static void setDiscard(Channel channel) { setAttribute(channel, DiscardEvent.DISCARD); }