cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yu...@apache.org
Subject [01/10] cassandra git commit: Fix nodetool info error when the node is not joined
Date Wed, 05 Aug 2015 22:07:12 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 1a2c1bcdc -> 20f12e974
  refs/heads/cassandra-2.2 5c59d5af7 -> 32bc8b0b1
  refs/heads/cassandra-3.0 90e001312 -> c3ed25b0a
  refs/heads/trunk 760dbd957 -> c1aff4fa6


Fix nodetool info error when the node is not joined

patch by yukim; reviewed by stefania for CASSANDRA-9031


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

Branch: refs/heads/cassandra-2.1
Commit: 20f12e97446eee55461a8d3512a94389a67e79ee
Parents: 1a2c1bc
Author: Yuki Morishita <yukim@apache.org>
Authored: Wed Aug 5 15:58:36 2015 -0500
Committer: Yuki Morishita <yukim@apache.org>
Committed: Wed Aug 5 16:01:53 2015 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../org/apache/cassandra/tools/NodeProbe.java   | 16 ++-------------
 .../org/apache/cassandra/tools/NodeTool.java    | 21 ++++++++++++++------
 3 files changed, 18 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/20f12e97/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index de7cfa8..9a475ea 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -12,6 +12,7 @@
  * Remove repair snapshot leftover on startup (CASSANDRA-7357)
  * Use random nodes for batch log when only 2 racks (CASSANDRA-8735)
  * Ensure atomicity inside thrift and stream session (CASSANDRA-7757)
+ * Fix nodetool info error when the node is not joined (CASSANDRA-9031)
 Merged from 2.0:
  * Don't cast expected bf size to an int (CASSANDRA-9959)
  * Log when messages are dropped due to cross_node_timeout (CASSANDRA-9793)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/20f12e97/src/java/org/apache/cassandra/tools/NodeProbe.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeProbe.java b/src/java/org/apache/cassandra/tools/NodeProbe.java
index d3bce4d..caa12c3 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -807,20 +807,8 @@ public class NodeProbe implements AutoCloseable
 
     public String getEndpoint()
     {
-        // Try to find the endpoint using the local token, doing so in a crazy manner
-        // to maintain backwards compatibility with the MBean interface
-        String stringToken = ssProxy.getTokens().get(0);
-        Map<String, String> tokenToEndpoint = ssProxy.getTokenToEndpointMap();
-
-        for (Map.Entry<String, String> pair : tokenToEndpoint.entrySet())
-        {
-            if (pair.getKey().equals(stringToken))
-            {
-                return pair.getValue();
-            }
-        }
-
-        throw new RuntimeException("Could not find myself in the endpoint list, something
is very wrong!  Is the Cassandra node fully started?");
+        Map<String, String> hostIdToEndpoint = ssProxy.getHostIdMap();
+        return hostIdToEndpoint.get(ssProxy.getLocalHostId());
     }
 
     public String getDataCenter()

http://git-wip-us.apache.org/repos/asf/cassandra/blob/20f12e97/src/java/org/apache/cassandra/tools/NodeTool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/NodeTool.java b/src/java/org/apache/cassandra/tools/NodeTool.java
index a2d4ead..6a7a930 100644
--- a/src/java/org/apache/cassandra/tools/NodeTool.java
+++ b/src/java/org/apache/cassandra/tools/NodeTool.java
@@ -463,13 +463,22 @@ public class NodeTool
                     probe.getCacheMetric("CounterCache", "HitRate"),
                     cacheService.getCounterCacheSavePeriodInSeconds());
 
-            // Tokens
-            List<String> tokens = probe.getTokens();
-            if (tokens.size() == 1 || this.tokens)
-                for (String token : tokens)
-                    System.out.printf("%-23s: %s%n", "Token", token);
+            // check if node is already joined, before getting tokens, since it throws exception
if not.
+            if (probe.isJoined())
+            {
+                // Tokens
+                List<String> tokens = probe.getTokens();
+                if (tokens.size() == 1 || this.tokens)
+                    for (String token : tokens)
+                        System.out.printf("%-23s: %s%n", "Token", token);
+                else
+                    System.out.printf("%-23s: (invoke with -T/--tokens to see all %d tokens)%n",
"Token",
+                                      tokens.size());
+            }
             else
-                System.out.printf("%-23s: (invoke with -T/--tokens to see all %d tokens)%n",
"Token", tokens.size());
+            {
+                System.out.printf("%-23s: (node is not joined to the cluster)%n", "Token");
+            }
         }
 
         /**


Mime
View raw message