Java Code Examples for java.lang.management.BufferPoolMXBean

The following are top voted examples for showing how to use java.lang.management.BufferPoolMXBean. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: swage   File: BufferPoolSensor.java   View source code 6 votes vote down vote up
@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);
    }

}
 
Example 2
Project: openjdk-systemtest   File: ByteBufferMXBeanTest.java   View source code 6 votes vote down vote up
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() != "");
		}
	}
}
 
Example 3
Project: QDrill   File: MemoryIterator.java   View source code 6 votes vote down vote up
@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;
}
 
Example 4
Project: jdk8u-jdk   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 5
Project: jdk8u-jdk   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 6
Project: openjdk-jdk10   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 7
Project: openjdk-jdk10   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 8
Project: dremio-oss   File: MemoryIterator.java   View source code 6 votes vote down vote up
@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;
}
 
Example 9
Project: openjdk9   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 10
Project: openjdk9   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 11
Project: jdk8u_jdk   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 12
Project: jdk8u_jdk   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 13
Project: lookaside_java-1.8.0-openjdk   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 14
Project: lookaside_java-1.8.0-openjdk   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 15
Project: antsdb   File: MemoryUtil.java   View source code 6 votes vote down vote up
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());
}
 
Example 16
Project: drill   File: MemoryIterator.java   View source code 6 votes vote down vote up
@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;
}
 
Example 17
Project: routing-bird   File: DirectBufferHealthChecker.java   View source code 6 votes vote down vote up
@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?
    }
}
 
Example 18
Project: sdcct   File: MemoryMetricSet.java   View source code 6 votes vote down vote up
@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;
}
 
Example 19
Project: infobip-open-jdk-8   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 20
Project: infobip-open-jdk-8   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 21
Project: jdk8u-dev-jdk   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 22
Project: jdk8u-dev-jdk   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 23
Project: heron   File: JVMMetrics.java   View source code 6 votes vote down vote up
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());
  }
}
 
Example 24
Project: jdk7-jdk   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 25
Project: tajo   File: QueryTestCaseBase.java   View source code 6 votes vote down vote up
@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()));
}
 
Example 26
Project: openjdk-source-code-learn   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 27
Project: OLD-OpenJDK8   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 28
Project: OLD-OpenJDK8   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 29
Project: JAVA_UNIT   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 30
Project: openjdk-jdk7u-jdk   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 31
Project: openjdk-jdk7u-jdk   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 32
Project: openjdk-icedtea7   File: Basic.java   View source code 6 votes vote down vote up
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");
}
 
Example 33
Project: openjdk-icedtea7   File: GetObjectName.java   View source code 6 votes vote down vote up
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");
                    }
                }
            }
        });
    }
}
 
Example 34
Project: openjdk-systemtest   File: EchoServer.java   View source code 5 votes vote down vote up
@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();
}
 
Example 35
Project: QDrill   File: MemoryIterator.java   View source code 5 votes vote down vote up
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.");
}
 
Example 36
Project: QDrill   File: DrillTest.java   View source code 5 votes vote down vote up
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;
}
 
Example 37
Project: jdk8u-jdk   File: TestMaxCachedBufferSize.java   View source code 5 votes vote down vote up
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");
}
 
Example 38
Project: openjdk-jdk10   File: TestMaxCachedBufferSize.java   View source code 5 votes vote down vote up
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");
}
 
Example 39
Project: dremio-oss   File: MemoryIterator.java   View source code 5 votes vote down vote up
/**
 * @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.");
}
 
Example 40
Project: dremio-oss   File: DremioTest.java   View source code 5 votes vote down vote up
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;
}