Examples of GarbageCollectorMXBean


Examples of com.sun.management.GarbageCollectorMXBean

        try
        {
            ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
            for (ObjectName name : server.queryNames(gcName, null))
            {
                GarbageCollectorMXBean gc = ManagementFactory.newPlatformMXBeanProxy(server, name.getCanonicalName(), GarbageCollectorMXBean.class);
                beans.add(gc);
            }
        }
        catch (Exception e)
        {
View Full Code Here

Examples of com.sun.management.GarbageCollectorMXBean

        try
        {
            ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
            for (ObjectName name : server.queryNames(gcName, null))
            {
                GarbageCollectorMXBean gc = ManagementFactory.newPlatformMXBeanProxy(server, name.getCanonicalName(), GarbageCollectorMXBean.class);
                beans.add(gc);
            }
        }
        catch (Exception e)
        {
View Full Code Here

Examples of com.sun.management.GarbageCollectorMXBean

        try
        {
            ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
            for (ObjectName name : server.queryNames(gcName, null))
            {
                GarbageCollectorMXBean gc = ManagementFactory.newPlatformMXBeanProxy(server, name.getCanonicalName(), GarbageCollectorMXBean.class);
                beans.add(gc);
            }
        }
        catch (Exception e)
        {
View Full Code Here

Examples of com.sun.management.GarbageCollectorMXBean

            afterGcUsage = lastGcInfo.getMemoryUsageAfterGc().get(poolName);
        }

        Set<Map.Entry<ObjectName,Long>> set = gcMBeans.entrySet();
        for (Map.Entry<ObjectName,Long> e : set) {
            GarbageCollectorMXBean gc =
                client.getMXBean(e.getKey(),
                                 com.sun.management.GarbageCollectorMXBean.class);
            Long gcCount = e.getValue();
            Long newCount = gc.getCollectionCount();
            if (newCount > gcCount) {
                gcMBeans.put(e.getKey(), new Long(newCount));
                lastGcInfo = gc.getLastGcInfo();
                if (lastGcInfo.getEndTime() > lastGcEndTime) {
                    gcId = lastGcInfo.getId();
                    lastGcStartTime = lastGcInfo.getStartTime();
                    lastGcEndTime = lastGcInfo.getEndTime();
                    beforeGcUsage = lastGcInfo.getMemoryUsageBeforeGc().get(poolName);
View Full Code Here

Examples of com.sun.management.GarbageCollectorMXBean

        System.gc();
        List mgrs = ManagementFactory.getGarbageCollectorMXBeans();
        for (ListIterator iter = mgrs.listIterator(); iter.hasNext(); ) {
            Object mgr = iter.next();
            if (mgr instanceof GarbageCollectorMXBean) {
                GarbageCollectorMXBean gc = (GarbageCollectorMXBean) mgr;
                GcInfo info = gc.getLastGcInfo();
                if (info != null) {
                    checkGcInfo(gc.getName(), info);
                    hasGcInfo = true;
                }
            }
        }
View Full Code Here

Examples of java.lang.management.GarbageCollectorMXBean

    if (config.containsKey("wrapper.java.monitor.gc"))
    try
    {
      final MessageFormat format = new MessageFormat(config.getString("wrapper.java.monitor.gc"));
      final long cycle = config.getLong("wrapper.java.monitor.gc.interval", 1)*1000;
      GarbageCollectorMXBean minorGCBeanX = null;
      GarbageCollectorMXBean fullGCBeanX = null;
      List<GarbageCollectorMXBean> gcMBeans = ManagementFactory.getGarbageCollectorMXBeans();

         for (GarbageCollectorMXBean gcBean : gcMBeans) {
             if ("Copy".equals(gcBean.getName())) {
                 minorGCBeanX = gcBean;
             } else if ("MarkSweepCompact".equals(gcBean.getName())) {
                 fullGCBeanX = gcBean;
             } else if ("ParNew".equals(gcBean.getName())) {
                 minorGCBeanX = gcBean;
             } else if ("ConcurrentMarkSweep".equals(gcBean.getName())) {
                 fullGCBeanX = gcBean;
             } else {
                 System.err.println("Unable to classify GarbageCollectorMXBean [" + gcBean.getName() + "]");
             }
         }
      final GarbageCollectorMXBean minorGCBean = minorGCBeanX;
      final GarbageCollectorMXBean fullGCBean = fullGCBeanX;
      final MemoryMXBean bean = ManagementFactory.getMemoryMXBean();

      System.err.println("monitor gc: start");
      executor.execute(new Runnable()
      {
        private long lastMinorCollectionCount;
        private long lastMinorCollectionTime;

        private long lastFullCollectionCount;
        private long lastFullCollectionTime;
       
        Long usedHeap = null;
        Long timeMinorGC = null;
        Long timeFullGC = null;

        public void run()
        {
          if (minorGCBean == null)
          {
            System.err.println("monitor gc: could not find minorGCBean -> abort monitor");
            return;
          }
          if (fullGCBean == null)
          {
            System.err.println("monitor gc: could not find fullGCBean -> abort monitor");
            return;
          }
          try
          {
            while (!_stopping)
          {
            if (minorGCBean.getCollectionCount() != lastMinorCollectionCount) {
                       long diffCount = minorGCBean.getCollectionCount() - lastMinorCollectionCount;
                       long diffTime = minorGCBean.getCollectionTime() - lastMinorCollectionTime;
                       if (diffCount!= 0 && diffCount != 1)
                         timeMinorGC = diffTime/diffCount;
                       else
                         timeMinorGC = diffTime;
                       usedHeap = bean.getHeapMemoryUsage().getUsed();
                 
                       lastMinorCollectionCount = minorGCBean.getCollectionCount();
                       lastMinorCollectionTime = minorGCBean.getCollectionTime();
                   }
             
                   if (fullGCBean.getCollectionCount() != lastFullCollectionCount) {
                       long diffCount = fullGCBean.getCollectionCount() - lastFullCollectionCount;
                       long diffTime = fullGCBean.getCollectionTime() - lastFullCollectionTime;
                       if (diffCount!= 0 && diffCount != 1)
                         timeFullGC = diffTime/diffCount;
                       else
                         timeFullGC = diffTime;
                       usedHeap = bean.getHeapMemoryUsage().getUsed();
                 
                       lastFullCollectionCount = fullGCBean.getCollectionCount();
                       lastFullCollectionTime = fullGCBean.getCollectionTime();
                   }
                   if (usedHeap != null)
                   {
                     if (timeMinorGC == null)
                       timeMinorGC = 0L;
View Full Code Here

Examples of java.lang.management.GarbageCollectorMXBean

        try
        {
            ObjectName gcName = new ObjectName(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",*");
            for (ObjectName name : server.queryNames(gcName, null))
            {
                GarbageCollectorMXBean gc = ManagementFactory.newPlatformMXBeanProxy(server, name.getCanonicalName(), GarbageCollectorMXBean.class);
                beans.add(gc);
            }
        }
        catch (Exception e)
        {
View Full Code Here

Examples of java.lang.management.GarbageCollectorMXBean

    protected void executeReadAttribute(OperationContext context, ModelNode operation) throws OperationFailedException {

        final String gcName = PathAddress.pathAddress(operation.require(ModelDescriptionConstants.OP_ADDR)).getLastElement().getValue();
        final String name = operation.require(ModelDescriptionConstants.NAME).asString();

        GarbageCollectorMXBean gcMBean = null;

        for (GarbageCollectorMXBean mbean : ManagementFactory.getGarbageCollectorMXBeans()) {
            if (gcName.equals(escapeMBeanName(mbean.getName()))) {
                gcMBean = mbean;
            }
        }

        if (gcMBean == null) {
            throw new OperationFailedException(new ModelNode().set(String.format("No GarbageCollectorMXBean with name %s currently exists", gcName)));
        }

        if (PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name)) {
            final String objName = PlatformMBeanUtil.getObjectNameStringWithNameKey(ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE, gcName);
            context.getResult().set(objName);
        } else if (ModelDescriptionConstants.NAME.equals(name)) {
            context.getResult().set(escapeMBeanName(gcMBean.getName()));
        } else if (PlatformMBeanConstants.VALID.equals(name)) {
            context.getResult().set(gcMBean.isValid());
        } else if (PlatformMBeanConstants.MEMORY_POOL_NAMES.equals(name)) {
            final ModelNode result = context.getResult();
            result.setEmptyList();
            for (String pool : gcMBean.getMemoryPoolNames()) {
                result.add(escapeMBeanName(pool));
            }
        } else if (PlatformMBeanConstants.COLLECTION_COUNT.equals(name)) {
            context.getResult().set(gcMBean.getCollectionCount());
        } else if (PlatformMBeanConstants.COLLECTION_TIME.equals(name)) {
            context.getResult().set(gcMBean.getCollectionTime());
        } else if (PlatformMBeanConstants.GARBAGE_COLLECTOR_READ_ATTRIBUTES.contains(name)
                || PlatformMBeanConstants.GARBAGE_COLLECTOR_METRICS.contains(name)) {
            // Bug
            throw new IllegalStateException(String.format("Read support for attribute %s was not properly implemented", name));
        } else {
View Full Code Here

Examples of java.lang.management.GarbageCollectorMXBean

        List<GarbageCollectorMXBean> gcMxBeans = ManagementFactory.getGarbageCollectorMXBeans();
        stats.gc = new GarbageCollectors();
        stats.gc.collectors = new GarbageCollector[gcMxBeans.size()];
        for (int i = 0; i < stats.gc.collectors.length; i++) {
            GarbageCollectorMXBean gcMxBean = gcMxBeans.get(i);
            stats.gc.collectors[i] = new GarbageCollector();
            stats.gc.collectors[i].name = gcMxBean.getName();
            stats.gc.collectors[i].collectionCount = gcMxBean.getCollectionCount();
            stats.gc.collectors[i].collectionTime = gcMxBean.getCollectionTime();
            if (enableLastGc) {
                try {
                    Object lastGcInfo = getLastGcInfoMethod.invoke(gcMxBean);
                    if (lastGcInfo != null) {
                        Map<String, MemoryUsage> usageBeforeGc = (Map<String, MemoryUsage>) getMemoryUsageBeforeGcMethod.invoke(lastGcInfo);
View Full Code Here

Examples of java.lang.management.GarbageCollectorMXBean

    List<GarbageCollectorMXBean> garbageCollectorMXBeans = ManagementFactory.getGarbageCollectorMXBeans();
    for (GarbageCollectorMXBean bean : garbageCollectorMXBeans) {
      NotificationListener listener = new NotificationListener() {
        @Override
        public void handleNotification(Notification notification, Object bean) {
          GarbageCollectorMXBean garbageCollectorMXBean = (GarbageCollectorMXBean) bean;
          GcInfo gcInfo = getGcInfo(garbageCollectorMXBean);
          long startTime = gcInfo.getStartTime();
          long endTime = gcInfo.getEndTime();
          Map<String, MemoryUsage> usageBeforeGc = gcInfo.getMemoryUsageBeforeGc();
          Map<String, MemoryUsage> usageAfterGc = gcInfo.getMemoryUsageAfterGc();
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.