zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] ivmaykov commented on a change in pull request #753: ZOOKEEPER-3204: Reconfig tests are constantly failing on 3.5 after applying Java 11 fix
Date Fri, 01 Feb 2019 22:45:54 GMT
ivmaykov commented on a change in pull request #753: ZOOKEEPER-3204: Reconfig tests are constantly
failing on 3.5 after applying Java 11 fix
URL: https://github.com/apache/zookeeper/pull/753#discussion_r253219624
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/NettyServerCnxn.java
 ##########
 @@ -411,19 +494,44 @@ public void receiveMessage(ChannelBuffer message) {
         }
     }
 
+    /**
+     * An event that triggers a change in the channel's "Auto Read" setting.
+     * Used for throttling. By using an enum we can treat the two values as
+     * singletons and compare with ==.
+     */
+    enum AutoReadEvent {
+        DISABLE,
+        ENABLE
+    }
+
     @Override
     public void disableRecv() {
-        disableRecvNoWait().awaitUninterruptibly();
+        if (throttled.compareAndSet(false, true)) {
+            if (LOG.isDebugEnabled()) {
+                LOG.debug("Throttling - disabling recv {}", this);
+            }
+            channel.pipeline().fireUserEventTriggered(AutoReadEvent.DISABLE);
+        }
     }
-    
-    private ChannelFuture disableRecvNoWait() {
-        throttled = true;
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Throttling - disabling recv " + this);
+
+    /**
+     * Note that the netty implementation ignores the <code>waitDisableRecv</code>
 
 Review comment:
   This comment is for the master branch, where there is a single `disableRecv(bool waitDisableRecv)`
method. A more appropriate comment for 3.5 which has 2 methods might be something like:
   
   "Note that both disableRecv() and disableRecvNoWait() are asynchronous in the netty implementation."
   
   And put that comment on the `disableRecv()` method instead.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message