cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brandonwilli...@apache.org
Subject [1/2] git commit: Expose SP histograms via nodetool. Patch by brandonwilliams, reviewed by vijay for CASSANDRA-3722
Date Fri, 30 Mar 2012 23:15:59 GMT
Updated Branches:
  refs/heads/trunk d9236e4a9 -> 98a70bdeb


Expose SP histograms via nodetool.
Patch by brandonwilliams, reviewed by vijay for CASSANDRA-3722


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

Branch: refs/heads/trunk
Commit: 08345fabbc7536051d57ec4cde615704e5426788
Parents: d9236e4
Author: Brandon Williams <brandonwilliams@apache.org>
Authored: Fri Mar 30 16:43:43 2012 -0500
Committer: Brandon Williams <brandonwilliams@apache.org>
Committed: Fri Mar 30 18:15:50 2012 -0500

----------------------------------------------------------------------
 .../org/apache/cassandra/service/StorageProxy.java |    3 +-
 src/java/org/apache/cassandra/tools/NodeCmd.java   |   29 +++++++++++++++
 src/java/org/apache/cassandra/tools/NodeProbe.java |   12 +++++--
 3 files changed, 40 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/08345fab/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 b860c3f..63c5481 100644
--- a/src/java/org/apache/cassandra/service/StorageProxy.java
+++ b/src/java/org/apache/cassandra/service/StorageProxy.java
@@ -62,6 +62,7 @@ import org.apache.cassandra.utils.*;
 
 public class StorageProxy implements StorageProxyMBean
 {
+    public static final String MBEAN_NAME = "org.apache.cassandra.db:type=StorageProxy";
     private static final Logger logger = LoggerFactory.getLogger(StorageProxy.class);
     private static final boolean OPTIMIZE_LOCAL_REQUESTS = true; // set to false to test
messagingservice path on single node
 
@@ -98,7 +99,7 @@ public class StorageProxy implements StorageProxyMBean
         MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
         try
         {
-            mbs.registerMBean(new StorageProxy(), new ObjectName("org.apache.cassandra.db:type=StorageProxy"));
+            mbs.registerMBean(new StorageProxy(), new ObjectName(MBEAN_NAME));
         }
         catch (Exception e)
         {

http://git-wip-us.apache.org/repos/asf/cassandra/blob/08345fab/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 fa2d210..22a8cad 100644
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@ -28,6 +28,7 @@ import java.util.Map.Entry;
 import java.util.concurrent.ExecutionException;
 
 import org.apache.cassandra.service.CacheServiceMBean;
+import org.apache.cassandra.service.StorageProxyMBean;
 import org.apache.commons.cli.*;
 
 import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutorMBean;
@@ -96,6 +97,7 @@ public class NodeCmd
         JOIN,
         MOVE,
         NETSTATS,
+        PROXYHISTOGRAMS,
         REBUILD,
         REFRESH,
         REMOVETOKEN,
@@ -134,6 +136,7 @@ public class NodeCmd
         addCmdHelp(header, "cfstats", "Print statistics on column families");
         addCmdHelp(header, "version", "Print cassandra version");
         addCmdHelp(header, "tpstats", "Print usage statistics of thread pools");
+        addCmdHelp(header, "proxyhistograms", "Print statistic histograms for network operations");
         addCmdHelp(header, "drain", "Drain the node (stop accepting writes and flush all
column families)");
         addCmdHelp(header, "decommission", "Decommission the node");
         addCmdHelp(header, "compactionstats", "Print statistics on compactions");
@@ -582,6 +585,27 @@ public class NodeCmd
                                          (i < ecch.length ? ecch[i] : "")));
         }
     }
+    
+    private void printProxyHistograms(PrintStream output)
+    {
+        StorageProxyMBean sp = this.probe.getSpProxy();
+        long[] offsets = new EstimatedHistogram().getBucketOffsets();
+        long[] rrlh = sp.getRecentReadLatencyHistogramMicros();
+        long[] rwlh = sp.getRecentWriteLatencyHistogramMicros();
+        long[] rrnglh = sp.getRecentRangeLatencyHistogramMicros();
+
+        output.println("proxy histograms");
+        output.println(String.format("%-10s%18s%18s%18s",
+                                    "Offset", "Read Latency", "Write Latency", "Range Latency"));
+        for (int i = 0; i < offsets.length; i++)
+        {
+            output.println(String.format("%-10d%18s%18s%18s",
+                                        offsets[i],
+                                        (i < rrlh.length ? rrlh[i] : ""),
+                                        (i < rwlh.length ? rwlh[i] : ""),
+                                        (i < rrnglh.length ? rrnglh[i] : "")));
+        }
+    }
 
     private void printEndPoints(String keySpace, String cf, String key, PrintStream output)
     {
@@ -780,6 +804,11 @@ public class NodeCmd
                     nodeCmd.printEndPoints(arguments[0], arguments[1], arguments[2], System.out);
                     break;
 
+                case PROXYHISTOGRAMS :
+                    if (arguments.length != 0) { badUse("proxyhistograms does not take arguments");
}
+                    nodeCmd.printProxyHistograms(System.out);
+                    break;
+
                 case REFRESH:
                     if (arguments.length != 2) { badUse("load_new_sstables requires ks and
cf args"); }
                     probe.loadNewSSTables(arguments[0], arguments[1]);

http://git-wip-us.apache.org/repos/asf/cassandra/blob/08345fab/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 4573d8b..30a77b3 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -46,9 +46,7 @@ import org.apache.cassandra.gms.FailureDetectorMBean;
 import org.apache.cassandra.locator.EndpointSnitchInfoMBean;
 import org.apache.cassandra.net.MessagingService;
 import org.apache.cassandra.net.MessagingServiceMBean;
-import org.apache.cassandra.service.CacheService;
-import org.apache.cassandra.service.CacheServiceMBean;
-import org.apache.cassandra.service.StorageServiceMBean;
+import org.apache.cassandra.service.*;
 import org.apache.cassandra.streaming.StreamingService;
 import org.apache.cassandra.streaming.StreamingServiceMBean;
 import org.apache.cassandra.thrift.InvalidRequestException;
@@ -77,6 +75,7 @@ public class NodeProbe
     public MessagingServiceMBean msProxy;
     private FailureDetectorMBean fdProxy;
     private CacheServiceMBean cacheService;
+    private StorageProxyMBean spProxy;
 
     /**
      * Creates a NodeProbe using the specified JMX host, port, username, and password.
@@ -155,6 +154,8 @@ public class NodeProbe
             fdProxy = JMX.newMBeanProxy(mbeanServerConn, name, FailureDetectorMBean.class);
             name = new ObjectName(CacheService.MBEAN_NAME);
             cacheService = JMX.newMBeanProxy(mbeanServerConn, name, CacheServiceMBean.class);
+            name = new ObjectName(StorageProxy.MBEAN_NAME);
+            spProxy = JMX.newMBeanProxy(mbeanServerConn, name, StorageProxyMBean.class);
         } catch (MalformedObjectNameException e)
         {
             throw new RuntimeException(
@@ -530,6 +531,11 @@ public class NodeProbe
         return cfsProxy;
     }
 
+    public StorageProxyMBean getSpProxy()
+    {
+        return spProxy;
+    }
+
     public String getEndpoint()
     {
         // Try to find the endpoint using the local token, doing so in a crazy manner


Mime
View raw message