@Test public void onCloseReleasesPermit() throws Exception { ConnectionFactory<String, ? extends ListenableAsyncCloseable> cf = makeCF(LimitingConnectionFactoryFilter.withMax(1), original); cf.newConnection("c1", null).toFuture().get(); connectAndVerifyFailed(cf); connectionOnClose.take().onComplete(); cf.newConnection("c3", null).toFuture().get(); }
public static <A, C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A, C> withMax( int maxConnections) { return new LimitingConnectionFactoryFilter<>(new MaxConnectionsLimiter<>(maxConnections)); }
LimitingConnectionFactoryFilter implements ConnectionFactoryFilter<ResolvedAddress, C> { public static <A, C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A, C> withMax( int maxConnections) { return new LimitingConnectionFactoryFilter<>(new MaxConnectionsLimiter<>(maxConnections)); } }
LimitingConnectionFactoryFilter implements ConnectionFactoryFilter<ResolvedAddress, C> { public static <A, C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A, C> withMax( int maxConnections) { return new LimitingConnectionFactoryFilter<>(new MaxConnectionsLimiter<>(maxConnections)); } private  LimitingConnectionFactoryFilter(final ConnectionLimiter<ResolvedAddress, C> limiter); }
LimitingConnectionFactoryFilter implements ConnectionFactoryFilter<ResolvedAddress, C> { public static <A, C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A, C> withMax( int maxConnections) { return new LimitingConnectionFactoryFilter<>(new MaxConnectionsLimiter<>(maxConnections)); } private  LimitingConnectionFactoryFilter(final ConnectionLimiter<ResolvedAddress, C> limiter); static ConnectionFactoryFilter<A, C> withMax(
            int maxConnections); static ConnectionFactoryFilter<A, C> with(
            ConnectionLimiter<A, C> limiter); @Override ConnectionFactory<ResolvedAddress, C> create(final ConnectionFactory<ResolvedAddress, C> original); }
LimitingConnectionFactoryFilter implements ConnectionFactoryFilter<ResolvedAddress, C> { public static <A, C extends ListenableAsyncCloseable> ConnectionFactoryFilter<A, C> withMax( int maxConnections) { return new LimitingConnectionFactoryFilter<>(new MaxConnectionsLimiter<>(maxConnections)); } private  LimitingConnectionFactoryFilter(final ConnectionLimiter<ResolvedAddress, C> limiter); static ConnectionFactoryFilter<A, C> withMax(
            int maxConnections); static ConnectionFactoryFilter<A, C> with(
            ConnectionLimiter<A, C> limiter); @Override ConnectionFactory<ResolvedAddress, C> create(final ConnectionFactory<ResolvedAddress, C> original);  }