@Test(timeout = 60000) public void testDiscard() throws Exception { final Connection<String, String> connection = pooledFactoryRule.getAConnection(); assertThat("Connection is null.", connection, notNullValue()); pooledFactoryRule.assertNoIdleConnection(); connection.unsafeNettyChannel().attr(ClientConnectionToChannelBridge.DISCARD_CONNECTION).set(true); pooledFactoryRule.closeAndAwait(connection); pooledFactoryRule.assertNoIdleConnection(); }
@Override public Observable<Void> discard(final PooledConnection<?, ?> connection) { return connection.discard().doOnSubscribe(new Action0() { @Override public void call() { EventPublisher eventPublisher = connection.unsafeNettyChannel().attr(EVENT_PUBLISHER).get(); if (eventPublisher.publishingEnabled()) { ClientEventListener eventListener = connection.unsafeNettyChannel() .attr(CLIENT_EVENT_LISTENER).get(); eventListener.onPooledConnectionEviction(); } limitDeterminationStrategy.releasePermit(); } }); }
PooledConnectionProviderImpl extends PooledConnectionProvider<W, R> { @Override public Observable<Void> discard(final PooledConnection<?, ?> connection) { return connection.discard().doOnSubscribe(new Action0() { @Override public void call() { EventPublisher eventPublisher = connection.unsafeNettyChannel().attr(EVENT_PUBLISHER).get(); if (eventPublisher.publishingEnabled()) { ClientEventListener eventListener = connection.unsafeNettyChannel() .attr(CLIENT_EVENT_LISTENER).get(); eventListener.onPooledConnectionEviction(); } limitDeterminationStrategy.releasePermit(); } }); } }
PooledConnectionProviderImpl extends PooledConnectionProvider<W, R> { @Override public Observable<Void> discard(final PooledConnection<?, ?> connection) { return connection.discard().doOnSubscribe(new Action0() { @Override public void call() { EventPublisher eventPublisher = connection.unsafeNettyChannel().attr(EVENT_PUBLISHER).get(); if (eventPublisher.publishingEnabled()) { ClientEventListener eventListener = connection.unsafeNettyChannel() .attr(CLIENT_EVENT_LISTENER).get(); eventListener.onPooledConnectionEviction(); } limitDeterminationStrategy.releasePermit(); } }); } PooledConnectionProviderImpl(PoolConfig<W, R> poolConfig, HostConnector<W, R> hostConnector); }
PooledConnectionProviderImpl extends PooledConnectionProvider<W, R> { @Override public Observable<Void> discard(final PooledConnection<?, ?> connection) { return connection.discard().doOnSubscribe(new Action0() { @Override public void call() { EventPublisher eventPublisher = connection.unsafeNettyChannel().attr(EVENT_PUBLISHER).get(); if (eventPublisher.publishingEnabled()) { ClientEventListener eventListener = connection.unsafeNettyChannel() .attr(CLIENT_EVENT_LISTENER).get(); eventListener.onPooledConnectionEviction(); } limitDeterminationStrategy.releasePermit(); } }); } PooledConnectionProviderImpl(PoolConfig<W, R> poolConfig, HostConnector<W, R> hostConnector); @Override Observable<Connection<R, W>> newConnectionRequest(); @Override Observable<Void> release(final PooledConnection<?, ?> connection); @Override Observable<Void> discard(final PooledConnection<?, ?> connection); }
PooledConnectionProviderImpl extends PooledConnectionProvider<W, R> { @Override public Observable<Void> discard(final PooledConnection<?, ?> connection) { return connection.discard().doOnSubscribe(new Action0() { @Override public void call() { EventPublisher eventPublisher = connection.unsafeNettyChannel().attr(EVENT_PUBLISHER).get(); if (eventPublisher.publishingEnabled()) { ClientEventListener eventListener = connection.unsafeNettyChannel() .attr(CLIENT_EVENT_LISTENER).get(); eventListener.onPooledConnectionEviction(); } limitDeterminationStrategy.releasePermit(); } }); } PooledConnectionProviderImpl(PoolConfig<W, R> poolConfig, HostConnector<W, R> hostConnector); @Override Observable<Connection<R, W>> newConnectionRequest(); @Override Observable<Void> release(final PooledConnection<?, ?> connection); @Override Observable<Void> discard(final PooledConnection<?, ?> connection);  }