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 08:36:30 UTC

[zookeeper] branch branch-3.5 updated (161e50574 -> aa20b0e80)

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 161e50574 ZOOKEEPER-3642: Fix potential data inconsistency due to DIFF sync after partial SNAP sync.
     new fd9219c4f ZOOKEEPER-3876: zkServer.sh status command fails when IPV6 is configured
     new 90322afd4 ZOOKEEPER-3877: JMX Bean RemotePeerBean should enclose IPV6 host in square bracket same as LocalPeerBean
     new aa20b0e80 ZOOKEEPER-3887: In SSL-only server zkServer.sh status command should use secureClientPortAddress instead of clientPortAddress

The 3 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:
 bin/zkServer.sh                                           | 12 +++++++++++-
 .../apache/zookeeper/server/quorum/RemotePeerBean.java    | 12 ++++++------
 .../zookeeper/server/quorum/RemotePeerBeanTest.java       | 15 +++++++++++++++
 3 files changed, 32 insertions(+), 7 deletions(-)


[zookeeper] 02/03: ZOOKEEPER-3877: JMX Bean RemotePeerBean should enclose IPV6 host in square bracket same as LocalPeerBean

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 90322afd4301af461175ef2f0fb1539593fb2f77
Author: Mohammad Arshad <ar...@apache.org>
AuthorDate: Tue Mar 2 11:37:47 2021 +0530

    ZOOKEEPER-3877: JMX Bean RemotePeerBean should enclose IPV6 host in square bracket same as LocalPeerBean
    
    …quare bracket same as LocalPeerBean
    
    Author: Mohammad Arshad <ar...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>
    
    Closes #1493 from arshadmohammad/ZOOKEEPER-3877-master
    
    (cherry picked from commit 425ee189dcf952fd7a2a38df375ec245dcdfbfc6)
    Signed-off-by: Mohammad Arshad <ar...@apache.org>
    (cherry picked from commit a51b222de42fd0d0591dd8eda39a9045324a11fc)
---
 .../apache/zookeeper/server/quorum/RemotePeerBean.java    | 12 ++++++------
 .../zookeeper/server/quorum/RemotePeerBeanTest.java       | 15 +++++++++++++++
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/RemotePeerBean.java b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/RemotePeerBean.java
index 285f11a85..573859eb3 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/RemotePeerBean.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/server/quorum/RemotePeerBean.java
@@ -18,11 +18,12 @@
 
 package org.apache.zookeeper.server.quorum;
 
+import static org.apache.zookeeper.common.NetUtils.formatInetAddr;
 import org.apache.zookeeper.jmx.ZKMBeanInfo;
 
 /**
  * A remote peer bean only provides limited information about the remote peer,
- * and the peer cannot be managed remotely. 
+ * and the peer cannot be managed remotely.
  */
 public class RemotePeerBean implements RemotePeerMXBean,ZKMBeanInfo {
     private QuorumPeer.QuorumServer peer;
@@ -45,19 +46,18 @@ public class RemotePeerBean implements RemotePeerMXBean,ZKMBeanInfo {
     }
 
     public String getQuorumAddress() {
-        return peer.addr.getHostString()+":"+peer.addr.getPort();
+        return formatInetAddr(peer.addr);
     }
 
     public String getElectionAddress() {
-        return peer.electionAddr.getHostString() + ":" + peer.electionAddr.getPort();
+        return formatInetAddr(peer.electionAddr);
     }
 
     public String getClientAddress() {
         if (null == peer.clientAddr) {
             return "";
         }
-        return peer.clientAddr.getHostString() + ":"
-                + peer.clientAddr.getPort();
+        return formatInetAddr(peer.clientAddr);
     }
 
     public String getLearnerType() {
@@ -68,5 +68,5 @@ public class RemotePeerBean implements RemotePeerMXBean,ZKMBeanInfo {
     public boolean isLeader() {
         return localPeer.isLeader(peer.getId());
     }
-    
+
 }
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java
index 08dff63fb..f4457a762 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/server/quorum/RemotePeerBeanTest.java
@@ -61,4 +61,19 @@ public class RemotePeerBeanTest {
         assertFalse(remotePeerBean.isLeader());
     }
 
+    @Test
+    public void testHostPortReturnedWhenIPIsIPV6() {
+        QuorumPeer.QuorumServer quorumServerMock = mock(QuorumPeer.QuorumServer.class);
+        InetSocketAddress address = new InetSocketAddress("127::1", 2181);
+        quorumServerMock.clientAddr = address;
+        quorumServerMock.electionAddr = address;
+        quorumServerMock.addr = address;
+        QuorumPeer peerMock = mock(QuorumPeer.class);
+        RemotePeerBean remotePeerBean = new RemotePeerBean(peerMock, quorumServerMock);
+        String expectedHostPort = "[127:0:0:0:0:0:0:1]:2181";
+        assertEquals(expectedHostPort, remotePeerBean.getClientAddress());
+        assertEquals(expectedHostPort, remotePeerBean.getElectionAddress());
+        assertEquals(expectedHostPort, remotePeerBean.getQuorumAddress());
+    }
+
 }


[zookeeper] 03/03: ZOOKEEPER-3887: In SSL-only server zkServer.sh status command should use secureClientPortAddress instead of clientPortAddress

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 aa20b0e80ab9afc9043f716a06b1c862a6125092
Author: Mohammad Arshad <ar...@apache.org>
AuthorDate: Sat Mar 27 22:41:02 2021 +0530

    ZOOKEEPER-3887: In SSL-only server zkServer.sh status command should use secureClientPortAddress instead of clientPortAddress
    
    Author: Mohammad Arshad <ar...@apache.org>
    
    Reviewers: Mate Szalay-Beko <sy...@apache.org>
    
    Closes #1654 from arshadmohammad/ZOOKEEPER-3887-master
    
    (cherry picked from commit 51be692523b65afc21cfb0edaa4a5e60ab996aa2)
    Signed-off-by: Mohammad Arshad <ar...@apache.org>
    (cherry picked from commit 4946c582fa002803075bf32d0c2fec638c8f9a45)
---
 bin/zkServer.sh | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/bin/zkServer.sh b/bin/zkServer.sh
index 816a12de5..5e16ac698 100755
--- a/bin/zkServer.sh
+++ b/bin/zkServer.sh
@@ -266,6 +266,11 @@ status)
       if [ "$secureClientPort" ] ; then
         isSSL="true"
         clientPort=$secureClientPort
+        clientPortAddress=`$GREP "^[[:space:]]*secureClientPortAddress[^[:alpha:]]" "$ZOOCFG" | sed -e 's/.*=//'`
+        if ! [ $clientPortAddress ]
+        then
+            clientPortAddress="localhost"
+        fi
       else
         echo "Unable to find either secure or unsecure client port in any configs. Terminating."
         exit 1


[zookeeper] 01/03: ZOOKEEPER-3876: zkServer.sh status command fails when IPV6 is configured

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 fd9219c4f5d4a0e9423cc2fd3d03c86a2edfa6d6
Author: Mohammad Arshad <ar...@apache.org>
AuthorDate: Wed Jul 29 12:31:40 2020 +0200

    ZOOKEEPER-3876: zkServer.sh status command fails when IPV6 is configured
    
    Modified host and IP parsing logic for IPV6
    
    Author: Mohammad Arshad <ar...@apache.org>
    
    Reviewers: Enrico Olivelli <eo...@apache.org>
    
    Closes #1395 from arshadmohammad/ZOOKEEPER-3876
    
    (cherry picked from commit c9f15213663fc9b86809adcbc27a4dbe1232c31a)
    Signed-off-by: Enrico Olivelli <eo...@apache.org>
    (cherry picked from commit f6b7b1b35be13a2bb35f44f58773ba87f5b40b50)
---
 bin/zkServer.sh | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/bin/zkServer.sh b/bin/zkServer.sh
index 1a5056c09..816a12de5 100755
--- a/bin/zkServer.sh
+++ b/bin/zkServer.sh
@@ -249,7 +249,12 @@ status)
           echo "Client port not found in the server configs"
         else
           if [[ "$clientPortAndAddress" =~ ^.*:[0-9]+ ]] ; then
-            clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's/:.*//'`
+            if [[ "$clientPortAndAddress" =~ \[.*\]:[0-9]+ ]] ; then
+              # Extracts address from address:port for example extracts 127::1 from "[127::1]:2181"
+              clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's|\[||' | sed -e 's|\]:.*||'`
+            else
+              clientPortAddress=`echo "$clientPortAndAddress" | sed -e 's/:.*//'`
+            fi
           fi
           clientPort=`echo "$clientPortAndAddress" | sed -e 's/.*://'`
         fi