From 4351a0fad948b8cd99674712226e8d96bb54a63b Mon Sep 17 00:00:00 2001 From: TLPC <470193496@qq.com> Date: Mon, 28 Aug 2023 15:08:37 +0800 Subject: [PATCH] =?UTF-8?q?JDK17=E5=8D=87=E7=BA=A7-Lombok=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E3=80=81ByteBuddy=E7=89=88=E6=9C=AC=E3=80=81Shenandoa?= =?UTF-8?q?h=E6=94=B6=E9=9B=86=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 2 +- .../sermant-agentcore-core/pom.xml | 2 +- sermant-backend/pom.xml | 2 +- .../integration/monitor/MonitorTest.java | 28 +++++++++++++++---- .../intergration/monitor/MonitorTest.java | 27 ++++++++++++++---- .../com/huawei/monitor/common/MemoryType.java | 9 +++++- .../com/huawei/monitor/common/MetricEnum.java | 22 ++++++++++++++- .../collector/JvmCollectorService.java | 2 +- 8 files changed, 76 insertions(+), 18 deletions(-) diff --git a/pom.xml b/pom.xml index d6bbbd558d..a7ae7aa30e 100644 --- a/pom.xml +++ b/pom.xml @@ -49,7 +49,7 @@ 2.12.1 1.32 3.6.3 - 1.18.10 + 1.18.22 8.0.1 1.3.2 0.8.8 diff --git a/sermant-agentcore/sermant-agentcore-core/pom.xml b/sermant-agentcore/sermant-agentcore-core/pom.xml index 861beee467..c1dd7aa3df 100644 --- a/sermant-agentcore/sermant-agentcore-core/pom.xml +++ b/sermant-agentcore/sermant-agentcore-core/pom.xml @@ -43,7 +43,7 @@ ${pom.basedir}/../.. ${sermant.basedir}/${sermant.name}-${project.version} - 1.10.14 + 1.10.21 3.2.4 3.0.1 diff --git a/sermant-backend/pom.xml b/sermant-backend/pom.xml index 7c91c5749e..44de8a2677 100644 --- a/sermant-backend/pom.xml +++ b/sermant-backend/pom.xml @@ -18,7 +18,7 @@ 4.1.86.Final 2.6.1 3.9.1 - 1.18.12 + 1.18.22 1.2.83 2.6 4.13.1 diff --git a/sermant-integration-tests/dubbo-test/dubbo-integration-test/src/test/java/com/huaweicloud/integration/monitor/MonitorTest.java b/sermant-integration-tests/dubbo-test/dubbo-integration-test/src/test/java/com/huaweicloud/integration/monitor/MonitorTest.java index 575deab4e2..d641ba1ccc 100644 --- a/sermant-integration-tests/dubbo-test/dubbo-integration-test/src/test/java/com/huaweicloud/integration/monitor/MonitorTest.java +++ b/sermant-integration-tests/dubbo-test/dubbo-integration-test/src/test/java/com/huaweicloud/integration/monitor/MonitorTest.java @@ -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 JDK8_MONOPOLIZE_INDEX_SET = new HashSet<>( Arrays.asList("code_cache_init", "code_cache_max", "code_cache_used", "code_cache_committed")); @@ -65,6 +67,10 @@ public class MonitorTest { "epsilon_heap_init", "epsilon_heap_max", "epsilon_heap_used", "epsilon_heap_committed")); + private static final Set 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); @@ -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 diff --git a/sermant-integration-tests/spring-test/spring-intergration-test/src/test/java/com/huaweicloud/intergration/monitor/MonitorTest.java b/sermant-integration-tests/spring-test/spring-intergration-test/src/test/java/com/huaweicloud/intergration/monitor/MonitorTest.java index d52a5f35c8..852cce1466 100644 --- a/sermant-integration-tests/spring-test/spring-intergration-test/src/test/java/com/huaweicloud/intergration/monitor/MonitorTest.java +++ b/sermant-integration-tests/spring-test/spring-intergration-test/src/test/java/com/huaweicloud/intergration/monitor/MonitorTest.java @@ -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 JDK8_MONOPOLIZE_INDEX_SET = new HashSet<>( Arrays.asList("code_cache_init", "code_cache_max", "code_cache_used", "code_cache_committed")); @@ -65,6 +67,10 @@ public class MonitorTest { "epsilon_heap_init", "epsilon_heap_max", "epsilon_heap_used", "epsilon_heap_committed")); + private static final Set 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); @@ -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 diff --git a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MemoryType.java b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MemoryType.java index 462a53a4ee..bc6db94540 100644 --- a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MemoryType.java +++ b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MemoryType.java @@ -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); /** * 类型 diff --git a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MetricEnum.java b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MetricEnum.java index 2b4ed59754..84ec75fdac 100644 --- a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MetricEnum.java +++ b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/common/MetricEnum.java @@ -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"); /** * 名称 diff --git a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/collector/JvmCollectorService.java b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/collector/JvmCollectorService.java index 88e109b2a0..79309d824a 100644 --- a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/collector/JvmCollectorService.java +++ b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/collector/JvmCollectorService.java @@ -49,7 +49,7 @@ */ public class JvmCollectorService extends SwitchService implements PluginService { private static final Set 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的名称