cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmcken...@apache.org
Subject cassandra git commit: Expose thread pool max in metrics
Date Mon, 15 Dec 2014 19:16:43 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 6d8862b00 -> a6c6d0f60


Expose thread pool max in metrics

Patch by Chris Lohfink; reviewed by jmckenzie for CASSANDRA-8328


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

Branch: refs/heads/cassandra-2.1
Commit: a6c6d0f60c74a9b9889f49ca1cba41e855cad091
Parents: 6d8862b
Author: Chris Lohfink <clohfink85@gmail.com>
Authored: Mon Dec 15 13:14:12 2014 -0600
Committer: Joshua McKenzie <jmckenzie@apache.org>
Committed: Mon Dec 15 13:14:12 2014 -0600

----------------------------------------------------------------------
 .../concurrent/JMXEnabledThreadPoolExecutor.java      |  3 ++-
 .../org/apache/cassandra/concurrent/SEPExecutor.java  |  2 +-
 src/java/org/apache/cassandra/metrics/SEPMetrics.java | 12 +++++++++++-
 .../apache/cassandra/metrics/ThreadPoolMetrics.java   | 14 +++++++++++++-
 4 files changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/a6c6d0f6/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java b/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
index de448b5..5c96bb6 100644
--- a/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
+++ b/src/java/org/apache/cassandra/concurrent/JMXEnabledThreadPoolExecutor.java
@@ -37,6 +37,7 @@ public class JMXEnabledThreadPoolExecutor extends DebuggableThreadPoolExecutor
i
 {
     private final String mbeanName;
     private final ThreadPoolMetrics metrics;
+    public final int maxPoolSize;
 
     public JMXEnabledThreadPoolExecutor(String threadPoolName)
     {
@@ -73,7 +74,7 @@ public class JMXEnabledThreadPoolExecutor extends DebuggableThreadPoolExecutor
i
     {
         super(corePoolSize, maxPoolSize, keepAliveTime, unit, workQueue, threadFactory);
         super.prestartAllCoreThreads();
-
+        this.maxPoolSize = maxPoolSize;
         metrics = new ThreadPoolMetrics(this, jmxPath, threadFactory.id);
 
         MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a6c6d0f6/src/java/org/apache/cassandra/concurrent/SEPExecutor.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/concurrent/SEPExecutor.java b/src/java/org/apache/cassandra/concurrent/SEPExecutor.java
index b6f5e97..f6d1940 100644
--- a/src/java/org/apache/cassandra/concurrent/SEPExecutor.java
+++ b/src/java/org/apache/cassandra/concurrent/SEPExecutor.java
@@ -33,7 +33,7 @@ public class SEPExecutor extends AbstractTracingAwareExecutorService
 {
     private final SharedExecutorPool pool;
 
-    private final int maxWorkers;
+    public final int maxWorkers;
     private final int maxTasksQueued;
 
     // stores both a set of work permits and task permits:

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a6c6d0f6/src/java/org/apache/cassandra/metrics/SEPMetrics.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/metrics/SEPMetrics.java b/src/java/org/apache/cassandra/metrics/SEPMetrics.java
index fbccc3b..58fe9c5 100644
--- a/src/java/org/apache/cassandra/metrics/SEPMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/SEPMetrics.java
@@ -19,6 +19,7 @@ package org.apache.cassandra.metrics;
 
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.Gauge;
+
 import org.apache.cassandra.concurrent.SEPExecutor;
 
 public class SEPMetrics
@@ -34,9 +35,10 @@ public class SEPMetrics
     public final Gauge<Long> currentBlocked;
     /** Number of completed tasks. */
     public final Gauge<Long> completedTasks;
-
     /** Number of tasks waiting to be executed. */
     public final Gauge<Long> pendingTasks;
+    /** Maximum number of threads before it will start queuing tasks */
+    public final Gauge<Integer> maxPoolSize;
 
     private MetricNameFactory factory;
 
@@ -85,6 +87,13 @@ public class SEPMetrics
                 return executor.getCompletedTasks();
             }
         });
+        maxPoolSize =  Metrics.newGauge(factory.createMetricName("MaxPoolSize"), new Gauge<Integer>()
+        {
+            public Integer value()
+            {
+                return executor.maxWorkers;
+            }
+        });
     }
 
     public void release()
@@ -94,5 +103,6 @@ public class SEPMetrics
         Metrics.defaultRegistry().removeMetric(factory.createMetricName("CompletedTasks"));
         Metrics.defaultRegistry().removeMetric(factory.createMetricName("TotalBlockedTasks"));
         Metrics.defaultRegistry().removeMetric(factory.createMetricName("CurrentlyBlockedTasks"));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("MaxPoolSize"));
     }
 }

http://git-wip-us.apache.org/repos/asf/cassandra/blob/a6c6d0f6/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 3cebf07..8600e0c 100644
--- a/src/java/org/apache/cassandra/metrics/ThreadPoolMetrics.java
+++ b/src/java/org/apache/cassandra/metrics/ThreadPoolMetrics.java
@@ -19,6 +19,8 @@ package org.apache.cassandra.metrics;
 
 import java.util.concurrent.ThreadPoolExecutor;
 
+import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutor;
+
 import com.yammer.metrics.Metrics;
 import com.yammer.metrics.core.*;
 
@@ -40,6 +42,8 @@ public class ThreadPoolMetrics
     public final Gauge<Long> completedTasks;
     /** Number of tasks waiting to be executed. */
     public final Gauge<Long> pendingTasks;
+    /** Maximum number of threads before it will start queuing tasks */
+    public final Gauge<Integer> maxPoolSize;
 
     private MetricNameFactory factory;
 
@@ -50,7 +54,7 @@ public class ThreadPoolMetrics
      * @param path Type of thread pool
      * @param poolName Name of thread pool to identify metrics
      */
-    public ThreadPoolMetrics(final ThreadPoolExecutor executor, String path, String poolName)
+    public ThreadPoolMetrics(final JMXEnabledThreadPoolExecutor executor, String path, String
poolName)
     {
         this.factory = new ThreadPoolMetricNameFactory("ThreadPools", path, poolName);
 
@@ -77,6 +81,13 @@ public class ThreadPoolMetrics
                 return executor.getTaskCount() - executor.getCompletedTaskCount();
             }
         });
+        maxPoolSize =  Metrics.newGauge(factory.createMetricName("MaxPoolSize"), new Gauge<Integer>()
+        {
+            public Integer value()
+            {
+                return executor.maxPoolSize;
+            }
+        });
     }
 
     public void release()
@@ -86,5 +97,6 @@ public class ThreadPoolMetrics
         Metrics.defaultRegistry().removeMetric(factory.createMetricName("CompletedTasks"));
         Metrics.defaultRegistry().removeMetric(factory.createMetricName("TotalBlockedTasks"));
         Metrics.defaultRegistry().removeMetric(factory.createMetricName("CurrentlyBlockedTasks"));
+        Metrics.defaultRegistry().removeMetric(factory.createMetricName("MaxPoolSize"));
     }
 }


Mime
View raw message