Remove plugin for ServiceComb Java Chassis 0.x with plugin tests. (#108)
This commit is contained in:
parent
add2bbf208
commit
4c71b72817
|
|
@ -62,7 +62,6 @@ jobs:
|
|||
- rabbitmq-scenario
|
||||
- redisson-scenario
|
||||
- resttemplate-4.x-scenario
|
||||
- servicecomb-0.x-scenario
|
||||
- servicecomb-1.x-scenario
|
||||
- shardingsphere-3.x-scenario
|
||||
- shardingsphere-4.0.x-scenario
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ Release Notes.
|
|||
------------------
|
||||
* Support Undertow thread pool metrics collecting.
|
||||
* Support Tomcat thread pool metric collect.
|
||||
* Remove plugin for ServiceComb Java Chassis 0.x
|
||||
|
||||
#### Documentation
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
<artifactId>servicecomb-plugin</artifactId>
|
||||
|
||||
<modules>
|
||||
<module>servicecomb-java-chassis-0.x-plugin</module>
|
||||
<module>servicecomb-java-chassis-1.x-plugin</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
|
|
|||
|
|
@ -1,46 +0,0 @@
|
|||
<?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>servicecomb-plugin</artifactId>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
<version>8.10.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>apm-servicecomb-java-chassis-0.x-plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>servicecomb-java-chassis-0.x-plugin</name>
|
||||
<url>http://maven.apache.org</url>
|
||||
|
||||
<properties>
|
||||
<java-chassis-core.version>0.5.0</java-chassis-core.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.servicecomb</groupId>
|
||||
<artifactId>java-chassis-core</artifactId>
|
||||
<version>${java-chassis-core.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* 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.servicecomb;
|
||||
|
||||
import io.servicecomb.core.Invocation;
|
||||
import java.lang.reflect.Method;
|
||||
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;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
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.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
|
||||
public class ProducerOperationHandlerInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
Invocation invocation = (Invocation) allArguments[0];
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
CarrierItem next = contextCarrier.items();
|
||||
while (next.hasNext()) {
|
||||
next = next.next();
|
||||
next.setHeadValue(invocation.getContext().get(next.getHeadKey()));
|
||||
}
|
||||
String operationName = invocation.getMicroserviceQualifiedName();
|
||||
AbstractSpan span = ContextManager.createEntrySpan(operationName, contextCarrier);
|
||||
String url = invocation.getOperationMeta().getOperationPath();
|
||||
Tags.URL.set(span, url);
|
||||
span.setComponent(ComponentsDefine.SERVICECOMB);
|
||||
SpanLayer.asRPCFramework(span);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
Object ret) throws Throwable {
|
||||
Invocation invocation = (Invocation) allArguments[0];
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
int statusCode = invocation.getStatus().getStatusCode();
|
||||
if (statusCode >= 400) {
|
||||
span.errorOccurred();
|
||||
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, statusCode);
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
Class<?>[] argumentsTypes, Throwable t) {
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
span.log(t);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* 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.servicecomb;
|
||||
|
||||
import io.servicecomb.core.Invocation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.net.URI;
|
||||
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;
|
||||
import org.apache.skywalking.apm.agent.core.context.tag.Tags;
|
||||
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.agent.core.plugin.interceptor.enhance.InstanceMethodsAroundInterceptor;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
|
||||
public class TransportClientHandlerInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
Invocation invocation = (Invocation) allArguments[0];
|
||||
if (!checkRegisterStatus(invocation)) {
|
||||
return;
|
||||
}
|
||||
URI uri = new URI(invocation.getEndpoint().toString());
|
||||
String peer = uri.getHost() + ":" + uri.getPort();
|
||||
String operationName = invocation.getMicroserviceQualifiedName();
|
||||
final ContextCarrier contextCarrier = new ContextCarrier();
|
||||
AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, peer);
|
||||
CarrierItem next = contextCarrier.items();
|
||||
while (next.hasNext()) {
|
||||
next = next.next();
|
||||
invocation.getContext().put(next.getHeadKey(), next.getHeadValue());
|
||||
}
|
||||
String url = invocation.getOperationMeta().getOperationPath();
|
||||
Tags.URL.set(span, url);
|
||||
span.setComponent(ComponentsDefine.SERVICECOMB);
|
||||
SpanLayer.asRPCFramework(span);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
Object ret) throws Throwable {
|
||||
Invocation invocation = (Invocation) allArguments[0];
|
||||
if (!checkRegisterStatus(invocation)) {
|
||||
return ret;
|
||||
}
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
int statusCode = invocation.getStatus().getStatusCode();
|
||||
if (statusCode >= 400) {
|
||||
span.errorOccurred();
|
||||
Tags.HTTP_RESPONSE_STATUS_CODE.set(span, statusCode);
|
||||
}
|
||||
ContextManager.stopSpan();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
Class<?>[] argumentsTypes, Throwable t) {
|
||||
Invocation invocation = (Invocation) allArguments[0];
|
||||
if (!checkRegisterStatus(invocation)) {
|
||||
return;
|
||||
}
|
||||
AbstractSpan span = ContextManager.activeSpan();
|
||||
span.log(t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Serviecomb chassis Consumers and providers need to register at the service center. If the consumer is not
|
||||
* registered then return false.
|
||||
*/
|
||||
private Boolean checkRegisterStatus(Invocation invocation) {
|
||||
return null != invocation.getOperationMeta() && null != invocation.getEndpoint();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* 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.servicecomb.define;
|
||||
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
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 org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
||||
/**
|
||||
* {@link ProducerOperationHandlerInstrumentation} represents that skywalking intercept {@link
|
||||
* io.servicecomb.core.handler.impl.ProducerOperationHandler#handle(io.servicecomb.core.Invocation,
|
||||
* io.servicecomb.swagger.invocation.AsyncResponse)}by using ProducerOperationHandlerInterceptor
|
||||
*/
|
||||
public class ProducerOperationHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
private static final String ENHANCE_CLASS = "io.servicecomb.core.handler.impl.ProducerOperationHandler";
|
||||
|
||||
private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.servicecomb.ProducerOperationHandlerInterceptor";
|
||||
|
||||
@Override
|
||||
protected ClassMatch enhanceClass() {
|
||||
return NameMatch.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("handle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return INTERCEPT_CLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOverrideArgs() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* 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.servicecomb.define;
|
||||
|
||||
import net.bytebuddy.description.method.MethodDescription;
|
||||
import net.bytebuddy.matcher.ElementMatcher;
|
||||
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 org.apache.skywalking.apm.agent.core.plugin.match.NameMatch;
|
||||
|
||||
import static net.bytebuddy.matcher.ElementMatchers.named;
|
||||
|
||||
/**
|
||||
* {@link TransportClientHandlerInstrumentation} represents that skywalking intercept {@link
|
||||
* io.servicecomb.core.handler.impl.TransportClientHandler} by using linkTransportClientHandlerInterceptor
|
||||
*/
|
||||
public class TransportClientHandlerInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
|
||||
|
||||
private static final String ENHANCE_CLASS = "io.servicecomb.core.handler.impl.TransportClientHandler";
|
||||
|
||||
private static final String INTERCEPT_CLASS = "org.apache.skywalking.apm.plugin.servicecomb.TransportClientHandlerInterceptor";
|
||||
|
||||
@Override
|
||||
protected ClassMatch enhanceClass() {
|
||||
return NameMatch.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("handle");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMethodsInterceptor() {
|
||||
return INTERCEPT_CLASS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOverrideArgs() {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
# 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.
|
||||
|
||||
servicecomb-0.x=org.apache.skywalking.apm.plugin.servicecomb.define.ProducerOperationHandlerInstrumentation
|
||||
servicecomb-0.x=org.apache.skywalking.apm.plugin.servicecomb.define.TransportClientHandlerInstrumentation
|
||||
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
* 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.servicecomb;
|
||||
|
||||
import io.servicecomb.core.Endpoint;
|
||||
import io.servicecomb.core.Invocation;
|
||||
import io.servicecomb.core.definition.OperationMeta;
|
||||
import io.servicecomb.core.definition.SchemaMeta;
|
||||
import io.servicecomb.swagger.invocation.InvocationType;
|
||||
import io.servicecomb.swagger.invocation.SwaggerInvocation;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.List;
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.apache.skywalking.apm.agent.core.conf.Config;
|
||||
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
|
||||
import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.apache.skywalking.apm.agent.core.context.util.TagValuePair;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.agent.test.helper.SegmentHelper;
|
||||
import org.apache.skywalking.apm.agent.test.helper.SpanHelper;
|
||||
import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
|
||||
import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
|
||||
import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
|
||||
import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockRunnerDelegate(TracingSegmentRunner.class)
|
||||
public class ProducerOperationHandlerInterceptorTest {
|
||||
|
||||
@Rule
|
||||
public AgentServiceRule agentServiceRule = new AgentServiceRule();
|
||||
@Mock
|
||||
Response.StatusType statusType;
|
||||
@SegmentStoragePoint
|
||||
private SegmentStorage segmentStorage;
|
||||
private ProducerOperationHandlerInterceptor invocationInterceptor;
|
||||
@Mock
|
||||
private OperationMeta operationMeta;
|
||||
@Mock
|
||||
private EnhancedInstance enhancedInstance;
|
||||
@Mock
|
||||
private Invocation invocation;
|
||||
@Mock
|
||||
private Endpoint endpoint;
|
||||
@Mock
|
||||
private Method method;
|
||||
@Mock
|
||||
private SwaggerInvocation swagger;
|
||||
private Object[] allArguments;
|
||||
private Class[] argumentsType;
|
||||
private Object[] swaggerArguments;
|
||||
|
||||
@Mock
|
||||
private SchemaMeta schemaMeta;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ServiceManager.INSTANCE.boot();
|
||||
invocationInterceptor = new ProducerOperationHandlerInterceptor();
|
||||
PowerMockito.mock(Invocation.class);
|
||||
when(operationMeta.getSchemaMeta()).thenReturn(schemaMeta);
|
||||
when(endpoint.getAddress()).thenReturn("0.0.0.0:7777");
|
||||
when(invocation.getEndpoint()).thenReturn(endpoint);
|
||||
when(invocation.getMicroserviceQualifiedName()).thenReturn("productorTest");
|
||||
when(operationMeta.getOperationPath()).thenReturn("/bmi");
|
||||
when(invocation.getOperationMeta()).thenReturn(operationMeta);
|
||||
when(invocation.getStatus()).thenReturn(statusType);
|
||||
when(statusType.getStatusCode()).thenReturn(200);
|
||||
when(method.getName()).thenReturn("producer");
|
||||
when(invocation.getInvocationType()).thenReturn(InvocationType.PRODUCER);
|
||||
Config.Agent.SERVICE_NAME = "serviceComnTestCases-APP";
|
||||
|
||||
allArguments = new Object[] {invocation};
|
||||
argumentsType = new Class[] {};
|
||||
swaggerArguments = new Class[] {};
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConsumer() throws Throwable {
|
||||
|
||||
invocationInterceptor.beforeMethod(enhancedInstance, method, allArguments, argumentsType, null);
|
||||
invocationInterceptor.afterMethod(enhancedInstance, method, allArguments, argumentsType, null);
|
||||
|
||||
Assert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
|
||||
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
|
||||
|
||||
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
|
||||
assertCombSpan(spans.get(0));
|
||||
verify(invocation, times(3)).getContext();
|
||||
}
|
||||
|
||||
private void assertCombSpan(AbstractTracingSpan span) {
|
||||
assertThat(span.getOperationName(), is("productorTest"));
|
||||
assertThat(SpanHelper.getComponentId(span), is(28));
|
||||
List<TagValuePair> tags = SpanHelper.getTags(span);
|
||||
assertThat(tags.get(0).getValue(), is("/bmi"));
|
||||
assertThat(span.isEntry(), is(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
/*
|
||||
* 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.servicecomb;
|
||||
|
||||
import io.servicecomb.core.Endpoint;
|
||||
import io.servicecomb.core.Invocation;
|
||||
import io.servicecomb.core.definition.OperationMeta;
|
||||
import io.servicecomb.core.definition.SchemaMeta;
|
||||
import io.servicecomb.core.provider.consumer.ReferenceConfig;
|
||||
import io.servicecomb.swagger.invocation.InvocationType;
|
||||
import io.servicecomb.swagger.invocation.SwaggerInvocation;
|
||||
import java.util.List;
|
||||
import javax.ws.rs.core.Response;
|
||||
import org.apache.skywalking.apm.agent.core.boot.ServiceManager;
|
||||
import org.apache.skywalking.apm.agent.core.conf.Config;
|
||||
import org.apache.skywalking.apm.agent.core.context.trace.AbstractTracingSpan;
|
||||
import org.apache.skywalking.apm.agent.core.context.trace.TraceSegment;
|
||||
import org.apache.skywalking.apm.agent.core.context.util.TagValuePair;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.agent.test.helper.SegmentHelper;
|
||||
import org.apache.skywalking.apm.agent.test.helper.SpanHelper;
|
||||
import org.apache.skywalking.apm.agent.test.tools.AgentServiceRule;
|
||||
import org.apache.skywalking.apm.agent.test.tools.SegmentStorage;
|
||||
import org.apache.skywalking.apm.agent.test.tools.SegmentStoragePoint;
|
||||
import org.apache.skywalking.apm.agent.test.tools.TracingSegmentRunner;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import org.powermock.modules.junit4.PowerMockRunnerDelegate;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockRunnerDelegate(TracingSegmentRunner.class)
|
||||
public class TransportClientHandlerInterceptorTest {
|
||||
|
||||
@Rule
|
||||
public AgentServiceRule agentServiceRule = new AgentServiceRule();
|
||||
@Mock
|
||||
Response.StatusType statusType;
|
||||
@Mock
|
||||
ReferenceConfig referenceConfig;
|
||||
@SegmentStoragePoint
|
||||
private SegmentStorage segmentStorage;
|
||||
private TransportClientHandlerInterceptor nextInterceptor;
|
||||
@Mock
|
||||
private OperationMeta operationMeta;
|
||||
@Mock
|
||||
private EnhancedInstance enhancedInstance;
|
||||
@Mock
|
||||
private Invocation invocation;
|
||||
@Mock
|
||||
private Endpoint endpoint;
|
||||
@Mock
|
||||
private SwaggerInvocation swagger;
|
||||
private Object[] allArguments;
|
||||
private Class[] argumentsType;
|
||||
private Object[] swaggerArguments;
|
||||
|
||||
@Mock
|
||||
private SchemaMeta schemaMeta;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
ServiceManager.INSTANCE.boot();
|
||||
nextInterceptor = new TransportClientHandlerInterceptor();
|
||||
PowerMockito.mock(Invocation.class);
|
||||
when(operationMeta.getSchemaMeta()).thenReturn(schemaMeta);
|
||||
when(endpoint.toString()).thenReturn("/bmi");
|
||||
when(invocation.getEndpoint()).thenReturn(endpoint);
|
||||
when(invocation.getMicroserviceQualifiedName()).thenReturn("consumerTest");
|
||||
when(operationMeta.getOperationPath()).thenReturn("/bmi");
|
||||
when(invocation.getOperationMeta()).thenReturn(operationMeta);
|
||||
when(invocation.getStatus()).thenReturn(statusType);
|
||||
when(statusType.getStatusCode()).thenReturn(200);
|
||||
when(invocation.getInvocationType()).thenReturn(InvocationType.CONSUMER);
|
||||
Config.Agent.SERVICE_NAME = "serviceComnTestCases-APP";
|
||||
|
||||
allArguments = new Object[] {invocation};
|
||||
argumentsType = new Class[] {};
|
||||
swaggerArguments = new Class[] {};
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConsumer() throws Throwable {
|
||||
nextInterceptor.beforeMethod(enhancedInstance, null, allArguments, argumentsType, null);
|
||||
nextInterceptor.afterMethod(enhancedInstance, null, allArguments, argumentsType, null);
|
||||
Assert.assertThat(segmentStorage.getTraceSegments().size(), is(1));
|
||||
TraceSegment traceSegment = segmentStorage.getTraceSegments().get(0);
|
||||
List<AbstractTracingSpan> spans = SegmentHelper.getSpans(traceSegment);
|
||||
assertCombSpan(spans.get(0));
|
||||
verify(invocation, times(3)).getContext();
|
||||
}
|
||||
|
||||
private void assertCombSpan(AbstractTracingSpan span) {
|
||||
assertThat(span.getOperationName(), is("consumerTest"));
|
||||
assertThat(SpanHelper.getComponentId(span), is(28));
|
||||
List<TagValuePair> tags = SpanHelper.getTags(span);
|
||||
assertThat(tags.get(0).getValue(), is("/bmi"));
|
||||
assertThat(span.isExit(), is(true));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -74,7 +74,6 @@
|
|||
- rocketMQ-3.x
|
||||
- rocketMQ-4.x
|
||||
- sentinel-1.x
|
||||
- servicecomb-0.x
|
||||
- servicecomb-1.x
|
||||
- sharding-sphere-3.x
|
||||
- sharding-sphere-4.0.0
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ metrics based on the tracing data.
|
|||
* [Apache Dubbo](https://github.com/apache/dubbo) 2.7.x -> 3.x
|
||||
* [Motan](https://github.com/weibocom/motan) 0.2.x -> 1.1.0
|
||||
* [gRPC](https://github.com/grpc/grpc-java) 1.x
|
||||
* [Apache ServiceComb Java Chassis](https://github.com/apache/servicecomb-java-chassis) 0.1 -> 0.5,1.x
|
||||
* [Apache ServiceComb Java Chassis](https://github.com/apache/servicecomb-java-chassis) 1.x
|
||||
* [SOFARPC](https://github.com/alipay/sofa-rpc) 5.4.0
|
||||
* [Armeria](https://github.com/line/armeria) 0.63.0 -> 0.98.0
|
||||
* [Apache Avro](http://avro.apache.org) 1.7.0 - 1.8.x
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
#!/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} ${home}/../libs/servicecomb-0.x-scenario.jar &
|
||||
|
|
@ -1,67 +0,0 @@
|
|||
# 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: servicecomb-0.x-scenario
|
||||
segmentSize: gt 2
|
||||
segments:
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: codefirst.codeFirstHello.sayHi
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: RPCFramework
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 28
|
||||
isError: false
|
||||
spanType: Entry
|
||||
peer: ''
|
||||
tags:
|
||||
- {key: url, value: /sayHi}
|
||||
refs:
|
||||
- {parentEndpoint: codefirst.codeFirstSpringmvcHelloClient.say, networkAddress: not
|
||||
null, refType: CrossProcess, parentSpanId: 1, parentTraceSegmentId: not
|
||||
null, parentServiceInstance: not null, parentService: not null, traceId: not
|
||||
null}
|
||||
skipAnalysis: 'false'
|
||||
- segmentId: not null
|
||||
spans:
|
||||
- operationName: codefirst.codeFirstHello.sayHi
|
||||
parentSpanId: 0
|
||||
spanId: 1
|
||||
spanLayer: RPCFramework
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 28
|
||||
isError: false
|
||||
spanType: Exit
|
||||
peer: not null
|
||||
tags:
|
||||
- {key: url, value: /sayHi}
|
||||
skipAnalysis: 'false'
|
||||
- operationName: codefirst.codeFirstSpringmvcHelloClient.say
|
||||
parentSpanId: -1
|
||||
spanId: 0
|
||||
spanLayer: RPCFramework
|
||||
startTime: nq 0
|
||||
endTime: nq 0
|
||||
componentId: 28
|
||||
isError: false
|
||||
spanType: Entry
|
||||
peer: ''
|
||||
tags:
|
||||
- {key: url, value: /case}
|
||||
skipAnalysis: 'false'
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
# 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:8080/servicecomb/case
|
||||
healthCheck: http://localhost:8080/servicecomb/healthCheck
|
||||
startScript: ./bin/startup.sh
|
||||
|
|
@ -1,124 +0,0 @@
|
|||
<?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.apm.testcase</groupId>
|
||||
<artifactId>servicecomb-0.x-scenario</artifactId>
|
||||
<version>1.0.0</version>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<compiler.version>1.8</compiler.version>
|
||||
|
||||
<test.framework.version>0.5.0</test.framework.version>
|
||||
</properties>
|
||||
|
||||
<name>skywalking-servicecomb-0.x-scenario</name>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.servicecomb</groupId>
|
||||
<artifactId>java-chassis-dependencies</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.servicecomb</groupId>
|
||||
<artifactId>provider-pojo</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.servicecomb</groupId>
|
||||
<artifactId>transport-highway</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.servicecomb</groupId>
|
||||
<artifactId>transport-rest-vertx</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.7.7</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.servicecomb</groupId>
|
||||
<artifactId>provider-springmvc</artifactId>
|
||||
<version>${test.framework.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>servicecomb-0.x-scenario</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>${compiler.version}</source>
|
||||
<target>${compiler.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<version>1.5.9.RELEASE</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<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>
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
<?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>${project.build.directory}/servicecomb-0.x-scenario.jar</source>
|
||||
<outputDirectory>./libs</outputDirectory>
|
||||
<fileMode>0775</fileMode>
|
||||
</file>
|
||||
</files>
|
||||
</assembly>
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
* 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.testcase.servicecomb;
|
||||
|
||||
import io.servicecomb.foundation.common.utils.BeanUtils;
|
||||
import io.servicecomb.foundation.common.utils.Log4jUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class CodeFirstMain {
|
||||
|
||||
private static Logger LOGGER = Logger.getLogger(CodeFirstMain.class);
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.setProperty("local.registry.file", "notExistJustForceLocal");
|
||||
init();
|
||||
}
|
||||
|
||||
public static void init() {
|
||||
while (true) {
|
||||
try {
|
||||
Log4jUtils.init();
|
||||
BeanUtils.init();
|
||||
return;
|
||||
} catch (Throwable e) {
|
||||
try {
|
||||
LOGGER.error(e.getMessage(), e);
|
||||
Thread.sleep(5000);
|
||||
} catch (InterruptedException ex) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* 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.testcase.servicecomb.consumer;
|
||||
|
||||
import io.servicecomb.provider.pojo.RpcReference;
|
||||
import io.servicecomb.provider.pojo.RpcSchema;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.Hello;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@RpcSchema(schemaId = "codeFirstSpringmvcHelloClient")
|
||||
@RequestMapping(path = "/servicecomb")
|
||||
public class CodeFirstPojoConsumerHelloImpl {
|
||||
private static Logger LOGGER = Logger.getLogger(CodeFirstPojoConsumerHelloImpl.class);
|
||||
@RpcReference(microserviceName = "codefirst", schemaId = "codeFirstHello")
|
||||
private Hello hello;
|
||||
|
||||
@RequestMapping(path = "/case", method = RequestMethod.GET)
|
||||
public String say() {
|
||||
String repo = " sayHi invoke filed";
|
||||
try {
|
||||
repo = hello.sayHi("Java Chassis");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("sayHi invoke filed");
|
||||
}
|
||||
return repo;
|
||||
}
|
||||
|
||||
@RequestMapping(path = "/healthCheck", method = {RequestMethod.HEAD})
|
||||
public String healthCheck() {
|
||||
return "Success";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
* 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.testcase.servicecomb.provider;
|
||||
|
||||
import io.servicecomb.provider.pojo.RpcSchema;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.Hello;
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.models.Person;
|
||||
|
||||
@RpcSchema(schemaId = "codeFirstJaxrsHello")
|
||||
@Path("/codefirstjaxrshello")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public class CodeFirstJaxrsHelloImpl implements Hello {
|
||||
|
||||
@Path("/sayhi")
|
||||
@POST
|
||||
@Override
|
||||
public String sayHi(String name) {
|
||||
return "Jaxrs Hello " + name;
|
||||
}
|
||||
|
||||
@Path("/sayhello")
|
||||
@POST
|
||||
@Override
|
||||
public String sayHello(Person person) {
|
||||
return "Jaxrs Hello person " + person.getName();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
/*
|
||||
* 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.testcase.servicecomb.provider;
|
||||
|
||||
import io.servicecomb.provider.pojo.RpcSchema;
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.Hello;
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.models.Person;
|
||||
|
||||
@RpcSchema(schemaId = "codeFirstHello")
|
||||
public class CodeFirstPojoHelloProviderImpl implements Hello {
|
||||
|
||||
@Override
|
||||
public String sayHi(String name) {
|
||||
return "Pojo Hello " + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String sayHello(Person person) {
|
||||
return "Pojo Hello person " + person.getName();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* 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.testcase.servicecomb.provider;
|
||||
|
||||
import io.servicecomb.provider.pojo.RpcSchema;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.Hello;
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.models.Person;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
@RpcSchema(schemaId = "codeFirstSpringmvcHello")
|
||||
@RequestMapping(path = "/springmvchello", produces = MediaType.APPLICATION_JSON)
|
||||
public class CodeFirstSpringmvcHelloImpl implements Hello {
|
||||
|
||||
@Override
|
||||
@RequestMapping(path = "/sayhi", method = RequestMethod.POST)
|
||||
public String sayHi(@RequestParam(name = "name") String name) {
|
||||
return "Spring mvc Hello " + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@RequestMapping(path = "/sayhello", method = RequestMethod.POST)
|
||||
public String sayHello(@RequestBody Person person) {
|
||||
return "Spring mvc Hello person " + person.getName();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* 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.testcase.servicecomb.schema;
|
||||
|
||||
import org.apache.skywalking.apm.testcase.servicecomb.schema.models.Person;
|
||||
|
||||
public interface Hello {
|
||||
|
||||
String sayHi(String name);
|
||||
|
||||
String sayHello(Person person);
|
||||
}
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
* 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.testcase.servicecomb.schema.models;
|
||||
|
||||
public class Person {
|
||||
|
||||
private String name;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
<?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.
|
||||
~
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:context="http://www.springframework.org/schema/context"
|
||||
xsi:schemaLocation="
|
||||
http://www.springframework.org/schema/beans classpath:org/springframework/beans/factory/xml/spring-beans-3.0.xsd
|
||||
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
|
||||
">
|
||||
|
||||
<context:component-scan base-package="org.apache.skywalking.apm.testcase.servicecomb"/>
|
||||
</beans>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#
|
||||
# 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.
|
||||
#
|
||||
#
|
||||
log4j.rootLogger=WARN,stderr
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
# 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.
|
||||
|
||||
APPLICATION_ID: codefirsttest
|
||||
service_description:
|
||||
name: codefirst
|
||||
version: 0.0.1
|
||||
cse:
|
||||
isolation:
|
||||
Consumer:
|
||||
enabled: false
|
||||
references:
|
||||
codefirst:
|
||||
version-rule: 0.0.1
|
||||
rest:
|
||||
address: 0.0.0.0:8080
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
# 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.
|
||||
|
||||
0.1.0
|
||||
0.2.0
|
||||
0.3.0
|
||||
0.4.0
|
||||
0.5.0
|
||||
Loading…
Reference in New Issue