expose threadpool's pendingtasks via nodeprobe. patch by Sammy Yu; reviewed by jbellis for CASSANDRA-360

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@803285 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-08-11 20:40:10 +00:00
parent a461792de9
commit 3ec8258db6
1 changed files with 37 additions and 1 deletions

View File

@ -39,6 +39,7 @@ import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
import org.apache.cassandra.concurrent.DebuggableThreadPoolExecutorMBean;
import org.apache.cassandra.db.ColumnFamilyStoreMBean;
import org.apache.cassandra.dht.Range;
import org.apache.cassandra.net.EndPoint;
@ -452,6 +453,37 @@ public class NodeProbe
ssProxy.clearSnapshot();
}
/**
* Print out the size of the queues in the thread pools
*
* @param outs Output stream to generate the output on.
*/
public void printThreadPoolStats(PrintStream outs)
{
ObjectName query;
try
{
query = new ObjectName("org.apache.cassandra.concurrent:type=*");
Set<ObjectName> result = mbeanServerConn.queryNames(query, null);
for (ObjectName objectName : result)
{
String poolName = objectName.getKeyProperty("type");
DebuggableThreadPoolExecutorMBean threadPoolProxy = JMX.newMBeanProxy(mbeanServerConn,
objectName,
DebuggableThreadPoolExecutorMBean.class);
outs.println(poolName + ", pending tasks=" + threadPoolProxy.getPendingTasks());
}
}
catch (MalformedObjectNameException e)
{
throw new RuntimeException("Invalid ObjectName? Please report this as a bug.", e);
}
catch (IOException e)
{
throw new RuntimeException("Could not retrieve list of stat mbeans.", e);
}
}
/**
* Retrieve any non-option arguments passed on the command line.
*
@ -481,7 +513,7 @@ public class NodeProbe
{
HelpFormatter hf = new HelpFormatter();
String header = String.format(
"%nAvailable commands: ring, cluster, info, cleanup, compact, cfstats, snapshot [name], clearsnapshot, bootstrap");
"%nAvailable commands: ring, cluster, info, cleanup, compact, cfstats, snapshot [name], clearsnapshot, bootstrap, tpstats");
String usage = String.format("java %s -host <arg> <command>%n", NodeProbe.class.getName());
hf.printHelp(usage, "", options, header);
}
@ -569,6 +601,10 @@ public class NodeProbe
System.exit(1);
}
}
else if (cmdName.equals("tpstats"))
{
probe.printThreadPoolStats(System.out);
}
else
{
System.err.println("Unrecognized command: " + cmdName + ".");