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 int
DEFAULT_MAX_CONCURRENT_STREAMS
static int
DEFAULT_MAX_REUSE_STREAM_CHANNELS_LIMIT
static io.netty.util.AttributeKey<io.netty.handler.codec.http2.Http2Connection>
HTTP2_CONNECTION
static io.netty.util.AttributeKey<java.lang.Boolean>
HTTP2_REUSED_STREAM_CHANNEL
static 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)
void
close()
io.netty.util.concurrent.Future<java.lang.Void>
closeFuture()
protected EspressoHttp2StreamChannelBootstrap
createHttp2StreamChannelBootstrap(io.netty.channel.Channel ch)
int
getAcquiredChannelCount()
long
getActiveStreamsLimitReachedCount()
long
getChannelReusePoolSize()
Returns the current reuse channel pool size.int
getConnectedChannels()
long
getCurrentStreamChannelsReused()
int
getH2ActiveConnections()
io.netty.channel.group.ChannelGroup
getHttp2ChannelGroup()
long
getMaxConcurrentStreamsLimit()
int
getMaxConnections()
int
getMaxPendingAcquires()
int
getMaxReuseStreamChannelsLimit()
int
getPendingAcquireCount()
long
getTotalAcquireRetries()
long
getTotalActiveStreamChannels()
long
getTotalActiveStreams()
long
getTotalStreamChannelsReused()
long
getTotalStreamCreations()
io.netty.channel.pool.ChannelPoolHandler
handler()
Returns theChannelPoolHandler
that will be notified for the different pool actions.boolean
hasMoreThanOneHttp2Connection()
boolean
isClosed()
boolean
isClosing()
boolean
isHealthy()
static boolean
isTooManyActiveStreamsError(java.lang.Throwable t)
Deprecated.java.lang.String
name()
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)
void
setChannelReuse(boolean channelReuse)
void
setMaxConcurrentStreams(long maxConcurrentStreams)
void
setMaxReuseStreamChannelsLimit(int maxReuseStreamChannelsLimit)
void
setMoreThanOneHttp2Connection(boolean value)
void
setRetryOnMaxStreamsLimit(boolean retryOnMaxStreamsLimit)
void
setUseCustomH2Codec(boolean useCustomH2Codec)
boolean
shouldRetryOnMaxStreamsLimit()
boolean
useCustomH2Codec()
boolean
wantMoreThanOneHttp2Connection()
-
-
-
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:
name
in interfaceChannelPoolWithStats
-
setMaxConcurrentStreams
public void setMaxConcurrentStreams(long maxConcurrentStreams)
-
getActiveStreamsLimitReachedCount
public long getActiveStreamsLimitReachedCount()
- Specified by:
getActiveStreamsLimitReachedCount
in interfaceManagedChannelPool
-
getMaxConcurrentStreamsLimit
public long getMaxConcurrentStreamsLimit()
-
setMoreThanOneHttp2Connection
public void setMoreThanOneHttp2Connection(boolean value)
-
setChannelReuse
public void setChannelReuse(boolean channelReuse)
-
getTotalActiveStreams
public long getTotalActiveStreams()
- Specified by:
getTotalActiveStreams
in interfaceManagedChannelPool
-
getCurrentStreamChannelsReused
public long getCurrentStreamChannelsReused()
- Specified by:
getCurrentStreamChannelsReused
in interfaceManagedChannelPool
-
getTotalStreamChannelsReused
public long getTotalStreamChannelsReused()
- Specified by:
getTotalStreamChannelsReused
in interfaceManagedChannelPool
-
getTotalStreamCreations
public long getTotalStreamCreations()
- Specified by:
getTotalStreamCreations
in interfaceManagedChannelPool
-
getTotalAcquireRetries
public long getTotalAcquireRetries()
- Specified by:
getTotalAcquireRetries
in interfaceManagedChannelPool
-
getTotalActiveStreamChannels
public long getTotalActiveStreamChannels()
- Specified by:
getTotalActiveStreamChannels
in 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:
acquire
in 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:
acquire
in 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:
release
in 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:
release
in interfaceio.netty.channel.pool.ChannelPool
-
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
-
handler
public io.netty.channel.pool.ChannelPoolHandler handler()
Description copied from interface:ManagedChannelPool
Returns theChannelPoolHandler
that will be notified for the different pool actions.- Specified by:
handler
in interfaceManagedChannelPool
- Returns:
- the
ChannelPoolHandler
that will be notified for the different pool actions
-
getConnectedChannels
public int getConnectedChannels()
- Specified by:
getConnectedChannels
in interfaceManagedChannelPool
-
isHealthy
public boolean isHealthy()
- Specified by:
isHealthy
in interfaceManagedChannelPool
-
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
-
getMaxConnections
public int getMaxConnections()
- Specified by:
getMaxConnections
in interfaceChannelPoolWithStats
-
getH2ActiveConnections
public int getH2ActiveConnections()
- Specified by:
getH2ActiveConnections
in interfaceManagedChannelPool
-
getHttp2ChannelGroup
public io.netty.channel.group.ChannelGroup getHttp2ChannelGroup()
- Specified by:
getHttp2ChannelGroup
in interfaceManagedChannelPool
-
getMaxPendingAcquires
public int getMaxPendingAcquires()
- Specified by:
getMaxPendingAcquires
in interfaceChannelPoolWithStats
-
getAcquiredChannelCount
public int getAcquiredChannelCount()
- Specified by:
getAcquiredChannelCount
in interfaceChannelPoolWithStats
-
getPendingAcquireCount
public int getPendingAcquireCount()
- Specified by:
getPendingAcquireCount
in interfaceChannelPoolWithStats
-
isClosed
public boolean isClosed()
- Specified by:
isClosed
in interfaceChannelPoolWithStats
- Specified by:
isClosed
in interfaceManagedChannelPool
-
getChannelReusePoolSize
public long getChannelReusePoolSize()
Description copied from interface:ManagedChannelPool
Returns the current reuse channel pool size. Normally this should be 0 since we should be reusing as much as possible.- Specified by:
getChannelReusePoolSize
in interfaceManagedChannelPool
- Returns:
- current reuse channel pool size
-
-