当前位置: 首页>>代码示例>>Java>>正文


Java BufferPoolMXBean.getCount方法代码示例

本文整理汇总了Java中java.lang.management.BufferPoolMXBean.getCount方法的典型用法代码示例。如果您正苦于以下问题:Java BufferPoolMXBean.getCount方法的具体用法?Java BufferPoolMXBean.getCount怎么用?Java BufferPoolMXBean.getCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.BufferPoolMXBean的用法示例。


在下文中一共展示了BufferPoolMXBean.getCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: check

import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
static void check(List<BufferPoolMXBean> pools,
                  int minBufferCount,
                  long minTotalCapacity)
{
    int bufferCount = 0;
    long totalCap = 0;
    long totalMem = 0;
    for (BufferPoolMXBean pool: pools) {
        bufferCount += pool.getCount();
        totalCap += pool.getTotalCapacity();
        totalMem += pool.getMemoryUsed();
    }
    if (bufferCount < minBufferCount)
        throw new RuntimeException("Count less than expected");
    if (totalMem < minTotalCapacity)
        throw new RuntimeException("Memory usage less than expected");
    if (totalCap < minTotalCapacity)
        throw new RuntimeException("Total capacity less than expected");
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:20,代码来源:Basic.java

示例2: BufferPoolMetricSet

import java.lang.management.BufferPoolMXBean; //导入方法依赖的package包/类
BufferPoolMetricSet() {
    this.bufferPoolMXBeans = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);

    List<BufferPoolStatus> bufferPoolStatuses = new ArrayList<>();
    Map<String, Metric> metricsByNames = new HashMap<>();

    for (final BufferPoolMXBean bufferPoolMXBean : bufferPoolMXBeans) {
        final String bufferPoolName = bufferPoolMXBean.getName();

        final Gauge<Long> sizeGauge = new Gauge<Long>() {
            @Override
            public Long getValue() {
                return bufferPoolMXBean.getCount();
            }
        };
        metricsByNames.put(MetricNamingUtil.join(bufferPoolName, "size"), sizeGauge);

        final Gauge<Long> totalCapacityInBytesGauge = new Gauge<Long>() {
            @Override
            public Long getValue() {
                return bufferPoolMXBean.getTotalCapacity();
            }
        };
        metricsByNames.put(MetricNamingUtil.join(bufferPoolName, "totalCapacityInBytes"), totalCapacityInBytesGauge);

        final Gauge<Long> usedMemoryInBytesGauge;
        if (bufferPoolMXBean.getMemoryUsed() >= 0) {
            usedMemoryInBytesGauge = new Gauge<Long>() {
                @Override
                public Long getValue() {
                    return bufferPoolMXBean.getMemoryUsed();
                }
            };
            metricsByNames.put(MetricNamingUtil.join(bufferPoolName, "usedMemoryInBytes"), usedMemoryInBytesGauge);
        } else {
            usedMemoryInBytesGauge = null;
        }

        bufferPoolStatuses.add(new BufferPoolStatus() {
            @Override
            public String getName() {
                return bufferPoolName;
            }

            @Override
            public Gauge<Long> getSizeGauge() {
                return sizeGauge;
            }

            @Override
            public Gauge<Long> getTotalCapacityInBytesGauge() {
                return totalCapacityInBytesGauge;
            }

            @Override
            public Gauge<Long> getUsedMemoryInBytesGauge() {
                return usedMemoryInBytesGauge;
            }
        });
    }

    this.bufferPoolStatuses = bufferPoolStatuses;
    this.metricsByNames = metricsByNames;
}
 
开发者ID:centro,项目名称:monitoring-center,代码行数:65,代码来源:BufferPoolMetricSet.java


注:本文中的java.lang.management.BufferPoolMXBean.getCount方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。