use of java.lang.management.GarbageCollectorMXBean in project Payara by payara.
the class MemoryReporter method init.
private void init() throws RuntimeException {
try {
this.rmbean = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.RUNTIME_MXBEAN_NAME, RuntimeMXBean.class);
this.mmbean = ManagementFactory.newPlatformMXBeanProxy(mbsc, ManagementFactory.MEMORY_MXBEAN_NAME, MemoryMXBean.class);
ObjectName poolName = new ObjectName(ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",*");
;
ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
Set mbeans = mbsc.queryNames(poolName, null);
if (mbeans != null) {
pools = new ArrayList<MemoryPoolMXBean>();
Iterator iterator = mbeans.iterator();
MemoryPoolMXBean p = null;
while (iterator.hasNext()) {
ObjectName objName = (ObjectName) iterator.next();
p = ManagementFactory.newPlatformMXBeanProxy(mbsc, objName.getCanonicalName(), MemoryPoolMXBean.class);
pools.add(p);
}
}
mbeans = mbsc.queryNames(gcName, null);
if (mbeans != null) {
gcmbeans = new ArrayList<GarbageCollectorMXBean>();
Iterator iterator = mbeans.iterator();
GarbageCollectorMXBean gc = null;
while (iterator.hasNext()) {
ObjectName objName = (ObjectName) iterator.next();
gc = ManagementFactory.newPlatformMXBeanProxy(mbsc, objName.getCanonicalName(), GarbageCollectorMXBean.class);
gcmbeans.add(gc);
}
}
} catch (final Exception e) {
throw new RuntimeException(e);
}
}
use of java.lang.management.GarbageCollectorMXBean in project Payara by payara.
the class JVMGCStatsProvider method getCollectionCount.
@ManagedAttribute(id = "collectioncount-count")
@Description("total number of collections that have occurred")
public CountStatistic getCollectionCount() {
long counts = -1;
for (GarbageCollectorMXBean gcBean : gcBeanList) {
if (gcBean.getName().equals(gcName)) {
counts = gcBean.getCollectionCount();
}
}
collectionCount.setCount(counts);
return collectionCount;
}
Aggregations