Search in sources :

Example 1 with MBeanAttrs

use of io.fabric8.insight.metrics.model.MBeanAttrs in project fabric8 by jboss-fuse.

the class MetricsTest method testDefault.

@Test
public void testDefault() throws Exception {
    Query query = new Query("test", new HashSet<Request>(Arrays.asList(new MBeanAttrs("memory", "java.lang:type=Memory", Arrays.asList("HeapMemoryUsage", "NonHeapMemoryUsage")), new MBeanOpers("deadlocks", "java.lang:type=Threading", "dumpAllThreads", Arrays.<Object>asList(true, true), Arrays.<String>asList(boolean.class.getName(), boolean.class.getName())))), null, null, null, 0, 0);
    System.gc();
    QueryResult qrs = JmxUtils.execute(new Server("local"), query, ManagementFactory.getPlatformMBeanServer());
    String output = new Renderer().render(qrs);
    Map map = new ObjectMapper().readValue(output, Map.class);
    assertEquals("local", map.get("host"));
    assertNotNull(map.get("@timestamp"));
}
Also used : QueryResult(io.fabric8.insight.metrics.model.QueryResult) Query(io.fabric8.insight.metrics.model.Query) Server(io.fabric8.insight.metrics.model.Server) Request(io.fabric8.insight.metrics.model.Request) Renderer(io.fabric8.insight.metrics.mvel.Renderer) MBeanOpers(io.fabric8.insight.metrics.model.MBeanOpers) MBeanAttrs(io.fabric8.insight.metrics.model.MBeanAttrs) Map(java.util.Map) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 MBeanAttrs (io.fabric8.insight.metrics.model.MBeanAttrs)1 MBeanOpers (io.fabric8.insight.metrics.model.MBeanOpers)1 Query (io.fabric8.insight.metrics.model.Query)1 QueryResult (io.fabric8.insight.metrics.model.QueryResult)1 Request (io.fabric8.insight.metrics.model.Request)1 Server (io.fabric8.insight.metrics.model.Server)1 Renderer (io.fabric8.insight.metrics.mvel.Renderer)1 Map (java.util.Map)1 Test (org.junit.Test)1