zookeeper-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an...@apache.org
Subject [zookeeper] branch master updated: ZOOKEEPER-3350: Remove CommonNames
Date Fri, 03 May 2019 15:38:02 GMT
This is an automated email from the ASF dual-hosted git repository.

andor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/zookeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new bee2ef8  ZOOKEEPER-3350: Remove CommonNames
bee2ef8 is described below

commit bee2ef8da3c4a7a2a1925ac8fc5375a7dee702ae
Author: tison <wander4096@gmail.com>
AuthorDate: Fri May 3 17:37:55 2019 +0200

    ZOOKEEPER-3350: Remove CommonNames
    
    Remove `CommonNames`.
    
    - Delete unused `DATA_TREE_KEY`(superseded by `DataTreeBean#getName`)
    - Delete unused `STANDALONE_SERVER_KEY `(superseded by `ZooKeeperServerBean#getName`)
    - Move `DOMAIN` into `MBeanRegistry` where it is actually used.
    
    Author: tison <wander4096@gmail.com>
    
    Reviewers: fangmin@apache.org, andor@apache.org
    
    Closes #914 from TisonKun/ZOOKEEPER-3350
---
 .../java/org/apache/zookeeper/jmx/CommonNames.java | 29 ----------------------
 .../org/apache/zookeeper/jmx/MBeanRegistry.java    |  5 ++--
 .../zookeeper/test/HierarchicalQuorumTest.java     |  6 ++---
 .../java/org/apache/zookeeper/test/JMXEnv.java     | 13 +++++-----
 .../apache/zookeeper/test/ObserverMasterTest.java  |  3 +--
 .../apache/zookeeper/test/QuorumMajorityTest.java  |  6 ++---
 .../org/apache/zookeeper/test/ReconfigTest.java    | 14 +++++------
 7 files changed, 23 insertions(+), 53 deletions(-)

diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/jmx/CommonNames.java b/zookeeper-server/src/main/java/org/apache/zookeeper/jmx/CommonNames.java
deleted file mode 100644
index 986d69d..0000000
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/jmx/CommonNames.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.zookeeper.jmx;
-
-/**
- * A bunch of constants.
- * TODO: will get rid of it eventually.
- */
-public class CommonNames {
-    public static final String DOMAIN="org.apache.ZooKeeperService";
-    public static final String DATA_TREE_KEY="DataTree";
-    public static final String STANDALONE_SERVER_KEY="StandaloneServer";
-}
diff --git a/zookeeper-server/src/main/java/org/apache/zookeeper/jmx/MBeanRegistry.java b/zookeeper-server/src/main/java/org/apache/zookeeper/jmx/MBeanRegistry.java
index 817afc0..a865540 100644
--- a/zookeeper-server/src/main/java/org/apache/zookeeper/jmx/MBeanRegistry.java
+++ b/zookeeper-server/src/main/java/org/apache/zookeeper/jmx/MBeanRegistry.java
@@ -41,8 +41,9 @@ import org.slf4j.LoggerFactory;
  * will be stored in the zookeeper data tree instance as a virtual data tree.
  */
 public class MBeanRegistry {
+    public static final String DOMAIN = "org.apache.ZooKeeperService";
+
     private static final Logger LOG = LoggerFactory.getLogger(MBeanRegistry.class);
-    
     private static volatile MBeanRegistry instance = new MBeanRegistry();
     
     private final Object LOCK = new Object();
@@ -205,7 +206,7 @@ public class MBeanRegistry {
     {
         if(path==null)
             return null;
-        StringBuilder beanName = new StringBuilder(CommonNames.DOMAIN + ":");
+        StringBuilder beanName = new StringBuilder(DOMAIN + ":");
         int counter=0;
         counter=tokenize(beanName,path,counter);
         tokenize(beanName,bean.getName(),counter);
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/HierarchicalQuorumTest.java
b/zookeeper-server/src/test/java/org/apache/zookeeper/test/HierarchicalQuorumTest.java
index ecf38cd..a1dc6c5 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/HierarchicalQuorumTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/HierarchicalQuorumTest.java
@@ -26,11 +26,11 @@ import java.util.LinkedHashSet;
 import java.util.Properties;
 import java.util.Set;
 
+import org.apache.zookeeper.jmx.MBeanRegistry;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.apache.zookeeper.PortAssignment;
 import org.apache.zookeeper.TestableZooKeeper;
-import org.apache.zookeeper.jmx.CommonNames;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 import org.apache.zookeeper.server.quorum.flexible.QuorumHierarchical;
@@ -250,7 +250,7 @@ public class HierarchicalQuorumTest extends ClientBase {
         JMXEnv.ensureAll(ensureNames.toArray(new String[ensureNames.size()]));
         for (int i = 1; i <= numberOfPeers; i++) {
             // LocalPeerBean
-            String bean = CommonNames.DOMAIN + ":name0=ReplicatedServer_id" + i
+            String bean = MBeanRegistry.DOMAIN + ":name0=ReplicatedServer_id" + i
                     + ",name1=replica." + i;
             JMXEnv.ensureBeanAttribute(bean, "ConfigVersion");
             JMXEnv.ensureBeanAttribute(bean, "LearnerType");
@@ -264,7 +264,7 @@ public class HierarchicalQuorumTest extends ClientBase {
             for (int j = 1; j <= numberOfPeers; j++) {
                 if (j != i) {
                     // RemotePeerBean
-                    String bean = CommonNames.DOMAIN + ":name0=ReplicatedServer_id" + i
+                    String bean = MBeanRegistry.DOMAIN + ":name0=ReplicatedServer_id" + i
                             + ",name1=replica." + j;
                     JMXEnv.ensureBeanAttribute(bean, "Name");
                     JMXEnv.ensureBeanAttribute(bean, "LearnerType");
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/JMXEnv.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/JMXEnv.java
index d8a923a..af7eb3f 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/JMXEnv.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/JMXEnv.java
@@ -37,7 +37,6 @@ import javax.management.remote.JMXConnectorServerFactory;
 import javax.management.remote.JMXServiceURL;
 
 
-import org.apache.zookeeper.jmx.CommonNames;
 import org.apache.zookeeper.jmx.MBeanRegistry;
 import org.junit.Assert;
 import org.slf4j.Logger;
@@ -110,7 +109,7 @@ public class JMXEnv {
             }
             try {
                 beans = conn().queryNames(
-                        new ObjectName(CommonNames.DOMAIN + ":*"), null);
+                        new ObjectName(MBeanRegistry.DOMAIN + ":*"), null);
             } catch (MalformedObjectNameException e) {
                 throw new RuntimeException(e);
             }
@@ -168,7 +167,7 @@ public class JMXEnv {
             }
             try {
                 beans = conn().queryNames(
-                        new ObjectName(CommonNames.DOMAIN + ":*"), null);
+                        new ObjectName(MBeanRegistry.DOMAIN + ":*"), null);
             } catch (MalformedObjectNameException e) {
                 throw new RuntimeException(e);
             }
@@ -202,7 +201,7 @@ public class JMXEnv {
         Set<ObjectName> beans;
         try {
             beans = conn().queryNames(
-                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
+                    new ObjectName(MBeanRegistry.DOMAIN + ":*"), null);
         } catch (MalformedObjectNameException e) {
             throw new RuntimeException(e);
         }
@@ -239,7 +238,7 @@ public class JMXEnv {
             }
             try {
                 beans = conn().queryNames(
-                        new ObjectName(CommonNames.DOMAIN + ":*"), null);
+                        new ObjectName(MBeanRegistry.DOMAIN + ":*"), null);
             } catch (MalformedObjectNameException e) {
                 throw new RuntimeException(e);
             }
@@ -290,7 +289,7 @@ public class JMXEnv {
             }
             try {
                 beans = conn().queryNames(
-                        new ObjectName(CommonNames.DOMAIN + ":*"), null);
+                        new ObjectName(MBeanRegistry.DOMAIN + ":*"), null);
             } catch (MalformedObjectNameException e) {
                 throw new RuntimeException(e);
             }
@@ -341,7 +340,7 @@ public class JMXEnv {
         Set<ObjectName> beans;
         try {
             beans = conn().queryNames(
-                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
+                    new ObjectName(MBeanRegistry.DOMAIN + ":*"), null);
         } catch (MalformedObjectNameException e) {
             throw new RuntimeException(e);
         }
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ObserverMasterTest.java
b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ObserverMasterTest.java
index 4cec0ef..4e07d48 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ObserverMasterTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ObserverMasterTest.java
@@ -33,7 +33,6 @@ import java.util.concurrent.TimeUnit;
 
 import org.apache.zookeeper.AsyncCallback;
 import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.jmx.CommonNames;
 import org.apache.zookeeper.jmx.MBeanRegistry;
 import org.apache.zookeeper.jmx.ZKMBeanInfo;
 import org.apache.zookeeper.server.admin.Commands;
@@ -550,7 +549,7 @@ public class ObserverMasterTest extends QuorumPeerTestBase implements
Watcher{
 
         // test admin commands for disconnection
         ObjectName connBean = null;
-        for (ObjectName bean : JMXEnv.conn().queryNames(new ObjectName(CommonNames.DOMAIN
+ ":*"), null)) {
+        for (ObjectName bean : JMXEnv.conn().queryNames(new ObjectName(MBeanRegistry.DOMAIN
+ ":*"), null)) {
             if (bean.getCanonicalName().contains("Learner_Connections") &&
                     bean.getCanonicalName().contains("id:" + q3.getQuorumPeer().getId()))
{
                 connBean = bean;
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/QuorumMajorityTest.java
b/zookeeper-server/src/test/java/org/apache/zookeeper/test/QuorumMajorityTest.java
index 6966626..db40f31 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/QuorumMajorityTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/QuorumMajorityTest.java
@@ -19,7 +19,7 @@
 package org.apache.zookeeper.test;
 import java.util.ArrayList;
 
-import org.apache.zookeeper.jmx.CommonNames;
+import org.apache.zookeeper.jmx.MBeanRegistry;
 import org.apache.zookeeper.server.quorum.Leader.Proposal;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
@@ -48,11 +48,11 @@ public class QuorumMajorityTest extends QuorumBase {
             if (qp.getPeerState() == ServerState.FOLLOWING) {
                 bean = String.format(
                         "%s:name0=ReplicatedServer_id%d,name1=replica.%d,name2=Follower",
-                        CommonNames.DOMAIN, i, i);
+                        MBeanRegistry.DOMAIN, i, i);
             } else if (qp.getPeerState() == ServerState.LEADING) {
                 bean = String.format(
                         "%s:name0=ReplicatedServer_id%d,name1=replica.%d,name2=Leader",
-                        CommonNames.DOMAIN, i, i);
+                        MBeanRegistry.DOMAIN, i, i);
             }
             electionTimeTaken = (Long) JMXEnv.ensureBeanAttribute(bean,
                     "ElectionTimeTaken");
diff --git a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ReconfigTest.java b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ReconfigTest.java
index 2015fe5..cb05459 100644
--- a/zookeeper-server/src/test/java/org/apache/zookeeper/test/ReconfigTest.java
+++ b/zookeeper-server/src/test/java/org/apache/zookeeper/test/ReconfigTest.java
@@ -33,7 +33,7 @@ import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.ZKTestCase;
 import org.apache.zookeeper.AsyncCallback.DataCallback;
 import org.apache.zookeeper.data.Stat;
-import org.apache.zookeeper.jmx.CommonNames;
+import org.apache.zookeeper.jmx.MBeanRegistry;
 import org.apache.zookeeper.server.quorum.QuorumPeer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.QuorumServer;
 import org.apache.zookeeper.server.quorum.QuorumPeer.ServerState;
@@ -920,7 +920,7 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
         int replica2 = 2;
         QuorumPeer peer2 = qu.getPeer(replica2).peer;
         QuorumServer leavingQS2 = peer2.getView().get(new Long(leavingIndex));
-        String remotePeerBean2 = CommonNames.DOMAIN
+        String remotePeerBean2 = MBeanRegistry.DOMAIN
                 + ":name0=ReplicatedServer_id" + replica2 + ",name1=replica."
                 + leavingIndex;
         assertRemotePeerMXBeanAttributes(leavingQS2, remotePeerBean2);
@@ -929,7 +929,7 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
         int replica3 = 3;
         QuorumPeer peer3 = qu.getPeer(replica3).peer;
         QuorumServer leavingQS3 = peer3.getView().get(new Long(leavingIndex));
-        String remotePeerBean3 = CommonNames.DOMAIN
+        String remotePeerBean3 = MBeanRegistry.DOMAIN
                 + ":name0=ReplicatedServer_id" + replica3 + ",name1=replica."
                 + leavingIndex;
         assertRemotePeerMXBeanAttributes(leavingQS3, remotePeerBean3);
@@ -952,7 +952,7 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
 
         // localPeerBean.1 of ReplicatedServer_1
         QuorumPeer removedPeer = qu.getPeer(leavingIndex).peer;
-        String localPeerBean = CommonNames.DOMAIN
+        String localPeerBean = MBeanRegistry.DOMAIN
                 + ":name0=ReplicatedServer_id" + leavingIndex
                 + ",name1=replica." + leavingIndex;
         assertLocalPeerMXBeanAttributes(removedPeer, localPeerBean, false);
@@ -998,7 +998,7 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
         int replica2 = 2;
         QuorumPeer peer2 = qu.getPeer(replica2).peer;
         QuorumServer changingQS2 = peer2.getView().get(new Long(changingIndex));
-        String remotePeerBean2 = CommonNames.DOMAIN
+        String remotePeerBean2 = MBeanRegistry.DOMAIN
                 + ":name0=ReplicatedServer_id" + replica2 + ",name1=replica."
                 + changingIndex;
         assertRemotePeerMXBeanAttributes(changingQS2, remotePeerBean2);
@@ -1007,7 +1007,7 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
         int replica3 = 3;
         QuorumPeer peer3 = qu.getPeer(replica3).peer;
         QuorumServer changingQS3 = peer3.getView().get(new Long(changingIndex));
-        String remotePeerBean3 = CommonNames.DOMAIN
+        String remotePeerBean3 = MBeanRegistry.DOMAIN
                 + ":name0=ReplicatedServer_id" + replica3 + ",name1=replica."
                 + changingIndex;
         assertRemotePeerMXBeanAttributes(changingQS3, remotePeerBean3);
@@ -1034,7 +1034,7 @@ public class ReconfigTest extends ZKTestCase implements DataCallback{
         Assert.assertTrue(qu.getPeer(changingIndex).peer.getPeerState() == ServerState.OBSERVING);
 
         QuorumPeer qp = qu.getPeer(changingIndex).peer;
-        String localPeerBeanName = CommonNames.DOMAIN
+        String localPeerBeanName = MBeanRegistry.DOMAIN
                 + ":name0=ReplicatedServer_id" + changingIndex
                 + ",name1=replica." + changingIndex;
 


Mime
View raw message