Package com.linkedin.alpini.netty4.pool
Class FixedChannelPoolImpl
- java.lang.Object
-
- com.linkedin.alpini.netty4.pool.EspressoSimpleChannelPool
-
- com.linkedin.alpini.netty4.pool.EspressoFixedChannelPool
-
- com.linkedin.alpini.netty4.pool.FixedChannelPoolImpl
-
- All Implemented Interfaces:
ChannelPoolWithStats
,ManagedChannelPool
,io.netty.channel.pool.ChannelPool
,java.io.Closeable
,java.lang.AutoCloseable
public class FixedChannelPoolImpl extends EspressoFixedChannelPool implements ManagedChannelPool
Created by acurtis on 5/8/18.
-
-
Constructor Summary
Constructors Constructor Description FixedChannelPoolImpl(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.pool.ChannelPoolHandler handler, io.netty.channel.pool.ChannelHealthChecker healthCheck, io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed)
FixedChannelPoolImpl(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.pool.ChannelPoolHandler handler, io.netty.channel.pool.ChannelHealthChecker healthCheck, io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed, java.util.function.BooleanSupplier useQueueSizeForAcquiredChannelCount)
FixedChannelPoolImpl(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.pool.ChannelPoolHandler handler, io.netty.channel.pool.ChannelHealthChecker healthCheck, io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, java.util.function.IntSupplier minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed)
FixedChannelPoolImpl(io.netty.bootstrap.Bootstrap bootstrap, io.netty.channel.pool.ChannelPoolHandler handler, io.netty.channel.pool.ChannelHealthChecker healthCheck, io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, java.util.function.IntSupplier minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed, java.util.function.BooleanSupplier useQueueSizeForAcquiredChannelCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.netty.util.concurrent.Future<io.netty.channel.Channel>
acquire(io.netty.util.concurrent.Promise<io.netty.channel.Channel> promise)
int
acquiredChannelCount()
Returns the number of acquired channels that this pool thinks it has.void
close()
io.netty.util.concurrent.Future<java.lang.Void>
closeFuture()
protected io.netty.channel.ChannelFuture
connectChannel(io.netty.bootstrap.Bootstrap bs)
Bootstrap a newChannel
.protected io.netty.channel.ChannelFuture
connectChannel0(io.netty.bootstrap.Bootstrap bs)
int
getConnectedChannels()
int
getMinConnections()
io.netty.channel.pool.ChannelPoolHandler
handler()
Returns theChannelPoolHandler
that will be notified for the different pool actions.boolean
isClosing()
boolean
isHealthy()
java.lang.String
name()
protected void
notifyGrowFailure(java.net.SocketAddress remoteAddress, java.lang.Throwable cause)
io.netty.util.concurrent.Future<java.lang.Void>
release(io.netty.channel.Channel channel, io.netty.util.concurrent.Promise<java.lang.Void> promise)
void
setMinConnections(int minConnections)
void
setMinConnections(java.util.function.IntSupplier minConnections)
-
Methods inherited from class com.linkedin.alpini.netty4.pool.EspressoFixedChannelPool
closeAsync, getAcquiredChannelCount, getMaxConnections, getMaxPendingAcquires, getPendingAcquireCount, incrementAcquiredChannelCount, isClosed, isPoolClosed
-
Methods inherited from class com.linkedin.alpini.netty4.pool.EspressoSimpleChannelPool
acquire, bootstrap, getAvailableChannels, healthChecker, offerChannel, pollChannel, release, releaseHealthCheck
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.linkedin.alpini.netty4.pool.ChannelPoolWithStats
getAcquiredChannelCount, getMaxConnections, getMaxPendingAcquires, getPendingAcquireCount
-
Methods inherited from interface com.linkedin.alpini.netty4.pool.ManagedChannelPool
getActiveStreamsLimitReachedCount, getChannelReusePoolSize, getCurrentStreamChannelsReused, getH2ActiveConnections, getHttp2ChannelGroup, getTotalAcquireRetries, getTotalActiveStreamChannels, getTotalActiveStreams, getTotalStreamChannelsReused, getTotalStreamCreations, isClosed
-
-
-
-
Constructor Detail
-
FixedChannelPoolImpl
public FixedChannelPoolImpl(@Nonnull io.netty.bootstrap.Bootstrap bootstrap, @Nonnull io.netty.channel.pool.ChannelPoolHandler handler, @Nonnull io.netty.channel.pool.ChannelHealthChecker healthCheck, @Nonnull io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, @Nonnull java.util.function.IntSupplier minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed)
-
FixedChannelPoolImpl
public FixedChannelPoolImpl(@Nonnull io.netty.bootstrap.Bootstrap bootstrap, @Nonnull io.netty.channel.pool.ChannelPoolHandler handler, @Nonnull io.netty.channel.pool.ChannelHealthChecker healthCheck, @Nonnull io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed)
-
FixedChannelPoolImpl
public FixedChannelPoolImpl(@Nonnull io.netty.bootstrap.Bootstrap bootstrap, @Nonnull io.netty.channel.pool.ChannelPoolHandler handler, @Nonnull io.netty.channel.pool.ChannelHealthChecker healthCheck, @Nonnull io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, int minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed, @Nonnull java.util.function.BooleanSupplier useQueueSizeForAcquiredChannelCount)
-
FixedChannelPoolImpl
public FixedChannelPoolImpl(@Nonnull io.netty.bootstrap.Bootstrap bootstrap, @Nonnull io.netty.channel.pool.ChannelPoolHandler handler, @Nonnull io.netty.channel.pool.ChannelHealthChecker healthCheck, @Nonnull io.netty.channel.pool.FixedChannelPool.AcquireTimeoutAction action, long acquireTimeoutMillis, @Nonnull java.util.function.IntSupplier minConnections, int maxConnections, int maxPendingAcquires, boolean releaseHealthCheck, boolean lastRecentUsed, @Nonnull java.util.function.BooleanSupplier useQueueSizeForAcquiredChannelCount)
-
-
Method Detail
-
name
public java.lang.String name()
- Specified by:
name
in interfaceChannelPoolWithStats
- Overrides:
name
in classEspressoFixedChannelPool
-
handler
public io.netty.channel.pool.ChannelPoolHandler handler()
Description copied from class:EspressoSimpleChannelPool
Returns theChannelPoolHandler
that will be notified for the different pool actions.- Specified by:
handler
in interfaceManagedChannelPool
- Overrides:
handler
in classEspressoSimpleChannelPool
- Returns:
- the
ChannelPoolHandler
that will be notified for the different pool actions
-
getConnectedChannels
public int getConnectedChannels()
- Specified by:
getConnectedChannels
in interfaceManagedChannelPool
-
setMinConnections
public void setMinConnections(int minConnections)
-
setMinConnections
public void setMinConnections(@Nonnull java.util.function.IntSupplier minConnections)
-
getMinConnections
public int getMinConnections()
-
connectChannel0
protected io.netty.channel.ChannelFuture connectChannel0(io.netty.bootstrap.Bootstrap bs)
-
connectChannel
protected io.netty.channel.ChannelFuture connectChannel(io.netty.bootstrap.Bootstrap bs)
Description copied from class:EspressoSimpleChannelPool
Bootstrap a newChannel
. The default implementation usesBootstrap.connect()
, sub-classes may override this.The
Bootstrap
that is passed in here is cloned viaBootstrap.clone()
, so it is safe to modify.- Overrides:
connectChannel
in classEspressoSimpleChannelPool
-
isHealthy
public boolean isHealthy()
- Specified by:
isHealthy
in interfaceManagedChannelPool
-
acquire
public io.netty.util.concurrent.Future<io.netty.channel.Channel> acquire(io.netty.util.concurrent.Promise<io.netty.channel.Channel> promise)
- Specified by:
acquire
in interfaceio.netty.channel.pool.ChannelPool
- Overrides:
acquire
in classEspressoFixedChannelPool
-
release
public io.netty.util.concurrent.Future<java.lang.Void> release(io.netty.channel.Channel channel, io.netty.util.concurrent.Promise<java.lang.Void> promise)
- Specified by:
release
in interfaceio.netty.channel.pool.ChannelPool
- Overrides:
release
in classEspressoFixedChannelPool
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfaceio.netty.channel.pool.ChannelPool
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classEspressoFixedChannelPool
-
closeFuture
public final io.netty.util.concurrent.Future<java.lang.Void> closeFuture()
- Specified by:
closeFuture
in interfaceManagedChannelPool
-
isClosing
public final boolean isClosing()
- Specified by:
isClosing
in interfaceManagedChannelPool
-
acquiredChannelCount
public int acquiredChannelCount()
Description copied from class:EspressoFixedChannelPool
Returns the number of acquired channels that this pool thinks it has.- Overrides:
acquiredChannelCount
in classEspressoFixedChannelPool
-
notifyGrowFailure
protected void notifyGrowFailure(java.net.SocketAddress remoteAddress, java.lang.Throwable cause)
-
-