diff --git a/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/NettyClientConnectionFactory.java b/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/NettyClientConnectionFactory.java index 9200ce1458..ecac84fb1d 100644 --- a/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/NettyClientConnectionFactory.java +++ b/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/NettyClientConnectionFactory.java @@ -43,7 +43,7 @@ public final class NettyClientConnectionFactory { this.channelInitializer = channelInitializer; } - public ChannelFuture connect(final EventLoop eventLoop, SocketAddress socketAddress, CurrentPassport passport) { + public ChannelFuture connect(final EventLoop eventLoop, SocketAddress socketAddress, CurrentPassport passport, IConnectionPool pool) { Objects.requireNonNull(socketAddress, "socketAddress"); if (socketAddress instanceof InetSocketAddress) { // This should be checked by the ClientConnectionManager @@ -54,6 +54,7 @@ public ChannelFuture connect(final EventLoop eventLoop, SocketAddress socketAddr .handler(channelInitializer) .group(eventLoop) .attr(CurrentPassport.CHANNEL_ATTR, passport) + .attr(PerServerConnectionPool.CHANNEL_ATTR, pool) .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, connPoolConfig.getConnectTimeout()) .option(ChannelOption.SO_KEEPALIVE, connPoolConfig.getTcpKeepAlive()) .option(ChannelOption.TCP_NODELAY, connPoolConfig.getTcpNoDelay()) diff --git a/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/PerServerConnectionPool.java b/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/PerServerConnectionPool.java index bf2386b9e7..f7fc599098 100644 --- a/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/PerServerConnectionPool.java +++ b/zuul-core/src/main/java/com/netflix/zuul/netty/connectionpool/PerServerConnectionPool.java @@ -23,8 +23,10 @@ import com.netflix.zuul.exception.OutboundErrorType; import com.netflix.zuul.passport.CurrentPassport; import com.netflix.zuul.passport.PassportState; +import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.EventLoop; +import io.netty.util.AttributeKey; import io.netty.util.concurrent.Promise; import java.net.InetAddress; import java.net.InetSocketAddress; @@ -49,7 +51,7 @@ public class PerServerConnectionPool implements IConnectionPool { private static final Logger LOG = LoggerFactory.getLogger(PerServerConnectionPool.class); - + public static final AttributeKey CHANNEL_ATTR = AttributeKey.newInstance("_connection_pool"); private final ConcurrentHashMap> connectionsPerEventLoop = new ConcurrentHashMap<>(); protected final PooledConnectionFactory pooledConnectionFactory; @@ -277,7 +279,7 @@ protected void tryMakingNewConnection( } protected ChannelFuture connectToServer(EventLoop eventLoop, CurrentPassport passport, SocketAddress serverAddr) { - return connectionFactory.connect(eventLoop, serverAddr, passport); + return connectionFactory.connect(eventLoop, serverAddr, passport, this); } protected void handleConnectCompletion( @@ -287,7 +289,6 @@ protected void handleConnectCompletion( if (cf.isSuccess()) { passport.add(PassportState.ORIGIN_CH_CONNECTED); - server.incrementOpenConnectionsCount(); createConnSucceededCounter.increment(); connsInUse.incrementAndGet();