Skip to content

Commit

Permalink
增加判断服务
Browse files Browse the repository at this point in the history
  • Loading branch information
chengyouling committed Mar 3, 2025
1 parent 0de51a2 commit 6b9d22f
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,29 @@
import java.util.logging.Logger;

import org.apache.dubbo.common.Version;

Check failure on line 5 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 Wrong order for 'org.apache.dubbo.common.Version' import. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:5:1: error: Wrong order for 'org.apache.dubbo.common.Version' import. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
import org.apache.dubbo.rpc.Invocation;
import org.apache.dubbo.rpc.Invoker;

import io.sermant.core.common.LoggerFactory;

Check failure on line 9 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 Wrong order for 'io.sermant.core.common.LoggerFactory' import. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:9:1: error: Wrong order for 'io.sermant.core.common.LoggerFactory' import. (com.puppycrawl.tools.checkstyle.checks.imports.ImportOrderCheck)
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 {

Check failure on line 14 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 Type Javadoc comment is missing @SInCE tag. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:14:0: error: Type Javadoc comment is missing @SInCE tag. (com.puppycrawl.tools.checkstyle.checks.javadoc.WriteTagCheck)
private static final Logger LOGGER = LoggerFactory.getLogger();

Check failure on line 15 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'member def modifier' has incorrect indentation level 2, expected level should be 4. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:15:3: error: 'member def modifier' has incorrect indentation level 2, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)

@Override

Check failure on line 17 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'method def modifier' has incorrect indentation level 2, expected level should be 4. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:17:3: error: 'method def modifier' has incorrect indentation level 2, expected level should be 4. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
public ExecuteContext before(ExecuteContext context) throws Exception {
Object invoke = context.getArguments()[0];
String currentVersion = invoke.getClass().getPackage().getImplementationVersion();
Invocation invocation = (Invocation) context.getArguments()[1];

Check failure on line 19 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'method def' child has incorrect indentation level 4, expected level should be 8. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:19:5: error: 'method def' child has incorrect indentation level 4, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
Invoker<?> curInvoker = invocation.getInvoker();

Check failure on line 20 in sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java

View workflow job for this annotation

GitHub Actions / Checkstyle

[Checkstyle Check] reported by reviewdog 🐶 'method def' child has incorrect indentation level 4, expected level should be 8. Raw Output: /home/runner/work/Sermant/Sermant/./sermant-plugins/sermant-flowcontrol/flowcontrol-plugin/src/main/java/io/sermant/flowcontrol/FilterExtendTestInterceptor.java:20:5: error: 'method def' child has incorrect indentation level 4, expected level should be 8. (com.puppycrawl.tools.checkstyle.checks.indentation.IndentationCheck)
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();
}
Expand All @@ -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;
Expand Down

0 comments on commit 6b9d22f

Please sign in to comment.