Skip to content

Commit

Permalink
JDK17升级-Lombok版本、ByteBuddy版本、Shenandoah收集器
Browse files Browse the repository at this point in the history
  • Loading branch information
TangLeDaily committed Sep 4, 2023
1 parent a023e50 commit 4351a0f
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 18 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<xerces.version>2.12.1</xerces.version>
<snake.yaml.version>1.32</snake.yaml.version>
<zookeeper.version>3.6.3</zookeeper.version>
<lombok.version>1.18.10</lombok.version>
<lombok.version>1.18.22</lombok.version>
<asm.version>8.0.1</asm.version>
<common.io.version>1.3.2</common.io.version>
<org.jacoco.version>0.8.8</org.jacoco.version>
Expand Down
2 changes: 1 addition & 1 deletion sermant-agentcore/sermant-agentcore-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
<sermant.basedir>${pom.basedir}/../..</sermant.basedir>
<package.temp.dir>${sermant.basedir}/${sermant.name}-${project.version}</package.temp.dir>

<byte.buddy.version>1.10.14</byte.buddy.version>
<byte.buddy.version>1.10.21</byte.buddy.version>

<shade.plugin.version>3.2.4</shade.plugin.version>
<source.plugin.version>3.0.1</source.plugin.version>
Expand Down
2 changes: 1 addition & 1 deletion sermant-backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<io.netty.version>4.1.86.Final</io.netty.version>
<spring-boot.version>2.6.1</spring-boot.version>
<protobuf-java.version>3.9.1</protobuf-java.version>
<lombok.version>1.18.12</lombok.version>
<lombok.version>1.18.22</lombok.version>
<fastjson.version>1.2.83</fastjson.version>
<commons-lang.version>2.6</commons-lang.version>
<junit.version>4.13.1</junit.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class MonitorTest {

private static final int JDK9_VERSION_INDEX = 9;

private static final int JDK12_VERSION_INDEX = 12;

private static final Set<String> JDK8_MONOPOLIZE_INDEX_SET = new HashSet<>(
Arrays.asList("code_cache_init", "code_cache_max",
"code_cache_used", "code_cache_committed"));
Expand All @@ -65,6 +67,10 @@ public class MonitorTest {
"epsilon_heap_init", "epsilon_heap_max",
"epsilon_heap_used", "epsilon_heap_committed"));

private static final Set<String> JDK12PLUS_MONOPOLIZE_INDEX_SET = new HashSet<>(
Arrays.asList("shenandoah_init", "shenandoah_used",
"shenandoah_max", "shenandoah_committed"));

@Test
public void testMonitor() {
String string = RequestUtils.get(URL, new HashMap<>(), String.class);
Expand All @@ -81,23 +87,33 @@ public void testMonitor() {
}
}
Assert.notEmpty(map, "解析响应结果获取指标信息失败");
final int javaVersion = getJavaVersion();
for (MetricEnum metricEnum : MetricEnum.values()) {
String metricEnumName = metricEnum.getName();
// 当JDK大于8时,JDK8独有的指标则忽略
if (javaVersionGreaterThanJDK8() && JDK8_MONOPOLIZE_INDEX_SET.contains(metricEnumName)) {
// 当JDK小于等于8时,JDK9及以上版本独有的指标则忽略
if (javaVersion < JDK9_VERSION_INDEX
&& (JDK9PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName)
|| JDK12PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName))) {
continue;
}
// 当JDK小于等于8时,JDK9及以上版本独有的指标则忽略
if (!javaVersionGreaterThanJDK8() && JDK9PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName)) {
// 当JDK大于8小于12时,JDK8独有的指标和JDK12及以上版本独有的指标则忽略
if (javaVersion >= JDK9_VERSION_INDEX && javaVersion < JDK12_VERSION_INDEX
&& (JDK8_MONOPOLIZE_INDEX_SET.contains(metricEnumName)
|| JDK12PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName))) {
continue;
}
// 当JDK大于等于12时,JDK8独有的指标则忽略(仍然包含JDK9PLUS的指标)
if (javaVersion >= JDK12_VERSION_INDEX
&& JDK8_MONOPOLIZE_INDEX_SET.contains(metricEnumName)) {
continue;
}
Assert.isTrue(map.containsKey(metricEnumName), "缺少指标信息" + metricEnumName);
}
}

private boolean javaVersionGreaterThanJDK8() {
private int getJavaVersion() {
String javaVersion[] = System.getProperty("java.version").split("\\.");
return Integer.valueOf(javaVersion[0]) >= JDK9_VERSION_INDEX;
return Integer.valueOf(javaVersion[0]);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public class MonitorTest {

private static final int JDK9_VERSION_INDEX = 9;

private static final int JDK12_VERSION_INDEX = 12;

private static final Set<String> JDK8_MONOPOLIZE_INDEX_SET = new HashSet<>(
Arrays.asList("code_cache_init", "code_cache_max",
"code_cache_used", "code_cache_committed"));
Expand All @@ -65,6 +67,10 @@ public class MonitorTest {
"epsilon_heap_init", "epsilon_heap_max",
"epsilon_heap_used", "epsilon_heap_committed"));

private static final Set<String> JDK12PLUS_MONOPOLIZE_INDEX_SET = new HashSet<>(
Arrays.asList("shenandoah_init", "shenandoah_used",
"shenandoah_max", "shenandoah_committed"));

@Test
public void testMonitor() {
String string = RequestUtils.get(URL, new HashMap<>(), String.class);
Expand All @@ -81,23 +87,32 @@ public void testMonitor() {
}
}
Assertions.assertFalse(map.isEmpty(), "解析响应结果获取指标信息失败");
final int javaVersion = getJavaVersion();
for (MetricEnum metricEnum : MetricEnum.values()) {
String metricEnumName = metricEnum.getName();
// 当JDK大于8时,JDK8独有的指标则忽略
if (javaVersionGreaterThanJDK8() && JDK8_MONOPOLIZE_INDEX_SET.contains(metricEnumName)) {
// 当JDK小于等于8时,JDK9及以上版本独有的指标则忽略
if (javaVersion < JDK9_VERSION_INDEX
&& (JDK9PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName)
|| JDK12PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName))) {
continue;
}
// 当JDK小于等于8时,JDK9及以上版本独有的指标则忽略
if (!javaVersionGreaterThanJDK8() && JDK9PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName)) {
// 当JDK大于8小于12时,JDK8独有的指标和JDK12及以上版本独有的指标则忽略
if (javaVersion >= JDK9_VERSION_INDEX && javaVersion < JDK12_VERSION_INDEX
&& (JDK8_MONOPOLIZE_INDEX_SET.contains(metricEnumName)
|| JDK12PLUS_MONOPOLIZE_INDEX_SET.contains(metricEnumName))) {
continue;
}
// 当JDK大于等于12时,JDK8独有的指标则忽略(仍然包含JDK9PLUS的指标)
if (javaVersion >= JDK12_VERSION_INDEX && JDK8_MONOPOLIZE_INDEX_SET.contains(metricEnumName)) {
continue;
}
Assertions.assertTrue(map.containsKey(metricEnumName), "缺少指标信息" + metricEnumName);
}
}

private boolean javaVersionGreaterThanJDK8() {
private int getJavaVersion() {
String javaVersion[] = System.getProperty("java.version").split("\\.");
return Integer.valueOf(javaVersion[0]) >= JDK9_VERSION_INDEX;
return Integer.valueOf(javaVersion[0]);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,14 @@ public enum MemoryType {
*/
EPSILON_HEAP("Epsilon Heap", MetricEnum.EPSILON_HEAP_INIT, MetricEnum.EPSILON_HEAP_USED,
MetricEnum.EPSILON_HEAP_MAX,
MetricEnum.EPSILON_HEAP_COMMITTED);
MetricEnum.EPSILON_HEAP_COMMITTED),

/**
* JDK17的Shenandoah收集器指标枚举
*/
SHENANDOAH("Shenandoah", MetricEnum.SHENANDOAH_INIT, MetricEnum.SHENANDOAH_USED,
MetricEnum.SHENANDOAH_MAX,
MetricEnum.SHENANDOAH_COMMITTED);

/**
* 类型
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,27 @@ public enum MetricEnum {
/**
* JDK11的Epsilon收集器提交值
*/
EPSILON_HEAP_COMMITTED("epsilon_heap_committed", "the number is committed of Epsilon Heap");
EPSILON_HEAP_COMMITTED("epsilon_heap_committed", "the number is committed of Epsilon Heap"),

/**
* JDK17的Shenandoah收集器初始值
*/
SHENANDOAH_INIT("shenandoah_init", "the number is init of Shenandoah"),

/**
* JDK17的Shenandoah收集器使用值
*/
SHENANDOAH_USED("shenandoah_used", "the number is used of Shenandoah"),

/**
* JDK17的Shenandoah收集器最大值
*/
SHENANDOAH_MAX("shenandoah_max", "the number is max of Shenandoah"),

/**
* JDK17的Shenandoah收集器提交值
*/
SHENANDOAH_COMMITTED("shenandoah_committed", "the number is committed of Shenandoah");

/**
* 名称
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
*/
public class JvmCollectorService extends SwitchService implements PluginService {
private static final Set<String> NEW_GEN_NAME_SET = new HashSet<>(Arrays.asList("PS Scavenge", "ParNew", "Copy",
"G1 Young Generation", "ZGC Cycles"));
"G1 Young Generation", "ZGC Cycles", "Shenandoah Cycles"));

/**
* JDK11中不分代的Epsilon GC的名称
Expand Down

0 comments on commit 4351a0f

Please sign in to comment.