Skip to content

Instantly share code, notes, and snippets.

@nickman
Created January 6, 2012 21:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickman/1572517 to your computer and use it in GitHub Desktop.
Save nickman/1572517 to your computer and use it in GitHub Desktop.
Gmx Example: Remote call to compute sum of all thread's block counts
import org.helios.gmx.*;
def gmx = Gmx.remote("service:jmx:rmi://testserver1:8002/jndi/rmi://testserver1:8003/jmxrmi");
gmx.installRemote();
def remoteMBeanServer = gmx.gmxRemote();
def script =
"import java.lang.management.*; 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