cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject [1/6] git commit: Add snitch, schema version, cluster, partitioner to JMX patch by Lyuben Todorov; reviewed by Jeremiah Jordan for CASSANDRA-5881
Date Thu, 29 Aug 2013 04:14:56 GMT
Updated Branches:
  refs/heads/cassandra-1.2 a35f1c288 -> 254d315d5
  refs/heads/cassandra-2.0 299c95075 -> 8d4b51d5a
  refs/heads/trunk 5d395b66b -> 48ea937b8


Add snitch, schema version, cluster, partitioner to JMX
patch by Lyuben Todorov; reviewed by Jeremiah Jordan for CASSANDRA-5881


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

Branch: refs/heads/cassandra-1.2
Commit: 254d315d52e0d442212b4a3840ae225dcb4086e2
Parents: a35f1c2
Author: Jonathan Ellis <jbellis@apache.org>
Authored: Wed Aug 28 23:12:31 2013 -0500
Committer: Jonathan Ellis <jbellis@apache.org>
Committed: Wed Aug 28 23:12:31 2013 -0500

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 .../cassandra/locator/EndpointSnitchInfo.java   |  5 ++++
 .../locator/EndpointSnitchInfoMBean.java        |  8 +++++++
 .../apache/cassandra/service/StorageProxy.java  |  5 ++++
 .../cassandra/service/StorageProxyMBean.java    |  6 +++++
 .../cassandra/service/StorageService.java       | 12 ++++++++++
 .../cassandra/service/StorageServiceMBean.java  |  5 ++++
 .../org/apache/cassandra/tools/NodeCmd.java     | 25 ++++++++++++++++++++
 .../org/apache/cassandra/tools/NodeProbe.java   | 10 ++++++++
 .../apache/cassandra/tools/NodeToolHelp.yaml    |  3 +++
 10 files changed, 80 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6aa5762..9ef0651 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 1.2.10
+ * Add snitch, schema version, cluster, partitioner to JMX (CASSANDRA-5881)
  * Fix CqlRecordWriter with composite keys (CASSANDRA-5949)
  * Allow disabling SlabAllocator (CASSANDRA-5935)
  * Make user-defined compaction JMX blocking (CASSANDRA-4952)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/src/java/org/apache/cassandra/locator/EndpointSnitchInfo.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/EndpointSnitchInfo.java b/src/java/org/apache/cassandra/locator/EndpointSnitchInfo.java
index 6447b19..c2f88bb 100644
--- a/src/java/org/apache/cassandra/locator/EndpointSnitchInfo.java
+++ b/src/java/org/apache/cassandra/locator/EndpointSnitchInfo.java
@@ -50,4 +50,9 @@ public class EndpointSnitchInfo implements EndpointSnitchInfoMBean
     {
         return DatabaseDescriptor.getEndpointSnitch().getRack(InetAddress.getByName(host));
     }
+
+    public String getSnitchName()
+    {
+        return DatabaseDescriptor.getEndpointSnitch().getClass().getName();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/src/java/org/apache/cassandra/locator/EndpointSnitchInfoMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/EndpointSnitchInfoMBean.java b/src/java/org/apache/cassandra/locator/EndpointSnitchInfoMBean.java
index 0918039..84d2499 100644
--- a/src/java/org/apache/cassandra/locator/EndpointSnitchInfoMBean.java
+++ b/src/java/org/apache/cassandra/locator/EndpointSnitchInfoMBean.java
@@ -37,4 +37,12 @@ public interface EndpointSnitchInfoMBean
      * @throws UnknownHostException
      */
     public String getDatacenter(String host) throws UnknownHostException;
+
+
+    /**
+     * Provides the snitch name of the cluster
+     * @return Snitch name
+     */
+    public String getSnitchName();
+
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/src/java/org/apache/cassandra/service/StorageProxy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxy.java b/src/java/org/apache/cassandra/service/StorageProxy.java
index 126bb38..ec27891 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -1275,6 +1275,11 @@ public class StorageProxy implements StorageProxyMBean
             return rows.size() > command.maxResults ? rows.subList(0, command.maxResults)
: rows;
     }
 
+    public Map<String, List<String>> getSchemaVersions()
+    {
+        return this.describeSchemaVersions();
+    }
+
     /**
      * initiate a request/response session with each live node to check whether or not everybody
is using the same
      * migration id. This is useful for determining if a schema change has propagated through
the cluster. Disagreement

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/src/java/org/apache/cassandra/service/StorageProxyMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageProxyMBean.java b/src/java/org/apache/cassandra/service/StorageProxyMBean.java
index e8f5b4a..f00b94f 100644
--- a/src/java/org/apache/cassandra/service/StorageProxyMBean.java
+++ b/src/java/org/apache/cassandra/service/StorageProxyMBean.java
@@ -17,6 +17,9 @@
  */
 package org.apache.cassandra.service;
 
+import java.util.List;
+import java.util.Map;
+
 import org.apache.cassandra.metrics.ReadRepairMetrics;
 
 public interface StorageProxyMBean
@@ -92,4 +95,7 @@ public interface StorageProxyMBean
     public long getReadRepairAttempted();
     public long getReadRepairRepairedBlocking();
     public long getReadRepairRepairedBackground();
+
+    /** Returns each live node's schema version */
+    public Map<String, List<String>> getSchemaVersions();
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageService.java b/src/java/org/apache/cassandra/service/StorageService.java
index 9339132..2c3a1c8 100644
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@ -3922,4 +3922,16 @@ public class StorageService extends NotificationBroadcasterSupport
implements IE
     {
         rangeXferExecutor.tearDown();
     }
+
+    /** Returns the name of the cluster */
+    public String getClusterName()
+    {
+        return DatabaseDescriptor.getClusterName();
+    }
+
+    /** Returns the cluster partitioner */
+    public String getPartitionerName()
+    {
+        return DatabaseDescriptor.getPartitionerName();
+    }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/src/java/org/apache/cassandra/service/StorageServiceMBean.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/StorageServiceMBean.java b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
index 15f2113..2c63b46 100644
--- a/src/java/org/apache/cassandra/service/StorageServiceMBean.java
+++ b/src/java/org/apache/cassandra/service/StorageServiceMBean.java
@@ -470,4 +470,9 @@ public interface StorageServiceMBean extends NotificationEmitter
     public void enableScheduledRangeXfers();
     /** Disable processing of queued range transfers. */
     public void disableScheduledRangeXfers();
+
+    /** Returns the name of the cluster */
+    public String getClusterName();
+    /** Returns the cluster partitioner */
+    public String getPartitionerName();
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/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 4e9f461..2b7bfbf 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -111,6 +111,7 @@ public class NodeCmd
         COMPACT,
         COMPACTIONSTATS,
         DECOMMISSION,
+        DESCRIBECLUSTER,
         DISABLEBINARY,
         DISABLEGOSSIP,
         DISABLEHANDOFF,
@@ -771,6 +772,29 @@ public class NodeCmd
         outs.println("Current stream throughput: " + probe.getStreamThroughput() + " MB/s");
     }
 
+    /**
+     * Print the name, snitch, partitioner and schema version(s) of a cluster
+     *
+     * @param outs Output stream
+     * @param host Server address
+     */
+    public void printClusterDescription(PrintStream outs, String host)
+    {
+        // display cluster name, snitch and partitioner
+        outs.println("Cluster Information:");
+        outs.println("\tName: " + probe.getClusterName());
+        outs.println("\tSnitch: " + probe.getEndpointSnitchInfoProxy().getSnitchName());
+        outs.println("\tPartitioner: " + probe.getPartitioner());
+
+        // display schema version for each node
+        outs.println("\tSchema versions:");
+        Map<String, List<String>> schemaVersions = probe.getSpProxy().getSchemaVersions();
+        for (String version : schemaVersions.keySet())
+        {
+            outs.println(String.format("\t\t%s: %s%n", version, schemaVersions.get(version)));
+        }
+    }
+
     public void printColumnFamilyStats(PrintStream outs)
     {
         Map <String, List <ColumnFamilyStoreMBean>> cfstoreMap = new HashMap
<String, List <ColumnFamilyStoreMBean>>();
@@ -1109,6 +1133,7 @@ public class NodeCmd
                 case TPSTATS         : nodeCmd.printThreadPoolStats(System.out); break;
                 case VERSION         : nodeCmd.printReleaseVersion(System.out); break;
                 case COMPACTIONSTATS : nodeCmd.printCompactionStats(System.out); break;
+                case DESCRIBECLUSTER : nodeCmd.printClusterDescription(System.out, host);
break;
                 case DISABLEBINARY   : probe.stopNativeTransport(); break;
                 case ENABLEBINARY    : probe.startNativeTransport(); break;
                 case STATUSBINARY    : nodeCmd.printIsNativeTransportRunning(System.out);
break;

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/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 a9b0bb5..e7cf592 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -671,6 +671,16 @@ public class NodeProbe
         return ssProxy.getKeyspaces();
     }
 
+    public String getClusterName()
+    {
+        return ssProxy.getClusterName();
+    }
+
+    public String getPartitioner()
+    {
+        return ssProxy.getPartitionerName();
+    }
+
     public void disableHintedHandoff()
     {
         spProxy.setHintedHandoffEnabled(false);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/254d315d/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
----------------------------------------------------------------------
diff --git a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
index 6e366f4..b540b2c 100644
--- a/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
+++ b/src/resources/org/apache/cassandra/tools/NodeToolHelp.yaml
@@ -118,6 +118,9 @@ commands:
   - name: setstreamthroughput  <value_in_mb>
     help: |
       Set the MB/s throughput cap for streaming in the system, or 0 to disable throttling.
+  - name: describecluster
+    help: |
+      Print the name, snitch, partitioner and schema version of a cluster.
   - name: describering [keyspace]
     help: |
       Shows the token ranges info of a given keyspace.


Mime
View raw message