cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject [1/2] git commit: nodetool no longer shows node joining patch by driftx; reviewed by Vijay for CASSANDRA-6811
Date Sun, 09 Mar 2014 21:03:00 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.0 8f0952eb5 -> 8d2c3fe67


nodetool no longer shows node joining
patch by driftx; reviewed by Vijay for CASSANDRA-6811


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/57f6f929
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/57f6f929
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/57f6f929

Branch: refs/heads/cassandra-2.0
Commit: 57f6f9291d5d8351dce2d493e87fdc5e62c4ebcd
Parents: 1e1129c
Author: Vijay <vijay2win@gmail.com>
Authored: Sun Mar 9 13:55:32 2014 -0700
Committer: Vijay <vijay2win@gmail.com>
Committed: Sun Mar 9 13:55:32 2014 -0700

----------------------------------------------------------------------
 .../org/apache/cassandra/tools/NodeCmd.java     | 71 +++++++++++---------
 1 file changed, 39 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/57f6f929/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeCmd.java b/src/java/org/apache/cassandra/tools/NodeCmd.java
index e14ba1a..75af915 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -328,42 +328,49 @@ public class NodeCmd
         else
             outs.println();
 
-        for (Map.Entry<InetAddress, Float> entry : filteredOwnerships.entrySet())
+        for (Map.Entry<String, String> entry : endpointsToTokens.entries())
         {
-            String endpoint = entry.getKey().getHostAddress();
-            for (String token : endpointsToTokens.get(endpoint))
+            String endpoint = entry.getKey();
+            String rack;
+            try
             {
-                String rack;
-                try
-                {
-                    rack = probe.getEndpointSnitchInfoProxy().getRack(endpoint);
-                }
-                catch (UnknownHostException e)
-                {
-                    rack = "Unknown";
-                }
+                rack = probe.getEndpointSnitchInfoProxy().getRack(endpoint);
+            }
+            catch (UnknownHostException e)
+            {
+                rack = "Unknown";
+            }
 
-                String status = liveNodes.contains(endpoint)
-                        ? "Up"
-                        : deadNodes.contains(endpoint)
-                                ? "Down"
-                                : "?";
-
-                String state = "Normal";
-
-                if (joiningNodes.contains(endpoint))
-                    state = "Joining";
-                else if (leavingNodes.contains(endpoint))
-                    state = "Leaving";
-                else if (movingNodes.contains(endpoint))
-                    state = "Moving";
-
-                String load = loadMap.containsKey(endpoint)
-                        ? loadMap.get(endpoint)
-                        : "?";
-                String owns = new DecimalFormat("##0.00%").format(entry.getValue());
-                outs.printf(format, endpoint, rack, status, state, load, owns, token);
+            String status = liveNodes.contains(endpoint)
+                    ? "Up"
+                    : deadNodes.contains(endpoint)
+                            ? "Down"
+                            : "?";
+
+            String state = "Normal";
+
+            if (joiningNodes.contains(endpoint))
+                state = "Joining";
+            else if (leavingNodes.contains(endpoint))
+                state = "Leaving";
+            else if (movingNodes.contains(endpoint))
+                state = "Moving";
+
+            String load = loadMap.containsKey(endpoint)
+                    ? loadMap.get(endpoint)
+                    : "?";
+            String owns;
+            try
+            {
+                InetAddress ep = InetAddress.getByName(endpoint);
+                Float percent = filteredOwnerships.get(ep);
+                owns = (percent != null) ? new DecimalFormat("##0.00%").format(percent) :
"?";
+            }
+            catch (UnknownHostException e)
+            {
+                throw new RuntimeException(e);
             }
+            outs.printf(format, endpoint, rack, status, state, load, owns, entry.getValue());
         }
         outs.println();
     }


Mime
View raw message