Top Description Inners Fields Constructors Methods
io.netty.channel.pool

public Class FixedChannelPool

extends SimpleChannelPool
Class Inheritance
Static Imports
io.netty.util.internal.ObjectUtil.checkPositive

ChannelPool implementation that takes another ChannelPool implementation and enforce a maximum number of concurrent connections.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
private class
public static enum
private static class
private abstract class

Field Summary

Modifier and TypeField and Description
private final AtomicInteger
private final long
private boolean
private final EventExecutor
private final int
private final int
private int
private final Queue<FixedChannelPool.AcquireTask>
private final Runnable

Constructor Summary

AccessConstructor and Description
public
FixedChannelPool(Bootstrap
the Bootstrap that is used for connections
bootstrap
,
ChannelPoolHandler
the ChannelPoolHandler that will be notified for the different pool actions
handler
,
int
the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.
maxConnections
)

Creates a new instance using the ChannelHealthChecker#ACTIVE.

public
FixedChannelPool(Bootstrap
the Bootstrap that is used for connections
bootstrap
,
ChannelPoolHandler
the ChannelPoolHandler that will be notified for the different pool actions
handler
,
int
the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.
maxConnections
,
int
the maximum number of pending acquires. Once this is exceed acquire tries will be failed.
maxPendingAcquires
)

Creates a new instance using the ChannelHealthChecker#ACTIVE.

public
FixedChannelPool(Bootstrap
the Bootstrap that is used for connections
bootstrap
,
ChannelPoolHandler
the ChannelPoolHandler that will be notified for the different pool actions
handler
,
ChannelHealthChecker
the ChannelHealthChecker that will be used to check if a Channel is still healthy when obtain from the ChannelPool
healthCheck
,
FixedChannelPool.AcquireTimeoutAction
the AcquireTimeoutAction to use or null if non should be used. In this case {@param acquireTimeoutMillis} must be -1.
action
,
final long
the time (in milliseconds) after which an pending acquire must complete or the AcquireTimeoutAction takes place.
acquireTimeoutMillis
,
int
the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.
maxConnections
,
int
the maximum number of pending acquires. Once this is exceed acquire tries will be failed.
maxPendingAcquires
)

Creates a new instance.

public
FixedChannelPool(Bootstrap
the Bootstrap that is used for connections
bootstrap
,
ChannelPoolHandler
the ChannelPoolHandler that will be notified for the different pool actions
handler
,
ChannelHealthChecker
the ChannelHealthChecker that will be used to check if a Channel is still healthy when obtain from the ChannelPool
healthCheck
,
FixedChannelPool.AcquireTimeoutAction
the AcquireTimeoutAction to use or null if non should be used. In this case {@param acquireTimeoutMillis} must be -1.
action
,
final long
the time (in milliseconds) after which an pending acquire must complete or the AcquireTimeoutAction takes place.
acquireTimeoutMillis
,
int
the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.
maxConnections
,
int
the maximum number of pending acquires. Once this is exceed acquire tries will be failed.
maxPendingAcquires
,
final boolean
will check channel health before offering back if this parameter set to true.
releaseHealthCheck
)

Creates a new instance.

public
FixedChannelPool(Bootstrap
the Bootstrap that is used for connections
bootstrap
,
ChannelPoolHandler
the ChannelPoolHandler that will be notified for the different pool actions
handler
,
ChannelHealthChecker
the ChannelHealthChecker that will be used to check if a Channel is still healthy when obtain from the ChannelPool
healthCheck
,
FixedChannelPool.AcquireTimeoutAction
the AcquireTimeoutAction to use or null if non should be used. In this case {@param acquireTimeoutMillis} must be -1.
action
,
final long
the time (in milliseconds) after which an pending acquire must complete or the AcquireTimeoutAction takes place.
acquireTimeoutMillis
,
int
the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.
maxConnections
,
int
the maximum number of pending acquires. Once this is exceed acquire tries will be failed.
maxPendingAcquires
,
boolean
will check channel health before offering back if this parameter set to true.
releaseHealthCheck
,
boolean
true Channel selection will be LIFO, if false FIFO.
lastRecentUsed
)

Creates a new instance.

Method Summary

Modifier and TypeMethod and Description
public Future<Channel>
private void
acquire0(final Promise<Channel> promise)

public int
acquiredChannelCount()

Returns the number of acquired channels that this pool thinks it has.

public void
close()

Overrides io.netty.channel.pool.SimpleChannelPool.close.

Implements io.netty.channel.pool.ChannelPool.close.

Closes this stream and releases any system resources associated with it.
private Future<Void>
public Future<Void>

Returns:

Future which represents completion of the close task
closeAsync
()

Overrides io.netty.channel.pool.SimpleChannelPool.closeAsync.

Closes the pool in an async manner.
private void
public Future<Void>
private void
private void
Inherited from io.netty.channel.pool.SimpleChannelPool:
acquirebootstrapconnectChannelhandlerhealthCheckerofferChannelpollChannelreleasereleaseHealthCheck

Field Detail

acquiredChannelCountback to summary
private final AtomicInteger acquiredChannelCount
acquireTimeoutNanosback to summary
private final long acquireTimeoutNanos
closedback to summary
private boolean closed
executorback to summary
private final EventExecutor executor
maxConnectionsback to summary
private final int maxConnections
maxPendingAcquiresback to summary
private final int maxPendingAcquires
pendingAcquireCountback to summary
private int pendingAcquireCount
pendingAcquireQueueback to summary
private final Queue<FixedChannelPool.AcquireTask> pendingAcquireQueue
timeoutTaskback to summary
private final Runnable timeoutTask

Constructor Detail

FixedChannelPoolback to summary
public FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, int maxConnections)

Creates a new instance using the ChannelHealthChecker#ACTIVE.

Parameters
bootstrap:Bootstrap

the Bootstrap that is used for connections

handler:ChannelPoolHandler

the ChannelPoolHandler that will be notified for the different pool actions

maxConnections:int

the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.

FixedChannelPoolback to summary
public FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, int maxConnections, int maxPendingAcquires)

Creates a new instance using the ChannelHealthChecker#ACTIVE.

Parameters
bootstrap:Bootstrap

the Bootstrap that is used for connections

handler:ChannelPoolHandler

the ChannelPoolHandler that will be notified for the different pool actions

maxConnections:int

the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.

maxPendingAcquires:int

the maximum number of pending acquires. Once this is exceed acquire tries will be failed.

FixedChannelPoolback to summary
public FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedChannelPool.AcquireTimeoutAction action, final long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires)

Creates a new instance.

Parameters
bootstrap:Bootstrap

the Bootstrap that is used for connections

handler:ChannelPoolHandler

the ChannelPoolHandler that will be notified for the different pool actions

healthCheck:ChannelHealthChecker

the ChannelHealthChecker that will be used to check if a Channel is still healthy when obtain from the ChannelPool

action:FixedChannelPool.AcquireTimeoutAction

the AcquireTimeoutAction to use or null if non should be used. In this case {@param acquireTimeoutMillis} must be -1.

acquireTimeoutMillis:long

the time (in milliseconds) after which an pending acquire must complete or the AcquireTimeoutAction takes place.

maxConnections:int

the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.

maxPendingAcquires:int

the maximum number of pending acquires. Once this is exceed acquire tries will be failed.

FixedChannelPoolback to summary
public FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedChannelPool.AcquireTimeoutAction action, final long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires, final boolean releaseHealthCheck)

Creates a new instance.

Parameters
bootstrap:Bootstrap

the Bootstrap that is used for connections

handler:ChannelPoolHandler

the ChannelPoolHandler that will be notified for the different pool actions

healthCheck:ChannelHealthChecker

the ChannelHealthChecker that will be used to check if a Channel is still healthy when obtain from the ChannelPool

action:FixedChannelPool.AcquireTimeoutAction

the AcquireTimeoutAction to use or null if non should be used. In this case {@param acquireTimeoutMillis} must be -1.

acquireTimeoutMillis:long

the time (in milliseconds) after which an pending acquire must complete or the AcquireTimeoutAction takes place.

maxConnections:int

the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.

maxPendingAcquires:int

the maximum number of pending acquires. Once this is exceed acquire tries will be failed.

releaseHealthCheck:boolean

will check channel health before offering back if this parameter set to true.

FixedChannelPoolback to summary
public FixedChannelPool(Bootstrap bootstrap, ChannelPoolHandler handler, ChannelHealthChecker healthCheck, FixedChannelPool.AcquireTimeoutAction action, final long acquireTimeoutMillis, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed)

Creates a new instance.

Parameters
bootstrap:Bootstrap

the Bootstrap that is used for connections

handler:ChannelPoolHandler

the ChannelPoolHandler that will be notified for the different pool actions

healthCheck:ChannelHealthChecker

the ChannelHealthChecker that will be used to check if a Channel is still healthy when obtain from the ChannelPool

action:FixedChannelPool.AcquireTimeoutAction

the AcquireTimeoutAction to use or null if non should be used. In this case {@param acquireTimeoutMillis} must be -1.

acquireTimeoutMillis:long

the time (in milliseconds) after which an pending acquire must complete or the AcquireTimeoutAction takes place.

maxConnections:int

the number of maximal active connections, once this is reached new tries to acquire a Channel will be delayed until a connection is returned to the pool again.

maxPendingAcquires:int

the maximum number of pending acquires. Once this is exceed acquire tries will be failed.

releaseHealthCheck:boolean

will check channel health before offering back if this parameter set to true.

lastRecentUsed:boolean

true Channel selection will be LIFO, if false FIFO.

Method Detail

acquireback to summary
public Future<Channel> acquire(final Promise<Channel> promise)

Overrides io.netty.channel.pool.SimpleChannelPool.acquire.

Implements io.netty.channel.pool.ChannelPool.acquire.

Doc from io.netty.channel.pool.ChannelPool.acquire.

Acquire a Channel from this ChannelPool. The given Promise is notified once the acquire is successful and failed otherwise. Its important that an acquired is always released to the pool again, even if the Channel is explicitly closed..

Annotations
@Override
acquire0back to summary
private void acquire0(final Promise<Channel> promise)
acquiredChannelCountback to summary
public int acquiredChannelCount()

Returns the number of acquired channels that this pool thinks it has.

closeback to summary
public void close()

Overrides io.netty.channel.pool.SimpleChannelPool.close.

Implements io.netty.channel.pool.ChannelPool.close.

Doc from java.io.Closeable.close.

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 AutoCloseable#close(), cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally mark the Closeable as closed, prior to throwing the IOException.

Annotations
@Override
close0back to summary
private Future<Void> close0()
closeAsyncback to summary
public Future<Void> closeAsync()

Overrides io.netty.channel.pool.SimpleChannelPool.closeAsync.

Closes the pool in an async manner.

Returns:Future<Void>

Future which represents completion of the close task

Annotations
@Override
decrementAndRunTaskQueueback to summary
private void decrementAndRunTaskQueue()
releaseback to summary
public Future<Void> release(final Channel channel, final Promise<Void> promise)

Overrides io.netty.channel.pool.SimpleChannelPool.release.

Implements io.netty.channel.pool.ChannelPool.release.

Doc from io.netty.channel.pool.ChannelPool.release.

Release a Channel back to this ChannelPool. The given Promise is notified once the release is successful and failed otherwise. When failed the Channel will automatically closed.

Annotations
@Override
runTaskQueueback to summary
private void runTaskQueue()
tooManyOutstandingback to summary
private void tooManyOutstanding(Promise<?> promise)
io.netty.channel.pool back to summary

private Class FixedChannelPool.AcquireListener

extends Object
implements FutureListener<Channel>
Class Inheritance
All Implemented Interfaces
io.netty.util.concurrent.FutureListener, io.netty.util.concurrent.GenericFutureListener, java.util.EventListener
Known Direct Subclasses
io.netty.channel.pool.FixedChannelPool.AcquireTask

Field Summary

Modifier and TypeField and Description
protected boolean
private final Promise<Channel>

Constructor Summary

AccessConstructor and Description
pack-priv
AcquireListener(Promise<Channel> originalPromise)

Method Summary

Modifier and TypeMethod and Description
public void
public void
operationComplete(Future<Channel>
the source Future which called this callback
future
)

Implements io.netty.util.concurrent.GenericFutureListener.operationComplete.

Invoked when the operation associated with the Future has been completed.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

acquiredback to summary
protected boolean acquired
originalPromiseback to summary
private final Promise<Channel> originalPromise

Constructor Detail

AcquireListenerback to summary
pack-priv AcquireListener(Promise<Channel> originalPromise)

Method Detail

acquiredback to summary
public void acquired()
operationCompleteback to summary
public void operationComplete(Future<Channel> future) throws Exception

Implements io.netty.util.concurrent.GenericFutureListener.operationComplete.

Doc from io.netty.util.concurrent.GenericFutureListener.operationComplete.

Invoked when the operation associated with the Future has been completed.

Parameters
future:Future<Channel>

the source Future which called this callback

Annotations
@Override
io.netty.channel.pool back to summary

private final Class FixedChannelPool.AcquireTask

extends AcquireListener
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final long
pack-priv final Promise<Channel>
pack-priv ScheduledFuture<?>
Inherited from io.netty.channel.pool.FixedChannelPool.AcquireListener:
acquired

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from io.netty.channel.pool.FixedChannelPool.AcquireListener:
acquiredoperationComplete

Field Detail

expireNanoTimeback to summary
pack-priv final long expireNanoTime
promiseback to summary
pack-priv final Promise<Channel> promise
timeoutFutureback to summary
pack-priv ScheduledFuture<?> timeoutFuture

Constructor Detail

AcquireTaskback to summary
pack-priv AcquireTask(Promise<Channel> promise)
io.netty.channel.pool back to summary

public final Enum FixedChannelPool.AcquireTimeoutAction

extends Enum<FixedChannelPool.AcquireTimeoutAction>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final FixedChannelPool.AcquireTimeoutAction
FAIL

Fail the Future of the acquire call with a TimeoutException.

public static final FixedChannelPool.AcquireTimeoutAction
NEW

Create a new connection when the timeout is detected.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static FixedChannelPool.AcquireTimeoutAction
public static FixedChannelPool.AcquireTimeoutAction[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

FAILback to summary
public static final FixedChannelPool.AcquireTimeoutAction FAIL

Fail the Future of the acquire call with a TimeoutException.

NEWback to summary
public static final FixedChannelPool.AcquireTimeoutAction NEW

Create a new connection when the timeout is detected.

Constructor Detail

AcquireTimeoutActionback to summary
private AcquireTimeoutAction()

Method Detail

valueOfback to summary
public static FixedChannelPool.AcquireTimeoutAction valueOf(String name)
valuesback to summary
public static FixedChannelPool.AcquireTimeoutAction[] values()
io.netty.channel.pool back to summary

private final Class FixedChannelPool.AcquireTimeoutException

extends TimeoutException
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Throwable
fillInStackTrace()

Overrides java.lang.Throwable.fillInStackTrace.

Fills in the execution stack trace.

Constructor Detail

AcquireTimeoutExceptionback to summary
private AcquireTimeoutException()

Method Detail

fillInStackTraceback to summary
public Throwable fillInStackTrace()

Overrides java.lang.Throwable.fillInStackTrace.

Doc from java.lang.Throwable.fillInStackTrace.

Fills in the execution stack trace. This method records within this Throwable object information about the current state of the stack frames for the current thread.

If the stack trace of this Throwable is not writable, calling this method has no effect.

Returns:Throwable

a reference to this Throwable instance.

Annotations
@Override
io.netty.channel.pool back to summary

private abstract Class FixedChannelPool.TimeoutTask

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public abstract void
public final void
run()

Implements java.lang.Runnable.run.

Runs this operation.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

TimeoutTaskback to summary
private TimeoutTask()

Method Detail

onTimeoutback to summary
public abstract void onTimeout(FixedChannelPool.AcquireTask task)
runback to summary
public final void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override