Checks if config tags contains "virtual-service" or "destination-rule".
+ * @param configTags the tags to check + * @return {@code true} if the config tags contains "virtual-service" or "destination-rule". + * @throws IllegalArgumentException if configTags is null. + */ + public static boolean isIstio(String configTags) { + if (configTags == null) { + throw new IllegalArgumentException("configTags cannot be null."); + } + + if (configTags.isEmpty()) { + return false; + } + + return Arrays.stream(configTags.split(TAGS_DELIMITER)) + .map(tag -> tag.trim().replaceAll(HYPHEN, "")) + .anyMatch(tag -> tag.equalsIgnoreCase(VIRTUAL_SERVICE.replaceAll(HYPHEN, "")) + || tag.equalsIgnoreCase(DESTINATION_RULE.replaceAll(HYPHEN, ""))); + } + + /** + *Gets the type of Istio from the config tags.
+ * @param configTags the tags to check + * @return the type of Istio if it is found, {@code null} otherwise. + * @throws IllegalArgumentException if configTags is null. + */ + public static String getIstioType(String configTags) { + if (configTags == null) { + throw new IllegalArgumentException("configTags cannot be null."); + } + + if (configTags.isEmpty()) { + return null; + } + + return Arrays.stream(configTags.split(TAGS_DELIMITER)) + .map(tag -> tag.trim().replaceAll(HYPHEN, "")) + .filter(tag -> tag.equalsIgnoreCase(VIRTUAL_SERVICE.replaceAll(HYPHEN, "")) + || tag.equalsIgnoreCase(DESTINATION_RULE.replaceAll(HYPHEN, ""))) + .findFirst() + .orElse(null); + } +} diff --git a/core/src/main/resources/META-INF/logback/nacos.xml b/core/src/main/resources/META-INF/logback/nacos.xml index ca543a8bdd1..1296290bad8 100644 --- a/core/src/main/resources/META-INF/logback/nacos.xml +++ b/core/src/main/resources/META-INF/logback/nacos.xml @@ -275,7 +275,6 @@generate Rds From VirtualService.
+ * @param virtualService VirtualService Parsed + * @param pushRequest PushRequest + * @return + */ + public static Any generateRdsFromVirtualService(VirtualService virtualService, PushRequest pushRequest) { + ListChecks if config tags contains "virtual-service" or "destination-rule".
* @param configTags the tags to check * @return {@code true} if the config tags contains "virtual-service" or "destination-rule". - * @throws IllegalArgumentException if configTags is null. */ public static boolean isIstio(String configTags) { if (configTags == null) { - throw new IllegalArgumentException("configTags cannot be null."); + return false; } - if (configTags.isEmpty()) { return false; } - return Arrays.stream(configTags.split(TAGS_DELIMITER)) .map(tag -> tag.trim().replaceAll(HYPHEN, "")) .anyMatch(tag -> tag.equalsIgnoreCase(VIRTUAL_SERVICE.replaceAll(HYPHEN, "")) From e2d44f2fd2b12124d844d152b7025e3f758d00e6 Mon Sep 17 00:00:00 2001 From: "blake.qiu" <46370663+Bo-Qiu@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:54:14 +0800 Subject: [PATCH 7/7] fix(#12769): remove config history by derby. (#12796) --- .../datasource/impl/derby/HistoryConfigInfoMapperByDerby.java | 4 ++-- .../impl/derby/HistoryConfigInfoMapperByDerbyTest.java | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerby.java b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerby.java index 08942c9a4fe..041d580ff7e 100644 --- a/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerby.java +++ b/plugin/datasource/src/main/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerby.java @@ -33,8 +33,8 @@ public class HistoryConfigInfoMapperByDerby extends AbstractMapperByDerby implem @Override public MapperResult removeConfigHistory(MapperContext context) { - String sql = "DELETE FROM his_config_info WHERE id IN( " - + "SELECT id FROM his_config_info WHERE gmt_modified < ? OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY)"; + String sql = "DELETE FROM his_config_info WHERE nid IN( " + + "SELECT nid FROM his_config_info WHERE gmt_modified < ? OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY)"; return new MapperResult(sql, CollectionUtils.list(context.getWhereParameter(FieldConstant.START_TIME), context.getWhereParameter(FieldConstant.LIMIT_SIZE))); } diff --git a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerbyTest.java b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerbyTest.java index 434a4d583fc..61d16757141 100644 --- a/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerbyTest.java +++ b/plugin/datasource/src/test/java/com/alibaba/nacos/plugin/datasource/impl/derby/HistoryConfigInfoMapperByDerbyTest.java @@ -63,7 +63,7 @@ void setUp() throws Exception { void testRemoveConfigHistory() { MapperResult mapperResult = historyConfigInfoMapperByDerby.removeConfigHistory(context); assertEquals(mapperResult.getSql(), - "DELETE FROM his_config_info WHERE id IN( SELECT id FROM his_config_info WHERE gmt_modified < ? " + "DELETE FROM his_config_info WHERE nid IN( SELECT nid FROM his_config_info WHERE gmt_modified < ? " + "OFFSET 0 ROWS FETCH NEXT ? ROWS ONLY)"); assertArrayEquals(new Object[] {startTime, limitSize}, mapperResult.getParamList().toArray()); }