Java 类java.lang.management.BufferPoolMXBean 实例源码

项目:swage    文件:BufferPoolSensor.java   
@Override
public void sense(final MetricRecorder.Context 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);
    }

}
项目:openjdk-systemtest    文件:ByteBufferMXBeanTest.java   
public void testByteBufferMXBeanMethods() {
    List<BufferPoolMXBean> byteBufferPools = 
        ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);

    for (int counter = 0; counter < 10; counter++) {

        for (BufferPoolMXBean bean: byteBufferPools) {

            // Name should not be blank or null
            assertNotNull ("MXBean name is null", bean.getName());
            assertFalse ("MXBean name is blank", bean.getName().equalsIgnoreCase(""));
            // Total capacity should not be negative
            assertTrue (bean.getName() + "'s total capacity was not greater than zero", bean.getTotalCapacity() >= 0);
            // Likewise memoryUsed
            assertTrue (bean.getName() + "'s memory used was not greater than zero", bean.getMemoryUsed() >= 0);

            assertTrue (bean.getName() + "'s object name is null or blank", 
                    bean.getObjectName() != null && bean.getObjectName().toString() != "");
        }
    }
}
项目:QDrill    文件:MemoryIterator.java   
@Override
public Object next() {
  if (!beforeFirst) {
    throw new IllegalStateException();
  }
  beforeFirst = false;
  final MemoryInfo memoryInfo = new MemoryInfo();

  final DrillbitEndpoint endpoint = context.getIdentity();
  memoryInfo.hostname = endpoint.getAddress();
  memoryInfo.user_port = endpoint.getUserPort();

  final MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
  memoryInfo.heap_current = heapMemoryUsage.getUsed();
  memoryInfo.heap_max = heapMemoryUsage.getMax();

  BufferPoolMXBean directBean = getDirectBean();
  memoryInfo.jvm_direct_current = directBean.getMemoryUsed();


  memoryInfo.direct_current = context.getDrillbitContext().getAllocator().getAllocatedMemory();
  memoryInfo.direct_max = TopLevelAllocator.MAXIMUM_DIRECT_MEMORY;
  return memoryInfo;
}
项目:jdk8u-jdk    文件:Basic.java   
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");
}
项目:jdk8u-jdk    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:openjdk-jdk10    文件:Basic.java   
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");
}
项目:openjdk-jdk10    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:dremio-oss    文件:MemoryIterator.java   
@Override
public Object next() {
  if (!beforeFirst) {
    throw new IllegalStateException();
  }
  beforeFirst = false;
  final MemoryInfo memoryInfo = new MemoryInfo();

  final NodeEndpoint endpoint = dbContext.getEndpoint();
  memoryInfo.hostname = endpoint.getAddress();
  memoryInfo.fabric_port = endpoint.getFabricPort();

  final MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
  memoryInfo.heap_current = heapMemoryUsage.getUsed();
  memoryInfo.heap_max = heapMemoryUsage.getMax();

  BufferPoolMXBean directBean = getDirectBean();
  memoryInfo.jvm_direct_current = directBean.getMemoryUsed();


  memoryInfo.direct_current = dbContext.getAllocator().getAllocatedMemory();
  memoryInfo.direct_max = SabotConfig.getMaxDirectMemory();
  return memoryInfo;
}
项目:openjdk9    文件:Basic.java   
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");
}
项目:openjdk9    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:jdk8u_jdk    文件:Basic.java   
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");
}
项目:jdk8u_jdk    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:lookaside_java-1.8.0-openjdk    文件:Basic.java   
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");
}
项目:lookaside_java-1.8.0-openjdk    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:antsdb    文件:MemoryUtil.java   
public static void main(String[] args) {
    List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
    for (BufferPoolMXBean pool:pools) {
        System.out.println(String.format(
                "%s %d/%d", 
                pool.getName(), 
                pool.getMemoryUsed(), 
                pool.getTotalCapacity()));
    }
    RuntimeMXBean RuntimemxBean = ManagementFactory.getRuntimeMXBean();
    for (String arg:RuntimemxBean.getInputArguments()) {
        System.out.println(arg); 
    }
    HotSpotDiagnosticMXBean hsdiag = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
    for (VMOption i:hsdiag.getDiagnosticOptions()) {
        System.out.println(i.getName() + ":" + i.getValue());
    }
    System.out.println(hsdiag.getVMOption("MaxDirectMemorySize"));
    System.out.println(sun.misc.VM.maxDirectMemory());
    System.out.println(ByteBuffer.allocateDirect(1000000000));
    System.out.println(ByteBuffer.allocateDirect(1000000000));
    System.out.println(ByteBuffer.allocateDirect(1000000000));
    System.out.println(getDirectMemoryUsed());
}
项目:drill    文件:MemoryIterator.java   
@Override
public Object next() {
  if (!beforeFirst) {
    throw new IllegalStateException();
  }
  beforeFirst = false;
  final MemoryInfo memoryInfo = new MemoryInfo();

  final DrillbitEndpoint endpoint = context.getIdentity();
  memoryInfo.hostname = endpoint.getAddress();
  memoryInfo.user_port = endpoint.getUserPort();

  final MemoryUsage heapMemoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage();
  memoryInfo.heap_current = heapMemoryUsage.getUsed();
  memoryInfo.heap_max = heapMemoryUsage.getMax();

  BufferPoolMXBean directBean = getDirectBean();
  memoryInfo.jvm_direct_current = directBean.getMemoryUsed();


  memoryInfo.direct_current = context.getDrillbitContext().getAllocator().getAllocatedMemory();
  memoryInfo.direct_max = DrillConfig.getMaxDirectMemory();
  return memoryInfo;
}
项目:routing-bird    文件:DirectBufferHealthChecker.java   
@Override
public void run() {
    try {
        long memoryUsed = 0;
        for (BufferPoolMXBean bufferPool : bufferPools) {
            if (bufferPool.getName().equals("direct")) {
                memoryUsed = bufferPool.getMemoryUsed();
            }
        }

        Counter counter = new Counter(ValueType.VALUE);
        counter.set(memoryUsed);
        check(counter, config.getDescription(), "Allocate more direct memory. ");
    } catch (Exception x) {
        // TODO what?
    }
}
项目:sdcct    文件:MemoryMetricSet.java   
@Override
public Map<String, Metric> getMetrics() {
    Map<String, Metric> metrics = super.getMetrics();
    MemoryMXBean memMxBean = ManagementFactory.getMemoryMXBean();

    registerGauge(metrics, MEMORY_OBJ_PENDING_FINALIZATION_COUNT_METRIC_NAME, memMxBean.getObjectPendingFinalizationCount());

    MemoryUsage heapMemUsage = memMxBean.getHeapMemoryUsage(), nonHeapMemUsage = memMxBean.getNonHeapMemoryUsage();

    registerMemoryUsageMetrics(metrics, MEMORY_HEAP_METRIC_NAME_PREFIX, heapMemUsage);
    registerMemoryUsageMetrics(metrics, MEMORY_NON_HEAP_METRIC_NAME_PREFIX, nonHeapMemUsage);
    registerMemoryUsageMetrics(metrics, MEMORY_TOTAL_METRIC_NAME_PREFIX, (heapMemUsage.getCommitted() + nonHeapMemUsage.getCommitted()),
        (heapMemUsage.getInit() + nonHeapMemUsage.getInit()), -1, (heapMemUsage.getUsed() + nonHeapMemUsage.getUsed()),
        (heapMemUsage.getMax() + nonHeapMemUsage.getMax()));

    ManagementFactory.getMemoryPoolMXBeans().stream().filter(MemoryPoolMXBean::isValid)
        .forEach(memPoolMxBean -> registerMemoryPoolMetrics(metrics, memPoolMxBean));

    ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class).stream().forEach(bufferPoolMxBean -> registerBufferPoolMetrics(metrics, bufferPoolMxBean));

    return metrics;
}
项目:infobip-open-jdk-8    文件:Basic.java   
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");
}
项目:infobip-open-jdk-8    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:jdk8u-dev-jdk    文件:Basic.java   
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");
}
项目:jdk8u-dev-jdk    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:heron    文件:JVMMetrics.java   
private void updateBufferPoolMetrics() {
  for (BufferPoolMXBean bufferPoolMXBean : bufferPoolMXBeanList) {
    String normalizedKeyName = bufferPoolMXBean.getName().replaceAll("[^\\w]", "-");

    final ByteAmount memoryUsed = ByteAmount.fromBytes(bufferPoolMXBean.getMemoryUsed());
    final ByteAmount totalCapacity = ByteAmount.fromBytes(bufferPoolMXBean.getTotalCapacity());
    final ByteAmount count = ByteAmount.fromBytes(bufferPoolMXBean.getCount());

    // The estimated memory the JVM is using for this buffer pool
    jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-memory-used")
        .setValue(memoryUsed.asMegabytes());

    // The estimated total capacity of the buffers in this pool
    jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-total-capacity")
        .setValue(totalCapacity.asMegabytes());

    // THe estimated number of buffers in this pool
    jvmBufferPoolMemoryUsage.safeScope(normalizedKeyName + "-count")
        .setValue(count.asMegabytes());
  }
}
项目:jdk7-jdk    文件:Basic.java   
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");
}
项目:tajo    文件:QueryTestCaseBase.java   
@Before
public void printTestName() {
  /* protect a travis stalled build */
  BufferPoolMXBean direct = BufferPool.getDirectBufferPool();
  BufferPoolMXBean mapped = BufferPool.getMappedBufferPool();
  System.out.println(String.format("Used heap: %s/%s, direct:%s/%s, mapped:%s/%s, Active Threads: %d, Run: %s.%s",
      FileUtil.humanReadableByteCount(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(), false),
      FileUtil.humanReadableByteCount(Runtime.getRuntime().maxMemory(), false),
      FileUtil.humanReadableByteCount(direct.getMemoryUsed(), false),
      FileUtil.humanReadableByteCount(direct.getTotalCapacity(), false),
      FileUtil.humanReadableByteCount(mapped.getMemoryUsed(), false),
      FileUtil.humanReadableByteCount(mapped.getTotalCapacity(), false),
      Thread.activeCount(),
      getClass().getSimpleName(),
      name.getMethodName()));
}
项目:openjdk-source-code-learn    文件:Basic.java   
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");
}
项目:OLD-OpenJDK8    文件:Basic.java   
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");
}
项目:OLD-OpenJDK8    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:JAVA_UNIT    文件:Basic.java   
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");
}
项目:openjdk-jdk7u-jdk    文件:Basic.java   
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");
}
项目:openjdk-jdk7u-jdk    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:openjdk-icedtea7    文件:Basic.java   
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");
}
项目:openjdk-icedtea7    文件:GetObjectName.java   
static void submitTasks(ExecutorService executor, int count) {
    for (int i=0; i < count && !failed; i++) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                List<PlatformManagedObject> mbeans = new ArrayList<>();
                mbeans.add(ManagementFactory.getPlatformMXBean(PlatformLoggingMXBean.class));
                mbeans.addAll(ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class));
                for (PlatformManagedObject pmo : mbeans) {
                    // Name should not be null
                    if (pmo.getObjectName() == null) {
                        failed = true;
                        throw new RuntimeException("TEST FAILED: getObjectName() returns null");
                    }
                }
            }
        });
    }
}
项目:openjdk-systemtest    文件:EchoServer.java   
@Override
protected void heartbeat() {
    // Let them know we are alive
    // Print some stats about the ByteBuffers
    List<BufferPoolMXBean> byteBufferPools = 
        ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);

    String direct = "direct";
    String mapped = "mapped";

    for (BufferPoolMXBean bean: byteBufferPools) {
        if (bean.getName().equalsIgnoreCase(direct)) {
            direct += " - " + bean.getMemoryUsed() + "/" + bean.getTotalCapacity();
        }
        if (bean.getName().equalsIgnoreCase(mapped)) {
            mapped += " - " + bean.getMemoryUsed() + "/" + bean.getTotalCapacity();
        }
    }

    logMessage(direct + " , " + mapped);
    logMessage("Currently connected clients: " + getConnectedClients().size());
    logMessage("Total bytes received       : " + bytesReceived);
    logMessage("Total clients connected    : " + clientsConnected);
    logMessage("Total clients disconnected : " + clientsDisconnected);

    synchronized (connectionsPerSecond) {
        if (!connectionsPerSecond.isEmpty()) {
            logMessage("CPS Max: " + Collections.max(connectionsPerSecond.values()) );
        }
    }
    synchronized (connectionsPerMinute) {
        if (!connectionsPerMinute.isEmpty()) {
            logMessage("CPM Max: " + Collections.max(connectionsPerMinute.values()) );
        }
    }

    logMessage();
}
项目:QDrill    文件:MemoryIterator.java   
private BufferPoolMXBean getDirectBean() {
  List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
  for (BufferPoolMXBean b : pools) {
    if (b.getName().equals("direct")) {
      return b;
    }
  }
  throw new IllegalStateException("Unable to find direct buffer bean.  JVM must be too old.");
}
项目:QDrill    文件:DrillTest.java   
public SystemManager(){
  memoryBean = ManagementFactory.getMemoryMXBean();
  BufferPoolMXBean localBean = null;
  List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
  for(BufferPoolMXBean b : pools){
    if(b.getName().equals("direct")){
      localBean = b;

    }
  }
  directBean = localBean;
}
项目:jdk8u-jdk    文件:TestMaxCachedBufferSize.java   
private static BufferPoolMXBean getDirectPool() {
    final List<BufferPoolMXBean> pools =
              ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
    for (BufferPoolMXBean pool : pools) {
        if (pool.getName().equals("direct")) {
            return pool;
        }
    }
    throw new Error("could not find direct pool");
}
项目:openjdk-jdk10    文件:TestMaxCachedBufferSize.java   
private static BufferPoolMXBean getDirectPool() {
    final List<BufferPoolMXBean> pools =
              ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
    for (BufferPoolMXBean pool : pools) {
        if (pool.getName().equals("direct")) {
            return pool;
        }
    }
    throw new Error("could not find direct pool");
}
项目:dremio-oss    文件:MemoryIterator.java   
/**
 * @return Direct buffer JMX bean
 */
public static BufferPoolMXBean getDirectBean() {
  List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
  for (BufferPoolMXBean b : pools) {
    if (b.getName().equals("direct")) {
      return b;
    }
  }
  throw new IllegalStateException("Unable to find direct buffer bean.  JVM must be too old.");
}
项目:dremio-oss    文件:DremioTest.java   
public SystemManager(){
  memoryBean = ManagementFactory.getMemoryMXBean();
  BufferPoolMXBean localBean = null;
  List<BufferPoolMXBean> pools = ManagementFactory.getPlatformMXBeans(BufferPoolMXBean.class);
  for(BufferPoolMXBean b : pools){
    if(b.getName().equals("direct")){
      localBean = b;

    }
  }
  directBean = localBean;
}