Examples of MemoryPoolMXBean


Examples of java.lang.management.MemoryPoolMXBean

        return PlatformMBeanDescriptions.getDescriptionOnlyOperation(locale, "reset-peak-usage", PlatformMBeanConstants.MEMORY_POOL);
    }

    private MemoryPoolMXBean getMemoryPoolMXBean(ModelNode operation) throws OperationFailedException {
        final String gcName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        MemoryPoolMXBean memoryPoolMXBean = null;

        for (MemoryPoolMXBean mbean : ManagementFactory.getMemoryPoolMXBeans()) {
            if (gcName.equals(escapeMBeanName(mbean.getName()))) {
                memoryPoolMXBean = mbean;
            }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

    @Override
    public void execute(OperationContext context, ModelNode operation) throws OperationFailedException {

        final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();

        MemoryPoolMXBean memoryPoolMXBean = MemoryPoolMXBeanAttributeHandler.getMemoryPoolMXBean(memPoolName);

        final ModelNode result = context.getResult();

        for (String attribute : PlatformMBeanConstants.MEMORY_POOL_READ_ATTRIBUTES) {
            final ModelNode store = result.get(attribute);
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

        try {
            if ((PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name))
                    || PlatformMBeanConstants.MEMORY_POOL_READ_ATTRIBUTES.contains(name)
                    || PlatformMBeanConstants.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name)
                    || PlatformMBeanConstants.MEMORY_POOL_METRICS.contains(name)) {
                MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName);
                storeResult(name, context.getResult(), memoryPoolMXBean, memPoolName);
            } else {
                // Shouldn't happen; the global handler should reject
                throw unknownAttribute(operation);
            }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

    @Override
    protected void executeWriteAttribute(OperationContext context, ModelNode operation) throws OperationFailedException {

        final String memPoolName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        MemoryPoolMXBean memoryPoolMXBean = getMemoryPoolMXBean(memPoolName);

        final String name = operation.require(ModelDescriptionConstants.NAME).asString();

        try {
            if (PlatformMBeanConstants.USAGE_THRESHOLD.equals(name)) {
                usageValidator.validate(operation);
                memoryPoolMXBean.setUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong());
            } else if (PlatformMBeanConstants.COLLECTION_USAGE_THRESHOLD.equals(name)) {
                usageValidator.validate(operation);
                memoryPoolMXBean.setCollectionUsageThreshold(operation.require(ModelDescriptionConstants.VALUE).asLong());
            } else if (PlatformMBeanConstants.MEMORY_POOL_READ_WRITE_ATTRIBUTES.contains(name)) {
                // Bug
                throw new IllegalStateException(String.format("Write support for attribute %s was not properly implemented", name));
            } else {
                // Shouldn't happen; the global handler should reject
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

      NumberFormat format = NumberFormat.getIntegerInstance();
      if (format instanceof DecimalFormat) {
        DecimalFormat decf = (DecimalFormat) format;
        decf.applyPattern(decf.toPattern() + " KB");
      }
      MemoryPoolMXBean memoryPoolMXBean = (MemoryPoolMXBean) handback;
      String message = "Threshold " +
              format.format(memoryPoolMXBean.getUsageThreshold() / 1024) +
              " for memory pool: " + memoryPoolMXBean.getName() +
              ", type: " + memoryPoolMXBean.getType().toString() +
              " exceeded.";
      sendWarningOut(message, handback);
    }
  }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

     */
    public void testNewPlatformMXBeanProxy_MemoryPoolMXBean() throws Exception {
        List<MemoryPoolMXBean> allBeans = ManagementFactory
                .getMemoryPoolMXBeans();
        for (MemoryPoolMXBean mb : allBeans) {
            MemoryPoolMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
                    ManagementFactory.getPlatformMBeanServer(),
                    "java.lang:type=MemoryPool,name=" + mb.getName(),
                    MemoryPoolMXBean.class);
            // Not doing an exhaustive check on properties...
            assertEquals(mb.getName(), proxy.getName());
            assertEquals(mb.isValid(), proxy.isValid());
            assertEquals(mb.getType(), proxy.getType());
            assertEquals(mb.isCollectionUsageThresholdSupported(), proxy
                    .isCollectionUsageThresholdSupported());
            String[] names1 = mb.getMemoryManagerNames();
            String[] names2 = mb.getMemoryManagerNames();
            assertEquals(names1.length, names2.length);
            for (int i = 0; i < names1.length; i++) {
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

    Iterator iter = ManagementFactory.getMemoryPoolMXBeans().iterator();

    while (iter.hasNext())
    {
      MemoryPoolMXBean item = (MemoryPoolMXBean) iter.next();
      String name = item.getName();

      try
      {
        AkteraJvmMemoryProbe probeUsage = new AkteraJvmMemoryProbe(name + "Usage", start, item.getUsage()
                .getMax());

        probeUsage.init(name + "Usage", start);
        probeUsage.startMeasurand(name + "Usage");
        probeUsage.measurand("Init", start, item.getUsage().getInit());
        probeUsage.measurand("Used", start, item.getUsage().getUsed());
        probeUsage.measurand("Committed", start, item.getUsage().getCommitted());
        probeUsage.measurand("Max", start, item.getUsage().getMax());
        probeUsage.commitMeasurand();
        probes.put(name + "Usage", probeUsage);

        AkteraJvmMemoryProbe probePeak = new AkteraJvmMemoryProbe(name + "Peak", start, item.getPeakUsage()
                .getMax());

        probePeak.init(name + "Peak", start);
        probePeak.startMeasurand(name + "Peak");
        probePeak.measurand("Init", start, item.getPeakUsage().getInit());
        probePeak.measurand("Used", start, item.getPeakUsage().getUsed());
        probePeak.measurand("Committed", start, item.getPeakUsage().getCommitted());
        probePeak.measurand("Max", start, item.getPeakUsage().getMax());
        probePeak.commitMeasurand();
        probes.put(name + "Peak", probePeak);

        if (item.getCollectionUsage() != null)
        {
          AkteraJvmMemoryProbe probeCollection = new AkteraJvmMemoryProbe(name + "Collection", start, item
                  .getCollectionUsage().getMax());

          probeCollection.init(name + "Collection", start);
          probeCollection.startMeasurand(name + "Collection");
          probeCollection.measurand("Init", start, item.getCollectionUsage().getInit());
          probeCollection.measurand("Used", start, item.getCollectionUsage().getUsed());
          probeCollection.measurand("Committed", start, item.getCollectionUsage().getCommitted());
          probeCollection.measurand("Max", start, item.getCollectionUsage().getMax());
          probeCollection.commitMeasurand();
          probes.put(name + "Collection", probeCollection);
        }
      }
      catch (IOException x)
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

  {
    Iterator iter = ManagementFactory.getMemoryPoolMXBeans().iterator();

    while (iter.hasNext())
    {
      MemoryPoolMXBean item = (MemoryPoolMXBean) iter.next();
      String name = item.getName();

      try
      {
        AkteraJvmMemoryProbe probeUsage = probes.get(name + "Usage");

        if (probeUsage != null)
        {
          probeUsage.startMeasurand(name + "Usage");
          probeUsage.measurand("Init", time, item.getUsage().getInit());
          probeUsage.measurand("Used", time, item.getUsage().getUsed());
          probeUsage.measurand("Committed", time, item.getUsage().getCommitted());
          probeUsage.measurand("Max", time, item.getUsage().getMax());
          probeUsage.commitMeasurand();
        }

        AkteraJvmMemoryProbe probePeak = probes.get(name + "Peak");

        if (probePeak != null)
        {
          probePeak.startMeasurand(name + "Peak");
          probePeak.measurand("Init", time, item.getPeakUsage().getInit());
          probePeak.measurand("Used", time, item.getPeakUsage().getUsed());
          probePeak.measurand("Committed", time, item.getPeakUsage().getCommitted());
          probePeak.measurand("Max", time, item.getPeakUsage().getMax());
          probePeak.commitMeasurand();
        }

        AkteraJvmMemoryProbe probeCollection = probes.get(name + "Collection");

        if (probeCollection != null)
        {
          probeCollection.startMeasurand(name + "Collection");
          probeCollection.measurand("Init", time, item.getCollectionUsage().getInit());
          probeCollection.measurand("Used", time, item.getCollectionUsage().getUsed());
          probeCollection.measurand("Committed", time, item.getCollectionUsage().getCommitted());
          probeCollection.measurand("Max", time, item.getCollectionUsage().getMax());
          probeCollection.commitMeasurand();
        }
      }
      catch (IOException x)
      {
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

    private static volatile SpillableMemoryManager manager;

    private SpillableMemoryManager() {
        ((NotificationEmitter)ManagementFactory.getMemoryMXBean()).addNotificationListener(this, null, null);
        List<MemoryPoolMXBean> mpbeans = ManagementFactory.getMemoryPoolMXBeans();
        MemoryPoolMXBean biggestHeap = null;
        long biggestSize = 0;
        long totalSize = 0;
        for (MemoryPoolMXBean b: mpbeans) {
            log.debug("Found heap (" + b.getName() +
                ") of type " + b.getType());
            if (b.getType() == MemoryType.HEAP) {
                /* Here we are making the leap of faith that the biggest
                 * heap is the tenured heap
                 */
                long size = b.getUsage().getMax();
                totalSize += size;
                if (size > biggestSize) {
                    biggestSize = size;
                    biggestHeap = b;
                }
            }
        }
        extraGCSpillSizeThreshold  = (long) (totalSize * extraGCThresholdFraction);
        if (biggestHeap == null) {
            throw new RuntimeException("Couldn't find heap");
        }
        log.debug("Selected heap to monitor (" +
            biggestHeap.getName() + ")");
       
        // we want to set both collection and usage threshold alerts to be
        // safe. In some local tests after a point only collection threshold
        // notifications were being sent though usage threshold notifications
        // were sent early on. So using both would ensure that
        // 1) we get notified early (though usage threshold exceeded notifications)
        // 2) we get notified always when threshold is exceeded (either usage or
        //    collection)
       
        /* We set the threshold to be 50% of tenured since that is where
         * the GC starts to dominate CPU time according to Sun doc */
        biggestHeap.setCollectionUsageThreshold((long)(biggestSize * collectionMemoryThresholdFraction));
        // we set a higher threshold for usage threshold exceeded notification
        // since this is more likely to be effective sooner and we do not
        // want to be spilling too soon
        biggestHeap.setUsageThreshold((long)(biggestSize * memoryThresholdFraction));
    }
View Full Code Here

Examples of java.lang.management.MemoryPoolMXBean

     */
    public void testNewPlatformMXBeanProxy_MemoryPoolMXBean() throws Exception {
        List<MemoryPoolMXBean> allBeans = ManagementFactory
                .getMemoryPoolMXBeans();
        for (MemoryPoolMXBean mb : allBeans) {
            MemoryPoolMXBean proxy = ManagementFactory.newPlatformMXBeanProxy(
                    ManagementFactory.getPlatformMBeanServer(),
                    "java.lang:type=MemoryPool,name=" + mb.getName(),
                    MemoryPoolMXBean.class);
            // Not doing an exhaustive check on properties...
            assertEquals(mb.getName(), proxy.getName());
            assertEquals(mb.isValid(), proxy.isValid());
            assertEquals(mb.getType(), proxy.getType());
            assertEquals(mb.isCollectionUsageThresholdSupported(), proxy
                    .isCollectionUsageThresholdSupported());
            String[] names1 = mb.getMemoryManagerNames();
            String[] names2 = mb.getMemoryManagerNames();
            assertEquals(names1.length, names2.length);
            for (int i = 0; i < names1.length; i++) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.