zookeeper-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [zookeeper] enixon commented on a change in pull request #898: ZOOKEEPER-3353: Admin commands for showing initial settings
Date Tue, 14 May 2019 20:19:36 GMT
enixon commented on a change in pull request #898: ZOOKEEPER-3353: Admin commands for showing
initial settings
URL: https://github.com/apache/zookeeper/pull/898#discussion_r283982376
 
 

 ##########
 File path: zookeeper-server/src/main/java/org/apache/zookeeper/server/admin/Commands.java
 ##########
 @@ -317,79 +322,81 @@ public CommandResponse run(ZooKeeperServer zkServer, Map<String,
String> kwargs)
      */
     public static class MonitorCommand extends CommandBase {
         public MonitorCommand() {
-            super(Arrays.asList("monitor", "mntr"));
+            super(Arrays.asList("monitor", "mntr"), false);
         }
 
         @Override
         public CommandResponse run(ZooKeeperServer zkServer, Map<String, String> kwargs)
{
-            ZKDatabase zkdb = zkServer.getZKDatabase();
-            ServerStats stats = zkServer.serverStats();
-
             CommandResponse response = initializeResponse();
 
             response.put("version", Version.getFullVersion());
 
-            response.put("avg_latency", stats.getAvgLatency());
-            response.put("max_latency", stats.getMaxLatency());
-            response.put("min_latency", stats.getMinLatency());
+            OSMXBean osMbean = new OSMXBean();
+            response.put("open_file_descriptor_count", osMbean.getOpenFileDescriptorCount());
+            response.put("max_file_descriptor_count", osMbean.getMaxFileDescriptorCount());
 
-            response.put("packets_received", stats.getPacketsReceived());
-            response.put("packets_sent", stats.getPacketsSent());
-            response.put("num_alive_connections", stats.getNumAliveClientConnections());
+            if (zkServer != null) {
+                ZKDatabase zkdb = zkServer.getZKDatabase();
+                ServerStats stats = zkServer.serverStats();
+                response.put("avg_latency", stats.getAvgLatency());
+                response.put("max_latency", stats.getMaxLatency());
+                response.put("min_latency", stats.getMinLatency());
 
-            response.put("outstanding_requests", stats.getOutstandingRequests());
-            response.put("uptime", stats.getUptime());
+                response.put("packets_received", stats.getPacketsReceived());
+                response.put("packets_sent", stats.getPacketsSent());
+                response.put("num_alive_connections", stats.getNumAliveClientConnections());
 
-            response.put("server_state", stats.getServerState());
-            response.put("znode_count", zkdb.getNodeCount());
+                response.put("outstanding_requests", stats.getOutstandingRequests());
+                response.put("uptime", stats.getUptime());
 
-            response.put("watch_count", zkdb.getDataTree().getWatchCount());
-            response.put("ephemerals_count", zkdb.getDataTree().getEphemeralsCount());
-            response.put("approximate_data_size", zkdb.getDataTree().cachedApproximateDataSize());
+                response.put("server_state", stats.getServerState());
+                response.put("znode_count", zkdb.getNodeCount());
 
-            response.put("global_sessions", zkdb.getSessionCount());
-            response.put("local_sessions",
-                    zkServer.getSessionTracker().getLocalSessionCount());
+                response.put("watch_count", zkdb.getDataTree().getWatchCount());
+                response.put("ephemerals_count", zkdb.getDataTree().getEphemeralsCount());
+                response.put("approximate_data_size", zkdb.getDataTree().cachedApproximateDataSize());
 
-            OSMXBean osMbean = new OSMXBean();
-            response.put("open_file_descriptor_count", osMbean.getOpenFileDescriptorCount());
-            response.put("max_file_descriptor_count", osMbean.getMaxFileDescriptorCount());
-            response.put("connection_drop_probability", zkServer.getConnectionDropChance());
+                response.put("global_sessions", zkdb.getSessionCount());
+                response.put("local_sessions",
+                        zkServer.getSessionTracker().getLocalSessionCount());
 
-            response.put("last_client_response_size", stats.getClientResponseStats().getLastBufferSize());
-            response.put("max_client_response_size", stats.getClientResponseStats().getMaxBufferSize());
-            response.put("min_client_response_size", stats.getClientResponseStats().getMinBufferSize());
+                response.put("connection_drop_probability", zkServer.getConnectionDropChance());
 
-            if (zkServer instanceof QuorumZooKeeperServer) {
-                QuorumPeer peer = ((QuorumZooKeeperServer) zkServer).self;
-                response.put("quorum_size", peer.getQuorumSize());
-            }
+                response.put("last_client_response_size", stats.getClientResponseStats().getLastBufferSize());
+                response.put("max_client_response_size", stats.getClientResponseStats().getMaxBufferSize());
+                response.put("min_client_response_size", stats.getClientResponseStats().getMinBufferSize());
 
-            if (zkServer instanceof LeaderZooKeeperServer) {
-                Leader leader = ((LeaderZooKeeperServer) zkServer).getLeader();
-
-                response.put("learners", leader.getLearners().size());
-                response.put("synced_followers", leader.getForwardingFollowers().size());
-                response.put("synced_non_voting_followers", leader.getNonVotingFollowers().size());
-                response.put("synced_observers", leader.getObservingLearners().size());
-                response.put("pending_syncs", leader.getNumPendingSyncs());
-                response.put("leader_uptime", leader.getUptime());
-
-                response.put("last_proposal_size", leader.getProposalStats().getLastBufferSize());
-                response.put("max_proposal_size", leader.getProposalStats().getMaxBufferSize());
-                response.put("min_proposal_size", leader.getProposalStats().getMinBufferSize());
-            }
+                if (zkServer instanceof QuorumZooKeeperServer) {
 
 Review comment:
   :) 
   
   Not an issue, I'm happy to fix up any conflicts if yours lands first.

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