[Feature] [ShenYu]<Apache ShenYu (incubating) plugin support dubbo proxy>(#8869) (#162)

This commit is contained in:
hutaishi 2022-04-21 17:43:50 +08:00 committed by GitHub
parent 72bc256418
commit 504f9c415b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 1708 additions and 20 deletions

View File

@ -99,6 +99,7 @@ jobs:
- guava-eventbus-scenario
- shenyu-2.4.x-scenario
- jdk-threadpool-scenario
- shenyu-2.4.x-dubbo-scenario
steps:
- uses: actions/checkout@v2
with:

View File

@ -31,6 +31,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<spring-webflux.version>5.0.0.RELEASE</spring-webflux.version>
<apache-dubbo.version>2.7.0</apache-dubbo.version>
</properties>
@ -46,6 +47,15 @@
<artifactId>apm-spring-webflux-5.x-plugin</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${apache-dubbo.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>

View File

@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.plugin.shenyu.v24x;
import java.lang.reflect.Method;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
import org.apache.skywalking.apm.plugin.shenyu.v24x.util.CommonUtil;
/**
* shenyu ApacheDubboPlugin Interceptor.
*/
public class ApacheDubboPluginInterceptor implements InstanceMethodsAroundInterceptor {
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
CommonUtil.createLocalSpan(allArguments, "DubboPlugin");
}
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Object ret) throws Throwable {
return CommonUtil.stopLocalSpan(allArguments, ret);
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
CommonUtil.logErrorLocalSpan(allArguments, t);
}
}

View File

@ -0,0 +1,25 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.plugin.shenyu.v24x;
public class Constant {
public static final String SKYWALKING_CONTEXT_SNAPSHOT = "SKYWALKING_CONTEXT_SNAPSHOT";
public static final String PROXY_RPC_SPAN = "PROXY_RPC_SPAN";
}

View File

@ -18,11 +18,6 @@
package org.apache.skywalking.apm.plugin.shenyu.v24x;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.apache.skywalking.apm.agent.core.context.CarrierItem;
import org.apache.skywalking.apm.agent.core.context.ContextCarrier;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
@ -39,21 +34,27 @@ import org.springframework.http.HttpHeaders;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebExchangeDecorator;
import org.springframework.web.server.adapter.DefaultServerWebExchange;
import reactor.core.publisher.Mono;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import static org.apache.skywalking.apm.plugin.shenyu.v24x.Constant.SKYWALKING_CONTEXT_SNAPSHOT;
/**
* Apache shenyu global-plugin interceptor.
*/
public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsAroundInterceptor {
public static final String SHENYU_AGENT_TRACE_ID = "shenyu-agent-trace-id";
public static final String SKYWALKING_CONTEXT_SNAPSHOT = "SKYWALKING_CONTEXT_SNAPSHOT";
public static final String SKYWALKING_SPAN = "SKYWALKING_SPAN";
@Override
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
MethodInterceptResult result) throws Throwable {
MethodInterceptResult result) throws Throwable {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
ContextCarrier carrier = new ContextCarrier();
@ -85,7 +86,7 @@ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsArou
@Override
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
Object ret) throws Throwable {
Object ret) throws Throwable {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
@ -105,22 +106,22 @@ public class GlobalPluginExecuteMethodInterceptor implements InstanceMethodsArou
return monoReturn
.doOnError(throwable -> span.errorOccurred().log(throwable))
.doFinally(s -> {
try {
Optional.ofNullable(exchange.getResponse().getStatusCode()).ifPresent(httpStatus -> {
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, httpStatus.value());
if (httpStatus.isError()) {
span.errorOccurred();
}
});
} finally {
span.asyncFinish();
}
try {
Optional.ofNullable(exchange.getResponse().getStatusCode()).ifPresent(httpStatus -> {
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, httpStatus.value());
if (httpStatus.isError()) {
span.errorOccurred();
}
});
} finally {
span.asyncFinish();
}
});
}
@Override
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
Class<?>[] argumentsTypes, Throwable t) {
Class<?>[] argumentsTypes, Throwable t) {
}
public static EnhancedInstance getInstance(Object o) {

View File

@ -0,0 +1,73 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.plugin.shenyu.v24x.define;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static org.apache.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.InstanceMethodsInterceptPoint;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMethodsEnhancePluginDefine;
import org.apache.skywalking.apm.agent.core.plugin.match.ClassMatch;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
public class ApacheDubboPluginInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
private static final String ENHANCE_CLASS = "org.apache.shenyu.plugin.apache.dubbo.ApacheDubboPlugin";
private static final String INTERCEPT_CLASS =
"org.apache.skywalking.apm.plugin.shenyu.v24x.ApacheDubboPluginInterceptor";
private static final String INTERCEPT_METHOD = "doDubboInvoker";
@Override
protected ClassMatch enhanceClass() {
return byName(ENHANCE_CLASS);
}
@Override
public ConstructorInterceptPoint[] getConstructorsInterceptPoints() {
return new ConstructorInterceptPoint[0];
}
@Override
public InstanceMethodsInterceptPoint[] getInstanceMethodsInterceptPoints() {
return new InstanceMethodsInterceptPoint[]{
new InstanceMethodsInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getMethodsMatcher() {
return named(INTERCEPT_METHOD);
}
@Override
public String getMethodsInterceptor() {
return INTERCEPT_CLASS;
}
@Override
public boolean isOverrideArgs() {
return false;
}
}
};
}
}

View File

@ -0,0 +1,78 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.apache.skywalking.apm.plugin.shenyu.v24x.util;
import static org.apache.skywalking.apm.plugin.shenyu.v24x.Constant.PROXY_RPC_SPAN;
import java.util.Objects;
import org.apache.skywalking.apm.agent.core.context.ContextManager;
import org.apache.skywalking.apm.agent.core.context.ContextSnapshot;
import org.apache.skywalking.apm.agent.core.context.trace.AbstractSpan;
import org.apache.skywalking.apm.agent.core.context.trace.SpanLayer;
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
import org.springframework.web.server.ServerWebExchange;
import org.springframework.web.server.ServerWebExchangeDecorator;
import org.springframework.web.server.adapter.DefaultServerWebExchange;
public class CommonUtil {
public static EnhancedInstance getEnhancedServerWebExchange(Object o) {
EnhancedInstance instance = null;
if (o instanceof DefaultServerWebExchange) {
instance = (EnhancedInstance) o;
} else if (o instanceof ServerWebExchangeDecorator) {
ServerWebExchange delegate = ((ServerWebExchangeDecorator) o).getDelegate();
return getEnhancedServerWebExchange(delegate);
}
return instance;
}
public static void createLocalSpan(Object[] allArguments, String localOp) {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
EnhancedInstance enhancedInstance = CommonUtil.getEnhancedServerWebExchange(allArguments[0]);
AbstractSpan span = ContextManager.createLocalSpan(localOp);
span.setComponent(ComponentsDefine.APACHE_SHENYU);
SpanLayer.asRPCFramework(span);
if (enhancedInstance != null && enhancedInstance.getSkyWalkingDynamicField() != null) {
ContextManager.continued((ContextSnapshot) enhancedInstance.getSkyWalkingDynamicField());
}
exchange.getAttributes().put(PROXY_RPC_SPAN, span);
}
public static Object stopLocalSpan(Object[] allArguments, Object ret) {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
AbstractSpan span = (AbstractSpan) exchange.getAttributes().get(PROXY_RPC_SPAN);
if (Objects.isNull(span)) {
return ret;
}
ContextManager.stopSpan(span);
return ret;
}
public static void logErrorLocalSpan(Object[] allArguments, Throwable t) {
ServerWebExchange exchange = (ServerWebExchange) allArguments[0];
AbstractSpan span = (AbstractSpan) exchange.getAttributes().get(PROXY_RPC_SPAN);
if (Objects.isNull(span)) {
return ;
}
span.errorOccurred().log(t);
}
}

View File

@ -16,3 +16,5 @@
shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.GlobalPluginInstrumentation
shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.ServerWebExchangeInstrumentation
shenyu-2.4.x=org.apache.skywalking.apm.plugin.shenyu.v24x.define.ApacheDubboPluginInstrumentation

View File

@ -0,0 +1,134 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
segmentItems:
- serviceName: shenyu-gateway
segmentSize: nq 0
segments:
- segmentId: not null
spans:
- operationName: test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.$invoke(String,String[],Object[])
parentSpanId: 0
spanId: 1
spanLayer: RPCFramework
startTime: nq 0
endTime: nq 0
componentId: 3
isError: false
spanType: Exit
peer: localhost:9999
skipAnalysis: false
tags:
- { key: url, value: 'dubbo://localhost:9999/test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.$invoke(String,String[],Object[])' }
- operationName: DubboPlugin
parentSpanId: -1
spanId: 0
spanLayer: RPCFramework
startTime: nq 0
endTime: nq 0
componentId: 127
isError: false
spanType: Local
peer: ''
skipAnalysis: false
refs:
- { parentEndpoint: /dubbo/findById, networkAddress: '', refType: CrossThread,
parentSpanId: 0, parentTraceSegmentId: not null,
parentServiceInstance: not null, parentService: shenyu-gateway,
traceId: not null }
- segmentId: not null
spans:
- operationName: /dubbo/findById
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 127
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- { key: url, value: 'http://localhost:9196/dubbo/findById?id=1' }
- { key: http.method, value: GET }
- { key: http.status_code, value: '200' }
refs:
- { parentEndpoint: 'GET:/entry/dubbo-service', networkAddress: 'localhost:9196',
refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not null,
parentServiceInstance: not null, parentService: entry-service,
traceId: not null }
- serviceName: dubbo-provider
segmentSize: nq 0
segments:
- segmentId: not null
spans:
- operationName: test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService.findById(String)
operationId: 0
parentSpanId: -1
spanId: 0
spanLayer: RPCFramework
startTime: nq 0
endTime: nq 0
componentId: 3
isError: false
spanType: Entry
peer: not null
skipAnalysis: false
tags:
- { key: url, value: not null }
refs:
- {parentEndpoint: DubboPlugin, networkAddress: 'localhost:9999', refType: CrossProcess,
parentSpanId: 1, parentTraceSegmentId: not null,
parentServiceInstance: not null , parentService: shenyu-gateway,
traceId: not null }
- serviceName: entry-service
segmentSize: nq 0
segments:
- segmentId: not null
spans:
- operationName: /dubbo/findById
parentSpanId: 0
spanId: 1
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 13
isError: false
spanType: Exit
peer: localhost:9196
skipAnalysis: false
tags:
- {key: url, value: 'http://localhost:9196/dubbo/findById'}
- {key: http.method, value: GET}
- operationName: GET:/entry/dubbo-service
parentSpanId: -1
spanId: 0
spanLayer: Http
startTime: nq 0
endTime: nq 0
componentId: 14
isError: false
spanType: Entry
peer: ''
skipAnalysis: false
tags:
- {key: url, value: 'http://localhost:8888/entry/dubbo-service'}
- {key: http.method, value: GET}
meterItems: []

View File

@ -0,0 +1,24 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
type: jvm
entryService: http://localhost:8888/entry/dubbo-service
healthCheck: http://localhost:8888/entry/check
startScript: ./bin/startup.sh
runningMode: with_optional
withPlugins: apm-shenyu-2.4.x-plugin-*.jar
environment:
dependencies:

View File

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<groupId>org.apache.skywalking</groupId>
<artifactId>shenyu-2.4.x-dubbo-scenario</artifactId>
<version>1.0.0</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<modules>
<module>shenyu-dubbo-entry</module>
<module>shenyu-dubbo-gateway</module>
<module>shenyu-dubbo</module>
<module>shenyu-dubbo-dist</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<compiler.version>1.8</compiler.version>
<test.framework.version>2.4.2</test.framework.version>
<spring.boot.version>2.2.2.RELEASE</spring.boot.version>
<shenyu.gateway.version>2.4.2</shenyu.gateway.version>
<lombok.version>1.18.20</lombok.version>
<dubbo.version>2.7.0</dubbo.version>
<!--just for test-->
<fastjson.version>1.2.79</fastjson.version>
</properties>
<name>skywalking-shenyu-2.4.x-dubbo-scenario</name>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring.boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-gateway</artifactId>
<version>${test.framework.version}</version>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-apache-dubbo</artifactId>
<version>${test.framework.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
<version>${dubbo.version}</version>
</dependency>
<!--just for test-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<finalName>shenyu-2.4.x-dubbo-scenario</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${compiler.version}</source>
<target>${compiler.version}</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,29 @@
#!/bin/bash
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
home="$(cd "$(dirname $0)"; pwd)"
java -jar ${agent_opts} "-Dskywalking.agent.service_name=shenyu-gateway" ${home}/../libs/shenyu-dubbo-gateway.jar &
sleep 2
java -jar ${agent_opts} "-Dskywalking.agent.service_name=dubbo-provider" ${home}/../libs/shenyu-dubbo.jar &
sleep 1
java -jar ${agent_opts} "-Dskywalking.agent.service_name=entry-service" ${home}/../libs/shenyu-dubbo-entry.jar &
sleep 1

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>shenyu-2.4.x-dubbo-scenario</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shenyu-dubbo-dist</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>assemble</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
<outputDirectory>../target/</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<assembly
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>./bin</directory>
<fileMode>0775</fileMode>
</fileSet>
</fileSets>
<files>
<file>
<source>../shenyu-dubbo-entry/target/shenyu-dubbo-entry.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
<file>
<source>../shenyu-dubbo-gateway/target/shenyu-dubbo-gateway.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
<file>
<source>../shenyu-dubbo/target/shenyu-dubbo.jar</source>
<outputDirectory>./libs</outputDirectory>
<fileMode>0775</fileMode>
</file>
</files>
</assembly>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>shenyu-2.4.x-dubbo-scenario</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shenyu-dubbo-entry</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
</dependencies>
<build>
<finalName>shenyu-dubbo-entry</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.apache.skywalking.apm.testcase.shenyu.entry;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class EntryApplication {
public static void main(final String[] args) {
SpringApplication.run(EntryApplication.class, args);
}
}

View File

@ -0,0 +1,58 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.apache.skywalking.apm.testcase.shenyu.entry.http;
import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;
import java.util.Optional;
import java.util.concurrent.TimeUnit;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;
/**
* http entry service.
*/
@RestController
@RequestMapping("/entry")
public class HttpEntryController {
private static final String ORDER_GATEWAY_URL = "http://localhost:9196/dubbo/findById?id=1";
private final RestTemplate restTemplate = new RestTemplate();
@RequestMapping("/check")
public String healthCheck() {
return "ok";
}
@GetMapping(value = "/dubbo-service", produces = {APPLICATION_JSON_VALUE})
public ResponseEntity<String> httpService() throws Exception {
TimeUnit.MILLISECONDS.sleep(100);
ResponseEntity<String> entity = restTemplate.getForEntity(ORDER_GATEWAY_URL, String.class);
if (entity.getStatusCode().is2xxSuccessful()) {
return ResponseEntity.ok(Optional.ofNullable(entity.getBody()).orElse(""));
}
return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body("failed");
}
}

View File

@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
server:
port: 8888

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>shenyu-2.4.x-dubbo-scenario</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shenyu-dubbo-gateway</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-gateway</artifactId>
</dependency>
<dependency>
<groupId>org.apache.shenyu</groupId>
<artifactId>shenyu-spring-boot-starter-plugin-apache-dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
</dependency>
</dependencies>
<build>
<finalName>shenyu-dubbo-gateway</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,33 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.apache.skywalking.apm.testcase.shenyu.gateway;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* shenyu gateway application.
*/
@SpringBootApplication
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}

View File

@ -0,0 +1,108 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.apache.skywalking.apm.testcase.shenyu.gateway.init;
import java.io.InputStream;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import org.apache.shenyu.common.dto.MetaData;
import org.apache.shenyu.common.dto.PluginData;
import org.apache.shenyu.common.dto.RuleData;
import org.apache.shenyu.common.dto.SelectorData;
import org.apache.shenyu.common.dto.convert.plugin.DubboRegisterConfig;
import org.apache.shenyu.plugin.apache.dubbo.cache.ApacheDubboConfigCache;
import org.apache.shenyu.plugin.global.cache.MetaDataCache;
import org.apache.shenyu.sync.data.api.PluginDataSubscriber;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j;
/**
* init gateway router runner.
*/
@Slf4j
@Component
public class InitRouterRunner implements CommandLineRunner {
@Autowired
private PluginDataSubscriber subscriber;
@Override
public void run(String... args) throws Exception {
String pluginPath = "/shenyu-plugin.json";
String selectorPath = "/shenyu-selector.json";
String rulePath = "/shenyu-rule.json";
try (
InputStream pluginStream = getClass().getResourceAsStream(pluginPath);
InputStream selectorStream = getClass().getResourceAsStream(selectorPath);
InputStream ruleStream = getClass().getResourceAsStream(rulePath)) {
Map<String, PluginData> pluginDataMap = JSON.parseObject(pluginStream,
new TypeReference<Map<String, PluginData>>() {
}.getType(), Feature.AllowComment);
Map<String, List<SelectorData>> selectorDataMap = JSON.parseObject(selectorStream,
new TypeReference<Map<String, List<SelectorData>>>() {
}.getType(), Feature.AllowComment);
Map<String, List<RuleData>> ruleDataMap = JSON.parseObject(ruleStream,
new TypeReference<Map<String, List<RuleData>>>() {
}.getType(), Feature.AllowComment);
pluginDataMap.values().forEach(subscriber::onSubscribe);
selectorDataMap.values().stream().flatMap(Collection::stream)
.forEach(data -> subscriber.onSelectorSubscribe(data));
ruleDataMap.values().stream().flatMap(Collection::stream).forEach(subscriber::onRuleSubscribe);
initDubbo();
log.info("init router data finish.");
} catch (Exception e) {
log.error("init router failed", e);
}
}
private void initDubbo() {
DubboRegisterConfig config = new DubboRegisterConfig();
config.setProtocol("dubbo");
config.setRegister("N/A");
ApacheDubboConfigCache.getInstance().init(config);
MetaData metaData = new MetaData();
metaData.setId("1");
metaData.setAppName("demo");
metaData.setContextPath("/dubbo");
metaData.setPath("/dubbo/findById");
metaData.setRpcType("dubbo");
metaData.setServiceName("test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService");
metaData.setMethodName("findById");
metaData.setParameterTypes("java.lang.String");
metaData.setRpcExt("{\"url\":\"dubbo://localhost:9999\",\"loadbalance\":\"random\",\"retries\":0,"
+ "\"timeout\":3000,\"sent\":false,\"cluster\":\"failover\"}");
metaData.setEnabled(true);
ApacheDubboConfigCache.getInstance().build(metaData);
MetaDataCache.getInstance().cache(metaData);
}
}

View File

@ -0,0 +1,23 @@
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
server:
port: 9196
spring:
main:
allow-bean-definition-overriding: true

View File

@ -0,0 +1,252 @@
/**
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
*/
{
"request": {
"id": "20",
"name": "request",
"config": null,
"role": "HttpProcess",
"enabled": false,
"sort": 120
},
"jwt": {
"id": "19",
"name": "jwt",
"config": "{\"secretKey\":\"key\"}",
"role": "Authentication",
"enabled": false,
"sort": 30
},
"paramMapping": {
"id": "22",
"name": "paramMapping",
"config": "{\"ruleHandlePageType\":\"custom\"}",
"role": "HttpProcess",
"enabled": false,
"sort": 70
},
"modifyResponse": {
"id": "23",
"name": "modifyResponse",
"config": "{\"ruleHandlePageType\":\"custom\"}",
"role": "HttpProcess",
"enabled": false,
"sort": 220
},
"sign": {
"id": "1",
"name": "sign",
"config": null,
"role": "Authentication",
"enabled": false,
"sort": 20
},
"dubbo": {
"id": "6",
"name": "dubbo",
"config": "{\"register\":\"N/A\",\"multiSelectorHandle\":\"1\",\"threadpool\":\"cached\",\"corethreads\":0,\"threads\":2147483647,\"queues\":0}",
"role": "Proxy",
"enabled": true,
"sort": 310
},
"motan": {
"id": "17",
"name": "motan",
"config": "{\"register\":\"127.0.0.1:2181\"}",
"role": "Proxy",
"enabled": false,
"sort": 310
},
"oauth2": {
"id": "21",
"name": "oauth2",
"config": null,
"role": "Authentication",
"enabled": false,
"sort": 40
},
"rateLimiter": {
"id": "4",
"name": "rateLimiter",
"config": "{\"master\":\"mymaster\",\"mode\":\"standalone\",\"url\":\"192.168.1.1:6379\",\"password\":\"abc\"}",
"role": "FaultTolerance",
"enabled": false,
"sort": 60
},
"websocket": {
"id": "26",
"name": "websocket",
"config": "{\"multiSelectorHandle\":\"1\"}",
"role": "Proxy",
"enabled": true,
"sort": 200
},
"mqtt": {
"id": "28",
"name": "mqtt",
"config": "{\"port\": 9500,\"bossGroupThreadCount\": 1,\"maxPayloadSize\": 65536,\"workerGroupThreadCount\": 12,\"userName\": \"shenyu\",\"password\": \"shenyu\",\"isEncryptPassword\": false,\"encryptMode\": \"\",\"leakDetectorLevel\": \"DISABLED\"}",
"role": "Proxy",
"enabled": false,
"sort": 125
},
"tars": {
"id": "13",
"name": "tars tested",
"config": "{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}",
"role": "Proxy",
"enabled": false,
"sort": 310
},
"cryptorRequest": {
"id": "24",
"name": "cryptorRequest",
"config": null,
"role": "Cryptor",
"enabled": true,
"sort": 100
},
"divide": {
"id": "5",
"name": "divide",
"config": "{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\"}",
"role": "Proxy",
"enabled": false,
"sort": 200
},
"waf": {
"id": "2",
"name": "waf",
"config": "{\"model\":\"black\"}",
"role": "Authentication",
"enabled": false,
"sort": 50
},
"redirect": {
"id": "16",
"name": "redirect",
"config": null,
"role": "HttpProcess",
"enabled": false,
"sort": 110
},
"sentinel": {
"id": "10",
"name": "sentinel",
"config": null,
"role": "FaultTolerance",
"enabled": false,
"sort": 140
},
"hystrix": {
"id": "9",
"name": "hystrix",
"config": null,
"role": "FaultTolerance",
"enabled": false,
"sort": 130
},
"sofa": {
"id": "11",
"name": "sofa",
"config": "{\"protocol\":\"zookeeper\",\"register\":\"127.0.0.1:2181\"}",
"role": "Proxy",
"enabled": false,
"sort": 310
},
"cache": {
"id": "30",
"name": "cache",
"config": "{\"cacheType\":\"memory\"}",
"role": "Cache",
"enabled": false,
"sort": 10
},
"contextPath": {
"id": "14",
"name": "contextPath",
"config": null,
"role": "HttpProcess",
"enabled": true,
"sort": 80
},
"generalContext": {
"id": "27",
"name": "generalContext",
"config": null,
"role": "Common",
"enabled": true,
"sort": 125
},
"rewrite": {
"id": "3",
"name": "rewrite",
"config": null,
"role": "HttpProcess",
"enabled": false,
"sort": 90
},
"springCloud": {
"id": "8",
"name": "springCloud",
"config": null,
"role": "Proxy",
"enabled": false,
"sort": 200
},
"grpc": {
"id": "15",
"name": "grpc",
"config": "{\"multiSelectorHandle\":\"1\",\"multiRuleHandle\":\"0\",\"threadpool\":\"cached\"}",
"role": "Proxy",
"enabled": false,
"sort": 310
},
"resilience4j": {
"id": "12",
"name": "resilience4j",
"config": null,
"role": "FaultTolerance",
"enabled": false,
"sort": 310
},
"logging": {
"id": "18",
"name": "logging",
"config": null,
"role": "Logging",
"enabled": false,
"sort": 160
},
"cryptorResponse": {
"id": "25",
"name": "cryptorResponse",
"config": null,
"role": "Cryptor",
"enabled": true,
"sort": 410
},
"loggingRocketMQ": {
"id": "29",
"name": "loggingRocketMQ",
"config": "{\"topic\":\"shenyu-access-logging\", \"namesrvAddr\": \"localhost:9876\",\"producerGroup\":\"shenyu-plugin-logging-rocketmq\"}",
"role": "Logging",
"enabled": false,
"sort": 170
}
}

View File

@ -0,0 +1,41 @@
/**
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
*/
{
"1": [
{
"id":"1",
"name":"/dubbo/findById",
"pluginName":"dubbo",
"selectorId":"1",
"matchMode":0,
"sort":1,
"enabled":true,
"loged":true,
"handle":"{\"retries\":0,\"loadbalance\":\"random\",\"timeout\":3000}",
"conditionDataList":[
{
"paramType":"uri",
"operator":"=",
"paramName":"/",
"paramValue":"/dubbo/findById"
}
]
}
]
}

View File

@ -0,0 +1,43 @@
/**
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
*/
{
"dubbo": [
{
"id":"1",
"pluginId":"6",
"pluginName":"dubbo",
"name":"/dubbo",
"matchMode":0,
"type":1,
"sort":1,
"enabled":true,
"logged":true,
"continued":true,
"handle":"[{\"port\":0,\"weight\":50,\"warmup\":10,\"protocol\":\"dubbo://\",\"upstreamHost\":\"localhost\",\"upstreamUrl\":\"localhost:9999\",\"status\":true,\"timestamp\":1650471116019}]",
"conditionList":[
{
"paramType":"uri",
"operator":"match",
"paramName":"/",
"paramValue":"/dubbo/**"
}
]
}
]
}

View File

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one or more
~ contributor license agreements. See the NOTICE file distributed with
~ this work for additional information regarding copyright ownership.
~ The ASF licenses this file to You under the Apache License, Version 2.0
~ (the "License"); you may not use this file except in compliance with
~ the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
~
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>shenyu-2.4.x-dubbo-scenario</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>shenyu-dubbo</artifactId>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</dependency>
<dependency>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo</artifactId>
</dependency>
</dependencies>
<build>
<finalName>shenyu-dubbo</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.apache.skywalking.apm.testcase.shenyu.http;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService;
import test.apache.skywalking.apm.testcase.shenyu.http.services.impl.OrderServiceImpl;
@Configuration
public class DubboConfig {
private ApplicationConfig applicationConfig = new ApplicationConfig("demo");
private RegistryConfig registryConfig = new RegistryConfig("N/A");
private ProtocolConfig protocolConfig = new ProtocolConfig("dubbo", 9999);
@Bean(destroyMethod = "unexport")
public ServiceConfig<OrderService> service() {
ServiceConfig<OrderService> serviceConfig = new ServiceConfig<>();
serviceConfig.setApplication(applicationConfig);
serviceConfig.setRegistry(registryConfig);
serviceConfig.setProtocol(protocolConfig);
serviceConfig.setInterface(OrderService.class);
serviceConfig.setRef(new OrderServiceImpl());
serviceConfig.setTimeout(5000);
serviceConfig.export();
return serviceConfig;
}
@Bean(destroyMethod = "destroy")
public ReferenceConfig<OrderService> reference() {
ReferenceConfig<OrderService> referenceConfig = new ReferenceConfig<>();
referenceConfig.setApplication(applicationConfig);
referenceConfig.setInterface(OrderService.class);
referenceConfig.setUrl("dubbo://localhost:9999");
return referenceConfig;
}
}

View File

@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.apache.skywalking.apm.testcase.shenyu.http;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ShenyuDubboApplication {
public static void main(final String[] args) {
SpringApplication.run(ShenyuDubboApplication.class, args);
}
}

View File

@ -0,0 +1,34 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package test.apache.skywalking.apm.testcase.shenyu.http.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* http health check endpoint.
*/
@RestController
@RequestMapping("/health")
public class HealthController {
@RequestMapping("/check")
public String healthCheck() {
return "ok";
}
}

View File

@ -0,0 +1,24 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package test.apache.skywalking.apm.testcase.shenyu.http.services;
public interface OrderService {
String findById(String id);
}

View File

@ -0,0 +1,30 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package test.apache.skywalking.apm.testcase.shenyu.http.services.impl;
import test.apache.skywalking.apm.testcase.shenyu.http.services.OrderService;
public class OrderServiceImpl implements OrderService {
@Override
public String findById(String id) {
return "order data of id = " + id;
}
}

View File

@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
server:
port: 7777

View File

@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# lists your version here (Contains only the last version number of each minor version.)
2.4.2