You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@zookeeper.apache.org by GitBox <gi...@apache.org> on 2020/08/24 03:42:34 UTC

[GitHub] [zookeeper] yanllearnn opened a new pull request #1437: ZOOKEEPER-3916: check zkServer value

yanllearnn opened a new pull request #1437:
URL: https://github.com/apache/zookeeper/pull/1437


   ZOOKEEPER-3916: check whether zkServer is null or not, if null then refuse the connection, else accept.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [zookeeper] maoling commented on a change in pull request #1437: ZOOKEEPER-3916: check zkServer value

Posted by GitBox <gi...@apache.org>.
maoling commented on a change in pull request #1437:
URL: https://github.com/apache/zookeeper/pull/1437#discussion_r479624989



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxnFactory.java
##########
@@ -820,7 +820,12 @@ private void addCnxn(NIOServerCnxn cnxn) throws IOException {
     }
 
     protected NIOServerCnxn createConnection(SocketChannel sock, SelectionKey sk, SelectorThread selectorThread) throws IOException {
-        return new NIOServerCnxn(zkServer, sock, sk, this, selectorThread);
+        if (zkServer != null) {
+            return new NIOServerCnxn(zkServer, sock, sk, this, selectorThread);
+        }
+
+        LOG.warn("leader has not been voted yet, please wait a little time.");
+        throw new IOException("zkServer is null, chanel can't be used now.");
     }
 

Review comment:
       @yanllearnn 
   - Yes, `zkServer` can be null(`Leader#shutdown ---> self.setZooKeeperServer(null) `), but I guess that we cannot get null pointer exception. 
   - The workflow of code:
   ```
   Leader#shutdown ---> self.setZooKeeperServer(null) ---> NIOServerCnxnFactory.SelectorThread#run ---> processAcceptedConnections ---> createConnection(zkServer=null) 
   
   # when the client try to connect that uninitialized server
   NIOServerCnxn#doIO---> NIOServerCnxn#readLength ---> if (!isZKServerRunning()) ---> throw new IOException("ZooKeeperServer not running")
   ```




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [zookeeper] yanllearnn commented on a change in pull request #1437: ZOOKEEPER-3916: check zkServer value

Posted by GitBox <gi...@apache.org>.
yanllearnn commented on a change in pull request #1437:
URL: https://github.com/apache/zookeeper/pull/1437#discussion_r479948917



##########
File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/NIOServerCnxnFactory.java
##########
@@ -820,7 +820,12 @@ private void addCnxn(NIOServerCnxn cnxn) throws IOException {
     }
 
     protected NIOServerCnxn createConnection(SocketChannel sock, SelectionKey sk, SelectorThread selectorThread) throws IOException {
-        return new NIOServerCnxn(zkServer, sock, sk, this, selectorThread);
+        if (zkServer != null) {
+            return new NIOServerCnxn(zkServer, sock, sk, this, selectorThread);
+        }
+
+        LOG.warn("leader has not been voted yet, please wait a little time.");
+        throw new IOException("zkServer is null, chanel can't be used now.");
     }
 

Review comment:
       @maoling 
   I think adding the check is good, despite what you have said.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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



[GitHub] [zookeeper] yanllearnn closed pull request #1437: ZOOKEEPER-3916: check zkServer value

Posted by GitBox <gi...@apache.org>.
yanllearnn closed pull request #1437:
URL: https://github.com/apache/zookeeper/pull/1437


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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