You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@zookeeper.apache.org by sy...@apache.org on 2022/05/17 10:58:04 UTC

[zookeeper] branch branch-3.5 updated (a5f0eb0e5 -> 071e93f9c)

This is an automated email from the ASF dual-hosted git repository.

symat pushed a change to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


    from a5f0eb0e5 ZOOKEEPER-4269: acceptedEpoch.tmp rename failure will cause server startup error
     new 6f212fb04 ZOOKEEPER-4270: Flaky test: QuorumPeerMainTest#testLeaderOutOfView
     new 93b1455ee ZOOKEEPER-4251: Flaky test: org.apache.zookeeper.test.WatcherTest
     new 65615a54e ZOOKEEPER-4345: Avoid NoSunchMethodException caused by shaded zookeeper jar
     new 66dc95f98 ZOOKEEPER-4356: Code blocks do not render correctly in ZK docs site
     new 071e93f9c ZOOKEEPER-4377: KeeperException.create has NullPointerException when low version client requests the high version server

The 5 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 zookeeper-docs/pom.xml                             |  1 +
 .../java/org/apache/zookeeper/KeeperException.java | 10 +++++--
 .../main/java/org/apache/zookeeper/ZooKeeper.java  |  7 +++--
 .../java/org/apache/zookeeper/ZooKeeperTest.java   | 14 +++++++++
 .../server/quorum/QuorumPeerMainTest.java          | 34 ++++++++++++++++++----
 .../org/apache/zookeeper/test/ClientSSLTest.java   | 12 ++++++++
 .../apache/zookeeper/test/NettyNettySuiteTest.java |  4 +--
 .../apache/zookeeper/test/NioNettySuiteTest.java   |  4 +--
 8 files changed, 70 insertions(+), 16 deletions(-)


[zookeeper] 02/05: ZOOKEEPER-4251: Flaky test: org.apache.zookeeper.test.WatcherTest

Posted by sy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git

commit 93b1455ee34fe85b1a059191d18e4b675d7b8696
Author: Mohammad Arshad <ar...@apache.org>
AuthorDate: Thu Mar 25 10:19:36 2021 +0000

    ZOOKEEPER-4251: Flaky test: org.apache.zookeeper.test.WatcherTest
    
    Moved ReconfigTest in test suites in the last to avoid the ReconfigTest test impacts on other test classes
    
    Author: Mohammad Arshad <ar...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>
    
    Closes #1647 from arshadmohammad/ZOOKEEPER-4251-branch-3.6
    
    (cherry picked from commit 8625c363aa23ac0c14447ce6291bea17bda3293f)
---
 .../src/test/java/org/apache/zookeeper/test/NettyNettySuiteTest.java  | 4 ++--
 .../src/test/java/org/apache/zookeeper/test/NioNettySuiteTest.java    | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/NettyNettySuiteTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/NettyNettySuiteTest.java
index 35710ba3b..34adab14a 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/NettyNettySuiteTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/NettyNettySuiteTest.java
@@ -30,9 +30,9 @@ import org.junit.runners.Suite;
         ClientTest.class,
         FourLetterWordsTest.class,
         NullDataTest.class,
-        ReconfigTest.class,
         SessionTest.class,
-        WatcherTest.class
+        WatcherTest.class,
+        ReconfigTest.class
 })
 public class NettyNettySuiteTest extends NettyNettySuiteBase {
 }
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/NioNettySuiteTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/NioNettySuiteTest.java
index a1ef33db5..57ccb7d51 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/NioNettySuiteTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/NioNettySuiteTest.java
@@ -30,9 +30,9 @@ import org.junit.runners.Suite;
         ClientTest.class,
         FourLetterWordsTest.class,
         NullDataTest.class,
-        ReconfigTest.class,
         SessionTest.class,
-        WatcherTest.class
+        WatcherTest.class,
+        ReconfigTest.class
         })
 public class NioNettySuiteTest extends NioNettySuiteBase {
 }


[zookeeper] 05/05: ZOOKEEPER-4377: KeeperException.create has NullPointerException when low version client requests the high version server

Posted by sy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git

commit 071e93f9c940c5fd8be3269f32aeac674d4e508d
Author: maoling <ma...@apache.org>
AuthorDate: Sun Oct 17 15:07:58 2021 +0800

    ZOOKEEPER-4377: KeeperException.create has NullPointerException when low version client requests the high version server
    
    - When low version client accessed the high version server which has some new added error code, the client will get a NPE:
    ```
     java.lang.NullPointerException
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:94)
    at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
    at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1538)
    ```
    - How to reproduce this issue?For example:
    ```
    the client version we using is 3.6.0, and server version we using is 3.7.0 which has a new added error code QUOTAEXCEEDED(-125),
    we set quota at server side and use the client to create znodes which exceeds the quota,
    the client will get a NPE
    ```
    - Apply this patch, we will get the following:
    ```
     java.lang.IllegalArgumentException: The current client version cannot lookup this code:-125
     at org.apache.zookeeper.KeeperException$Code.get(KeeperException.java:449)
     at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1347)
    ```
    - we should backport this PR to all branches, making the client has upward compatibility
    - more details in the [ZOOKEEPER-4377](https://issues.apache.org/jira/browse/ZOOKEEPER-4377)
    
    Author: maoling <ma...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>, ruanwenjun <we...@apache.org>
    
    Closes #1764 from maoling/ZOOKEEPER-4377
    
    (cherry picked from commit 9f355f5a57f35d3760f8e669696622135c457938)
    Signed-off-by: maoling <ma...@apache.org>
    (cherry picked from commit 86c12634d22bbfee8cf9f5434c49eebe3ffa84c0)
---
 .../main/java/org/apache/zookeeper/KeeperException.java    | 10 +++++++---
 .../src/test/java/org/apache/zookeeper/ZooKeeperTest.java  | 14 ++++++++++++++
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/KeeperException.java b/zookeeper-server/src/main/java/org/apache/zookeeper/KeeperException.java
index 42f7a3392..ed7c7af03 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/KeeperException.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/KeeperException.java
@@ -150,7 +150,7 @@ public abstract class KeeperException extends Exception {
                 return new RequestTimeoutException();
             case OK:
             default:
-                throw new IllegalArgumentException("Invalid exception code");
+                throw new IllegalArgumentException("Invalid exception code:" + code.code);
         }
     }
 
@@ -427,10 +427,14 @@ public abstract class KeeperException extends Exception {
         /**
          * Get the Code value for a particular integer error code
          * @param code int error code
-         * @return Code value corresponding to specified int code, or null
+         * @return Code value corresponding to specified int code, if null throws IllegalArgumentException
          */
         public static Code get(int code) {
-            return lookup.get(code);
+            Code codeVal = lookup.get(code);
+            if (codeVal == null) {
+                throw new IllegalArgumentException("The current client version cannot lookup this code:" + code);
+            }
+            return codeVal;
         }
     }
 
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/ZooKeeperTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/ZooKeeperTest.java
index 00c4125e7..d8bbf38d6 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/ZooKeeperTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/ZooKeeperTest.java
@@ -17,6 +17,7 @@
  */
 package org.apache.zookeeper;
 
+import static org.apache.zookeeper.KeeperException.Code.NOAUTH;
 import static org.junit.Assert.*;
 
 import java.io.ByteArrayOutputStream;
@@ -27,6 +28,7 @@ import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
 
 import org.apache.zookeeper.AsyncCallback.VoidCallback;
+import org.apache.zookeeper.KeeperException.Code;
 import org.apache.zookeeper.ZooDefs.Ids;
 import org.apache.zookeeper.cli.*;
 import org.apache.zookeeper.client.ConnectStringParser;
@@ -630,4 +632,16 @@ public class ZooKeeperTest extends ClientBase {
 
         runCommandExpect(cmd, expected);
     }
+
+
+    @Test(expected = IllegalArgumentException.class)
+    public void testKeeperExceptionCreateNPE() {
+        // One existing code
+        KeeperException k1 = KeeperException.create(Code.get(NOAUTH.intValue()));
+        assertTrue(k1 instanceof KeeperException.NoAuthException);
+
+        // One impossible code (should throw IllegalArgumentException)
+        KeeperException.create(Code.get(Integer.MAX_VALUE));
+    }
+
 }


[zookeeper] 01/05: ZOOKEEPER-4270: Flaky test: QuorumPeerMainTest#testLeaderOutOfView

Posted by sy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git

commit 6f212fb049a28e450edbf5720626564a6bc01efc
Author: Mohammad Arshad <ar...@apache.org>
AuthorDate: Tue Mar 30 16:59:19 2021 +0530

    ZOOKEEPER-4270: Flaky test: QuorumPeerMainTest#testLeaderOutOfView
    
    The test case is expecting node3 to be leader but node2 sometimes becomes leader. This happens because leader election completes between node1 and node2 which is valid.
    Changed the expectations when node2 is leader otherwise kept the same expectations
    
    Author: Mohammad Arshad <ar...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>
    
    Closes #1665 from arshadmohammad/ZOOKEEPER-4270-branch-3.6
    
    (cherry picked from commit 72facc3b54ddcaedc4693c01fb74474f26f262cb)
---
 .../server/quorum/QuorumPeerMainTest.java          | 34 ++++++++++++++++++----
 1 file changed, 28 insertions(+), 6 deletions(-)

diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
index aef5bd417..4a90f38f6 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/QuorumPeerMainTest.java
@@ -971,11 +971,27 @@ public class QuorumPeerMainTest extends QuorumPeerTestBase {
                 Assert.assertTrue("waiting for server to start",
                         ClientBase.waitForServerUp("127.0.0.1:" + svrs.clientPorts[i], CONNECTION_TIMEOUT));
             }
+            // Expecting that only 3 node will be leader is wrong, even 2 node can be leader, when cluster is formed with 1 node
+            boolean firstAndSecondNodeFormedCluster = false;
+            if (QuorumPeer.ServerState.LEADING == svrs.mt[1].getQuorumPeer().getPeerState()) {
+                Assert.assertEquals(QuorumPeer.ServerState.FOLLOWING,
+                    svrs.mt[0].getQuorumPeer().getPeerState());
+                Assert.assertEquals(QuorumPeer.ServerState.FOLLOWING,
+                    svrs.mt[highestServerIndex].getQuorumPeer().getPeerState());
+                firstAndSecondNodeFormedCluster = true;
+            } else {
+                // Verify leader out of view scenario
+                Assert.assertEquals(QuorumPeer.ServerState.LOOKING,
+                    svrs.mt[0].getQuorumPeer().getPeerState());
+                Assert.assertEquals(QuorumPeer.ServerState.LEADING,
+                    svrs.mt[highestServerIndex].getQuorumPeer().getPeerState());
+            }
 
-            Assert.assertTrue(svrs.mt[0].getQuorumPeer().getPeerState() == QuorumPeer.ServerState.LOOKING);
-            Assert.assertTrue(svrs.mt[highestServerIndex].getQuorumPeer().getPeerState() == QuorumPeer.ServerState.LEADING);
             for (int i = 1; i < highestServerIndex; i++) {
-                Assert.assertTrue(svrs.mt[i].getQuorumPeer().getPeerState() == QuorumPeer.ServerState.FOLLOWING);
+                Assert.assertTrue(
+                    svrs.mt[i].getQuorumPeer().getPeerState() == QuorumPeer.ServerState.FOLLOWING
+                        || svrs.mt[i].getQuorumPeer().getPeerState()
+                        == QuorumPeer.ServerState.LEADING);
             }
 
             // Look through the logs for output that indicates Node 1 is LEADING or FOLLOWING
@@ -989,12 +1005,18 @@ public class QuorumPeerMainTest extends QuorumPeerTestBase {
                 foundFollowing = following.matcher(line).matches();
             }
 
+            if (firstAndSecondNodeFormedCluster) {
+                Assert.assertTrue(
+                    "Corrupt peer should join quorum with servers having same server configuration",
+                    foundFollowing);
+            } else {
+                Assert.assertFalse("Corrupt peer should never become leader", foundLeading);
+                Assert.assertFalse("Corrupt peer should not attempt connection to out of view leader",
+                    foundFollowing);
+            }
         } finally {
             qlogger.removeAppender(appender);
         }
-
-        Assert.assertFalse("Corrupt peer should never become leader", foundLeading);
-        Assert.assertFalse("Corrupt peer should not attempt connection to out of view leader", foundFollowing);
     }
 
     @Test


[zookeeper] 03/05: ZOOKEEPER-4345: Avoid NoSunchMethodException caused by shaded zookeeper jar

Posted by sy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git

commit 65615a54e30777af757ac52980fb2a5ac5fb0219
Author: Bo Cui <cu...@163.com>
AuthorDate: Wed Aug 11 20:40:33 2021 +0530

    ZOOKEEPER-4345: Avoid NoSunchMethodException caused by shaded zookeeper jar
    
    Author: Bo <cu...@163.com>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>, Mohammad Arshad <ar...@apache.org>
    
    Closes #1736 from cuibo01/zookeeper-4345 and squashes the following commits:
    
    3965f2e8d [Bo] [ZOOKEEPER-4345]Avoid NoSunchMethodException caused by shaded
    970972971 [Bo] [ZOOKEEPER-4345]Avoid NoSunchMethodException caused by shaded
    
    (cherry picked from commit f658cdced8a417d7969c4a72b7732ae32db0b266)
---
 .../src/main/java/org/apache/zookeeper/ZooKeeper.java        |  7 ++++---
 .../test/java/org/apache/zookeeper/test/ClientSSLTest.java   | 12 ++++++++++++
 2 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java b/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
index 4ee58a9d1..b82d3c213 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/ZooKeeper.java
@@ -3054,10 +3054,11 @@ public class ZooKeeper implements AutoCloseable {
     }
 
     private ClientCnxnSocket getClientCnxnSocket() throws IOException {
-        String clientCnxnSocketName = getClientConfig().getProperty(
-                ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
-        if (clientCnxnSocketName == null) {
+        String clientCnxnSocketName = getClientConfig().getProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET);
+        if (clientCnxnSocketName == null || clientCnxnSocketName.equals(ClientCnxnSocketNIO.class.getSimpleName())) {
             clientCnxnSocketName = ClientCnxnSocketNIO.class.getName();
+        } else if (clientCnxnSocketName.equals(ClientCnxnSocketNetty.class.getSimpleName())) {
+            clientCnxnSocketName = ClientCnxnSocketNetty.class.getName();
         }
         try {
             Constructor<?> clientCxnConstructor = Class.forName(clientCnxnSocketName).getDeclaredConstructor(ZKClientConfig.class);
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java
index 0d50bc925..66fb56df2 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ClientSSLTest.java
@@ -86,6 +86,18 @@ public class ClientSSLTest extends QuorumPeerTestBase {
         testClientServerSSL(false);
     }
 
+    @Test
+    public void testClientServerUnifiedPortWithCnxnClassName() throws Exception {
+        System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "ClientCnxnSocketNIO");
+        testClientServerSSL(false);
+    }
+
+    @Test
+    public void testClientServerSSLWithCnxnClassName() throws Exception {
+        System.setProperty(ZKClientConfig.ZOOKEEPER_CLIENT_CNXN_SOCKET, "ClientCnxnSocketNetty");
+        testClientServerSSL(true);
+    }
+
     /**
      * This test checks that client <-> server SSL works in cluster setup of ZK servers, which includes:
      * 1. setting "secureClientPort" in "zoo.cfg" file.


[zookeeper] 04/05: ZOOKEEPER-4356: Code blocks do not render correctly in ZK docs site

Posted by sy...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

symat pushed a commit to branch branch-3.5
in repository https://gitbox.apache.org/repos/asf/zookeeper.git

commit 66dc95f9836bc62278644a8df096ee29a132f099
Author: Nihal Jain <ni...@gmail.com>
AuthorDate: Wed Sep 1 08:47:18 2021 +0000

    ZOOKEEPER-4356: Code blocks do not render correctly in ZK docs site
    
    * Configure to use FENCED_CODE_BLOCKS.
    * Note: TABLES is the default setting. See https://github.com/walokra/markdown-page-generator-plugin for details on default `pegdownExtensions` setting
    
    Author: Nihal Jain <ni...@gmail.com>
    
    Reviewers: maoling <ma...@apache.org>, Damien Diederen <dd...@apache.org>
    
    Closes #1741 from NihalJain/ZOOKEEPER-4356
    
    (cherry picked from commit 2797116b33a505c8b36b396216c26afd7f7ba28c)
---
 zookeeper-docs/pom.xml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/zookeeper-docs/pom.xml b/zookeeper-docs/pom.xml
index 9880faa40..52e5dddeb 100644
--- a/zookeeper-docs/pom.xml
+++ b/zookeeper-docs/pom.xml
@@ -49,6 +49,7 @@
           <headerHtmlFile>${project.basedir}/src/main/resources/markdown/html/header.html</headerHtmlFile>
           <footerHtmlFile>${project.basedir}/src/main/resources/markdown/html/footer.html</footerHtmlFile>
           <copyDirectories>images,skin</copyDirectories>
+          <pegdownExtensions>TABLES,FENCED_CODE_BLOCKS</pegdownExtensions>
         </configuration>
       </plugin>
       <plugin>