Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Gmx Example: Remote call to compute sum of all thread's block counts
def gmx = Gmx.remote("service:jmx:rmi://testserver1:8002/jndi/rmi://testserver1:8003/jmxrmi");
def remoteMBeanServer = gmx.gmxRemote();
def script =
"import*; long blockedCount = 0; " +
"ManagementFactory.getThreadMXBean().getThreadInfo(ManagementFactory.getThreadMXBean().getAllThreadIds()).each() { " +
"blockedCount += it.getBlockedCount(); }; " +
"return blockedCount; ";
long totalBc = remoteMBeanServer.invokeScript(script, [] as Object[]);
println "Total Blocked Count:$totalBc";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment