From 5680849cfb108612db4cadc8c159b274722a9750 Mon Sep 17 00:00:00 2001 From: luanwenfei Date: Tue, 4 Jul 2023 18:02:48 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=8F=92=E4=BB=B6=E8=8E=B7?= =?UTF-8?q?=E5=8F=96PluginService=E5=8F=8APluginConfig=E7=9A=84=E6=96=B9?= =?UTF-8?q?=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../config/entity/DynamicProperties.java | 4 +- .../config/SpringApplicationInterceptor.java | 5 +- .../service/InterceptorSupporter.java | 24 ++-- .../loadbalancer/rule/RuleManagerTest.java | 3 +- .../com/huawei/monitor/util/MonitorUtil.java | 2 +- .../service/report/MetricServiceImpl.java | 4 +- .../report/PrometheusMetricServiceImpl.java | 4 +- .../handler/LaneContextFilterHandler.java | 4 +- .../AbstractDirectoryInterceptor.java | 4 +- .../interceptor/ClusterUtilsInterceptor.java | 4 +- .../interceptor/ContextFilterInterceptor.java | 4 +- .../SpringApplicationInterceptor.java | 4 +- .../router/config/utils/RuleUtils.java | 2 +- .../handler/AbstractMappingHandler.java | 4 +- .../spring/handler/LaneMappingHandler.java | 4 +- .../spring/handler/LaneRequestTagHandler.java | 4 +- .../BaseLoadBalancerInterceptor.java | 4 +- .../DiscoveryManagerInterceptor.java | 4 +- .../EurekaHttpClientInterceptor.java | 4 +- .../NopInstanceFilterInterceptor.java | 4 +- .../interceptor/RouteHandlerInterceptor.java | 4 +- ...erviceInstanceListSupplierInterceptor.java | 4 +- .../ServiceRegistryInterceptor.java | 4 +- .../dubbo/registry/alibaba/NacosRegistry.java | 4 +- .../alibaba/NacosRegistryFactory.java | 9 +- .../alibaba/ServiceCenterRegistry.java | 4 +- .../dubbo/registry/apache/NacosRegistry.java | 4 +- .../registry/apache/NacosRegistryFactory.java | 9 +- .../apache/ServiceCenterRegistry.java | 4 +- .../ApacheInterfaceConfigInterceptor.java | 4 +- .../ApplicationConfigInterceptor.java | 4 +- .../SpringApplicationInterceptor.java | 4 +- .../dubbo/registry/utils/ReflectUtils.java | 2 +- .../listener/GovernanceConfigListener.java | 4 +- .../registry/service/RegistryServiceImpl.java | 117 ++++++++++++------ .../DiscoveryClientInterceptor.java | 3 +- .../DiscoveryClientServiceInterceptor.java | 3 +- .../DynamicServerListInterceptor.java | 3 +- .../interceptors/RegistrationInterceptor.java | 3 +- .../SpringFactoriesInterceptor.java | 2 +- .../support/InstanceInterceptorSupport.java | 2 +- .../DiscoveryClientInterceptorTest.java | 3 +- ...DiscoveryClientServiceInterceptorTest.java | 3 +- .../DynamicServerListInterceptorTest.java | 3 +- .../RegistrationInterceptorTest.java | 3 +- .../huaweicloud/sermant/cache/RuleCache.java | 2 +- .../AbstractRemovalInterceptor.java | 5 +- .../AbstractSwitchInterceptor.java | 2 +- .../SpringApplicationInterceptor.java | 4 +- .../sermant/cache/RuleCacheTest.java | 4 +- .../sermant/service/RequestDataCountTask.java | 8 +- .../declarer/AbstractCollectorDeclarer.java | 4 +- .../AbstractCollectorInterceptor.java | 12 +- .../SpringApplicationInterceptor.java | 6 +- 54 files changed, 203 insertions(+), 149 deletions(-) diff --git a/sermant-plugins/sermant-dynamic-config/dynamic-config-plugin/src/main/java/com/huawei/dynamic/config/entity/DynamicProperties.java b/sermant-plugins/sermant-dynamic-config/dynamic-config-plugin/src/main/java/com/huawei/dynamic/config/entity/DynamicProperties.java index be43f480af..982ab74b0b 100644 --- a/sermant-plugins/sermant-dynamic-config/dynamic-config-plugin/src/main/java/com/huawei/dynamic/config/entity/DynamicProperties.java +++ b/sermant-plugins/sermant-dynamic-config/dynamic-config-plugin/src/main/java/com/huawei/dynamic/config/entity/DynamicProperties.java @@ -19,7 +19,7 @@ import com.huawei.dynamic.config.init.DynamicConfigInitializer; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import org.springframework.beans.factory.annotation.Value; import org.springframework.core.Ordered; @@ -44,7 +44,7 @@ public class DynamicProperties { @PostConstruct public void init() { ClientMeta.INSTANCE.setServiceName(serviceName); - final DynamicConfigInitializer service = ServiceManager.getService(DynamicConfigInitializer.class); + final DynamicConfigInitializer service = PluginServiceManager.getPluginService(DynamicConfigInitializer.class); service.doStart(); } diff --git a/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/config/SpringApplicationInterceptor.java b/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/config/SpringApplicationInterceptor.java index 0f7ef1eb4a..964dd2fece 100644 --- a/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/config/SpringApplicationInterceptor.java +++ b/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/config/SpringApplicationInterceptor.java @@ -21,7 +21,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import java.util.concurrent.atomic.AtomicBoolean; @@ -43,7 +43,8 @@ public ExecuteContext before(ExecuteContext context) throws Exception { public ExecuteContext after(ExecuteContext context) { Object logStartupInfo = context.getMemberFieldValue("logStartupInfo"); if ((logStartupInfo instanceof Boolean) && (Boolean) logStartupInfo && INIT.compareAndSet(false, true)) { - final FlowControlInitServiceImpl service = ServiceManager.getService(FlowControlInitServiceImpl.class); + final FlowControlInitServiceImpl service = PluginServiceManager.getPluginService( + FlowControlInitServiceImpl.class); service.doStart(); } return context; diff --git a/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/service/InterceptorSupporter.java b/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/service/InterceptorSupporter.java index b57fce3820..23cb2cb86e 100644 --- a/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/service/InterceptorSupporter.java +++ b/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/com/huawei/flowcontrol/service/InterceptorSupporter.java @@ -32,7 +32,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.Interceptor; import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import io.github.resilience4j.retry.RetryConfig; @@ -110,9 +110,9 @@ protected final DubboService chooseDubboService() { lock.lock(); try { if (flowControlConfig.getFlowFramework() == FlowFramework.SENTINEL) { - dubboService = ServiceManager.getService(DubboSenService.class); + dubboService = PluginServiceManager.getPluginService(DubboSenService.class); } else { - dubboService = ServiceManager.getService(DubboRest4jService.class); + dubboService = PluginServiceManager.getPluginService(DubboRest4jService.class); } } finally { lock.unlock(); @@ -131,9 +131,9 @@ protected final HttpService chooseHttpService() { lock.lock(); try { if (flowControlConfig.getFlowFramework() == FlowFramework.SENTINEL) { - httpService = ServiceManager.getService(HttpSenService.class); + httpService = PluginServiceManager.getPluginService(HttpSenService.class); } else { - httpService = ServiceManager.getService(HttpRest4jService.class); + httpService = PluginServiceManager.getPluginService(HttpRest4jService.class); } } finally { lock.unlock(); @@ -145,10 +145,10 @@ protected final HttpService chooseHttpService() { /** * 创建重试方法 * - * @param obj 增强类 - * @param method 目标方法 + * @param obj 增强类 + * @param method 目标方法 * @param allArguments 方法参数 - * @param result 默认结果 + * @param result 默认结果 * @return 方法 */ protected final Supplier createRetryFunc(Object obj, Method method, Object[] allArguments, Object result) { @@ -168,8 +168,8 @@ protected final Supplier createRetryFunc(Object obj, Method method, Obje /** * 进行重试前的判断,若不满足条件直接返回, 防止多调用一次宿主应用接口 * - * @param retry 重试执行器 - * @param result 结果 + * @param retry 重试执行器 + * @param result 结果 * @param throwable 第一次执行异常信息 * @return 是否核对通过 */ @@ -177,7 +177,7 @@ protected final boolean needRetry(io.github.resilience4j.retry.Retry retry, Obje final long interval = retry.getRetryConfig().getIntervalBiFunction().apply(1, null); final RetryConfig retryConfig = retry.getRetryConfig(); boolean isNeedRetry = isMatchResult(result, retryConfig.getResultPredicate()) || isTargetException(throwable, - retryConfig.getExceptionPredicate()); + retryConfig.getExceptionPredicate()); if (isNeedRetry) { try { // 按照第一次等待时间等待 @@ -240,7 +240,7 @@ public ExecuteContext onThrow(ExecuteContext context) throws Exception { */ protected final boolean canInjectClusterInvoker(String className) { boolean isClusterLoader = - APACHE_DUBBO_CLUSTER_CLASS_NAME.equals(className) || ALIBABA_DUBBO_CLUSTER_CLASS_NAME.equals(className); + APACHE_DUBBO_CLUSTER_CLASS_NAME.equals(className) || ALIBABA_DUBBO_CLUSTER_CLASS_NAME.equals(className); return isClusterLoader && !REFUSE_REPLACE_INVOKER.equals(flowControlConfig.getRetryClusterInvoker()); } diff --git a/sermant-plugins/sermant-loadbalancer/loadbalancer-common/src/test/java/com/huaweicloud/loadbalancer/rule/RuleManagerTest.java b/sermant-plugins/sermant-loadbalancer/loadbalancer-common/src/test/java/com/huaweicloud/loadbalancer/rule/RuleManagerTest.java index 80a50e7893..9cccb6af20 100644 --- a/sermant-plugins/sermant-loadbalancer/loadbalancer-common/src/test/java/com/huaweicloud/loadbalancer/rule/RuleManagerTest.java +++ b/sermant-plugins/sermant-loadbalancer/loadbalancer-common/src/test/java/com/huaweicloud/loadbalancer/rule/RuleManagerTest.java @@ -20,6 +20,7 @@ import com.huaweicloud.loadbalancer.service.RuleConverter; import com.huaweicloud.sermant.core.common.LoggerFactory; import com.huaweicloud.sermant.core.plugin.service.PluginService; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import com.huaweicloud.sermant.core.service.dynamicconfig.common.DynamicConfigEvent; import com.huaweicloud.sermant.core.utils.StringUtils; @@ -55,7 +56,7 @@ public class RuleManagerTest { @Test public void testResolve() { Mockito.mockStatic(ServiceManager.class) - .when(() -> ServiceManager.getService(RuleConverter.class)) + .when(() -> PluginServiceManager.getPluginService(RuleConverter.class)) .thenReturn(new YamlRuleConverter()); final AtomicBoolean isNotify = new AtomicBoolean(); RuleManager.INSTANCE.addRuleListener((rule, event) -> { diff --git a/sermant-plugins/sermant-monitor/monitor-plugin/src/main/java/com/huawei/monitor/util/MonitorUtil.java b/sermant-plugins/sermant-monitor/monitor-plugin/src/main/java/com/huawei/monitor/util/MonitorUtil.java index a55ff46e2c..c6ad3c748f 100644 --- a/sermant-plugins/sermant-monitor/monitor-plugin/src/main/java/com/huawei/monitor/util/MonitorUtil.java +++ b/sermant-plugins/sermant-monitor/monitor-plugin/src/main/java/com/huawei/monitor/util/MonitorUtil.java @@ -29,7 +29,7 @@ * @since 2022-11-02 */ public class MonitorUtil { - private static final MonitorServiceConfig CONFIG = PluginConfigManager.getConfig(MonitorServiceConfig.class); + private static final MonitorServiceConfig CONFIG = PluginConfigManager.getPluginConfig(MonitorServiceConfig.class); private MonitorUtil() { } diff --git a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/MetricServiceImpl.java b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/MetricServiceImpl.java index 9ab32ba1cd..d17e4287be 100644 --- a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/MetricServiceImpl.java +++ b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/MetricServiceImpl.java @@ -21,7 +21,7 @@ import com.huawei.monitor.service.MetricReportService; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.config.ConfigManager; +import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; import com.huaweicloud.sermant.core.plugin.service.PluginService; import com.huaweicloud.sermant.core.utils.StringUtils; @@ -42,7 +42,7 @@ public class MetricServiceImpl implements PluginService { @Override public void start() { LOGGER.info("start monitor service"); - MonitorServiceConfig config = ConfigManager.getConfig(MonitorServiceConfig.class); + MonitorServiceConfig config = PluginConfigManager.getPluginConfig(MonitorServiceConfig.class); if (config == null || StringUtils.isEmpty(config.getReportType()) || !config.isEnableStartService()) { LOGGER.info("monitor switch is close, not start monitor"); return; diff --git a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/PrometheusMetricServiceImpl.java b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/PrometheusMetricServiceImpl.java index 73e5001d44..526debd5ee 100644 --- a/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/PrometheusMetricServiceImpl.java +++ b/sermant-plugins/sermant-monitor/monitor-service/src/main/java/com/huawei/monitor/service/report/PrometheusMetricServiceImpl.java @@ -20,7 +20,7 @@ import com.huawei.monitor.service.MetricReportService; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.config.ConfigManager; +import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; import com.huaweicloud.sermant.core.utils.AesUtil; import com.huaweicloud.sermant.core.utils.StringUtils; @@ -52,7 +52,7 @@ public class PrometheusMetricServiceImpl implements MetricReportService { @Override public void startMonitorServer() { - MonitorServiceConfig monitorServiceConfig = ConfigManager.getConfig(MonitorServiceConfig.class); + MonitorServiceConfig monitorServiceConfig = PluginConfigManager.getPluginConfig(MonitorServiceConfig.class); if (StringUtils.isBlank(monitorServiceConfig.getAddress()) || monitorServiceConfig.getPort() == 0) { LOGGER.info("monitor config missing address or port"); return; diff --git a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/handler/LaneContextFilterHandler.java b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/handler/LaneContextFilterHandler.java index 3eb39d6aae..3820e9b4d7 100644 --- a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/handler/LaneContextFilterHandler.java +++ b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/handler/LaneContextFilterHandler.java @@ -17,7 +17,7 @@ package com.huaweicloud.sermant.router.dubbo.handler; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.constants.RouterConstant; import com.huaweicloud.sermant.router.common.utils.CollectionUtils; import com.huaweicloud.sermant.router.dubbo.service.LaneContextFilterService; @@ -45,7 +45,7 @@ public class LaneContextFilterHandler extends AbstractContextFilterHandler { * 构造方法 */ public LaneContextFilterHandler() { - laneContextFilterService = ServiceManager.getService(LaneContextFilterService.class); + laneContextFilterService = PluginServiceManager.getPluginService(LaneContextFilterService.class); } @Override diff --git a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/AbstractDirectoryInterceptor.java b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/AbstractDirectoryInterceptor.java index ec0b66e9cc..a665e7511f 100644 --- a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/AbstractDirectoryInterceptor.java +++ b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/AbstractDirectoryInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.utils.LogUtils; import com.huaweicloud.sermant.router.dubbo.service.AbstractDirectoryService; @@ -35,7 +35,7 @@ public class AbstractDirectoryInterceptor extends AbstractInterceptor { * 构造方法 */ public AbstractDirectoryInterceptor() { - abstractDirectoryService = ServiceManager.getService(AbstractDirectoryService.class); + abstractDirectoryService = PluginServiceManager.getPluginService(AbstractDirectoryService.class); } @Override diff --git a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ClusterUtilsInterceptor.java b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ClusterUtilsInterceptor.java index a8535f2d85..f69488dd70 100644 --- a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ClusterUtilsInterceptor.java +++ b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ClusterUtilsInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.dubbo.service.ClusterUtilsService; /** @@ -34,7 +34,7 @@ public class ClusterUtilsInterceptor extends AbstractInterceptor { * 构造方法 */ public ClusterUtilsInterceptor() { - clusterUtilsService = ServiceManager.getService(ClusterUtilsService.class); + clusterUtilsService = PluginServiceManager.getPluginService(ClusterUtilsService.class); } @Override diff --git a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ContextFilterInterceptor.java b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ContextFilterInterceptor.java index aace1c9078..4d7ff574ff 100644 --- a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ContextFilterInterceptor.java +++ b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/ContextFilterInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.handler.Handler; import com.huaweicloud.sermant.router.common.utils.CollectionUtils; import com.huaweicloud.sermant.router.common.utils.ThreadLocalUtils; @@ -52,7 +52,7 @@ public ContextFilterInterceptor() { handlers.add(new LaneContextFilterHandler()); handlers.add(new RouteContextFilterHandler()); handlers.sort(Comparator.comparingInt(Handler::getOrder)); - configService = ServiceManager.getService(DubboConfigService.class); + configService = PluginServiceManager.getPluginService(DubboConfigService.class); } @Override diff --git a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/SpringApplicationInterceptor.java b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/SpringApplicationInterceptor.java index 92065f808a..433c13cf93 100644 --- a/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/SpringApplicationInterceptor.java +++ b/sermant-plugins/sermant-router/dubbo-router-plugin/src/main/java/com/huaweicloud/sermant/router/dubbo/interceptor/SpringApplicationInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.constants.RouterConstant; import com.huaweicloud.sermant.router.dubbo.cache.DubboCache; import com.huaweicloud.sermant.router.dubbo.service.DubboConfigService; @@ -40,7 +40,7 @@ public class SpringApplicationInterceptor extends AbstractInterceptor { * 构造方法 */ public SpringApplicationInterceptor() { - configService = ServiceManager.getService(DubboConfigService.class); + configService = PluginServiceManager.getPluginService(DubboConfigService.class); } @Override diff --git a/sermant-plugins/sermant-router/router-config-common/src/main/java/com/huaweicloud/sermant/router/config/utils/RuleUtils.java b/sermant-plugins/sermant-router/router-config-common/src/main/java/com/huaweicloud/sermant/router/config/utils/RuleUtils.java index 44c6e9b79d..76d7a97a05 100644 --- a/sermant-plugins/sermant-router/router-config-common/src/main/java/com/huaweicloud/sermant/router/config/utils/RuleUtils.java +++ b/sermant-plugins/sermant-router/router-config-common/src/main/java/com/huaweicloud/sermant/router/config/utils/RuleUtils.java @@ -60,7 +60,7 @@ public class RuleUtils { private static final int ONO_HUNDRED = 100; - private static final RouterConfig ROUTER_CONFIG = PluginConfigManager.getConfig(RouterConfig.class); + private static final RouterConfig ROUTER_CONFIG = PluginConfigManager.getPluginConfig(RouterConfig.class); private RuleUtils() { } diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/AbstractMappingHandler.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/AbstractMappingHandler.java index 70f58330f8..d785b3deb4 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/AbstractMappingHandler.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/AbstractMappingHandler.java @@ -16,7 +16,7 @@ package com.huaweicloud.sermant.router.spring.handler; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.spring.service.SpringConfigService; import java.util.List; @@ -35,7 +35,7 @@ public abstract class AbstractMappingHandler extends AbstractHandler { * 构造方法 */ public AbstractMappingHandler() { - configService = ServiceManager.getService(SpringConfigService.class); + configService = PluginServiceManager.getPluginService(SpringConfigService.class); } /** diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneMappingHandler.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneMappingHandler.java index 1b6fd5a4fc..984163e3f5 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneMappingHandler.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneMappingHandler.java @@ -17,7 +17,7 @@ package com.huaweicloud.sermant.router.spring.handler; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.constants.RouterConstant; import com.huaweicloud.sermant.router.common.utils.CollectionUtils; import com.huaweicloud.sermant.router.spring.service.LaneService; @@ -44,7 +44,7 @@ public class LaneMappingHandler extends AbstractMappingHandler { * 构造方法 */ public LaneMappingHandler() { - laneService = ServiceManager.getService(LaneService.class); + laneService = PluginServiceManager.getPluginService(LaneService.class); } /** diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneRequestTagHandler.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneRequestTagHandler.java index 37b1ac20fb..696a871110 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneRequestTagHandler.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/handler/LaneRequestTagHandler.java @@ -17,7 +17,7 @@ package com.huaweicloud.sermant.router.spring.handler; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.constants.RouterConstant; import com.huaweicloud.sermant.router.common.utils.CollectionUtils; import com.huaweicloud.sermant.router.spring.service.LaneService; @@ -44,7 +44,7 @@ public class LaneRequestTagHandler extends AbstractRequestTagHandler { * 构造方法 */ public LaneRequestTagHandler() { - laneService = ServiceManager.getService(LaneService.class); + laneService = PluginServiceManager.getPluginService(LaneService.class); } /** diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/BaseLoadBalancerInterceptor.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/BaseLoadBalancerInterceptor.java index 438e9e6868..77bf16f2ef 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/BaseLoadBalancerInterceptor.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/BaseLoadBalancerInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.request.RequestData; import com.huaweicloud.sermant.router.common.request.RequestTag; import com.huaweicloud.sermant.router.common.utils.CollectionUtils; @@ -54,7 +54,7 @@ public class BaseLoadBalancerInterceptor extends AbstractInterceptor { * 构造方法 */ public BaseLoadBalancerInterceptor() { - loadBalancerService = ServiceManager.getService(LoadBalancerService.class); + loadBalancerService = PluginServiceManager.getPluginService(LoadBalancerService.class); canLoadZuul = canLoadZuul(); } diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/DiscoveryManagerInterceptor.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/DiscoveryManagerInterceptor.java index cba8353e0a..43272c464f 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/DiscoveryManagerInterceptor.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/DiscoveryManagerInterceptor.java @@ -20,7 +20,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.utils.ReflectUtils; import com.huaweicloud.sermant.router.common.config.RouterConfig; import com.huaweicloud.sermant.router.common.constants.RouterConstant; @@ -47,7 +47,7 @@ public class DiscoveryManagerInterceptor extends AbstractInterceptor { * 构造方法 */ public DiscoveryManagerInterceptor() { - configService = ServiceManager.getService(SpringConfigService.class); + configService = PluginServiceManager.getPluginService(SpringConfigService.class); routerConfig = PluginConfigManager.getPluginConfig(RouterConfig.class); } diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/EurekaHttpClientInterceptor.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/EurekaHttpClientInterceptor.java index 1d26017d0f..375c4eb43d 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/EurekaHttpClientInterceptor.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/EurekaHttpClientInterceptor.java @@ -19,7 +19,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.config.RouterConfig; import com.huaweicloud.sermant.router.common.constants.RouterConstant; import com.huaweicloud.sermant.router.spring.cache.AppCache; @@ -44,7 +44,7 @@ public class EurekaHttpClientInterceptor extends AbstractInterceptor { */ public EurekaHttpClientInterceptor() { routerConfig = PluginConfigManager.getPluginConfig(RouterConfig.class); - configService = ServiceManager.getService(SpringConfigService.class); + configService = PluginServiceManager.getPluginService(SpringConfigService.class); } @Override diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/NopInstanceFilterInterceptor.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/NopInstanceFilterInterceptor.java index 0d4ecb112c..88eb2b2cd8 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/NopInstanceFilterInterceptor.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/NopInstanceFilterInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.request.RequestData; import com.huaweicloud.sermant.router.common.utils.ThreadLocalUtils; import com.huaweicloud.sermant.router.spring.service.LoadBalancerService; @@ -38,7 +38,7 @@ public class NopInstanceFilterInterceptor extends AbstractInterceptor { * 构造方法 */ public NopInstanceFilterInterceptor() { - loadBalancerService = ServiceManager.getService(LoadBalancerService.class); + loadBalancerService = PluginServiceManager.getPluginService(LoadBalancerService.class); } @Override diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/RouteHandlerInterceptor.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/RouteHandlerInterceptor.java index 0ff912a653..454964cc67 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/RouteHandlerInterceptor.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/RouteHandlerInterceptor.java @@ -16,7 +16,7 @@ package com.huaweicloud.sermant.router.spring.interceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.handler.Handler; import com.huaweicloud.sermant.router.common.utils.CollectionUtils; import com.huaweicloud.sermant.router.common.utils.ThreadLocalUtils; @@ -56,7 +56,7 @@ public class RouteHandlerInterceptor implements HandlerInterceptor { * 构造方法 */ public RouteHandlerInterceptor() { - configService = ServiceManager.getService(SpringConfigService.class); + configService = PluginServiceManager.getPluginService(SpringConfigService.class); handlers = new ArrayList<>(); handlers.add(new LaneRequestTagHandler()); handlers.add(new RouteRequestTagHandler()); diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceInstanceListSupplierInterceptor.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceInstanceListSupplierInterceptor.java index db845db527..8666156dec 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceInstanceListSupplierInterceptor.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceInstanceListSupplierInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.utils.StringUtils; import com.huaweicloud.sermant.router.common.request.RequestData; import com.huaweicloud.sermant.router.common.utils.CollectionUtils; @@ -47,7 +47,7 @@ public class ServiceInstanceListSupplierInterceptor extends AbstractInterceptor * 构造方法 */ public ServiceInstanceListSupplierInterceptor() { - loadBalancerService = ServiceManager.getService(LoadBalancerService.class); + loadBalancerService = PluginServiceManager.getPluginService(LoadBalancerService.class); } @Override diff --git a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceRegistryInterceptor.java b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceRegistryInterceptor.java index 9f3a00d204..be1498b366 100644 --- a/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceRegistryInterceptor.java +++ b/sermant-plugins/sermant-router/spring-router-plugin/src/main/java/com/huaweicloud/sermant/router/spring/interceptor/ServiceRegistryInterceptor.java @@ -20,7 +20,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.router.common.config.RouterConfig; import com.huaweicloud.sermant.router.common.constants.RouterConstant; import com.huaweicloud.sermant.router.common.utils.ReflectUtils; @@ -52,7 +52,7 @@ public class ServiceRegistryInterceptor extends AbstractInterceptor { * 构造方法 */ public ServiceRegistryInterceptor() { - configService = ServiceManager.getService(SpringConfigService.class); + configService = PluginServiceManager.getPluginService(SpringConfigService.class); routerConfig = PluginConfigManager.getPluginConfig(RouterConfig.class); } diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistry.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistry.java index 0336af04ae..7253f974d0 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistry.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistry.java @@ -18,7 +18,7 @@ import com.huawei.dubbo.registry.service.nacos.NacosRegistryService; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.registry.NotifyListener; @@ -40,7 +40,7 @@ public class NacosRegistry extends FailbackRegistry { */ public NacosRegistry(URL url) { super(url); - registryService = ServiceManager.getService(NacosRegistryService.class); + registryService = PluginServiceManager.getPluginService(NacosRegistryService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistryFactory.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistryFactory.java index cb39111027..008724b9bb 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistryFactory.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/NacosRegistryFactory.java @@ -21,7 +21,7 @@ import com.huawei.dubbo.registry.utils.ReflectUtils; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.alibaba.dubbo.common.URL; import com.alibaba.dubbo.registry.Registry; @@ -41,8 +41,11 @@ */ public class NacosRegistryFactory extends AbstractRegistryFactory { private static final String ALIBABA_REGISTRY_CLASS_NAME = "com.huawei.dubbo.registry.alibaba.NacosRegistry"; + private static final Logger LOGGER = LoggerFactory.getLogger(); - private final NacosRegistryService registryService = ServiceManager.getService(NacosRegistryService.class); + + private final NacosRegistryService registryService = + PluginServiceManager.getPluginService(NacosRegistryService.class); @Override protected Registry createRegistry(URL url) { @@ -56,7 +59,7 @@ protected Registry createRegistry(URL url) { return (Registry) registryClass.get().getConstructor(URL.class).newInstance(url); } } catch (NoSuchMethodException | InstantiationException | IllegalAccessException - | InvocationTargetException e) { + | InvocationTargetException e) { LOGGER.log(Level.WARNING, "Can not get the registry", e); } return new NacosRegistry(url); diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/ServiceCenterRegistry.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/ServiceCenterRegistry.java index 53993f36b2..989c384a20 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/ServiceCenterRegistry.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/alibaba/ServiceCenterRegistry.java @@ -18,7 +18,7 @@ import com.huawei.dubbo.registry.service.RegistryService; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.alibaba.dubbo.registry.NotifyListener; import com.alibaba.dubbo.registry.support.FailbackRegistry; @@ -39,7 +39,7 @@ public class ServiceCenterRegistry extends FailbackRegistry { */ public ServiceCenterRegistry(com.alibaba.dubbo.common.URL url) { super(url); - registryService = ServiceManager.getService(RegistryService.class); + registryService = PluginServiceManager.getPluginService(RegistryService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistry.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistry.java index 84d00dbfcb..ffc987b754 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistry.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistry.java @@ -18,7 +18,7 @@ import com.huawei.dubbo.registry.service.nacos.NacosRegistryService; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.support.FailbackRegistry; @@ -39,7 +39,7 @@ public class NacosRegistry extends FailbackRegistry { */ public NacosRegistry(org.apache.dubbo.common.URL url) { super(url); - registryService = ServiceManager.getService(NacosRegistryService.class); + registryService = PluginServiceManager.getPluginService(NacosRegistryService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistryFactory.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistryFactory.java index 9113207119..df1b246cdc 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistryFactory.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/NacosRegistryFactory.java @@ -21,7 +21,7 @@ import com.huawei.dubbo.registry.utils.ReflectUtils; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import org.apache.dubbo.common.URL; import org.apache.dubbo.registry.Registry; @@ -41,8 +41,11 @@ */ public class NacosRegistryFactory extends AbstractRegistryFactory { private static final String APACHE_REGISTRY_CLASS_NAME = "com.huawei.dubbo.registry.apache.NacosRegistry"; + private static final Logger LOGGER = LoggerFactory.getLogger(); - private final NacosRegistryService registryService = ServiceManager.getService(NacosRegistryService.class); + + private final NacosRegistryService registryService = PluginServiceManager.getPluginService( + NacosRegistryService.class); @Override protected Registry createRegistry(URL url) { @@ -56,7 +59,7 @@ protected Registry createRegistry(URL url) { return (Registry) registryClass.get().getConstructor(URL.class).newInstance(url); } } catch (NoSuchMethodException | InstantiationException | IllegalAccessException - | InvocationTargetException e) { + | InvocationTargetException e) { LOGGER.log(Level.WARNING, "Can not get the registry", e); } return new com.huawei.dubbo.registry.apache.NacosRegistry(url); diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/ServiceCenterRegistry.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/ServiceCenterRegistry.java index 106afa3674..d3aaf4862e 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/ServiceCenterRegistry.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/apache/ServiceCenterRegistry.java @@ -18,7 +18,7 @@ import com.huawei.dubbo.registry.service.RegistryService; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import org.apache.dubbo.registry.NotifyListener; import org.apache.dubbo.registry.support.FailbackRegistry; @@ -39,7 +39,7 @@ public class ServiceCenterRegistry extends FailbackRegistry { */ public ServiceCenterRegistry(org.apache.dubbo.common.URL url) { super(url); - registryService = ServiceManager.getService(RegistryService.class); + registryService = PluginServiceManager.getPluginService(RegistryService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApacheInterfaceConfigInterceptor.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApacheInterfaceConfigInterceptor.java index 61caa8a62d..120cb4d814 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApacheInterfaceConfigInterceptor.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApacheInterfaceConfigInterceptor.java @@ -20,7 +20,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; /** * 增强AbstractInterfaceConfig类的setRegistries/loadRegistriesFromBackwardConfig方法 @@ -35,7 +35,7 @@ public class ApacheInterfaceConfigInterceptor extends AbstractInterceptor { * 构造方法 */ public ApacheInterfaceConfigInterceptor() { - registryConfigService = ServiceManager.getService(RegistryConfigService.class); + registryConfigService = PluginServiceManager.getPluginService(RegistryConfigService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApplicationConfigInterceptor.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApplicationConfigInterceptor.java index b9f21084f9..eb7f639713 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApplicationConfigInterceptor.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/ApplicationConfigInterceptor.java @@ -20,7 +20,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; /** * 增强ApplicationConfig类的setName方法 @@ -35,7 +35,7 @@ public class ApplicationConfigInterceptor extends AbstractInterceptor { * 构造方法 */ public ApplicationConfigInterceptor() { - applicationConfigService = ServiceManager.getService(ApplicationConfigService.class); + applicationConfigService = PluginServiceManager.getPluginService(ApplicationConfigService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/SpringApplicationInterceptor.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/SpringApplicationInterceptor.java index 2868c614de..fdd7f95c7d 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/SpringApplicationInterceptor.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/interceptor/SpringApplicationInterceptor.java @@ -20,7 +20,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import java.util.concurrent.atomic.AtomicBoolean; @@ -39,7 +39,7 @@ public class SpringApplicationInterceptor extends AbstractInterceptor { * 构造方法 */ public SpringApplicationInterceptor() { - registryService = ServiceManager.getService(RegistryService.class); + registryService = PluginServiceManager.getPluginService(RegistryService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/utils/ReflectUtils.java b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/utils/ReflectUtils.java index 2360cb0759..487bac6d3d 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/utils/ReflectUtils.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-plugin/src/main/java/com/huawei/dubbo/registry/utils/ReflectUtils.java @@ -80,7 +80,7 @@ public static Optional> defineClass(String className) { ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader(); try { return Optional.of(ClassLoaderUtils.defineClass(className, contextClassLoader, - ClassLoaderUtils.getClassResource(ClassLoader.getSystemClassLoader(), className))); + ClassLoaderUtils.getClassResource(ReflectUtils.class.getClassLoader(), className))); } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | IOException e) { // 有可能已经加载过了,直接用contextClassLoader.loadClass加载 try { diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/listener/GovernanceConfigListener.java b/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/listener/GovernanceConfigListener.java index 3d07b3afbc..d6433a22a0 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/listener/GovernanceConfigListener.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/listener/GovernanceConfigListener.java @@ -20,7 +20,7 @@ import com.huawei.dubbo.registry.entity.GovernanceData; import com.huawei.dubbo.registry.service.RegistryService; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.dynamicconfig.common.DynamicConfigEvent; import com.huaweicloud.sermant.core.service.dynamicconfig.common.DynamicConfigEventType; import com.huaweicloud.sermant.core.service.dynamicconfig.common.DynamicConfigListener; @@ -43,7 +43,7 @@ public class GovernanceConfigListener implements DynamicConfigListener { * 构造方法 */ public GovernanceConfigListener() { - registryService = ServiceManager.getService(RegistryService.class); + registryService = PluginServiceManager.getPluginService(RegistryService.class); } @Override diff --git a/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java b/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java index 32386c819a..eff485f22f 100644 --- a/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java +++ b/sermant-plugins/sermant-service-registry/dubbo-registry-service/src/main/java/com/huawei/dubbo/registry/service/RegistryServiceImpl.java @@ -37,7 +37,7 @@ import com.huaweicloud.sermant.core.plugin.common.PluginSchemaValidator; import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; import com.huaweicloud.sermant.core.plugin.config.ServiceMeta; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.utils.JarFileUtils; import com.huaweicloud.sermant.core.utils.StringUtils; @@ -104,40 +104,73 @@ */ public class RegistryServiceImpl implements RegistryService { private static final Logger LOGGER = LoggerFactory.getLogger(); + private static final EventBus EVENT_BUS = new EventBus(); + private static final Map> INTERFACE_MAP = new ConcurrentHashMap<>(); + private static final Map> SUBSCRIPTIONS = new ConcurrentHashMap<>(); + private static final Map> NOTIFIED_URL_MAP = new ConcurrentHashMap<>(); + private static final CountDownLatch FIRST_REGISTRATION_WAITER = new CountDownLatch(1); + private static final int REGISTRATION_WAITE_TIME = 30; + private static final List PENDING_SUBSCRIBE_EVENT = new CopyOnWriteArrayList<>(); + private static final AtomicBoolean SHUTDOWN = new AtomicBoolean(); + private static final String DEFAULT_TENANT_NAME = "default"; + private static final String CONSUMER_PROTOCOL_PREFIX = "consumer"; + private static final String GROUP_KEY = "group"; + private static final String VERSION_KEY = "version"; + private static final String ZONE_KEY = "zone"; + private static final String SERVICE_NAME_KEY = "service.name"; + private static final String INTERFACE_KEY = "interface"; + private static final String INTERFACE_DATA_KEY = "dubbo.interface.data"; + private static final String WILDCARD = "*"; + private static final String META_DATA_PREFIX = "service.meta.parameters."; + private static final String META_DATA_VERSION_KEY = "service.meta.version"; + private static final String META_DATA_ZONE_KEY = "service.meta.zone"; + private static final List IGNORE_REGISTRY_KEYS = Arrays.asList(GROUP_KEY, VERSION_KEY, SERVICE_NAME_KEY); + private static final List DEFAULT_INTERFACE_KEYS = Collections.singletonList("dubbo.tag"); private final List registryUrls = new ArrayList<>(); + private List ignoreKeys; + private ServiceCenterClient client; + private Microservice microservice; + private MicroserviceInstance microserviceInstance; + private ServiceCenterRegistration serviceCenterRegistration; + private ServiceCenterDiscovery serviceCenterDiscovery; + private boolean isRegistrationInProgress = true; + private RegisterConfig config; + private GovernanceService governanceService; + private ServiceMeta serviceMeta; + private RegisterServiceCommonConfig commonConfig; @Override @@ -149,10 +182,10 @@ public void startRegistration() { config = PluginConfigManager.getPluginConfig(RegisterConfig.class); commonConfig = PluginConfigManager.getPluginConfig(RegisterServiceCommonConfig.class); serviceMeta = ConfigManager.getConfig(ServiceMeta.class); - governanceService = ServiceManager.getService(GovernanceService.class); + governanceService = PluginServiceManager.getPluginService(GovernanceService.class); client = new ServiceCenterClient(new AddressManager(config.getProject(), commonConfig.getAddressList(), - EVENT_BUS), createSslProperties(), new DefaultRequestAuthHeaderProvider(), DEFAULT_TENANT_NAME, - Collections.emptyMap()); + EVENT_BUS), createSslProperties(), new DefaultRequestAuthHeaderProvider(), DEFAULT_TENANT_NAME, + Collections.emptyMap()); ignoreKeys = new ArrayList<>(); ignoreKeys.addAll(IGNORE_REGISTRY_KEYS); ignoreKeys.addAll(DEFAULT_INTERFACE_KEYS); @@ -224,18 +257,19 @@ public void addRegistryUrls(Object url) { @Override public void notifyGovernanceUrl() { SUBSCRIPTIONS.values().forEach(notifyListeners -> notifyListeners.forEach(notifyListener -> { - List urls = NOTIFIED_URL_MAP.get(notifyListener); - if (CollectionUtils.isEmpty(urls)) { - return; - } - List governanceUrls = wrapGovernanceData(urls); - if (governanceUrls == urls || (governanceUrls.containsAll(urls) && urls.containsAll(governanceUrls))) { - // 修改前后urls一致,或者修改前后的实例url一致,则不用通知 - return; + List urls = NOTIFIED_URL_MAP.get(notifyListener); + if (CollectionUtils.isEmpty(urls)) { + return; + } + List governanceUrls = wrapGovernanceData(urls); + if (governanceUrls == urls || (governanceUrls.containsAll(urls) + && urls.containsAll(governanceUrls))) { + // 修改前后urls一致,或者修改前后的实例url一致,则不用通知 + return; + } + ReflectUtils.notify(notifyListener, governanceUrls); + NOTIFIED_URL_MAP.put(notifyListener, governanceUrls); } - ReflectUtils.notify(notifyListener, governanceUrls); - NOTIFIED_URL_MAP.put(notifyListener, governanceUrls); - } )); } @@ -336,7 +370,7 @@ private String getVersion() { private List getSchemas() { return registryUrls.stream().map(this::getInterface).filter(StringUtils::isExist).distinct() - .collect(Collectors.toList()); + .collect(Collectors.toList()); } private String getInterface(Object url) { @@ -369,7 +403,7 @@ private String getHost() { private List getEndpoints() { return registryUrls.stream().map(this::getUrl).filter(StringUtils::isExist).distinct() - .collect(Collectors.toList()); + .collect(Collectors.toList()); } private Map getProperties() { @@ -378,7 +412,8 @@ private Map getProperties() { // 把registryUrls按接口名进行分组,组装成InterfaceData,并聚合到HashSet(去重)里面 Map> map = registryUrls.stream().collect(Collectors.groupingBy(this::getInterface, - Collectors.mapping(url -> getInterfaceData(url, protocolCache), Collectors.toCollection(HashSet::new)))); + Collectors.mapping(url -> getInterfaceData(url, protocolCache), + Collectors.toCollection(HashSet::new)))); Map properties = new HashMap<>(); properties.put(INTERFACE_DATA_KEY, JSONObject.toJSONString(map)); @@ -387,7 +422,7 @@ private Map getProperties() { // 由于http header的key不区分大小写,所以使用metadata做路由时,统一把key转为小写 // 由于dubbo注册时,会把'-'替换成'.',所以保持一致 serviceMeta.getParameters() - .forEach((key, value) -> properties.put(key.replace("-", ".").toLowerCase(Locale.ROOT), value)); + .forEach((key, value) -> properties.put(key.replace("-", ".").toLowerCase(Locale.ROOT), value)); } properties.put(VERSION_KEY, config.getVersion()); properties.put(ZONE_KEY, serviceMeta.getZone()); @@ -415,7 +450,7 @@ private InterfaceData getInterfaceData(Object url, Map> prot }); protocolCache.computeIfAbsent(interfaceName, value -> new HashSet<>()).add(ReflectUtils.getProtocol(url)); InterfaceData interfaceData = new InterfaceData(parameters.get(GROUP_KEY), parameters.get(VERSION_KEY), - parameters.get(SERVICE_NAME_KEY), order, map); + parameters.get(SERVICE_NAME_KEY), order, map); interfaceData.setProtocol(protocolCache.get(interfaceName)); return interfaceData; } @@ -445,7 +480,7 @@ private void createServiceCenterRegistration() { private List getSchemaInfos() { return registryUrls.stream().map(url -> createSchemaInfo(url).orElse(null)).filter(Objects::nonNull) - .collect(Collectors.toList()); + .collect(Collectors.toList()); } private Optional createSchemaInfo(Object url) { @@ -458,7 +493,7 @@ private Optional createSchemaInfo(Object url) { parameters.keySet().forEach(key -> { // 实例属性,会存到properties中,所以不需要在接口级参数中储存 if (key.startsWith(META_DATA_PREFIX) || META_DATA_VERSION_KEY.equals(key) || META_DATA_ZONE_KEY - .equals(key)) { + .equals(key)) { ignoreKeys.add(key); } }); @@ -467,7 +502,7 @@ private Optional createSchemaInfo(Object url) { // ignoreKeys中的参数会存在实例的properties中 // 2.6.x, 2.7.0-2.7.7在多实现的场景下,路径名会在接口名后拼一个序号,所以这里把路径名统一设置为接口名 String newUrlString = ReflectUtils.setPath(ReflectUtils.removeParameters(newUrl, ignoreKeys), interfaceName) - .toString(); + .toString(); String schema = newUrlString.substring(newUrlString.indexOf(microservice.getServiceName())); return Optional.of(new SchemaInfo(interfaceName, schema, DigestUtils.sha256Hex(schema))); } @@ -492,7 +527,7 @@ private void subscribe(Subscription subscription) { Object notifyListener = subscription.getNotifyListener(); if (notifyListener != null) { SUBSCRIPTIONS.computeIfAbsent(getSubscriptionKey(appId, serviceName, url), value -> new HashSet<>()) - .add(notifyListener); + .add(notifyListener); } List instances = new ArrayList<>(); serviceList.forEach(service -> { @@ -523,7 +558,7 @@ private void updateInterfaceMap() { private void updateInterfaceMap(Microservice service) { if (microservice.getAppId().equals(service.getAppId())) { service.getSchemas() - .forEach(schema -> INTERFACE_MAP.computeIfAbsent(schema, value -> new ArrayList<>()).add(service)); + .forEach(schema -> INTERFACE_MAP.computeIfAbsent(schema, value -> new ArrayList<>()).add(service)); } } @@ -590,11 +625,11 @@ private List wrapGovernanceData(List urls) { private com.huawei.dubbo.registry.entity.SchemaInfo getSchemaInfo(Object url) { Map parameters = ReflectUtils.getParameters(url); return new com.huawei.dubbo.registry.entity.SchemaInfo(parameters.get(INTERFACE_KEY), parameters.get(GROUP_KEY), - parameters.get(VERSION_KEY)); + parameters.get(VERSION_KEY)); } private Map> instancesToUrls(String appId, String serviceName, - List instances) { + List instances) { Map> urlMap = new HashMap<>(); // instances中的serviceId都是一样的,所以这里可以取第一个 @@ -610,17 +645,17 @@ private Map> getWildcardUrlMap(Map> map = new HashMap<>(); urlMap.forEach((key, urls) -> { map.computeIfAbsent(new SubscriptionKey(key.getAppId(), key.getServiceName(), key.getInterfaceName(), - WILDCARD, key.getVersion()), value -> new ArrayList<>()).addAll(urls); + WILDCARD, key.getVersion()), value -> new ArrayList<>()).addAll(urls); map.computeIfAbsent(new SubscriptionKey(key.getAppId(), key.getServiceName(), key.getInterfaceName(), - key.getGroup(), WILDCARD), value -> new ArrayList<>()).addAll(urls); + key.getGroup(), WILDCARD), value -> new ArrayList<>()).addAll(urls); map.computeIfAbsent(new SubscriptionKey(key.getAppId(), key.getServiceName(), key.getInterfaceName(), - WILDCARD, WILDCARD), value -> new ArrayList<>()).addAll(urls); + WILDCARD, WILDCARD), value -> new ArrayList<>()).addAll(urls); }); return map; } private void convertToUrlMap(Map> urlMap, String appId, String serviceName, - MicroserviceInstance instance, List schemaInfos) { + MicroserviceInstance instance, List schemaInfos) { Map properties = instance.getProperties(); String data = properties.get(INTERFACE_DATA_KEY); Map metaData = getMetaData(properties); @@ -629,7 +664,7 @@ private void convertToUrlMap(Map> urlMap, String a Object url = ReflectUtils.valueOf(endpoint); if (CollectionUtils.isEmpty(schemaInfos)) { urlMap.computeIfAbsent(new SubscriptionKey(appId, serviceName, getInterface(url)), - value -> new ArrayList<>()).add(url); + value -> new ArrayList<>()).add(url); return; } String protocol = ReflectUtils.getProtocol(url); @@ -645,15 +680,15 @@ private void convertToUrlMap(Map> urlMap, String a // 遍历所有的接口实现 list.forEach(interfaceData -> { if (!CollectionUtils.isEmpty(interfaceData.getProtocol()) - && !interfaceData.getProtocol().contains(protocol)) { + && !interfaceData.getProtocol().contains(protocol)) { return; } Map parameters = getParameters(interfaceData); // 组装所有接口实现的访问地址列表 urlMap.computeIfAbsent(getSubscriptionKey(appId, serviceName, newUrl, interfaceData), - value -> new ArrayList<>()) - .add(getUrlOnNotifying(newUrl, url, parameters, interfaceData.getOrder(), protocol)); + value -> new ArrayList<>()) + .add(getUrlOnNotifying(newUrl, url, parameters, interfaceData.getOrder(), protocol)); }); }); }); @@ -662,19 +697,19 @@ private void convertToUrlMap(Map> urlMap, String a private SubscriptionKey getSubscriptionKey(String appId, String serviceName, Object url) { Map parameters = ReflectUtils.getParameters(url); return new SubscriptionKey(appId, serviceName, parameters.get(INTERFACE_KEY), parameters.get(GROUP_KEY), - parameters.get(VERSION_KEY)); + parameters.get(VERSION_KEY)); } private SubscriptionKey getSubscriptionKey(String appId, String serviceName, Object url, - InterfaceData interfaceData) { + InterfaceData interfaceData) { return new SubscriptionKey(appId, serviceName, getInterface(url), interfaceData.getGroup(), - interfaceData.getVersion()); + interfaceData.getVersion()); } private Object getUrlOnNotifying(Object schemaUrl, Object addressUrl, Map parameters, - Integer order, String protocol) { + Integer order, String protocol) { Object url = ReflectUtils.setProtocol(ReflectUtils.setAddress(ReflectUtils.addParameters(schemaUrl, parameters), - ReflectUtils.getAddress(addressUrl)), protocol); + ReflectUtils.getAddress(addressUrl)), protocol); if (order == null) { return url; } @@ -710,7 +745,7 @@ private Map getMetaData(Map properties) { } private List getInterfaceDataList(Map> dataMap, - Map properties, String schemaId, Map metaData) { + Map properties, String schemaId, Map metaData) { if (CollectionUtils.isEmpty(dataMap)) { // 旧版本获取方式 return JSONArray.parseArray(properties.get(schemaId), InterfaceData.class); diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientInterceptor.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientInterceptor.java index 3723256ba3..d67ce75b82 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientInterceptor.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientInterceptor.java @@ -25,6 +25,7 @@ import com.huaweicloud.sermant.core.common.LoggerFactory; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import reactor.core.publisher.Flux; @@ -58,7 +59,7 @@ public ExecuteContext doBefore(ExecuteContext context) { try { mark(); String serviceId = (String) context.getArguments()[0]; - final RegisterCenterService service = ServiceManager.getService(RegisterCenterService.class); + final RegisterCenterService service = PluginServiceManager.getPluginService(RegisterCenterService.class); final List microServiceInstances = service.getServerList(serviceId); final Object target = context.getObject(); if (!microServiceInstances.isEmpty()) { diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptor.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptor.java index f4defbf9a0..cce454700b 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptor.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptor.java @@ -22,6 +22,7 @@ import com.huawei.registry.support.InstanceInterceptorSupport; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import reactor.core.publisher.Flux; @@ -47,7 +48,7 @@ public ExecuteContext doBefore(ExecuteContext context) { } try { mark(); - final RegisterCenterService service = ServiceManager.getService(RegisterCenterService.class); + final RegisterCenterService service = PluginServiceManager.getPluginService(RegisterCenterService.class); final List services = new ArrayList<>(service.getServices()); final Object target = context.getObject(); context.skip(isWebfLux(target) ? getServicesWithFlux(services, target) : getServices(services, target)); diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DynamicServerListInterceptor.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DynamicServerListInterceptor.java index 01855d29d3..ae19249f67 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DynamicServerListInterceptor.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/DynamicServerListInterceptor.java @@ -25,6 +25,7 @@ import com.huawei.registry.utils.HostUtils; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import com.huaweicloud.sermant.core.utils.ReflectUtils; @@ -50,7 +51,7 @@ public ExecuteContext doBefore(ExecuteContext context) { return context; } DynamicServerListLoadBalancer serverListLoadBalancer = (DynamicServerListLoadBalancer) object; - final RegisterCenterService service = ServiceManager.getService(RegisterCenterService.class); + final RegisterCenterService service = PluginServiceManager.getPluginService(RegisterCenterService.class); final List serverList = service.getServerList(serverListLoadBalancer.getName()); final List mergeServerList = convertAndMerge(serverListLoadBalancer, serverList); ReflectUtils.invokeMethod(object, "updateAllServerList", new Class[]{List.class}, diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/RegistrationInterceptor.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/RegistrationInterceptor.java index e8f83d0ac8..070a84b8aa 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/RegistrationInterceptor.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/RegistrationInterceptor.java @@ -28,6 +28,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import org.springframework.cloud.client.serviceregistry.Registration; @@ -50,7 +51,7 @@ public ExecuteContext doBefore(ExecuteContext context) { ZoneUtils.setZone(registration.getMetadata()); fillClientInfo(registration); if (super.isEnabled()) { - final RegisterCenterService service = ServiceManager.getService(RegisterCenterService.class); + final RegisterCenterService service = PluginServiceManager.getPluginService(RegisterCenterService.class); final FixedResult fixedResult = new FixedResult(); service.register(fixedResult); if (fixedResult.isSkip()) { diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/SpringFactoriesInterceptor.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/SpringFactoriesInterceptor.java index a8607a105a..3d45b38f97 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/SpringFactoriesInterceptor.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/interceptors/SpringFactoriesInterceptor.java @@ -58,7 +58,7 @@ public class SpringFactoriesInterceptor extends RegisterSwitchSupport { * 初始化加载注入定义 */ public SpringFactoriesInterceptor() { - for (ClassInjectDefine define : ServiceLoader.load(ClassInjectDefine.class)) { + for (ClassInjectDefine define : ServiceLoader.load(ClassInjectDefine.class, this.getClass().getClassLoader())) { if (define.plugin() == Plugin.SPRING_REGISTRY_PLUGIN) { CLASS_DEFINES.add(define); } diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/support/InstanceInterceptorSupport.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/support/InstanceInterceptorSupport.java index 1b6a45946e..ecf78cad4d 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/support/InstanceInterceptorSupport.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/main/java/com/huawei/registry/support/InstanceInterceptorSupport.java @@ -100,7 +100,7 @@ protected final Class getInstanceClass(String className) { Class result = null; try { result = ClassLoaderUtils.defineClass(className, contextClassLoader, - ClassLoaderUtils.getClassResource(ClassLoader.getSystemClassLoader(), className)); + ClassLoaderUtils.getClassResource(this.getClass().getClassLoader(), className)); } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException | IOException e) { // 有可能已经加载过了,直接用contextClassLoader.loadClass加载 try { diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientInterceptorTest.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientInterceptorTest.java index 50a0bbedf7..988a8b42cd 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientInterceptorTest.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientInterceptorTest.java @@ -23,6 +23,7 @@ import com.huawei.registry.services.RegisterCenterService; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import org.junit.Assert; @@ -64,7 +65,7 @@ public class DiscoveryClientInterceptorTest extends BaseRegistryTest ServiceManager.getService(RegisterCenterService.class)) + pluginServiceManagerMockedStatic.when(() -> PluginServiceManager.getPluginService(RegisterCenterService.class)) .thenReturn(registerCenterService); final ZookeeperInstanceSupplierInterceptorTest test = new ZookeeperInstanceSupplierInterceptorTest(); instanceList.add(test.buildInstance(8001)); diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptorTest.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptorTest.java index 044da2f916..1fcd79451e 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptorTest.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DiscoveryClientServiceInterceptorTest.java @@ -22,6 +22,7 @@ import com.huawei.registry.services.RegisterCenterService; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import org.junit.After; @@ -61,7 +62,7 @@ public class DiscoveryClientServiceInterceptorTest extends BaseRegistryTest ServiceManager.getService(RegisterCenterService.class)) + pluginServiceManagerMockedStatic.when(() -> PluginServiceManager.getPluginService(RegisterCenterService.class)) .thenReturn(registerCenterService); services.add("test1"); services.add("test2"); diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DynamicServerListInterceptorTest.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DynamicServerListInterceptorTest.java index 6cd937d14b..93f7b1f85b 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DynamicServerListInterceptorTest.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/DynamicServerListInterceptorTest.java @@ -23,6 +23,7 @@ import com.huawei.registry.services.RegisterCenterService; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import com.netflix.loadbalancer.DynamicServerListLoadBalancer; import com.netflix.loadbalancer.Server; @@ -63,7 +64,7 @@ public class DynamicServerListInterceptorTest extends BaseRegistryTest ServiceManager.getService(RegisterCenterService.class)) + pluginServiceManagerMockedStatic.when(() -> PluginServiceManager.getPluginService(RegisterCenterService.class)) .thenReturn(registerCenterService); final ZookeeperInstanceSupplierInterceptorTest test = new ZookeeperInstanceSupplierInterceptorTest(); instanceList.add(test.buildInstance(8001)); diff --git a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/RegistrationInterceptorTest.java b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/RegistrationInterceptorTest.java index b668e06f89..c277c9f96d 100644 --- a/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/RegistrationInterceptorTest.java +++ b/sermant-plugins/sermant-service-registry/spring-cloud-registry-plugin/src/test/java/com/huawei/registry/interceptors/RegistrationInterceptorTest.java @@ -23,6 +23,7 @@ import com.huawei.registry.services.RegisterCenterService; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.ServiceManager; import org.junit.Assert; @@ -50,7 +51,7 @@ public class RegistrationInterceptorTest extends BaseRegistryTest ServiceManager.getService(RegisterCenterService.class)) + pluginServiceManagerMockedStatic.when(() -> PluginServiceManager.getPluginService(RegisterCenterService.class)) .thenReturn(new RegisterCenterService() { @Override public void register(FixedResult result) { diff --git a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/cache/RuleCache.java b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/cache/RuleCache.java index 83888b27f9..c95980cffe 100644 --- a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/cache/RuleCache.java +++ b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/cache/RuleCache.java @@ -42,7 +42,7 @@ public class RuleCache { private static final String DEFAULT_RULE_NAME = "default-rule"; - private static final RemovalConfig REMOVAL_CONFIG = PluginConfigManager.getConfig(RemovalConfig.class); + private static final RemovalConfig REMOVAL_CONFIG = PluginConfigManager.getPluginConfig(RemovalConfig.class); private RuleCache() { } diff --git a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractRemovalInterceptor.java b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractRemovalInterceptor.java index fca88bd7c1..824101b8d6 100644 --- a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractRemovalInterceptor.java +++ b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractRemovalInterceptor.java @@ -21,7 +21,7 @@ import com.huaweicloud.sermant.config.RemovalRule; import com.huaweicloud.sermant.core.common.LoggerFactory; import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.entity.InstanceInfo; import com.huaweicloud.sermant.entity.RemovalCountInfo; import com.huaweicloud.sermant.service.RemovalEventService; @@ -42,7 +42,8 @@ public abstract class AbstractRemovalInterceptor extends AbstractSwitchInterceptor { private static final Logger LOGGER = LoggerFactory.getLogger(); - private final RemovalEventService removalEventService = ServiceManager.getService(RemovalEventService.class); + private final RemovalEventService removalEventService = PluginServiceManager.getPluginService( + RemovalEventService.class); @Override public ExecuteContext doBefore(ExecuteContext context) { diff --git a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractSwitchInterceptor.java b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractSwitchInterceptor.java index 6960fc0bf2..4b717de2e7 100644 --- a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractSwitchInterceptor.java +++ b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/AbstractSwitchInterceptor.java @@ -31,7 +31,7 @@ public abstract class AbstractSwitchInterceptor extends AbstractInterceptor { /** * 离群实例摘除配置 */ - protected static final RemovalConfig REMOVAL_CONFIG = PluginConfigManager.getConfig(RemovalConfig.class); + protected static final RemovalConfig REMOVAL_CONFIG = PluginConfigManager.getPluginConfig(RemovalConfig.class); @Override public ExecuteContext before(ExecuteContext context) { diff --git a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/SpringApplicationInterceptor.java b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/SpringApplicationInterceptor.java index e731a58635..74b5362ca4 100644 --- a/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/SpringApplicationInterceptor.java +++ b/sermant-plugins/sermant-service-removal/removal-plugin/src/main/java/com/huaweicloud/sermant/interceptor/SpringApplicationInterceptor.java @@ -18,7 +18,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.service.RemovalConfigService; import java.util.concurrent.atomic.AtomicBoolean; @@ -38,7 +38,7 @@ public class SpringApplicationInterceptor extends AbstractInterceptor { * 构造方法 */ public SpringApplicationInterceptor() { - removalConfigService = ServiceManager.getService(RemovalConfigService.class); + removalConfigService = PluginServiceManager.getPluginService(RemovalConfigService.class); } @Override diff --git a/sermant-plugins/sermant-service-removal/removal-plugin/src/test/java/com/huaweicloud/sermant/cache/RuleCacheTest.java b/sermant-plugins/sermant-service-removal/removal-plugin/src/test/java/com/huaweicloud/sermant/cache/RuleCacheTest.java index 1747543d52..ba85534b11 100644 --- a/sermant-plugins/sermant-service-removal/removal-plugin/src/test/java/com/huaweicloud/sermant/cache/RuleCacheTest.java +++ b/sermant-plugins/sermant-service-removal/removal-plugin/src/test/java/com/huaweicloud/sermant/cache/RuleCacheTest.java @@ -19,6 +19,8 @@ import com.huaweicloud.sermant.config.RemovalConfig; import com.huaweicloud.sermant.config.RemovalRule; import com.huaweicloud.sermant.core.config.ConfigManager; +import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; + import org.junit.AfterClass; import org.junit.Assert; import org.junit.BeforeClass; @@ -57,7 +59,7 @@ public static void setUp() { removalConfig.setRules(new ArrayList<>()); removalConfig.getRules().add(removalRule); configManagerMockedStatic = Mockito.mockStatic(ConfigManager.class); - configManagerMockedStatic.when(() -> ConfigManager.getConfig(RemovalConfig.class)).thenReturn(removalConfig); + configManagerMockedStatic.when(() -> PluginConfigManager.getPluginConfig(RemovalConfig.class)).thenReturn(removalConfig); } @Test diff --git a/sermant-plugins/sermant-service-removal/removal-service/src/main/java/com/huaweicloud/sermant/service/RequestDataCountTask.java b/sermant-plugins/sermant-service-removal/removal-service/src/main/java/com/huaweicloud/sermant/service/RequestDataCountTask.java index 33f1b1a7ca..a61666bdd8 100644 --- a/sermant-plugins/sermant-service-removal/removal-service/src/main/java/com/huaweicloud/sermant/service/RequestDataCountTask.java +++ b/sermant-plugins/sermant-service-removal/removal-service/src/main/java/com/huaweicloud/sermant/service/RequestDataCountTask.java @@ -19,9 +19,9 @@ import com.huaweicloud.sermant.cache.InstanceCache; import com.huaweicloud.sermant.config.RemovalConfig; import com.huaweicloud.sermant.core.common.LoggerFactory; -import com.huaweicloud.sermant.core.config.ConfigManager; +import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; import com.huaweicloud.sermant.core.plugin.service.PluginService; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.entity.InstanceInfo; import com.huaweicloud.sermant.entity.RequestCountData; @@ -46,7 +46,7 @@ public class RequestDataCountTask implements PluginService { private static final Logger LOGGER = LoggerFactory.getLogger(); - private final RemovalConfig removalConfig = ConfigManager.getConfig(RemovalConfig.class); + private final RemovalConfig removalConfig = PluginConfigManager.getPluginConfig(RemovalConfig.class); private ScheduledThreadPoolExecutor scheduledThreadPoolExecutor; @@ -129,7 +129,7 @@ public void start() { scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1); scheduledThreadPoolExecutor.scheduleWithFixedDelay(this::processData, removalConfig.getWindowsTime(), removalConfig.getWindowsTime(), TimeUnit.MILLISECONDS); - removalEventService = ServiceManager.getService(RemovalEventService.class); + removalEventService = PluginServiceManager.getPluginService(RemovalEventService.class); } @Override diff --git a/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/declarer/AbstractCollectorDeclarer.java b/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/declarer/AbstractCollectorDeclarer.java index 81106d1607..9f749e4cc6 100644 --- a/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/declarer/AbstractCollectorDeclarer.java +++ b/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/declarer/AbstractCollectorDeclarer.java @@ -17,8 +17,8 @@ package com.huaweicloud.visibility.declarer; -import com.huaweicloud.sermant.core.config.ConfigManager; import com.huaweicloud.sermant.core.plugin.agent.declarer.AbstractPluginDeclarer; +import com.huaweicloud.sermant.core.plugin.config.PluginConfigManager; import com.huaweicloud.visibility.config.VisibilityConfig; /** @@ -28,7 +28,7 @@ * @since 2023-01-09 */ public abstract class AbstractCollectorDeclarer extends AbstractPluginDeclarer { - private VisibilityConfig visibilityConfig = ConfigManager.getConfig(VisibilityConfig.class); + private VisibilityConfig visibilityConfig = PluginConfigManager.getPluginConfig(VisibilityConfig.class); @Override public boolean isEnabled() { diff --git a/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/interceptor/AbstractCollectorInterceptor.java b/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/interceptor/AbstractCollectorInterceptor.java index bcd319323f..1ebcd201cf 100644 --- a/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/interceptor/AbstractCollectorInterceptor.java +++ b/sermant-plugins/sermant-service-visibility/service-visibility-plugin/src/main/java/com/huaweicloud/visibility/interceptor/AbstractCollectorInterceptor.java @@ -19,7 +19,7 @@ import com.huaweicloud.sermant.core.common.BootArgsIndexer; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import com.huaweicloud.sermant.core.service.visibility.common.ServiceType; import com.huaweicloud.sermant.core.service.visibility.entity.Consanguinity; import com.huaweicloud.sermant.core.service.visibility.entity.Contract; @@ -48,14 +48,14 @@ public abstract class AbstractCollectorInterceptor extends AbstractInterceptor { /** * 消息发送服务 */ - protected final CollectorService collectorService = ServiceManager.getService(CollectorService.class); + protected final CollectorService collectorService = PluginServiceManager.getPluginService(CollectorService.class); /** * 保存方法信息 * - * @param methodName 方法名称 + * @param methodName 方法名称 * @param interfaceClass 接口信息 - * @param contract 契约信息 + * @param contract 契约信息 */ public void fillMethodInfo(String methodName, Class interfaceClass, Contract contract) { List methodNames = Arrays.asList(methodName.split(SEPARATOR)); @@ -74,7 +74,7 @@ public void fillMethodInfo(String methodName, Class interfaceClass, Contract /** * 保存参数信息 * - * @param method 方法 + * @param method 方法 * @param methodInfo 方法信息存储类 */ public void fillParamInfo(Method method, MethodInfo methodInfo) { @@ -94,7 +94,7 @@ public void fillParamInfo(Method method, MethodInfo methodInfo) { /** * 保存返回值信息 * - * @param method 方法 + * @param method 方法 * @param methodInfo 方法信息存储类 */ public void fillReturnInfo(Method method, MethodInfo methodInfo) { diff --git a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/SpringApplicationInterceptor.java b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/SpringApplicationInterceptor.java index c519facab3..cc68545638 100644 --- a/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/SpringApplicationInterceptor.java +++ b/sermant-plugins/sermant-springboot-registry/springboot-registry-plugin/src/main/java/com/huawei/discovery/interceptors/SpringApplicationInterceptor.java @@ -23,7 +23,7 @@ import com.huaweicloud.sermant.core.plugin.agent.entity.ExecuteContext; import com.huaweicloud.sermant.core.plugin.agent.interceptor.AbstractInterceptor; -import com.huaweicloud.sermant.core.service.ServiceManager; +import com.huaweicloud.sermant.core.plugin.service.PluginServiceManager; import java.util.concurrent.atomic.AtomicBoolean; @@ -44,8 +44,8 @@ public class SpringApplicationInterceptor extends AbstractInterceptor { * 构造方法 */ public SpringApplicationInterceptor() { - registryService = ServiceManager.getService(RegistryService.class); - configCenterService = ServiceManager.getService(ConfigCenterService.class); + registryService = PluginServiceManager.getPluginService(RegistryService.class); + configCenterService = PluginServiceManager.getPluginService(ConfigCenterService.class); } @Override