当前位置: 首页>>代码示例>>Java>>正文


Java MemoryManagerMXBean.getMemoryPoolNames方法代码示例

本文整理汇总了Java中java.lang.management.MemoryManagerMXBean.getMemoryPoolNames方法的典型用法代码示例。如果您正苦于以下问题:Java MemoryManagerMXBean.getMemoryPoolNames方法的具体用法?Java MemoryManagerMXBean.getMemoryPoolNames怎么用?Java MemoryManagerMXBean.getMemoryPoolNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.management.MemoryManagerMXBean的用法示例。


在下文中一共展示了MemoryManagerMXBean.getMemoryPoolNames方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getMemoryPools

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
/**
 * Get the list of memory pool associated with the
 * given MemoryManagerMXBean.
 **/
protected String[] getMemoryPools(Object userData,
                              MemoryManagerMXBean mmm, long mmarc) {
    final String listTag =
        "JvmMemManager." + mmarc + ".getMemoryPools";

    String[] result=null;
    if (userData instanceof Map) {
        result = (String[])((Map)userData).get(listTag);
        if (result != null) return result;
    }

    if (mmm!=null) {
        result = mmm.getMemoryPoolNames();
    }
    if ((result!=null)&&(userData instanceof Map)) {
        Map<Object, Object> map = Util.cast(userData);
        map.put(listTag,result);
    }

    return result;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:JvmMemMgrPoolRelTableMetaImpl.java

示例2: runTest

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
protected void runTest() {
    List<MemoryManagerMXBean> beans
            = ManagementFactory.getMemoryManagerMXBeans();
    Optional<MemoryManagerMXBean> any = beans
            .stream()
            .filter(bean -> CC_MANAGER.equals(bean.getName()))
            .findAny();
    Asserts.assertTrue(any.isPresent(), "Bean not found: " + CC_MANAGER);
    MemoryManagerMXBean ccManager = any.get();
    Asserts.assertNotNull(ccManager, "Found null for " + CC_MANAGER);
    String names[] = ccManager.getMemoryPoolNames();
    for (String name : names) {
        counters.put(name, counters.containsKey(name)
                ? counters.get(name) + 1 : 1);
    }
    for (BlobType btype : BlobType.getAvailable()) {
        Asserts.assertEQ(counters.get(btype.getMemoryPool().getName()), 1,
                "Found unexpected amount of beans for pool "
                + btype.getMemoryPool().getName());
    }
    Asserts.assertEQ(BlobType.getAvailable().size(),
            counters.keySet().size(), "Unexpected amount of bean names");
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:MemoryPoolsPresenceTest.java

示例3: getMemoryManagerNames

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
public String[] getMemoryManagerNames() {
    /* 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]);
}
 
开发者ID:shannah,项目名称:cn1,代码行数:18,代码来源:MemoryPoolMXBeanImpl.java

示例4: displayManagementBean

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
private String displayManagementBean(MemoryManagerMXBean mxBean) {
    StringBuilder sb = new StringBuilder();
    if (mxBean != null) {
        Generics.StringArrayList memoryPoolNames = new Generics.StringArrayList(mxBean.getMemoryPoolNames());
        sb.append("Memory Manager:\t").append(mxBean.getName()).append("\n");
        sb.append("Pool names:\t").append(memoryPoolNames).append('\n');
    }
    return sb.toString();
}
 
开发者ID:jwoehr,项目名称:ublu,代码行数:10,代码来源:JVMHelper.java

示例5: testNewPlatformMXBeanProxy_MemoryManagerMXBean

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
public void testNewPlatformMXBeanProxy_MemoryManagerMXBean()
        throws Exception {
    List<MemoryManagerMXBean> allBeans = ManagementFactory
            .getMemoryManagerMXBeans();
    for (MemoryManagerMXBean mb : allBeans) {
        // 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
    }// end for all known memory manager beans
}
 
开发者ID:shannah,项目名称:cn1,代码行数:28,代码来源:ManagementFactoryTest.java

示例6: testGetMemoryPoolNames

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
public void testGetMemoryPoolNames() {
    for (MemoryManagerMXBean mb : allBeans) {
        String[] managedPools = mb.getMemoryPoolNames();
        assertNotNull(managedPools);
        for (String poolName : managedPools) {
            assertNotNull(poolName);
            assertTrue(poolName.length() > 0);
        }// end for all managed pools
    }// end for all garbage collector beans
}
 
开发者ID:shannah,项目名称:cn1,代码行数:11,代码来源:MemoryManagerMXBeanTest.java

示例7: executeReadAttribute

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
@Override
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 PlatformMBeanLogger.ROOT_LOGGER.unknownMemoryManager(mmName);
    }

    if (PlatformMBeanConstants.OBJECT_NAME.getName().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.getName().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 (MemoryManagerResourceDefinition.MEMORY_MANAGER_READ_ATTRIBUTES.contains(name)) {
        // Bug
        throw PlatformMBeanLogger.ROOT_LOGGER.badReadAttributeImpl(name);
    } else {
        // Shouldn't happen; the global handler should reject
        throw unknownAttribute(operation);
    }

}
 
开发者ID:wildfly,项目名称:wildfly-core,代码行数:41,代码来源:MemoryManagerMXBeanAttributeHandler.java

示例8: testNewPlatformMXBeanProxy_MemoryManagerMXBean

import java.lang.management.MemoryManagerMXBean; //导入方法依赖的package包/类
public void testNewPlatformMXBeanProxy_MemoryManagerMXBean()
        throws Exception {
    List<MemoryManagerMXBean> allBeans = ManagementFactory
            .getMemoryManagerMXBeans();
    for (MemoryManagerMXBean mb : allBeans) {
        // 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]);
            }
        }// end if memory manager is registered with server connection
    }// end for all known memory manager beans
}
 
开发者ID:freeVM,项目名称:freeVM,代码行数:29,代码来源:ManagementFactoryTest.java


注:本文中的java.lang.management.MemoryManagerMXBean.getMemoryPoolNames方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。