From 6b9d22f2f3fe0cdbe208b2467546abea32688608 Mon Sep 17 00:00:00 2001 From: chengyouling Date: Mon, 3 Mar 2025 16:07:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=A4=E6=96=AD=E6=9C=8D?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FilterExtendTestInterceptor.java | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java b/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java index 3a20ca06b..999505154 100644 --- a/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java +++ b/sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java @@ -3,18 +3,29 @@ import java.util.logging.Logger; import org.apache.dubbo.common.Version; +import org.apache.dubbo.rpc.Invocation; +import org.apache.dubbo.rpc.Invoker; import io.sermant.core.common.LoggerFactory; import io.sermant.core.plugin.agent.entity.ExecuteContext; import io.sermant.core.plugin.agent.interceptor.Interceptor; +import io.sermant.flowcontrol.common.config.CommonConst; public class FilterExtendTestInterceptor implements Interceptor { private static final Logger LOGGER = LoggerFactory.getLogger(); @Override public ExecuteContext before(ExecuteContext context) throws Exception { - Object invoke = context.getArguments()[0]; - String currentVersion = invoke.getClass().getPackage().getImplementationVersion(); + Invocation invocation = (Invocation) context.getArguments()[1]; + Invoker curInvoker = invocation.getInvoker(); + if (curInvoker == null) { + curInvoker = (Invoker) context.getArguments()[0]; + } + if (isProvider(curInvoker)) { + LOGGER.info("===========================>is provider"); + return context; + } + String currentVersion = curInvoker.getClass().getPackage().getImplementationVersion(); if (currentVersion == null) { currentVersion = Version.getVersion(); } @@ -24,6 +35,11 @@ public ExecuteContext before(ExecuteContext context) throws Exception { return context; } + private boolean isProvider(Invoker invoker) { + return !CommonConst.DUBBO_CONSUMER.equals(invoker.getUrl().getParameter(CommonConst.DUBBO_SIDE, + CommonConst.DUBBO_PROVIDER)); + } + @Override public ExecuteContext after(ExecuteContext context) throws Exception { return context;