Skip to content

Instantly share code, notes, and snippets.

@wmfairuz
Created April 21, 2014 08:37
Show Gist options
  • Save wmfairuz/11136364 to your computer and use it in GitHub Desktop.
Save wmfairuz/11136364 to your computer and use it in GitHub Desktop.
jolokia classes
J4pExecRequest
J4pListRequest
J4pReadRequest
J4pSearchRequest
J4pVersionRequest
J4pWriteRequest
package com.sample;
import org.jolokia.client.*;
import org.jolokia.client.request.*;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
public class JmxClient {
public static void main(String[] args) throws Exception {
J4pClient j4pClient = new J4pClient("http://localhost:8080/jolokia/");
J4pReadRequest req = new J4pReadRequest("java.lang:type=Memory",
"HeapMemoryUsage");
J4pReadResponse resp = j4pClient.execute(req);
Map vals = resp.getValue();
Set set = vals.keySet();
Iterator i = set.iterator();
while (i.hasNext()) {
Object key = i.next();
System.out.println(key + " = " +vals.get(key));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment