public void onSuccess(DMRResponse result) {
ModelNode response = result.get();
ModelNode steps = response.get(RESULT);
CompositeVMMetric metric = new CompositeVMMetric();
if(response.isFailure())
{
callback.onFailure(new RuntimeException("Error loading VM metrics: "+response.getFailureDescription()));
}
else
{
// memory
ModelNode memory = steps.get("step-1").get(RESULT);
HeapMetric heap = heapMetricAdapter.fromDMR(memory.get("heap-memory-usage"));
HeapMetric nonHeap = heapMetricAdapter.fromDMR(memory.get("non-heap-memory-usage"));
metric.setHeap(heap);
metric.setNonHeap(nonHeap);
// threads
ModelNode threads = steps.get("step-2").get(RESULT);
ThreadMetric thread = threadMetricAdapter.fromDMR(threads);
metric.setThreads(thread);
// runtime
ModelNode runtime = steps.get("step-3").get(RESULT);
RuntimeMetric runtimeMetric = runtimeAdapter.fromDMR(runtime);
metric.setRuntime(runtimeMetric);
// os
ModelNode os = steps.get("step-4").get(RESULT);
OSMetric osMetric = osAdapter.fromDMR(os);
metric.setOs(osMetric);
callback.onSuccess(metric);
}