提交 4f8884de 编写于 作者: wu-sheng's avatar wu-sheng

[#558] Support new memory pool name of java8

上级 c7aff123
...@@ -29,27 +29,27 @@ public class CMSCollectorModule extends MemoryPoolModule { ...@@ -29,27 +29,27 @@ public class CMSCollectorModule extends MemoryPoolModule {
super(beans); super(beans);
} }
@Override protected String getPermName() { @Override protected String[] getPermNames() {
return "CMS Perm Gen"; return new String[] {"CMS Perm Gen"};
} }
@Override protected String getCodeCacheName() { @Override protected String[] getCodeCacheNames() {
return "Code Cache"; return new String[] {"Code Cache"};
} }
@Override protected String getEdenName() { @Override protected String[] getEdenNames() {
return "Par Eden Space"; return new String[] {"Par Eden Space"};
} }
@Override protected String getOldName() { @Override protected String[] getOldNames() {
return "CMS Old Gen"; return new String[] {"CMS Old Gen"};
} }
@Override protected String getSurvivorName() { @Override protected String[] getSurvivorNames() {
return "Par Survivor Space"; return new String[] {"Par Survivor Space"};
} }
@Override protected String getMetaspaceName() { @Override protected String[] getMetaspaceNames() {
return "Metaspace"; return new String[] {"Metaspace"};
} }
} }
...@@ -29,27 +29,27 @@ public class G1CollectorModule extends MemoryPoolModule { ...@@ -29,27 +29,27 @@ public class G1CollectorModule extends MemoryPoolModule {
super(beans); super(beans);
} }
@Override protected String getPermName() { @Override protected String[] getPermNames() {
return "G1 Perm Gen"; return new String[] {"G1 Perm Gen"};
} }
@Override protected String getCodeCacheName() { @Override protected String[] getCodeCacheNames() {
return "Code Cache"; return new String[] {"Code Cache"};
} }
@Override protected String getEdenName() { @Override protected String[] getEdenNames() {
return "G1 Eden Space"; return new String[] {"G1 Eden Space"};
} }
@Override protected String getOldName() { @Override protected String[] getOldNames() {
return "G1 Old Gen"; return new String[] {"G1 Old Gen"};
} }
@Override protected String getSurvivorName() { @Override protected String[] getSurvivorNames() {
return "G1 Survivor Space"; return new String[] {"G1 Survivor Space"};
} }
@Override protected String getMetaspaceName() { @Override protected String[] getMetaspaceNames() {
return "Metaspace"; return new String[] {"Metaspace"};
} }
} }
...@@ -40,18 +40,18 @@ public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor { ...@@ -40,18 +40,18 @@ public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor {
List<MemoryPool> poolList = new LinkedList<MemoryPool>(); List<MemoryPool> poolList = new LinkedList<MemoryPool>();
for (MemoryPoolMXBean bean : beans) { for (MemoryPoolMXBean bean : beans) {
String name = bean.getName(); String name = bean.getName();
PoolType type = null; PoolType type;
if (name.equals(getCodeCacheName())) { if (contains(getCodeCacheNames(), name)) {
type = PoolType.CODE_CACHE_USAGE; type = PoolType.CODE_CACHE_USAGE;
} else if (name.equals(getEdenName())) { } else if (contains(getEdenNames(), name)) {
type = PoolType.NEWGEN_USAGE; type = PoolType.NEWGEN_USAGE;
} else if (name.equals(getOldName())) { } else if (contains(getOldNames(), name)) {
type = PoolType.OLDGEN_USAGE; type = PoolType.OLDGEN_USAGE;
} else if (name.equals(getSurvivorName())) { } else if (contains(getSurvivorNames(), name)) {
type = PoolType.SURVIVOR_USAGE; type = PoolType.SURVIVOR_USAGE;
} else if (name.equals(getMetaspaceName())) { } else if (contains(getMetaspaceNames(), name)) {
type = PoolType.METASPACE_USAGE; type = PoolType.METASPACE_USAGE;
} else if (name.equals(getPermName())) { } else if (contains(getPermNames(), name)) {
type = PoolType.PERMGEN_USAGE; type = PoolType.PERMGEN_USAGE;
} else { } else {
continue; continue;
...@@ -68,15 +68,24 @@ public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor { ...@@ -68,15 +68,24 @@ public abstract class MemoryPoolModule implements MemoryPoolMetricAccessor {
return poolList; return poolList;
} }
protected abstract String getPermName(); private boolean contains(String[] possibleNames, String name) {
for (String possibleName : possibleNames) {
if (name.equals(possibleName)) {
return true;
}
}
return false;
}
protected abstract String[] getPermNames();
protected abstract String getCodeCacheName(); protected abstract String[] getCodeCacheNames();
protected abstract String getEdenName(); protected abstract String[] getEdenNames();
protected abstract String getOldName(); protected abstract String[] getOldNames();
protected abstract String getSurvivorName(); protected abstract String[] getSurvivorNames();
protected abstract String getMetaspaceName(); protected abstract String[] getMetaspaceNames();
} }
...@@ -30,27 +30,27 @@ public class ParallelCollectorModule extends MemoryPoolModule { ...@@ -30,27 +30,27 @@ public class ParallelCollectorModule extends MemoryPoolModule {
super(beans); super(beans);
} }
@Override protected String getPermName() { @Override protected String[] getPermNames() {
return "PS Perm Gen"; return new String[] {"PS Perm Gen", "Compressed Class Space"};
} }
@Override protected String getCodeCacheName() { @Override protected String[] getCodeCacheNames() {
return "Code Cache"; return new String[] {"Code Cache"};
} }
@Override protected String getEdenName() { @Override protected String[] getEdenNames() {
return "PS Eden Space"; return new String[] {"PS Eden Space"};
} }
@Override protected String getOldName() { @Override protected String[] getOldNames() {
return "PS Old Gen"; return new String[] {"PS Old Gen"};
} }
@Override protected String getSurvivorName() { @Override protected String[] getSurvivorNames() {
return "PS Survivor Space"; return new String[] {"PS Survivor Space"};
} }
@Override protected String getMetaspaceName() { @Override protected String[] getMetaspaceNames() {
return "Metaspace"; return new String[] {"Metaspace"};
} }
} }
...@@ -29,27 +29,27 @@ public class SerialCollectorModule extends MemoryPoolModule { ...@@ -29,27 +29,27 @@ public class SerialCollectorModule extends MemoryPoolModule {
super(beans); super(beans);
} }
@Override protected String getPermName() { @Override protected String[] getPermNames() {
return "Perm Gen"; return new String[] {"Perm Gen"};
} }
@Override protected String getCodeCacheName() { @Override protected String[] getCodeCacheNames() {
return "Code Cache"; return new String[] {"Code Cache"};
} }
@Override protected String getEdenName() { @Override protected String[] getEdenNames() {
return "Eden Space"; return new String[] {"Eden Space"};
} }
@Override protected String getOldName() { @Override protected String[] getOldNames() {
return "Tenured Gen"; return new String[] {"Tenured Gen"};
} }
@Override protected String getSurvivorName() { @Override protected String[] getSurvivorNames() {
return "Survivor Space"; return new String[] {"Survivor Space"};
} }
@Override protected String getMetaspaceName() { @Override protected String[] getMetaspaceNames() {
return "Metaspace"; return new String[] {"Metaspace"};
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册