zookeeper-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] maoling commented on a change in pull request #940: ZOOKEEPER-3386: Add admin command to display voting view
Date Wed, 03 Jul 2019 06:06:54 GMT
maoling commented on a change in pull request #940: ZOOKEEPER-3386: Add admin command to display
voting view
URL: https://github.com/apache/zookeeper/pull/940#discussion_r299788094
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/Commands.java
 ##########
 @@ -560,6 +574,47 @@ public CommandResponse run(ZooKeeperServer zkServer, Map<String,
String> kwargs)
         }
     }
 
+    /**
+     * All defined system properties.
+     */
+    public static class SystemPropertiesCommand extends CommandBase {
+        public SystemPropertiesCommand() {
+            super(Arrays.asList("system_properties", "sysp"), false);
+        }
+
+        @Override
+        public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs)
{
+            CommandResponse response = initializeResponse();
+            Properties systemProperties = System.getProperties();
+            SortedMap<String, String> sortedSystemProperties = new TreeMap<>();
+            systemProperties.forEach((k, v) -> sortedSystemProperties.put(k.toString(),
v.toString()));
+            response.putAll(sortedSystemProperties);
+            return response;
+        }
+    }
+
+    /**
+     * Returns the current ensemble configuration information.
+     * It provides list of current voting members in the ensemble.
+     */
+    public static class VotingViewCommand extends CommandBase {
+        public VotingViewCommand() {
+            super(Arrays.asList("voting_view"));
+        }
+
+        @Override
+        public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs)
{
+            CommandResponse response = initializeResponse();
+            if (zkServer instanceof QuorumZooKeeperServer) {
+                QuorumPeer peer = ((QuorumZooKeeperServer) zkServer).self;
+                response.put("current_config", peer.getVotingView());
+            } else {
+                response.put("current_config", "");
+            }
 
 Review comment:
   `response.put("current_config", Collections.emptyList());` is better?

----------------------------------------------------------------
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


With regards,
Apache Git Services

Mime
View raw message