Java Code Examples for java.lang.management.BufferPoolMXBean#getName()

The following examples show how to use java.lang.management.BufferPoolMXBean#getName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BufferPoolSensor.java    From swage with Apache License 2.0 6 votes vote down vote up
@Override
public void sense(final MetricContext metricContext)
{
    List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);

    for (BufferPoolMXBean mxBean : pools) {
        //TODO: something else?
        String name = mxBean.getName();
        Metric countMetric = Metric.define("BufferPoolCount_"+name);
        Metric usedMetric = Metric.define("BufferPoolUsed_"+name);
        Metric maxMetric = Metric.define("BufferPoolMax_"+name);

        metricContext.record(countMetric, mxBean.getCount(), Unit.NONE);
        metricContext.record(usedMetric, mxBean.getMemoryUsed() / M, Unit.MEGABYTE);
        metricContext.record(maxMetric,  mxBean.getTotalCapacity() / M, Unit.MEGABYTE);
    }

}
 
Example 2
Source File: AltBufferPoolMetricSet.java    From lucene-solr with Apache License 2.0 5 votes vote down vote up
@Override
public Map<String, Metric> getMetrics() {
  final Map<String, Metric> metrics = new HashMap<>();
  List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
  for (final BufferPoolMXBean pool : pools) {
    String name = pool.getName();
    metrics.put(name + ".Count", (Gauge<Long>)() -> pool.getCount());
    metrics.put(name + ".MemoryUsed", (Gauge<Long>)() -> pool.getMemoryUsed());
    metrics.put(name + ".TotalCapacity", (Gauge<Long>)() -> pool.getTotalCapacity());
  }
  return metrics;
}
 
Example 3
Source File: DefaultBufferMetric.java    From pinpoint with Apache License 2.0 5 votes vote down vote up
private BufferPoolMXBean getBufferPool(List<BufferPoolMXBean> pools, String type) {
    for (BufferPoolMXBean pool : pools) {
        final String poolName = pool.getName();
        if (poolName.equals(type)) {
            return pool;
        }
    }
    return new EmptyBufferPoolMXBean();
}