Package java.lang.management

Examples of java.lang.management.MemoryManagerMXBean


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

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

        MemoryManagerMXBean memoryManagerMXBean = null;

        for (MemoryManagerMXBean mbean : ManagementFactory.getMemoryManagerMXBeans()) {
            if (mmName.equals(escapeMBeanName(mbean.getName()))) {
                memoryManagerMXBean = mbean;
            }
        }

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

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


            // Not every memory manager will be registered with the server
            // connection. Only test those that are...
            if (ManagementFactory.getPlatformMBeanServer().isRegistered(
                    new ObjectName("java.lang:type=MemoryManager,name="
                            + mb.getName()))) {
                MemoryManagerMXBean proxy = ManagementFactory
                        .newPlatformMXBeanProxy(ManagementFactory
                                .getPlatformMBeanServer(),
                                "java.lang:type=MemoryManager,name="
                                        + mb.getName(),
                                MemoryManagerMXBean.class);
                assertEquals(mb.getName(), proxy.getName());
                assertEquals(mb.isValid(), proxy.isValid());
                String[] poolNames1 = mb.getMemoryPoolNames();
                String[] poolNames2 = proxy.getMemoryPoolNames();
                assertEquals(poolNames1.length, poolNames2.length);
                for (int i = 0; i < poolNames1.length; i++) {
                    String string = poolNames1[i];
                    assertEquals(poolNames1[i], poolNames2[i]);
                }
View Full Code Here

    public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
        List<GarbageCollectorMXBean> result = new LinkedList<GarbageCollectorMXBean>();
        Iterator<MemoryManagerMXBean> iter = getMemoryBean()
                .getMemoryManagerMXBeans().iterator();
        while (iter.hasNext()) {
            MemoryManagerMXBean b = iter.next();
            if (b instanceof GarbageCollectorMXBean) {
                result.add((GarbageCollectorMXBean) b);
            }
        }
        return result;
View Full Code Here

            // Not every memory manager will be registered with the server
            // connection. Only test those that are...
            if (ManagementFactory.getPlatformMBeanServer().isRegistered(
                    new ObjectName("java.lang:type=MemoryManager,name="
                            + mb.getName()))) {
                MemoryManagerMXBean proxy = ManagementFactory
                        .newPlatformMXBeanProxy(ManagementFactory
                                .getPlatformMBeanServer(),
                                "java.lang:type=MemoryManager,name="
                                        + mb.getName(),
                                MemoryManagerMXBean.class);
                assertEquals(mb.getName(), proxy.getName());
                assertEquals(mb.isValid(), proxy.isValid());
                String[] poolNames1 = mb.getMemoryPoolNames();
                String[] poolNames2 = proxy.getMemoryPoolNames();
                assertEquals(poolNames1.length, poolNames2.length);
                for (int i = 0; i < poolNames1.length; i++) {
                    assertEquals(poolNames1[i], poolNames2[i]);
                }
            }// end if memory manager is registered with server connection
View Full Code Here

    public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
        List<GarbageCollectorMXBean> result = new LinkedList<GarbageCollectorMXBean>();
        Iterator<MemoryManagerMXBean> iter = getMemoryBean()
                .getMemoryManagerMXBeans().iterator();
        while (iter.hasNext()) {
            MemoryManagerMXBean b = iter.next();
            if (b instanceof GarbageCollectorMXBean) {
                result.add((GarbageCollectorMXBean) b);
            }
        }
        return result;
View Full Code Here

        /* get the memory managers and check which of them manage this pool */
        Iterator<MemoryManagerMXBean> iter = memBean.getMemoryManagerMXBeans()
                .iterator();
        List<String> result = new LinkedList<String>();
        while (iter.hasNext()) {
            MemoryManagerMXBean bean = iter.next();
            String[] managedPools = bean.getMemoryPoolNames();
            for (int i = 0; i < managedPools.length; i++) {
                if (managedPools[i].equals(name)) {
                    result.add(bean.getName());
                    break;
                }
            }
        }
        return result.toArray(new String[0]);
View Full Code Here

    public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
        List<GarbageCollectorMXBean> result = new LinkedList<GarbageCollectorMXBean>();
        Iterator<MemoryManagerMXBean> iter = getMemoryBean()
                .getMemoryManagerMXBeans().iterator();
        while (iter.hasNext()) {
            MemoryManagerMXBean b = iter.next();
            if (b instanceof GarbageCollectorMXBean) {
                result.add((GarbageCollectorMXBean) b);
            }
        }
        return result;
View Full Code Here

        /* get the memory managers and check which of them manage this pool */
        Iterator<MemoryManagerMXBean> iter = memBean.getMemoryManagerMXBeans()
                .iterator();
        List<String> result = new LinkedList<String>();
        while (iter.hasNext()) {
            MemoryManagerMXBean bean = iter.next();
            String[] managedPools = bean.getMemoryPoolNames();
            for (int i = 0; i < managedPools.length; i++) {
                if (managedPools[i].equals(name)) {
                    result.add(bean.getName());
                    break;
                }
            }
        }
        return result.toArray(new String[0]);
View Full Code Here

    public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
        List<GarbageCollectorMXBean> result = new LinkedList<GarbageCollectorMXBean>();
        Iterator<MemoryManagerMXBean> iter = getMemoryBean()
                .getMemoryManagerMXBeans().iterator();
        while (iter.hasNext()) {
            MemoryManagerMXBean b = iter.next();
            if (b instanceof GarbageCollectorMXBean) {
                result.add((GarbageCollectorMXBean) b);
            }
        }
        return result;
View Full Code Here

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

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

        MemoryManagerMXBean memoryManagerMXBean = null;

        for (MemoryManagerMXBean mbean : ManagementFactory.getMemoryManagerMXBeans()) {
            if (mmName.equals(escapeMBeanName(mbean.getName()))) {
                memoryManagerMXBean = mbean;
            }
        }

        if (memoryManagerMXBean == null) {
            throw PlatformMBeanMessages.MESSAGES.unknownMemoryManager(mmName);
        }

        if (PlatformMBeanUtil.JVM_MAJOR_VERSION > 6 && PlatformMBeanConstants.OBJECT_NAME.equals(name)) {
            final String objName = PlatformMBeanUtil.getObjectNameStringWithNameKey(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE, mmName);
            context.getResult().set(objName);
        } else if (ModelDescriptionConstants.NAME.equals(name)) {
            context.getResult().set(escapeMBeanName(memoryManagerMXBean.getName()));
        } else if (PlatformMBeanConstants.VALID.equals(name)) {
            context.getResult().set(memoryManagerMXBean.isValid());
        } else if (PlatformMBeanConstants.MEMORY_POOL_NAMES.equals(name)) {
            final ModelNode result = context.getResult();
            result.setEmptyList();
            for (String pool : memoryManagerMXBean.getMemoryPoolNames()) {
                result.add(escapeMBeanName(pool));
            }
        } else if (PlatformMBeanConstants.MEMORY_MANAGER_READ_ATTRIBUTES.contains(name)) {
            // Bug
            throw PlatformMBeanMessages.MESSAGES.badReadAttributeImpl5(name);
View Full Code Here

TOP

Related Classes of java.lang.management.MemoryManagerMXBean

Copyright © 2018 www.massapicom. 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.