Class PerServerConnectionPool
java.lang.Object
com.netflix.zuul.netty.connectionpool.PerServerConnectionPool
- All Implemented Interfaces:
IConnectionPool
User: [email protected]
Date: 7/8/16
Time: 1:09 PM
-
Field Summary
Modifier and TypeFieldDescriptionstatic final io.netty.util.AttributeKey<IConnectionPool>
protected final com.netflix.spectator.api.Counter
protected final ConnectionPoolConfig
protected final AtomicInteger
This is the count of connections currently in progress of being established.protected final NettyClientConnectionFactory
protected final ConcurrentHashMap<io.netty.channel.EventLoop,
Deque<PooledConnection>> protected final com.netflix.spectator.api.Timer
protected final AtomicInteger
protected final AtomicInteger
protected final com.netflix.spectator.api.Counter
protected final com.netflix.spectator.api.Counter
protected final com.netflix.spectator.api.Counter
protected final com.netflix.spectator.api.Counter
protected boolean
protected final com.netflix.spectator.api.Counter
protected final com.netflix.client.config.IClientConfig
protected final PooledConnectionFactory
protected final com.netflix.spectator.api.Counter
protected final com.netflix.spectator.api.Counter
protected final com.netflix.zuul.discovery.DiscoveryResult
protected final SocketAddress
-
Constructor Summary
ConstructorDescriptionPerServerConnectionPool
(com.netflix.zuul.discovery.DiscoveryResult server, SocketAddress serverAddr, NettyClientConnectionFactory connectionFactory, PooledConnectionFactory pooledConnectionFactory, ConnectionPoolConfig config, com.netflix.client.config.IClientConfig niwsClientConfig, com.netflix.spectator.api.Counter createNewConnCounter, com.netflix.spectator.api.Counter createConnSucceededCounter, com.netflix.spectator.api.Counter createConnFailedCounter, com.netflix.spectator.api.Counter requestConnCounter, com.netflix.spectator.api.Counter reuseConnCounter, com.netflix.spectator.api.Counter connTakenFromPoolIsNotOpen, com.netflix.spectator.api.Counter closeAboveHighWaterMarkCounter, com.netflix.spectator.api.Counter maxConnsPerHostExceededCounter, com.netflix.spectator.api.Timer connEstablishTimer, AtomicInteger connsInPool, AtomicInteger connsInUse) -
Method Summary
Modifier and TypeMethodDescriptionio.netty.util.concurrent.Promise<PooledConnection>
acquire
(io.netty.channel.EventLoop eventLoop, CurrentPassport passport, AtomicReference<? super InetAddress> selectedHostAddr) protected io.netty.channel.ChannelFuture
connectToServer
(io.netty.channel.EventLoop eventLoop, CurrentPassport passport, SocketAddress serverAddr) protected void
createConnection
(io.netty.channel.ChannelFuture cf, io.netty.util.concurrent.Promise<PooledConnection> callerPromise, CurrentPassport passport) void
drain()
int
int
com.netflix.client.config.IClientConfig
protected Deque<PooledConnection>
getPoolForEventLoop
(io.netty.channel.EventLoop eventLoop) protected void
handleConnectCompletion
(io.netty.channel.ChannelFuture cf, io.netty.util.concurrent.Promise<PooledConnection> callerPromise, CurrentPassport passport) protected void
initPooledConnection
(PooledConnection conn, io.netty.util.concurrent.Promise<PooledConnection> promise) boolean
protected boolean
protected void
onAcquire
(PooledConnection conn, CurrentPassport passport) function to run when a connection is acquired before returning it to caller.boolean
release
(PooledConnection conn) boolean
remove
(PooledConnection conn) protected void
void
shutdown()
tryGettingFromConnectionPool
(io.netty.channel.EventLoop eventLoop) protected void
tryMakingNewConnection
(io.netty.channel.EventLoop eventLoop, io.netty.util.concurrent.Promise<PooledConnection> promise, CurrentPassport passport, AtomicReference<? super InetAddress> selectedHostAddr) protected void
protected void
updateServerStatsOnConnectCompletion
(io.netty.channel.ChannelFuture cf)
-
Field Details
-
CHANNEL_ATTR
-
connectionsPerEventLoop
protected final ConcurrentHashMap<io.netty.channel.EventLoop,Deque<PooledConnection>> connectionsPerEventLoop -
pooledConnectionFactory
-
server
protected final com.netflix.zuul.discovery.DiscoveryResult server -
serverAddr
-
connectionFactory
-
config
-
niwsClientConfig
protected final com.netflix.client.config.IClientConfig niwsClientConfig -
createNewConnCounter
protected final com.netflix.spectator.api.Counter createNewConnCounter -
createConnSucceededCounter
protected final com.netflix.spectator.api.Counter createConnSucceededCounter -
createConnFailedCounter
protected final com.netflix.spectator.api.Counter createConnFailedCounter -
requestConnCounter
protected final com.netflix.spectator.api.Counter requestConnCounter -
reuseConnCounter
protected final com.netflix.spectator.api.Counter reuseConnCounter -
connTakenFromPoolIsNotOpen
protected final com.netflix.spectator.api.Counter connTakenFromPoolIsNotOpen -
maxConnsPerHostExceededCounter
protected final com.netflix.spectator.api.Counter maxConnsPerHostExceededCounter -
closeAboveHighWaterMarkCounter
protected final com.netflix.spectator.api.Counter closeAboveHighWaterMarkCounter -
connEstablishTimer
protected final com.netflix.spectator.api.Timer connEstablishTimer -
connsInPool
-
connsInUse
-
connCreationsInProgress
This is the count of connections currently in progress of being established. They will only be added to connsInUse _after_ establishment has completed. -
draining
protected volatile boolean draining
-
-
Constructor Details
-
PerServerConnectionPool
public PerServerConnectionPool(com.netflix.zuul.discovery.DiscoveryResult server, SocketAddress serverAddr, NettyClientConnectionFactory connectionFactory, PooledConnectionFactory pooledConnectionFactory, ConnectionPoolConfig config, com.netflix.client.config.IClientConfig niwsClientConfig, com.netflix.spectator.api.Counter createNewConnCounter, com.netflix.spectator.api.Counter createConnSucceededCounter, com.netflix.spectator.api.Counter createConnFailedCounter, com.netflix.spectator.api.Counter requestConnCounter, com.netflix.spectator.api.Counter reuseConnCounter, com.netflix.spectator.api.Counter connTakenFromPoolIsNotOpen, com.netflix.spectator.api.Counter closeAboveHighWaterMarkCounter, com.netflix.spectator.api.Counter maxConnsPerHostExceededCounter, com.netflix.spectator.api.Timer connEstablishTimer, AtomicInteger connsInPool, AtomicInteger connsInUse)
-
-
Method Details
-
getConfig
- Specified by:
getConfig
in interfaceIConnectionPool
-
getNiwsClientConfig
public com.netflix.client.config.IClientConfig getNiwsClientConfig() -
isAvailable
public boolean isAvailable()- Specified by:
isAvailable
in interfaceIConnectionPool
-
onAcquire
function to run when a connection is acquired before returning it to caller. -
removeIdleStateHandler
-
acquire
public io.netty.util.concurrent.Promise<PooledConnection> acquire(io.netty.channel.EventLoop eventLoop, CurrentPassport passport, AtomicReference<? super InetAddress> selectedHostAddr) - Specified by:
acquire
in interfaceIConnectionPool
-
updateServerStatsOnAcquire
protected void updateServerStatsOnAcquire() -
tryGettingFromConnectionPool
-
isValidFromPool
-
initPooledConnection
protected void initPooledConnection(PooledConnection conn, io.netty.util.concurrent.Promise<PooledConnection> promise) -
getPoolForEventLoop
-
tryMakingNewConnection
protected void tryMakingNewConnection(io.netty.channel.EventLoop eventLoop, io.netty.util.concurrent.Promise<PooledConnection> promise, CurrentPassport passport, AtomicReference<? super InetAddress> selectedHostAddr) -
connectToServer
protected io.netty.channel.ChannelFuture connectToServer(io.netty.channel.EventLoop eventLoop, CurrentPassport passport, SocketAddress serverAddr) -
handleConnectCompletion
protected void handleConnectCompletion(io.netty.channel.ChannelFuture cf, io.netty.util.concurrent.Promise<PooledConnection> callerPromise, CurrentPassport passport) -
updateServerStatsOnConnectCompletion
protected void updateServerStatsOnConnectCompletion(io.netty.channel.ChannelFuture cf) -
createConnection
protected void createConnection(io.netty.channel.ChannelFuture cf, io.netty.util.concurrent.Promise<PooledConnection> callerPromise, CurrentPassport passport) -
release
- Specified by:
release
in interfaceIConnectionPool
-
remove
- Specified by:
remove
in interfaceIConnectionPool
-
shutdown
public void shutdown()- Specified by:
shutdown
in interfaceIConnectionPool
-
drain
public void drain()- Specified by:
drain
in interfaceIConnectionPool
-
getConnsInPool
public int getConnsInPool()- Specified by:
getConnsInPool
in interfaceIConnectionPool
-
getConnsInUse
public int getConnsInUse()- Specified by:
getConnsInUse
in interfaceIConnectionPool
-