cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject [08/13] cassandra git commit: 10018-3.0 patch
Date Fri, 04 Dec 2015 18:11:09 GMT
10018-3.0 patch


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

Branch: refs/heads/cassandra-3.1
Commit: 05300b26e7918a2c329f902ed0022680f981a3ab
Parents: bb1c773
Author: Joel Knighton <joel.knighton@datastax.com>
Authored: Fri Dec 4 13:10:20 2015 -0500
Committer: Joshua McKenzie <jmckenzie@apache.org>
Committed: Fri Dec 4 13:10:20 2015 -0500

----------------------------------------------------------------------
 .../cassandra/metrics/ThreadPoolMetrics.java    | 31 +++++++++++++++++++-
 .../org/apache/cassandra/tools/NodeProbe.java   | 15 ++++++++--
 .../cassandra/tools/nodetool/TpStats.java       | 23 ++++++++-------
 .../apache/cassandra/utils/StatusLogger.java    | 15 +++++-----
 4 files changed, 63 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/05300b26/src/java/org/apache/cassandra/metrics/ThreadPoolMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/ThreadPoolMetrics.java b/src/java/org/apache/cassandra/metrics/ThreadPoolMetrics.java
index fba92c4..268e878 100644
--- a/src/java/org/apache/cassandra/metrics/ThreadPoolMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/ThreadPoolMetrics.java
@@ -17,6 +17,8 @@
  */
 package org.apache.cassandra.metrics;
 
+import java.io.IOException;
+import java.util.Set;
 import java.util.concurrent.ThreadPoolExecutor;
 
 import com.codahale.metrics.Counter;
@@ -25,8 +27,12 @@ import com.codahale.metrics.JmxReporter;
 
 import javax.management.JMX;
 import javax.management.MBeanServerConnection;
+import javax.management.MalformedObjectNameException;
 import javax.management.ObjectName;
 
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
 import static org.apache.cassandra.metrics.CassandraMetricsRegistry.Metrics;
 
 
@@ -106,7 +112,6 @@ public class ThreadPoolMetrics
         Metrics.remove(factory.createMetricName("MaxPoolSize"));
     }
 
-
     public static Object getJmxMetric(MBeanServerConnection mbeanServerConn, String jmxPath,
String poolName, String metricName)
     {
         String name = String.format("org.apache.cassandra.metrics:type=ThreadPools,path=%s,scope=%s,name=%s",
jmxPath, poolName, metricName);
@@ -138,4 +143,28 @@ public class ThreadPoolMetrics
         }
     }
 
+    public static Multimap<String, String> getJmxThreadPools(MBeanServerConnection
mbeanServerConn)
+    {
+        try
+        {
+            Multimap<String, String> threadPools = HashMultimap.create();
+            Set<ObjectName> threadPoolObjectNames = mbeanServerConn.queryNames(new
ObjectName("org.apache.cassandra.metrics:type=ThreadPools,*"),
+                                                                               null);
+            for (ObjectName oName : threadPoolObjectNames)
+            {
+                threadPools.put(oName.getKeyProperty("path"), oName.getKeyProperty("scope"));
+            }
+
+            return threadPools;
+        }
+        catch (MalformedObjectNameException e)
+        {
+            throw new RuntimeException("Bad query to JMX server: ", e);
+        }
+        catch (IOException e)
+        {
+            throw new RuntimeException("Error getting threadpool names from JMX", e);
+        }
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/05300b26/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 2c5f91d..099876b 100644
--- a/src/java/org/apache/cassandra/tools/NodeProbe.java
+++ b/src/java/org/apache/cassandra/tools/NodeProbe.java
@@ -53,7 +53,6 @@ import javax.management.remote.JMXConnectorFactory;
 import javax.management.remote.JMXServiceURL;
 import javax.rmi.ssl.SslRMIClientSocketFactory;
 
-import org.apache.cassandra.concurrent.Stage;
 import org.apache.cassandra.batchlog.BatchlogManager;
 import org.apache.cassandra.batchlog.BatchlogManagerMBean;
 import org.apache.cassandra.db.ColumnFamilyStoreMBean;
@@ -87,6 +86,7 @@ import org.apache.cassandra.streaming.management.StreamStateCompositeData;
 import com.google.common.base.Function;
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
 import com.google.common.collect.Sets;
 import com.google.common.util.concurrent.Uninterruptibles;
 
@@ -1084,9 +1084,18 @@ public class NodeProbe implements AutoCloseable
         }
     }
 
-    public Object getThreadPoolMetric(Stage stage, String metricName)
+    public Object getThreadPoolMetric(String pathName, String poolName, String metricName)
     {
-        return ThreadPoolMetrics.getJmxMetric(mbeanServerConn, stage.getJmxType(), stage.getJmxName(),
metricName);
+        return ThreadPoolMetrics.getJmxMetric(mbeanServerConn, pathName, poolName, metricName);
+    }
+
+    /**
+     * Retrieve threadpool paths and names for threadpools with metrics.
+     * @return Multimap from path (internal, request, etc.) to name
+     */
+    public Multimap<String, String> getThreadPools()
+    {
+        return ThreadPoolMetrics.getJmxThreadPools(mbeanServerConn);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cassandra/blob/05300b26/src/java/org/apache/cassandra/tools/nodetool/TpStats.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/tools/nodetool/TpStats.java b/src/java/org/apache/cassandra/tools/nodetool/TpStats.java
index 5e47f50..5d3eab7 100644
--- a/src/java/org/apache/cassandra/tools/nodetool/TpStats.java
+++ b/src/java/org/apache/cassandra/tools/nodetool/TpStats.java
@@ -21,7 +21,8 @@ import io.airlift.command.Command;
 
 import java.util.Map;
 
-import org.apache.cassandra.concurrent.Stage;
+import com.google.common.collect.Multimap;
+
 import org.apache.cassandra.tools.NodeProbe;
 import org.apache.cassandra.tools.NodeTool.NodeToolCmd;
 
@@ -31,17 +32,19 @@ public class TpStats extends NodeToolCmd
     @Override
     public void execute(NodeProbe probe)
     {
-        System.out.printf("%-30s%10s%10s%15s%10s%18s%n", "Pool Name", "Active", "Pending",
"Completed", "Blocked", "All time blocked");
+        System.out.printf("%-25s%10s%10s%15s%10s%18s%n", "Pool Name", "Active", "Pending",
"Completed", "Blocked", "All time blocked");
+
 
-        for (Stage stage : Stage.jmxEnabledStages())
+        Multimap<String, String> threadPools = probe.getThreadPools();
+        for (Map.Entry<String, String> tpool : threadPools.entries())
         {
-            System.out.printf("%-30s%10s%10s%15s%10s%18s%n",
-                              stage.getJmxName(),
-                              probe.getThreadPoolMetric(stage, "ActiveTasks"),
-                              probe.getThreadPoolMetric(stage, "PendingTasks"),
-                              probe.getThreadPoolMetric(stage, "CompletedTasks"),
-                              probe.getThreadPoolMetric(stage, "CurrentlyBlockedTasks"),
-                              probe.getThreadPoolMetric(stage, "TotalBlockedTasks"));
+            System.out.printf("%-25s%10s%10s%15s%10s%18s%n",
+                              tpool.getValue(),
+                              probe.getThreadPoolMetric(tpool.getKey(), tpool.getValue(),
"ActiveTasks"),
+                              probe.getThreadPoolMetric(tpool.getKey(), tpool.getValue(),
"PendingTasks"),
+                              probe.getThreadPoolMetric(tpool.getKey(), tpool.getValue(),
"CompletedTasks"),
+                              probe.getThreadPoolMetric(tpool.getKey(), tpool.getValue(),
"CurrentlyBlockedTasks"),
+                              probe.getThreadPoolMetric(tpool.getKey(), tpool.getValue(),
"TotalBlockedTasks"));
         }
 
         System.out.printf("%n%-20s%10s%n", "Message type", "Dropped");

http://git-wip-us.apache.org/repos/asf/cassandra/blob/05300b26/src/java/org/apache/cassandra/utils/StatusLogger.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/utils/StatusLogger.java b/src/java/org/apache/cassandra/utils/StatusLogger.java
index 5f4eaf2..712e8f7 100644
--- a/src/java/org/apache/cassandra/utils/StatusLogger.java
+++ b/src/java/org/apache/cassandra/utils/StatusLogger.java
@@ -18,6 +18,7 @@
 package org.apache.cassandra.utils;
 
 import java.lang.management.ManagementFactory;
+import java.util.Map;
 import java.util.Set;
 import javax.management.*;
 
@@ -50,15 +51,15 @@ public class StatusLogger
         // everything from o.a.c.concurrent
         logger.info(String.format("%-25s%10s%10s%15s%10s%18s", "Pool Name", "Active", "Pending",
"Completed", "Blocked", "All Time Blocked"));
 
-        for (Stage stage : Stage.jmxEnabledStages())
+        for (Map.Entry<String, String> tpool : ThreadPoolMetrics.getJmxThreadPools(server).entries())
         {
             logger.info(String.format("%-25s%10s%10s%15s%10s%18s%n",
-                              stage.getJmxName(),
-                              ThreadPoolMetrics.getJmxMetric(server, stage.getJmxType(),
stage.getJmxName(), "ActiveTasks"),
-                              ThreadPoolMetrics.getJmxMetric(server, stage.getJmxType(),
stage.getJmxName(), "PendingTasks"),
-                              ThreadPoolMetrics.getJmxMetric(server, stage.getJmxType(),
stage.getJmxName(), "CompletedTasks"),
-                              ThreadPoolMetrics.getJmxMetric(server, stage.getJmxType(),
stage.getJmxName(), "CurrentlyBlockedTasks"),
-                              ThreadPoolMetrics.getJmxMetric(server, stage.getJmxType(),
stage.getJmxName(), "TotalBlockedTasks")));
+                                      tpool.getValue(),
+                                      ThreadPoolMetrics.getJmxMetric(server, tpool.getKey(),
tpool.getValue(), "ActiveTasks"),
+                                      ThreadPoolMetrics.getJmxMetric(server, tpool.getKey(),
tpool.getValue(), "PendingTasks"),
+                                      ThreadPoolMetrics.getJmxMetric(server, tpool.getKey(),
tpool.getValue(), "CompletedTasks"),
+                                      ThreadPoolMetrics.getJmxMetric(server, tpool.getKey(),
tpool.getValue(), "CurrentlyBlockedTasks"),
+                                      ThreadPoolMetrics.getJmxMetric(server, tpool.getKey(),
tpool.getValue(), "TotalBlockedTasks")));
         }
 
         // one offs


Mime
View raw message