本文整理汇总了Java中java.lang.management.MemoryManagerMXBean类的典型用法代码示例。如果您正苦于以下问题:Java MemoryManagerMXBean类的具体用法?Java MemoryManagerMXBean怎么用?Java MemoryManagerMXBean使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
MemoryManagerMXBean类属于java.lang.management包,在下文中一共展示了MemoryManagerMXBean类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: updateTreeMap
import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
SnmpTableHandler mmHandler,
SnmpTableHandler mpHandler,
Map<String, SnmpOid> poolIndexMap) {
if (mmHandler instanceof SnmpCachedData) {
updateTreeMap(table,userData,(SnmpCachedData)mmHandler,
mpHandler,poolIndexMap);
return;
}
SnmpOid mmIndex=null;
while ((mmIndex = mmHandler.getNext(mmIndex))!=null) {
final MemoryManagerMXBean mmm =
(MemoryManagerMXBean)mmHandler.getData(mmIndex);
if (mmm == null) continue;
updateTreeMap(table,userData,mmm,mmIndex,poolIndexMap);
}
}
示例3: 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");
}
示例4: updateTreeMap
import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
protected void updateTreeMap(TreeMap<SnmpOid, Object> table, Object userData,
SnmpTableHandler mmHandler,
SnmpTableHandler mpHandler,
Map poolIndexMap) {
if (mmHandler instanceof SnmpCachedData) {
updateTreeMap(table,userData,(SnmpCachedData)mmHandler,
mpHandler,poolIndexMap);
return;
}
SnmpOid mmIndex=null;
while ((mmIndex = mmHandler.getNext(mmIndex))!=null) {
final MemoryManagerMXBean mmm =
(MemoryManagerMXBean)mmHandler.getData(mmIndex);
if (mmm == null) continue;
updateTreeMap(table,userData,mmm,mmIndex,poolIndexMap);
}
}
示例5: 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]);
}
示例6: addMemoryManagerBeanInfo
import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
/**
* Creates the metadata for the
* {@link java.lang.management.MemoryManagerMXBean}. For this type of
* platform bean the metadata covers :
* <ul>
* <li>3 attribute
* <li>0 constructors
* <li>0 operations
* <li>0 notifications
* </ul>
*
* @param map
*/
private static void addMemoryManagerBeanInfo(HashMap<String, MBeanInfo> map) {
// Attributes
MBeanAttributeInfo[] attributes = new MBeanAttributeInfo[3];
attributes[0] = new MBeanAttributeInfo("MemoryPoolNames",
"[Ljava.lang.String;", "MemoryPoolNames", true, false, false);
attributes[1] = new MBeanAttributeInfo("Name", String.class.getName(),
"Name", true, false, false);
attributes[2] = new MBeanAttributeInfo("Valid", Boolean.TYPE.getName(),
"Valid", true, false, true);
map.put(MemoryManagerMXBean.class.getName(), new MBeanInfo(
MemoryManagerMXBeanImpl.class.getName(),
MemoryManagerMXBeanImpl.class.getName(), attributes, null,
null, null));
}
示例7: getMemoryManagerNames
import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
public String[] getMemoryManagerNames() {
MemoryManagerMXBean[] mgrs = getMemoryManagers();
String[] names = new String[mgrs.length];
for (int i = 0; i < mgrs.length; i++) {
names[i] = mgrs[i].getName();
}
return names;
}
示例8: verifyThatMetaspaceMemoryManagerExists
import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
private static void verifyThatMetaspaceMemoryManagerExists() {
List<MemoryManagerMXBean> managers = ManagementFactory.getMemoryManagerMXBeans();
for (MemoryManagerMXBean manager : managers) {
if (manager.getName().equals("Metaspace Manager")) {
return;
}
}
throw new RuntimeException("Expected to find a metaspace memory manager");
}
示例9: doMemoryManagerMXBeanTest
import java.lang.management.MemoryManagerMXBean; //导入依赖的package包/类
private final int doMemoryManagerMXBeanTest(MBeanServerConnection mbsc) {
int errorCount = 0 ;
System.out.println("---- MemoryManagerMXBean") ;
try {
ObjectName filterName =
new ObjectName(ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE
+ ",*");
Set<ObjectName> onSet = mbsc.queryNames(filterName, null);
for (Iterator<ObjectName> iter = onSet.iterator(); iter.hasNext(); ) {
ObjectName memoryManagerName = iter.next() ;
System.out.println("-------- " + memoryManagerName) ;
MBeanInfo mbInfo = mbsc.getMBeanInfo(memoryManagerName);
System.out.println("getMBeanInfo\t\t" + mbInfo);
errorCount += checkNonEmpty(mbInfo);
MemoryManagerMXBean memoryManager = null;
memoryManager =
JMX.newMXBeanProxy(mbsc,
memoryManagerName,
MemoryManagerMXBean.class) ;
System.out.println("getMemoryPoolNames\t\t"
+ Arrays.deepToString(memoryManager.getMemoryPoolNames()));
System.out.println("getName\t\t"
+ memoryManager.getName());
System.out.println("isValid\t\t"
+ memoryManager.isValid());
}
System.out.println("---- OK\n") ;
} catch (Exception e) {
Utils.printThrowable(e, true) ;
errorCount++ ;
System.out.println("---- ERROR\n") ;
}
return errorCount ;
}