Create a gist now

Instantly share code, notes, and snippets.

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