Created
January 6, 2012 21:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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