public static Map<String, Double> buffersMetrics(VirtualMachineMetrics.BufferPoolStats bps) { return ImmutableMap.<String, Double>builder() .put("count", (double) bps.getCount()) .put("memoryUsed", (double) bps.getMemoryUsed()) .put("totalCapacity", (double) bps.getTotalCapacity()) .build(); }
json.writeStartObject(); json.writeNumberField("count", bufferPoolStats.get("direct").getCount()); json.writeNumberField("memoryUsed", bufferPoolStats.get("direct").getMemoryUsed()); json.writeNumberField("totalCapacity", bufferPoolStats.get("direct").getTotalCapacity()); json.writeStartObject(); json.writeNumberField("count", bufferPoolStats.get("mapped").getCount()); json.writeNumberField("memoryUsed", bufferPoolStats.get("mapped").getMemoryUsed()); json.writeNumberField("totalCapacity", bufferPoolStats.get("mapped").getTotalCapacity());
json.writeStartObject(); json.writeNumberField("count", bufferPoolStats.get("direct").getCount()); json.writeNumberField("memoryUsed", bufferPoolStats.get("direct").getMemoryUsed()); json.writeNumberField("totalCapacity", bufferPoolStats.get("direct").getTotalCapacity()); json.writeStartObject(); json.writeNumberField("count", bufferPoolStats.get("mapped").getCount()); json.writeNumberField("memoryUsed", bufferPoolStats.get("mapped").getMemoryUsed()); json.writeNumberField("totalCapacity", bufferPoolStats.get("mapped").getTotalCapacity());
public Map<String, BufferPoolStats> getBufferPoolStats() { try { final String[] attributes = { "Count", "MemoryUsed", "TotalCapacity" }; final ObjectName direct = new ObjectName("java.nio:type=BufferPool,name=direct"); final ObjectName mapped = new ObjectName("java.nio:type=BufferPool,name=mapped"); final AttributeList directAttributes = mBeanServer.getAttributes(direct, attributes); final AttributeList mappedAttributes = mBeanServer.getAttributes(mapped, attributes); final Map<String, BufferPoolStats> stats = new TreeMap<String, BufferPoolStats>(); final BufferPoolStats directStats = new BufferPoolStats((Long) ((Attribute) directAttributes.get(0)).getValue(), (Long) ((Attribute) directAttributes.get(1)).getValue(), (Long) ((Attribute) directAttributes.get(2)).getValue()); stats.put("direct", directStats); final BufferPoolStats mappedStats = new BufferPoolStats((Long) ((Attribute) mappedAttributes.get(0)).getValue(), (Long) ((Attribute) mappedAttributes.get(1)).getValue(), (Long) ((Attribute) mappedAttributes.get(2)).getValue()); stats.put("mapped", mappedStats); return Collections.unmodifiableMap(stats); } catch (JMException e) { return Collections.emptyMap(); } } }
public static Map<String, Double> buffersMetrics(VirtualMachineMetrics.BufferPoolStats bps) { return ImmutableMap.<String, Double>builder() .put("count", (double) bps.getCount()) .put("memoryUsed", (double) bps.getMemoryUsed()) .put("totalCapacity", (double) bps.getTotalCapacity()) .build(); }