cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r823562 - in /incubator/cassandra/trunk/src/java/org/apache/cassandra: concurrent/DebuggableThreadPoolExecutor.java concurrent/IExecutorMBean.java db/CommitLogExecutorService.java tools/NodeProbe.java
Date Fri, 09 Oct 2009 14:28:41 GMT
Author: jbellis
Date: Fri Oct  9 14:28:40 2009
New Revision: 823562

URL: http://svn.apache.org/viewvc?rev=823562&view=rev
Log:
expose additional metrics for executors.  patch by Sammy Yu; reviewed by jbellis for CASSANDRA-482

Modified:
    incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/IExecutorMBean.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLogExecutorService.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java?rev=823562&r1=823561&r2=823562&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/DebuggableThreadPoolExecutor.java
Fri Oct  9 14:28:40 2009
@@ -84,6 +84,17 @@
         }
     }
 
+    /**
+     * Get the number of completed tasks
+     */
+    public long getCompletedTasks()
+    {
+        return getCompletedTaskCount();
+    }
+
+    /**
+     * Get the number of tasks waiting to be executed
+     */
     public long getPendingTasks()
     {
         return getTaskCount() - getCompletedTaskCount();

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/IExecutorMBean.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/IExecutorMBean.java?rev=823562&r1=823561&r2=823562&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/IExecutorMBean.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/concurrent/IExecutorMBean.java
Fri Oct  9 14:28:40 2009
@@ -20,5 +20,19 @@
 
 public interface IExecutorMBean
 {
+    /**
+     * Get the current number of running tasks
+     */
+    public int getActiveCount();
+
+    /**
+     * Get the number of completed tasks
+     */
+    public long getCompletedTasks();
+
+    /**
+     * Get the number of tasks waiting to be executed
+     */
     public long getPendingTasks();
+
 }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLogExecutorService.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLogExecutorService.java?rev=823562&r1=823561&r2=823562&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLogExecutorService.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/CommitLogExecutorService.java
Fri Oct  9 14:28:40 2009
@@ -26,6 +26,8 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.concurrent.*;
+import java.util.concurrent.atomic.AtomicLong;
+import java.util.concurrent.atomic.AtomicBoolean;
 import javax.management.MBeanServer;
 import javax.management.ObjectName;
 
@@ -35,6 +37,8 @@
 {
     BlockingQueue<CheaterFutureTask> queue;
 
+    private volatile long completedTaskCount = 0;
+
     public CommitLogExecutorService()
     {
         queue = new ArrayBlockingQueue<CheaterFutureTask>(10000);
@@ -49,6 +53,7 @@
                         while (true)
                         {
                             processWithSyncBatch();
+                            completedTaskCount++;
                         }
                     }
                     else
@@ -56,6 +61,7 @@
                         while (true)
                         {
                             process();
+                            completedTaskCount++;
                         }
                     }
                 }
@@ -78,7 +84,28 @@
         }
     }
 
-    public long getPendingTasks() {
+
+    /**
+     * Get the current number of running tasks
+     */
+    public int getActiveCount()
+    {
+        return 1;
+    }
+
+    /**
+     * Get the number of completed tasks
+     */
+    public long getCompletedTasks()
+    {   
+        return completedTaskCount;
+    }
+
+    /**
+     * Get the number of tasks waiting to be executed
+     */
+    public long getPendingTasks()
+    {
         return queue.size();
     }
 
@@ -133,6 +160,7 @@
         }
     }
 
+
     @Override
     protected <T> RunnableFuture<T> newTaskFor(Runnable runnable, T value)
     {

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java?rev=823562&r1=823561&r2=823562&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java Fri Oct 
9 14:28:40 2009
@@ -390,13 +390,23 @@
         ObjectName query;
         try
         {
+            outs.print(String.format("%-25s", "Pool Name"));
+            outs.print(String.format("%10s", "Active"));
+            outs.print(String.format("%10s", "Pending"));
+            outs.print(String.format("%15s", "Completed"));
+            outs.println();
+
             query = new ObjectName("org.apache.cassandra.concurrent:type=*");
             Set<ObjectName> result = mbeanServerConn.queryNames(query, null);
             for (ObjectName objectName : result)
             {
                 String poolName = objectName.getKeyProperty("type");
                 IExecutorMBean threadPoolProxy = JMX.newMBeanProxy(mbeanServerConn, objectName,
IExecutorMBean.class);
-                outs.println(poolName + ", pending tasks=" + threadPoolProxy.getPendingTasks());
+                outs.print(String.format("%-25s", poolName));
+                outs.print(String.format("%10d", threadPoolProxy.getActiveCount()));
+                outs.print(String.format("%10d", threadPoolProxy.getPendingTasks()));
+                outs.print(String.format("%15d", threadPoolProxy.getCompletedTasks()));
+                outs.println();
             }
         }
         catch (MalformedObjectNameException e)
@@ -464,7 +474,7 @@
     {
         HelpFormatter hf = new HelpFormatter();
         String header = String.format(
-                "%nAvailable commands: ring, cluster, info, cleanup, compact, cfstats, snapshot
[name], clearsnapshot, tpstats, flush_binary, " +
+                "%nAvailable commands: ring, info, cleanup, compact, cfstats, snapshot [name],
clearsnapshot, tpstats, flush_binary, " +
                 " getcompactionthreshold, setcompactionthreshold [minthreshold] ([maxthreshold])");
         String usage = String.format("java %s -host <arg> <command>%n", NodeProbe.class.getName());
         hf.printHelp(usage, "", options, header);



Mime
View raw message