ChannelPool implementation which will create new Channels if someone tries to acquire
a Channel but none is in the pool atm. No limit on the maximal concurrent Channels is enforced.
This implementation uses LIFO order for Channels in the ChannelPool.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final Bootstrap | |
| private final Deque | |
| private final ChannelPoolHandler | |
| private final ChannelHealthChecker | |
| private final boolean | |
| private static final AttributeKey | |
| private final boolean |
| Access | Constructor and Description |
|---|---|
| public | SimpleChannelPool(Bootstrap
the bootstrap, final ChannelPoolHandler Bootstrap that is used for connectionsthe handler)ChannelPoolHandler that will be notified for the different pool actionsCreates a new instance using the |
| public | SimpleChannelPool(Bootstrap
the bootstrap, final ChannelPoolHandler Bootstrap that is used for connectionsthe handler, ChannelHealthChecker ChannelPoolHandler that will be notified for the different pool actionsthe healthCheck)ChannelHealthChecker that will be used to check if a Channel is
still healthy when obtain from the ChannelPoolCreates a new instance. |
| public | SimpleChannelPool(Bootstrap
the bootstrap, final ChannelPoolHandler Bootstrap that is used for connectionsthe handler, ChannelHealthChecker ChannelPoolHandler that will be notified for the different pool actionsthe healthCheck, boolean ChannelHealthChecker that will be used to check if a Channel is
still healthy when obtain from the ChannelPoolwill check channel health before offering back if this parameter set to releaseHealthCheck)true;
otherwise, channel health is only checked at acquisition timeCreates a new instance. |
| public | SimpleChannelPool(Bootstrap
the bootstrap, final ChannelPoolHandler Bootstrap that is used for connectionsthe handler, ChannelHealthChecker ChannelPoolHandler that will be notified for the different pool actionsthe healthCheck, boolean ChannelHealthChecker that will be used to check if a Channel is
still healthy when obtain from the ChannelPoolwill check channel health before offering back if this parameter set to releaseHealthCheck, boolean lastRecentUsed)true;
otherwise, channel health is only checked at acquisition timeCreates a new instance. |
| Modifier and Type | Method and Description |
|---|---|
| public final Future | acquire()
Implements io. Channel from this ChannelPool.
|
| public Future | acquire(final Promise<Channel> promise)
Implements io. Channel from this ChannelPool.
|
| private Future | Returns: future for acquiring a channel.the promise to provide acquire result. promise)Tries to retrieve healthy channel from the pool if any or creates a new channel otherwise. |
| protected Bootstrap | |
| public void | close()
Implements io. |
| private void | |
| public Future | Returns: Future which represents completion of the close taskCloses the pool in an async manner. |
| private void | |
| protected ChannelFuture | |
| private void | |
| private void | |
| private void | |
| protected ChannelPoolHandler | Returns: theChannelPoolHandler that will be notified for the different pool actionsReturns the |
| protected ChannelHealthChecker | |
| private void | |
| private void | |
| protected boolean | |
| protected Channel | |
| public final Future | release(Channel channel)
Implements io. Channel back to this ChannelPool.
|
| public Future | release(final Channel channel, final Promise<Void> promise)
Implements io. Channel back to this ChannelPool.
|
| private void | |
| private void | |
| protected boolean | Returns: true if this pool will check the health of channels before offering them back into the pool, or
false if channel health is only checked at acquisition timeIndicates whether this pool will check the health of channels before offering them back into the pool. |
| bootstrap | back to summary |
|---|---|
| private final Bootstrap bootstrap | |
| deque | back to summary |
|---|---|
| private final Deque<Channel> deque | |
| handler | back to summary |
|---|---|
| private final ChannelPoolHandler handler | |
| healthCheck | back to summary |
|---|---|
| private final ChannelHealthChecker healthCheck | |
| lastRecentUsed | back to summary |
|---|---|
| private final boolean lastRecentUsed | |
| POOL_KEY | back to summary |
|---|---|
| private static final AttributeKey<SimpleChannelPool> POOL_KEY | |
| releaseHealthCheck | back to summary |
|---|---|
| private final boolean releaseHealthCheck | |
| SimpleChannelPool | back to summary |
|---|---|
| public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler) Creates a new instance using the
| |
| SimpleChannelPool | back to summary |
|---|---|
| public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler, ChannelHealthChecker healthCheck) Creates a new instance.
| |
| SimpleChannelPool | back to summary |
|---|---|
| public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler, ChannelHealthChecker healthCheck, boolean releaseHealthCheck) Creates a new instance.
| |
| SimpleChannelPool | back to summary |
|---|---|
| public SimpleChannelPool(Bootstrap bootstrap, final ChannelPoolHandler handler, ChannelHealthChecker healthCheck, boolean releaseHealthCheck, boolean lastRecentUsed) Creates a new instance.
| |
| acquire | back to summary |
|---|---|
| public final Future Implements io. Doc from io. Acquire a
| |
| acquire | back to summary |
|---|---|
| public Future Implements io. Doc from io. Acquire a
| |
| acquireHealthyFromPoolOrNew | back to summary |
|---|---|
| private Future Tries to retrieve healthy channel from the pool if any or creates a new channel otherwise. | |
| bootstrap | back to summary |
|---|---|
| protected Bootstrap bootstrap() Returns the | |
| close | back to summary |
|---|---|
| public void close() Implements io. Doc from java. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| closeAndFail | back to summary |
|---|---|
| private void closeAndFail(Channel channel, Throwable cause, Promise<?> promise) | |
| closeAsync | back to summary |
|---|---|
| public Future Closes the pool in an async manner. | |
| closeChannel | back to summary |
|---|---|
| private void closeChannel(Channel channel) throws Exception | |
| connectChannel | back to summary |
|---|---|
| protected ChannelFuture connectChannel(Bootstrap bs) Bootstrap a new
The | |
| doHealthCheck | back to summary |
|---|---|
| private void doHealthCheck(final Channel channel, final Promise<Channel> promise) | |
| doHealthCheckOnRelease | back to summary |
|---|---|
| private void doHealthCheckOnRelease(final Channel channel, final Promise<Void> promise) throws Exception | |
| doReleaseChannel | back to summary |
|---|---|
| private void doReleaseChannel(Channel channel, Promise<Void> promise) | |
| handler | back to summary |
|---|---|
| protected ChannelPoolHandler handler() Returns the
| |
| healthChecker | back to summary |
|---|---|
| protected ChannelHealthChecker healthChecker() Returns the
| |
| notifyConnect | back to summary |
|---|---|
| private void notifyConnect(ChannelFuture future, Promise<Channel> promise) | |
| notifyHealthCheck | back to summary |
|---|---|
| private void notifyHealthCheck(Future<Boolean> future, Channel channel, Promise<Channel> promise) | |
| offerChannel | back to summary |
|---|---|
| protected boolean offerChannel(Channel channel) Offer a | |
| pollChannel | back to summary |
|---|---|
| protected Channel pollChannel() Poll a | |
| release | back to summary |
|---|---|
| public final Future Implements io. Doc from io. Release a
| |
| release | back to summary |
|---|---|
| public Future Implements io. Doc from io. Release a
| |
| releaseAndOffer | back to summary |
|---|---|
| private void releaseAndOffer(Channel channel, Promise<Void> promise) throws Exception | |
| releaseAndOfferIfHealthy | back to summary |
|---|---|
| private void releaseAndOfferIfHealthy(Channel channel, Promise<Void> promise, Future<Boolean> future) Adds the channel back to the pool only if the channel is healthy. | |
| releaseHealthCheck | back to summary |
|---|---|
| protected boolean releaseHealthCheck() Indicates whether this pool will check the health of channels before offering them back into the pool.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public Throwable | fillInStackTrace()
Overrides java. |
| ChannelPoolFullException | back to summary |
|---|---|
| private ChannelPoolFullException() | |
| fillInStackTrace | back to summary |
|---|---|
| public Throwable fillInStackTrace() Overrides java. Doc from java. Fills in the execution stack trace. This method records within this
If the stack trace of this | |