Package com.linkedin.alpini.netty4.pool
Class Http2AwareChannelPool
- java.lang.Object
-
- com.linkedin.alpini.netty4.pool.Http2AwareChannelPool
-
- All Implemented Interfaces:
ChannelPoolWithStats,ManagedChannelPool,io.netty.channel.pool.ChannelPool,java.io.Closeable,java.lang.AutoCloseable
public class Http2AwareChannelPool extends java.lang.Object implements ManagedChannelPool
A ChannelPool Wrapper that would return either a ChannelPool if the request is an HTTP 1.1 request or A Stream if HTTP2
-
-
Field Summary
Fields Modifier and Type Field Description static intDEFAULT_MAX_CONCURRENT_STREAMSstatic intDEFAULT_MAX_REUSE_STREAM_CHANNELS_LIMITstatic io.netty.util.AttributeKey<io.netty.handler.codec.http2.Http2Connection>HTTP2_CONNECTIONstatic io.netty.util.AttributeKey<java.lang.Boolean>HTTP2_REUSED_STREAM_CHANNELstatic io.netty.util.AttributeKey<java.lang.Boolean>HTTP2_STREAM_CHANNEL_AVAILABLE_FOR_REUSE
-
Constructor Summary
Constructors Constructor Description Http2AwareChannelPool(ManagedChannelPool parentPool, java.util.function.Consumer<io.netty.channel.Channel> preStreamChannelInitializer, java.util.function.Consumer<io.netty.channel.Channel> postStreamInitializer)Http2AwareChannelPool(ManagedChannelPool parentPool, java.util.function.Consumer<io.netty.channel.Channel> preStreamChannelInitializer, java.util.function.Consumer<io.netty.channel.Channel> postStreamInitializer, boolean moreThanOneHttp2Connection)Http2AwareChannelPool(ManagedChannelPool parentPool, java.util.function.Consumer<io.netty.channel.Channel> preStreamChannelInitializer, java.util.function.Consumer<io.netty.channel.Channel> postStreamInitializer, boolean moreThanOneHttp2Connection, io.netty.channel.group.ChannelGroup http2ChannelGroup)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description io.netty.util.concurrent.Future<io.netty.channel.Channel>acquire()io.netty.util.concurrent.Future<io.netty.channel.Channel>acquire(io.netty.util.concurrent.Promise<io.netty.channel.Channel> promise)protected io.netty.util.concurrent.Promise<io.netty.channel.Channel>acquire0(io.netty.util.concurrent.Promise<io.netty.channel.Channel> promise)voidclose()io.netty.util.concurrent.Future<java.lang.Void>closeFuture()protected EspressoHttp2StreamChannelBootstrapcreateHttp2StreamChannelBootstrap(io.netty.channel.Channel ch)intgetAcquiredChannelCount()longgetActiveStreamsLimitReachedCount()longgetChannelReusePoolSize()Returns the current reuse channel pool size.intgetConnectedChannels()longgetCurrentStreamChannelsReused()intgetH2ActiveConnections()io.netty.channel.group.ChannelGroupgetHttp2ChannelGroup()longgetMaxConcurrentStreamsLimit()intgetMaxConnections()intgetMaxPendingAcquires()intgetMaxReuseStreamChannelsLimit()intgetPendingAcquireCount()longgetTotalAcquireRetries()longgetTotalActiveStreamChannels()longgetTotalActiveStreams()longgetTotalStreamChannelsReused()longgetTotalStreamCreations()io.netty.channel.pool.ChannelPoolHandlerhandler()Returns theChannelPoolHandlerthat will be notified for the different pool actions.booleanhasMoreThanOneHttp2Connection()booleanisClosed()booleanisClosing()booleanisHealthy()static booleanisTooManyActiveStreamsError(java.lang.Throwable t)Deprecated.java.lang.Stringname()io.netty.util.concurrent.Future<java.lang.Void>release(io.netty.channel.Channel channel)io.netty.util.concurrent.Future<java.lang.Void>release(io.netty.channel.Channel channel, io.netty.util.concurrent.Promise<java.lang.Void> promise)voidsetChannelReuse(boolean channelReuse)voidsetMaxConcurrentStreams(long maxConcurrentStreams)voidsetMaxReuseStreamChannelsLimit(int maxReuseStreamChannelsLimit)voidsetMoreThanOneHttp2Connection(boolean value)voidsetRetryOnMaxStreamsLimit(boolean retryOnMaxStreamsLimit)voidsetUseCustomH2Codec(boolean useCustomH2Codec)booleanshouldRetryOnMaxStreamsLimit()booleanuseCustomH2Codec()booleanwantMoreThanOneHttp2Connection()
-
-
-
Field Detail
-
HTTP2_STREAM_CHANNEL_AVAILABLE_FOR_REUSE
public static final io.netty.util.AttributeKey<java.lang.Boolean> HTTP2_STREAM_CHANNEL_AVAILABLE_FOR_REUSE
-
HTTP2_REUSED_STREAM_CHANNEL
public static final io.netty.util.AttributeKey<java.lang.Boolean> HTTP2_REUSED_STREAM_CHANNEL
-
HTTP2_CONNECTION
public static final io.netty.util.AttributeKey<io.netty.handler.codec.http2.Http2Connection> HTTP2_CONNECTION
-
DEFAULT_MAX_REUSE_STREAM_CHANNELS_LIMIT
public static final int DEFAULT_MAX_REUSE_STREAM_CHANNELS_LIMIT
- See Also:
- Constant Field Values
-
DEFAULT_MAX_CONCURRENT_STREAMS
public static final int DEFAULT_MAX_CONCURRENT_STREAMS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Http2AwareChannelPool
public Http2AwareChannelPool(ManagedChannelPool parentPool, java.util.function.Consumer<io.netty.channel.Channel> preStreamChannelInitializer, java.util.function.Consumer<io.netty.channel.Channel> postStreamInitializer)
-
Http2AwareChannelPool
public Http2AwareChannelPool(ManagedChannelPool parentPool, java.util.function.Consumer<io.netty.channel.Channel> preStreamChannelInitializer, java.util.function.Consumer<io.netty.channel.Channel> postStreamInitializer, boolean moreThanOneHttp2Connection)
-
Http2AwareChannelPool
public Http2AwareChannelPool(ManagedChannelPool parentPool, java.util.function.Consumer<io.netty.channel.Channel> preStreamChannelInitializer, java.util.function.Consumer<io.netty.channel.Channel> postStreamInitializer, boolean moreThanOneHttp2Connection, io.netty.channel.group.ChannelGroup http2ChannelGroup)
-
-
Method Detail
-
name
public java.lang.String name()
- Specified by:
namein interfaceChannelPoolWithStats
-
setMaxConcurrentStreams
public void setMaxConcurrentStreams(long maxConcurrentStreams)
-
getActiveStreamsLimitReachedCount
public long getActiveStreamsLimitReachedCount()
- Specified by:
getActiveStreamsLimitReachedCountin interfaceManagedChannelPool
-
getMaxConcurrentStreamsLimit
public long getMaxConcurrentStreamsLimit()
-
setMoreThanOneHttp2Connection
public void setMoreThanOneHttp2Connection(boolean value)
-
setChannelReuse
public void setChannelReuse(boolean channelReuse)
-
getTotalActiveStreams
public long getTotalActiveStreams()
- Specified by:
getTotalActiveStreamsin interfaceManagedChannelPool
-
getCurrentStreamChannelsReused
public long getCurrentStreamChannelsReused()
- Specified by:
getCurrentStreamChannelsReusedin interfaceManagedChannelPool
-
getTotalStreamChannelsReused
public long getTotalStreamChannelsReused()
- Specified by:
getTotalStreamChannelsReusedin interfaceManagedChannelPool
-
getTotalStreamCreations
public long getTotalStreamCreations()
- Specified by:
getTotalStreamCreationsin interfaceManagedChannelPool
-
getTotalAcquireRetries
public long getTotalAcquireRetries()
- Specified by:
getTotalAcquireRetriesin interfaceManagedChannelPool
-
getTotalActiveStreamChannels
public long getTotalActiveStreamChannels()
- Specified by:
getTotalActiveStreamChannelsin interfaceManagedChannelPool
-
wantMoreThanOneHttp2Connection
public boolean wantMoreThanOneHttp2Connection()
-
hasMoreThanOneHttp2Connection
public boolean hasMoreThanOneHttp2Connection()
-
useCustomH2Codec
public boolean useCustomH2Codec()
-
setUseCustomH2Codec
public void setUseCustomH2Codec(boolean useCustomH2Codec)
-
setMaxReuseStreamChannelsLimit
public void setMaxReuseStreamChannelsLimit(int maxReuseStreamChannelsLimit)
-
getMaxReuseStreamChannelsLimit
public int getMaxReuseStreamChannelsLimit()
-
setRetryOnMaxStreamsLimit
public void setRetryOnMaxStreamsLimit(boolean retryOnMaxStreamsLimit)
-
shouldRetryOnMaxStreamsLimit
public boolean shouldRetryOnMaxStreamsLimit()
-
acquire
public io.netty.util.concurrent.Future<io.netty.channel.Channel> acquire()
- Specified by:
acquirein interfaceio.netty.channel.pool.ChannelPool
-
createHttp2StreamChannelBootstrap
protected EspressoHttp2StreamChannelBootstrap createHttp2StreamChannelBootstrap(io.netty.channel.Channel ch)
-
acquire
public io.netty.util.concurrent.Future<io.netty.channel.Channel> acquire(io.netty.util.concurrent.Promise<io.netty.channel.Channel> promise)
- Specified by:
acquirein interfaceio.netty.channel.pool.ChannelPool
-
acquire0
protected io.netty.util.concurrent.Promise<io.netty.channel.Channel> acquire0(io.netty.util.concurrent.Promise<io.netty.channel.Channel> promise)
-
isTooManyActiveStreamsError
@Deprecated public static boolean isTooManyActiveStreamsError(java.lang.Throwable t)
Deprecated.
-
release
public io.netty.util.concurrent.Future<java.lang.Void> release(io.netty.channel.Channel channel)
- Specified by:
releasein interfaceio.netty.channel.pool.ChannelPool
-
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:
releasein interfaceio.netty.channel.pool.ChannelPool
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceio.netty.channel.pool.ChannelPool- Specified by:
closein interfacejava.io.Closeable
-
handler
public io.netty.channel.pool.ChannelPoolHandler handler()
Description copied from interface:ManagedChannelPoolReturns theChannelPoolHandlerthat will be notified for the different pool actions.- Specified by:
handlerin interfaceManagedChannelPool- Returns:
- the
ChannelPoolHandlerthat will be notified for the different pool actions
-
getConnectedChannels
public int getConnectedChannels()
- Specified by:
getConnectedChannelsin interfaceManagedChannelPool
-
isHealthy
public boolean isHealthy()
- Specified by:
isHealthyin interfaceManagedChannelPool
-
closeFuture
public final io.netty.util.concurrent.Future<java.lang.Void> closeFuture()
- Specified by:
closeFuturein interfaceManagedChannelPool
-
isClosing
public final boolean isClosing()
- Specified by:
isClosingin interfaceManagedChannelPool
-
getMaxConnections
public int getMaxConnections()
- Specified by:
getMaxConnectionsin interfaceChannelPoolWithStats
-
getH2ActiveConnections
public int getH2ActiveConnections()
- Specified by:
getH2ActiveConnectionsin interfaceManagedChannelPool
-
getHttp2ChannelGroup
public io.netty.channel.group.ChannelGroup getHttp2ChannelGroup()
- Specified by:
getHttp2ChannelGroupin interfaceManagedChannelPool
-
getMaxPendingAcquires
public int getMaxPendingAcquires()
- Specified by:
getMaxPendingAcquiresin interfaceChannelPoolWithStats
-
getAcquiredChannelCount
public int getAcquiredChannelCount()
- Specified by:
getAcquiredChannelCountin interfaceChannelPoolWithStats
-
getPendingAcquireCount
public int getPendingAcquireCount()
- Specified by:
getPendingAcquireCountin interfaceChannelPoolWithStats
-
isClosed
public boolean isClosed()
- Specified by:
isClosedin interfaceChannelPoolWithStats- Specified by:
isClosedin interfaceManagedChannelPool
-
getChannelReusePoolSize
public long getChannelReusePoolSize()
Description copied from interface:ManagedChannelPoolReturns the current reuse channel pool size. Normally this should be 0 since we should be reusing as much as possible.- Specified by:
getChannelReusePoolSizein interfaceManagedChannelPool- Returns:
- current reuse channel pool size
-
-