zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ivmaykov <...@git.apache.org>
Subject [GitHub] zookeeper pull request #669: ZOOKEEPER-3152: Port ZK netty stack to netty4
Date Fri, 19 Oct 2018 19:25:30 GMT
Github user ivmaykov commented on a diff in the pull request:

    https://github.com/apache/zookeeper/pull/669#discussion_r226757057
  
    --- Diff: zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxnFactory.java
---
    @@ -116,170 +115,94 @@ public void channelConnected(ChannelHandlerContext ctx,
     
                 NettyServerCnxn cnxn = new NettyServerCnxn(channel,
                         zkServer, NettyServerCnxnFactory.this);
    -            ctx.setAttachment(cnxn);
    +            ctx.channel().attr(CONNECTION_ATTRIBUTE).set(cnxn);
     
                 if (secure) {
    -                SslHandler sslHandler = ctx.getPipeline().get(SslHandler.class);
    -                ChannelFuture handshakeFuture = sslHandler.handshake();
    +                SslHandler sslHandler = ctx.pipeline().get(SslHandler.class);
    +                Future<Channel> handshakeFuture = sslHandler.handshakeFuture();
                     handshakeFuture.addListener(new CertificateVerifier(sslHandler, cnxn));
                 } else {
    -                allChannels.add(ctx.getChannel());
    +                allChannels.add(ctx.channel());
                     addCnxn(cnxn);
                 }
             }
     
             @Override
    -        public void channelDisconnected(ChannelHandlerContext ctx,
    -                ChannelStateEvent e) throws Exception
    -        {
    -            if (LOG.isTraceEnabled()) {
    -                LOG.trace("Channel disconnected " + e);
    -            }
    -            NettyServerCnxn cnxn = (NettyServerCnxn) ctx.getAttachment();
    +        public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    +            LOG.trace("Channel inactive {}", ctx.channel());
    --- End diff --
    
    LOG.trace() does an isTraceEnabled check internally. If the additional parameters passed
to the log method don't do any work (such as converting the contents of a buffer to a hex
string), then the enclosing isTraceEnabled check is redundant.


---

Mime
View raw message