diff --git a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/pojo/TrieNode.java b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/pojo/TrieNode.java index 9bfd41c09..3baa8e97f 100644 --- a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/pojo/TrieNode.java +++ b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/pojo/TrieNode.java @@ -50,6 +50,10 @@ public TrieNode getSubNode(String nodeKey) { return null; } + public boolean isEmptyChildren() { + return children.isEmpty(); + } + // only for build trie public TrieNode getOrCreateSubNode(String path) { if (path.startsWith("{") && path.endsWith("}")) { diff --git a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/RuleUtils.java b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/RuleUtils.java index a880d791b..17abad693 100644 --- a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/RuleUtils.java +++ b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/RuleUtils.java @@ -93,7 +93,7 @@ public static boolean matchStringValue(MatchStringType matchType, String actualV switch (matchType) { case EXACT: { if (useTrieNode && trieNodeFunction != null) { - return ApiTrieUtil.checkSimple(trieNodeFunction.apply(matchValue), actualValue); + return TrieUtil.checkSimpleApi(trieNodeFunction.apply(matchValue), actualValue); } return StringUtils.equalsIgnoreCase(actualValue, matchValue); } @@ -104,7 +104,7 @@ public static boolean matchStringValue(MatchStringType matchType, String actualV } case NOT_EQUALS: { if (useTrieNode && trieNodeFunction != null) { - return !ApiTrieUtil.checkSimple(trieNodeFunction.apply(matchValue), actualValue); + return !TrieUtil.checkSimpleApi(trieNodeFunction.apply(matchValue), actualValue); } return !StringUtils.equalsIgnoreCase(actualValue, matchValue); } @@ -112,7 +112,7 @@ public static boolean matchStringValue(MatchStringType matchType, String actualV String[] tokens = matchValue.split(","); for (String token : tokens) { if (useTrieNode && trieNodeFunction != null) { - if (ApiTrieUtil.checkSimple(trieNodeFunction.apply(matchValue), actualValue)) { + if (TrieUtil.checkSimpleApi(trieNodeFunction.apply(matchValue), actualValue)) { return true; } } else { @@ -127,7 +127,7 @@ public static boolean matchStringValue(MatchStringType matchType, String actualV String[] tokens = matchValue.split(","); for (String token : tokens) { if (useTrieNode && trieNodeFunction != null) { - if (ApiTrieUtil.checkSimple(trieNodeFunction.apply(matchValue), actualValue)) { + if (TrieUtil.checkSimpleApi(trieNodeFunction.apply(matchValue), actualValue)) { return false; } } else { diff --git a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/ApiTrieUtil.java b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/TrieUtil.java similarity index 67% rename from polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/ApiTrieUtil.java rename to polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/TrieUtil.java index 92996233d..bf7717e53 100644 --- a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/ApiTrieUtil.java +++ b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/api/utils/TrieUtil.java @@ -20,20 +20,20 @@ import com.tencent.polaris.api.pojo.HttpElement; import com.tencent.polaris.api.pojo.TrieNode; -public class ApiTrieUtil { +public class TrieUtil { /** * @param apiPath * @return TrieNode */ - public static TrieNode buildSimpleTrieNode(String apiPath) { + public static TrieNode buildSimpleApiTrieNode(String apiPath) { if (StringUtils.isEmpty(apiPath)) { return null; } - return buildSimpleTrieNode(new String[]{apiPath}); + return buildSimpleApiTrieNode(new String[]{apiPath}); } - public static TrieNode buildSimpleTrieNode(String[] apiPathInfoList) { + public static TrieNode buildSimpleApiTrieNode(String[] apiPathInfoList) { if (apiPathInfoList.length == 0) { return null; } @@ -72,7 +72,7 @@ public static TrieNode buildSimpleTrieNode(String[] apiPathInfoList) { return root; } - public static boolean checkSimple(TrieNode root, String apiPathInfo) { + public static boolean checkSimpleApi(TrieNode root, String apiPathInfo) { if (root == null) { return false; } @@ -108,4 +108,53 @@ public static boolean checkSimple(TrieNode root, String apiPathInfo) { return false; } + public static TrieNode buildConfigTrieNode(String prefix) { + TrieNode root = new TrieNode<>(TrieNode.ROOT_PATH); + return buildConfigTrieNode(prefix, root); + } + + public static TrieNode buildConfigTrieNode(String prefix, TrieNode root) { + if (StringUtils.isEmpty(prefix)) { + return null; + } + // split by . + String[] prefixes = prefix.split("\\."); + TrieNode node = root; + for (String s : prefixes) { + node = node.getOrCreateSubNode(s); + } + return root; + } + + public static boolean checkConfig(TrieNode root, String config) { + if (root == null || root.isEmptyChildren() || StringUtils.isEmpty(config)) { + return false; + } + + String[] entities = config.split("\\."); + + TrieNode node = root; + for (String entity : entities) { + // empty children means leaf in config matching + if (node.isEmptyChildren()) { + return true; + } + // for list + if (entity.indexOf("[") < entity.indexOf("]")) { + entity = entity.substring(0, entity.indexOf("[")); + } + node = node.getSubNode(entity); + if (node == null) { + return false; + } + } + + if (node != null && node.isEmptyChildren()) { + // exact match + return true; + } else { + // not match or config is shorter than prefix + return false; + } + } } diff --git a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/client/pojo/InstanceByProto.java b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/client/pojo/InstanceByProto.java index a8ded3be3..b17dad790 100644 --- a/polaris-common/polaris-model/src/main/java/com/tencent/polaris/client/pojo/InstanceByProto.java +++ b/polaris-common/polaris-model/src/main/java/com/tencent/polaris/client/pojo/InstanceByProto.java @@ -17,6 +17,7 @@ package com.tencent.polaris.client.pojo; +import com.google.protobuf.StringValue; import com.google.protobuf.UInt32Value; import com.tencent.polaris.api.pojo.CircuitBreakerStatus; import com.tencent.polaris.api.pojo.DetectResult; @@ -30,6 +31,7 @@ import java.util.Collections; import java.util.Map; import java.util.Objects; +import java.util.Optional; /** * 通过PB对象封装的实例信息 @@ -78,7 +80,8 @@ public int hashCode() { @Override public String getNamespace() { - return serviceKey.getNamespace(); + return Optional.of(instance).map(ServiceProto.Instance::getNamespace). + map(StringValue::getValue).orElse(serviceKey.getNamespace()); } @Override diff --git a/polaris-common/polaris-model/src/test/java/com/tencent/polaris/api/utils/ApiTrieUtilTest.java b/polaris-common/polaris-model/src/test/java/com/tencent/polaris/api/utils/ApiTrieUtilTest.java deleted file mode 100644 index 32957304d..000000000 --- a/polaris-common/polaris-model/src/test/java/com/tencent/polaris/api/utils/ApiTrieUtilTest.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Tencent is pleased to support the open source community by making Polaris available. - * - * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. - * - * Licensed under the BSD 3-Clause License (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://opensource.org/licenses/BSD-3-Clause - * - * Unless required by applicable law or agreed to in writing, software distributed - * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR - * CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - */ - -package com.tencent.polaris.api.utils; - -import com.tencent.polaris.api.pojo.TrieNode; -import org.junit.Test; - -import static org.assertj.core.api.Assertions.assertThat; - -/** - * Test for {@link ApiTrieUtil}. - */ -public class ApiTrieUtilTest { - - @Test - public void testCheckSimple() { - TrieNode rootWithMethod = ApiTrieUtil.buildSimpleTrieNode("/echo/{param}-GET"); - TrieNode rootWithoutMethod = ApiTrieUtil.buildSimpleTrieNode("/echo/{param}-GET"); - assertThat(ApiTrieUtil.checkSimple(rootWithMethod, "/echo/test")).isTrue(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echo/test")).isTrue(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echoo/test")).isFalse(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echo/")).isFalse(); - assertThat(ApiTrieUtil.checkSimple(rootWithMethod, "/echo/test-GET")).isTrue(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echo/test-GET")).isTrue(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echo/test-POST")).isTrue(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echo/test-POST")).isTrue(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echoo/test-GET")).isFalse(); - assertThat(ApiTrieUtil.checkSimple(rootWithoutMethod, "/echo/-GET")).isFalse(); - } -} diff --git a/polaris-common/polaris-model/src/test/java/com/tencent/polaris/api/utils/TrieUtilTest.java b/polaris-common/polaris-model/src/test/java/com/tencent/polaris/api/utils/TrieUtilTest.java new file mode 100644 index 000000000..238951b47 --- /dev/null +++ b/polaris-common/polaris-model/src/test/java/com/tencent/polaris/api/utils/TrieUtilTest.java @@ -0,0 +1,109 @@ +/* + * Tencent is pleased to support the open source community by making Polaris available. + * + * Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the BSD 3-Clause License (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://opensource.org/licenses/BSD-3-Clause + * + * Unless required by applicable law or agreed to in writing, software distributed + * under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + * CONDITIONS OF ANY KIND, either express or implied. See the License for the + * specific language governing permissions and limitations under the License. + */ + +package com.tencent.polaris.api.utils; + +import com.tencent.polaris.api.pojo.TrieNode; +import org.junit.Test; + +import static org.assertj.core.api.Assertions.assertThat; + +/** + * Test for {@link TrieUtil}. + */ +public class TrieUtilTest { + + @Test + public void testCheckSimple() { + TrieNode rootWithMethod = TrieUtil.buildSimpleApiTrieNode("/echo/{param}-GET"); + TrieNode rootWithoutMethod = TrieUtil.buildSimpleApiTrieNode("/echo/{param}-GET"); + assertThat(TrieUtil.checkSimpleApi(rootWithMethod, "/echo/test")).isTrue(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echo/test")).isTrue(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echoo/test")).isFalse(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echo/")).isFalse(); + assertThat(TrieUtil.checkSimpleApi(rootWithMethod, "/echo/test-GET")).isTrue(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echo/test-GET")).isTrue(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echo/test-POST")).isTrue(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echo/test-POST")).isTrue(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echoo/test-GET")).isFalse(); + assertThat(TrieUtil.checkSimpleApi(rootWithoutMethod, "/echo/-GET")).isFalse(); + } + + @Test + public void testCheckConfig() { + TrieNode root1 = TrieUtil.buildConfigTrieNode("provider.config"); + assertThat(TrieUtil.checkConfig(root1, "provider.config.test")).isTrue(); + assertThat(TrieUtil.checkConfig(root1, "provider.config.test.aaa")).isTrue(); + assertThat(TrieUtil.checkConfig(root1, "provider.config2.test")).isFalse(); + assertThat(TrieUtil.checkConfig(root1, "provider")).isFalse(); + assertThat(TrieUtil.checkConfig(root1, "provider.config")).isTrue(); + assertThat(TrieUtil.checkConfig(root1, "provider.config.nameList[1]")).isTrue(); + assertThat(TrieUtil.checkConfig(root1, null)).isFalse(); + + TrieNode root2 = TrieUtil.buildConfigTrieNode("provider.conf"); + assertThat(TrieUtil.checkConfig(root2, "provider.conf.test")).isTrue(); + assertThat(TrieUtil.checkConfig(root2, "provider.conf.test.aaa")).isTrue(); + assertThat(TrieUtil.checkConfig(root2, "provider.config2.test")).isFalse(); + assertThat(TrieUtil.checkConfig(root2, "provider")).isFalse(); + assertThat(TrieUtil.checkConfig(root2, "provider.config")).isFalse(); + assertThat(TrieUtil.checkConfig(root2, "provider.conf")).isTrue(); + assertThat(TrieUtil.checkConfig(root2, "provider.conf.nameList[1]")).isTrue(); + + TrieNode root3 = new TrieNode<>(TrieNode.ROOT_PATH); + assertThat(TrieUtil.checkConfig(root3, "provider.config.test")).isFalse(); + } + + @Test + public void testCheckConfig2() { + TrieNode root1 = TrieUtil.buildConfigTrieNode("provider.config.list"); + assertThat(TrieUtil.checkConfig(root1, "provider.config.list[1]")).isTrue(); + assertThat(TrieUtil.checkConfig(root1, "provider.config.list[1].name")).isTrue(); + assertThat(TrieUtil.checkConfig(root1, "provider.config.name")).isFalse(); + + TrieNode root2 = TrieUtil.buildConfigTrieNode("provider.config.map"); + assertThat(TrieUtil.checkConfig(root2, "provider.config.map.key1")).isTrue(); + assertThat(TrieUtil.checkConfig(root2, "provider.config.map.key2")).isTrue(); + assertThat(TrieUtil.checkConfig(root1, "provider.config.name")).isFalse(); + + TrieNode root3 = new TrieNode<>(TrieNode.ROOT_PATH); + assertThat(TrieUtil.checkConfig(root3, "provider.config.test")).isFalse(); + } + + @Test + public void testCheckConfigMergeRoot() { + TrieNode root = new TrieNode<>(TrieNode.ROOT_PATH); + + TrieUtil.buildConfigTrieNode("provider.config", root); + TrieUtil.buildConfigTrieNode("provider.conf", root); + + assertThat(TrieUtil.checkConfig(root, "provider.config.test")).isTrue(); + assertThat(TrieUtil.checkConfig(root, "provider.config.test.aaa")).isTrue(); + assertThat(TrieUtil.checkConfig(root, "provider.config2.test")).isFalse(); + assertThat(TrieUtil.checkConfig(root, "provider")).isFalse(); + assertThat(TrieUtil.checkConfig(root, "provider.config")).isTrue(); + assertThat(TrieUtil.checkConfig(root, "provider.config.nameList[1]")).isTrue(); + + + assertThat(TrieUtil.checkConfig(root, "provider.conf.test")).isTrue(); + assertThat(TrieUtil.checkConfig(root, "provider.conf.test.aaa")).isTrue(); + assertThat(TrieUtil.checkConfig(root, "provider.config2.test")).isFalse(); + assertThat(TrieUtil.checkConfig(root, "provider")).isFalse(); + assertThat(TrieUtil.checkConfig(root, "provider.config")).isTrue(); + assertThat(TrieUtil.checkConfig(root, "provider.conf")).isTrue(); + assertThat(TrieUtil.checkConfig(root, "provider.conf.nameList[1]")).isTrue(); + } +} diff --git a/polaris-configuration/polaris-configuration-client/src/main/java/com/tencent/polaris/configuration/client/internal/ConfigFileGroupManager.java b/polaris-configuration/polaris-configuration-client/src/main/java/com/tencent/polaris/configuration/client/internal/ConfigFileGroupManager.java index 63699412f..4bcf73606 100644 --- a/polaris-configuration/polaris-configuration-client/src/main/java/com/tencent/polaris/configuration/client/internal/ConfigFileGroupManager.java +++ b/polaris-configuration/polaris-configuration-client/src/main/java/com/tencent/polaris/configuration/client/internal/ConfigFileGroupManager.java @@ -26,6 +26,8 @@ import com.tencent.polaris.configuration.api.core.ConfigFileGroup; import com.tencent.polaris.configuration.api.core.ConfigFileGroupMetadata; import com.tencent.polaris.configuration.api.core.ConfigFileMetadata; +import com.tencent.polaris.logging.LoggerFactory; +import org.slf4j.Logger; import java.util.ArrayList; import java.util.List; @@ -33,6 +35,7 @@ import java.util.concurrent.ConcurrentHashMap; public class ConfigFileGroupManager { + private static final Logger LOGGER = LoggerFactory.getLogger(ConfigFileGroupManager.class); private final Map configFileGroupCache = new ConcurrentHashMap<>(); private RetryableConfigFileGroupConnector rpcConnector; @@ -69,7 +72,8 @@ public RetryableConfigFileGroupConnector.RetryableValidator getCacheMissedRetryS public ConfigFileGroup getConfigFileGroup(ConfigFileGroupMetadata metadata) { if (!enabled) { - throw new RuntimeException("Config file group manager is disabled."); + LOGGER.warn("config file group is not enabled, metadata: {}", metadata); + return null; } RevisableConfigFileGroup configFileGroup = configFileGroupCache.get(metadata); if (configFileGroup == null) { diff --git a/polaris-plugins/polaris-plugin-api/src/main/java/com/tencent/polaris/api/plugin/cache/FlowCacheUtils.java b/polaris-plugins/polaris-plugin-api/src/main/java/com/tencent/polaris/api/plugin/cache/FlowCacheUtils.java index 71f551d4c..a967f0a23 100644 --- a/polaris-plugins/polaris-plugin-api/src/main/java/com/tencent/polaris/api/plugin/cache/FlowCacheUtils.java +++ b/polaris-plugins/polaris-plugin-api/src/main/java/com/tencent/polaris/api/plugin/cache/FlowCacheUtils.java @@ -17,7 +17,7 @@ package com.tencent.polaris.api.plugin.cache; -import com.tencent.polaris.api.utils.ApiTrieUtil; +import com.tencent.polaris.api.utils.TrieUtil; import com.tencent.polaris.specification.api.v1.model.ModelProto; import static com.tencent.polaris.api.plugin.cache.CacheConstants.API_ID; @@ -31,12 +31,12 @@ public static void saveApiTrie(ModelProto.MatchString matchString, FlowCache flo if (matchString != null && matchString.getType() != ModelProto.MatchString.MatchStringType.REGEX) { if (matchString.getType() == ModelProto.MatchString.MatchStringType.EXACT || matchString.getType() == ModelProto.MatchString.MatchStringType.NOT_EQUALS) { flowCache.loadPluginCacheObject(API_ID, matchString.getValue().getValue(), - path -> ApiTrieUtil.buildSimpleTrieNode((String) path)); + path -> TrieUtil.buildSimpleApiTrieNode((String) path)); } else if (matchString.getType() == ModelProto.MatchString.MatchStringType.IN || matchString.getType() == ModelProto.MatchString.MatchStringType.NOT_IN) { String[] apis = matchString.getValue().getValue().split(","); for (String api : apis) { flowCache.loadPluginCacheObject(API_ID, api, - path -> ApiTrieUtil.buildSimpleTrieNode((String) path)); + path -> TrieUtil.buildSimpleApiTrieNode((String) path)); } } } diff --git a/polaris-plugins/polaris-plugins-auth/auth-block-allow-list/src/main/java/com/tencent/polaris/plugins/auth/blockallowlist/BlockAllowListAuthenticator.java b/polaris-plugins/polaris-plugins-auth/auth-block-allow-list/src/main/java/com/tencent/polaris/plugins/auth/blockallowlist/BlockAllowListAuthenticator.java index 05fea3f2f..0df3295fa 100644 --- a/polaris-plugins/polaris-plugins-auth/auth-block-allow-list/src/main/java/com/tencent/polaris/plugins/auth/blockallowlist/BlockAllowListAuthenticator.java +++ b/polaris-plugins/polaris-plugins-auth/auth-block-allow-list/src/main/java/com/tencent/polaris/plugins/auth/blockallowlist/BlockAllowListAuthenticator.java @@ -29,7 +29,7 @@ import com.tencent.polaris.api.plugin.compose.Extensions; import com.tencent.polaris.api.pojo.*; import com.tencent.polaris.api.rpc.RequestBaseEntity; -import com.tencent.polaris.api.utils.ApiTrieUtil; +import com.tencent.polaris.api.utils.TrieUtil; import com.tencent.polaris.api.utils.CollectionUtils; import com.tencent.polaris.api.utils.RuleUtils; import com.tencent.polaris.api.utils.StringUtils; @@ -221,7 +221,7 @@ public void postContextInit(Extensions ctx) throws PolarisException { return null; } FlowCache flowCache = extensions.getFlowCache(); - return flowCache.loadPluginCacheObject(API_ID, key, path -> ApiTrieUtil.buildSimpleTrieNode((String) path)); + return flowCache.loadPluginCacheObject(API_ID, key, path -> TrieUtil.buildSimpleApiTrieNode((String) path)); }; } diff --git a/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/PolarisCircuitBreaker.java b/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/PolarisCircuitBreaker.java index 3ea2effa6..dc88f069d 100644 --- a/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/PolarisCircuitBreaker.java +++ b/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/PolarisCircuitBreaker.java @@ -37,7 +37,7 @@ import com.tencent.polaris.api.plugin.compose.Extensions; import com.tencent.polaris.api.plugin.detect.HealthChecker; import com.tencent.polaris.api.pojo.*; -import com.tencent.polaris.api.utils.ApiTrieUtil; +import com.tencent.polaris.api.utils.TrieUtil; import com.tencent.polaris.api.utils.CollectionUtils; import com.tencent.polaris.client.flow.DefaultServiceResourceProvider; import com.tencent.polaris.client.util.NamedThreadFactory; @@ -348,7 +348,7 @@ public void init(InitContext ctx) throws PolarisException { return null; } FlowCache flowCache = extensions.getFlowCache(); - return flowCache.loadPluginCacheObject(API_ID, key, path -> ApiTrieUtil.buildSimpleTrieNode((String) path)); + return flowCache.loadPluginCacheObject(API_ID, key, path -> TrieUtil.buildSimpleApiTrieNode((String) path)); }; } diff --git a/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/ResourceCounters.java b/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/ResourceCounters.java index 30218f74c..ba5fa5964 100644 --- a/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/ResourceCounters.java +++ b/polaris-plugins/polaris-plugins-circuitbreaker/circuitbreaker-composite/src/main/java/com/tencent/polaris/plugins/circuitbreaker/composite/ResourceCounters.java @@ -34,7 +34,7 @@ import com.tencent.polaris.api.pojo.*; import com.tencent.polaris.api.pojo.CircuitBreakerStatus.FallbackInfo; import com.tencent.polaris.api.pojo.CircuitBreakerStatus.Status; -import com.tencent.polaris.api.utils.ApiTrieUtil; +import com.tencent.polaris.api.utils.TrieUtil; import com.tencent.polaris.api.utils.CollectionUtils; import com.tencent.polaris.api.utils.StringUtils; import com.tencent.polaris.client.flow.BaseFlow; @@ -113,7 +113,7 @@ public ResourceCounters(Resource resource, CircuitBreakerRule currentActiveRule, return null; } FlowCache flowCache = polarisCircuitBreaker.getExtensions().getFlowCache(); - return flowCache.loadPluginCacheObject(API_ID, key, path -> ApiTrieUtil.buildSimpleTrieNode((String) path)); + return flowCache.loadPluginCacheObject(API_ID, key, path -> TrieUtil.buildSimpleApiTrieNode((String) path)); }; circuitBreakerStatusReference .set(new CircuitBreakerStatus(currentActiveRule.getName(), Status.CLOSE, System.currentTimeMillis())); diff --git a/polaris-plugins/polaris-plugins-router/router-rule/src/main/java/com/tencent/polaris/plugins/router/rule/RuleBasedRouter.java b/polaris-plugins/polaris-plugins-router/router-rule/src/main/java/com/tencent/polaris/plugins/router/rule/RuleBasedRouter.java index 928db40a4..fa7a8c029 100644 --- a/polaris-plugins/polaris-plugins-router/router-rule/src/main/java/com/tencent/polaris/plugins/router/rule/RuleBasedRouter.java +++ b/polaris-plugins/polaris-plugins-router/router-rule/src/main/java/com/tencent/polaris/plugins/router/rule/RuleBasedRouter.java @@ -155,7 +155,7 @@ private boolean matchSource(List sources, Service sourceSer matched = RuleUtils.matchMetadata(source.getMetadataMap(), trafficLabels, metadataContainerGroup, true, multiEnvRouterParamMap, globalVariablesConfig, - key -> flowCache.loadPluginCacheObject(API_ID, key, path -> ApiTrieUtil.buildSimpleTrieNode((String) path))); + key -> flowCache.loadPluginCacheObject(API_ID, key, path -> TrieUtil.buildSimpleApiTrieNode((String) path))); if (matched) { break; } diff --git a/polaris-ratelimit/polaris-ratelimit-client/src/main/java/com/tencent/polaris/ratelimit/client/flow/QuotaFlow.java b/polaris-ratelimit/polaris-ratelimit-client/src/main/java/com/tencent/polaris/ratelimit/client/flow/QuotaFlow.java index fdce3e2a0..7a3446bf8 100644 --- a/polaris-ratelimit/polaris-ratelimit-client/src/main/java/com/tencent/polaris/ratelimit/client/flow/QuotaFlow.java +++ b/polaris-ratelimit/polaris-ratelimit-client/src/main/java/com/tencent/polaris/ratelimit/client/flow/QuotaFlow.java @@ -90,7 +90,7 @@ public void init(Extensions extensions) throws PolarisException { extensions.getLocalRegistry().registerResourceListener(new RateLimitRuleListener()); trieNodeFunction = key -> { FlowCache flowCache = extensions.getFlowCache(); - return flowCache.loadPluginCacheObject(API_ID, key, path -> ApiTrieUtil.buildSimpleTrieNode((String) path)); + return flowCache.loadPluginCacheObject(API_ID, key, path -> TrieUtil.buildSimpleApiTrieNode((String) path)); }; // init tsf rate limit master utils if need