Remove some unused variables (#5598)
This commit is contained in:
parent
772f1d2e82
commit
736dc3d3ec
|
|
@ -31,8 +31,6 @@ import org.apache.skywalking.apm.commons.datacarrier.partition.SimpleRollingPart
|
|||
* DataCarrier main class. use this instance to set Producer/Consumer Model.
|
||||
*/
|
||||
public class DataCarrier<T> {
|
||||
private final int bufferSize;
|
||||
private final int channelSize;
|
||||
private Channels<T> channels;
|
||||
private IDriver driver;
|
||||
private String name;
|
||||
|
|
@ -47,9 +45,9 @@ public class DataCarrier<T> {
|
|||
|
||||
public DataCarrier(String name, String envPrefix, int channelSize, int bufferSize) {
|
||||
this.name = name;
|
||||
this.bufferSize = EnvUtil.getInt(envPrefix + "_BUFFER_SIZE", bufferSize);
|
||||
this.channelSize = EnvUtil.getInt(envPrefix + "_CHANNEL_SIZE", channelSize);
|
||||
channels = new Channels<T>(channelSize, bufferSize, new SimpleRollingPartitioner<T>(), BufferStrategy.BLOCKING);
|
||||
bufferSize = EnvUtil.getInt(envPrefix + "_BUFFER_SIZE", bufferSize);
|
||||
channelSize = EnvUtil.getInt(envPrefix + "_CHANNEL_SIZE", channelSize);
|
||||
channels = new Channels<>(channelSize, bufferSize, new SimpleRollingPartitioner<T>(), BufferStrategy.BLOCKING);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -22,15 +22,9 @@ package org.apache.skywalking.apm.commons.datacarrier.partition;
|
|||
* use threadid % total to partition
|
||||
*/
|
||||
public class ProducerThreadPartitioner<T> implements IDataPartitioner<T> {
|
||||
private int retryTime = 3;
|
||||
|
||||
public ProducerThreadPartitioner() {
|
||||
}
|
||||
|
||||
public ProducerThreadPartitioner(int retryTime) {
|
||||
this.retryTime = retryTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int partition(int total, T data) {
|
||||
return (int) Thread.currentThread().getId() % total;
|
||||
|
|
|
|||
|
|
@ -33,11 +33,7 @@ import org.powermock.api.support.membermodification.MemberModifier;
|
|||
public class DataCarrierTest {
|
||||
@Test
|
||||
public void testCreateDataCarrier() throws IllegalAccessException {
|
||||
DataCarrier<SampleData> carrier = new DataCarrier<SampleData>(5, 100);
|
||||
Assert.assertEquals(((Integer) (MemberModifier.field(DataCarrier.class, "bufferSize")
|
||||
.get(carrier))).intValue(), 100);
|
||||
Assert.assertEquals(((Integer) (MemberModifier.field(DataCarrier.class, "channelSize")
|
||||
.get(carrier))).intValue(), 5);
|
||||
DataCarrier<SampleData> carrier = new DataCarrier<>(5, 100);
|
||||
|
||||
Channels<SampleData> channels = (Channels<SampleData>) (MemberModifier.field(DataCarrier.class, "channels")
|
||||
.get(carrier));
|
||||
|
|
@ -116,39 +112,36 @@ public class DataCarrierTest {
|
|||
}
|
||||
|
||||
long time1 = System.currentTimeMillis();
|
||||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
IConsumer<SampleData> consumer = new IConsumer<SampleData>() {
|
||||
int i = 0;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(List<SampleData> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(List<SampleData> data, Throwable t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit() {
|
||||
|
||||
}
|
||||
};
|
||||
carrier.consume(consumer, 1);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
Thread.sleep(3000);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
IConsumer<SampleData> consumer = new IConsumer<SampleData>() {
|
||||
int i = 0;
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void consume(List<SampleData> data) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(List<SampleData> data, Throwable t) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExit() {
|
||||
|
||||
}
|
||||
};
|
||||
carrier.consume(consumer, 1);
|
||||
}).start();
|
||||
|
||||
carrier.produce(new SampleData().setName("blocking-data"));
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ 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.elasticsearch.v6.RestClientEnhanceInfo;
|
||||
|
||||
public class RestHighLevelClientClusterMethodsInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
|
|
@ -36,7 +35,7 @@ public class RestHighLevelClientClusterMethodsInterceptor implements InstanceMet
|
|||
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
Class<?>[] argumentsTypes, Object ret) throws Throwable {
|
||||
if (ret instanceof EnhancedInstance) {
|
||||
((EnhancedInstance) ret).setSkyWalkingDynamicField((RestClientEnhanceInfo) (objInst.getSkyWalkingDynamicField()));
|
||||
((EnhancedInstance) ret).setSkyWalkingDynamicField(objInst.getSkyWalkingDynamicField());
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@
|
|||
package org.apache.skywalking.apm.plugin.elasticsearch.v6.interceptor;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.agent.core.logging.api.ILog;
|
||||
import org.apache.skywalking.apm.agent.core.logging.api.LogManager;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.EnhancedInstance;
|
||||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceConstructorInterceptor;
|
||||
import org.apache.skywalking.apm.plugin.elasticsearch.v6.RestClientEnhanceInfo;
|
||||
|
|
@ -29,9 +27,6 @@ import org.elasticsearch.client.RestClient;
|
|||
import org.elasticsearch.client.RestClientBuilder;
|
||||
|
||||
public class RestHighLevelClientConInterceptor implements InstanceConstructorInterceptor {
|
||||
|
||||
private static final ILog LOGGER = LogManager.getLogger(RestHighLevelClientConInterceptor.class);
|
||||
|
||||
@Override
|
||||
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
|
||||
RestClientBuilder restClientBuilder = (RestClientBuilder) (allArguments[0]);
|
||||
|
|
|
|||
|
|
@ -83,12 +83,11 @@ public class MongoDBCollectionMethodInterceptor implements InstanceMethodsAround
|
|||
|
||||
@Override
|
||||
public void onConstruct(EnhancedInstance objInst, Object[] allArguments) {
|
||||
List<ServerAddress> servers = null;
|
||||
DB db = (DB) allArguments[0];
|
||||
servers = db.getMongo().getAllAddress();
|
||||
List<ServerAddress> servers = db.getMongo().getAllAddress();
|
||||
StringBuilder peers = new StringBuilder();
|
||||
for (ServerAddress address : servers) {
|
||||
peers.append(address.getHost() + ":" + address.getPort() + ";");
|
||||
peers.append(address.getHost()).append(":").append(address.getPort()).append(";");
|
||||
}
|
||||
|
||||
objInst.setSkyWalkingDynamicField(peers.subSequence(0, peers.length() - 1).toString());
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ import com.alipay.sofa.rpc.client.ProviderInfo;
|
|||
import com.alipay.sofa.rpc.context.RpcInternalContext;
|
||||
import com.alipay.sofa.rpc.core.request.SofaRequest;
|
||||
import com.alipay.sofa.rpc.core.response.SofaResponse;
|
||||
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;
|
||||
|
|
@ -33,27 +34,23 @@ import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.InstanceM
|
|||
import org.apache.skywalking.apm.agent.core.plugin.interceptor.enhance.MethodInterceptResult;
|
||||
import org.apache.skywalking.apm.network.trace.component.ComponentsDefine;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class SofaRpcConsumerInterceptor implements InstanceMethodsAroundInterceptor {
|
||||
|
||||
public static final String SKYWALKING_PREFIX = "skywalking.";
|
||||
|
||||
@Override
|
||||
public void beforeMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
MethodInterceptResult result) throws Throwable {
|
||||
SofaRequest sofaRequest = (SofaRequest) allArguments[0];
|
||||
RpcInternalContext rpcContext = RpcInternalContext.getContext();
|
||||
|
||||
ProviderInfo providerInfo = rpcContext.getProviderInfo();
|
||||
|
||||
AbstractSpan span = null;
|
||||
|
||||
final String host = providerInfo.getHost();
|
||||
final int port = providerInfo.getPort();
|
||||
final ContextCarrier contextCarrier = new ContextCarrier();
|
||||
final String operationName = generateOperationName(providerInfo, sofaRequest);
|
||||
span = ContextManager.createExitSpan(operationName, contextCarrier, host + ":" + port);
|
||||
AbstractSpan span = ContextManager.createExitSpan(operationName, contextCarrier, host + ":" + port);
|
||||
CarrierItem next = contextCarrier.items();
|
||||
while (next.hasNext()) {
|
||||
next = next.next();
|
||||
|
|
@ -69,7 +66,7 @@ public class SofaRpcConsumerInterceptor implements InstanceMethodsAroundIntercep
|
|||
|
||||
@Override
|
||||
public Object afterMethod(EnhancedInstance objInst, Method method, Object[] allArguments, Class<?>[] argumentsTypes,
|
||||
Object ret) throws Throwable {
|
||||
Object ret) throws Throwable {
|
||||
SofaResponse result = (SofaResponse) ret;
|
||||
if (result != null && result.isError()) {
|
||||
dealException((Throwable) result.getAppResponse());
|
||||
|
|
@ -81,7 +78,7 @@ public class SofaRpcConsumerInterceptor implements InstanceMethodsAroundIntercep
|
|||
|
||||
@Override
|
||||
public void handleMethodException(EnhancedInstance objInst, Method method, Object[] allArguments,
|
||||
Class<?>[] argumentsTypes, Throwable t) {
|
||||
Class<?>[] argumentsTypes, Throwable t) {
|
||||
dealException(t);
|
||||
}
|
||||
|
||||
|
|
@ -101,9 +98,9 @@ public class SofaRpcConsumerInterceptor implements InstanceMethodsAroundIntercep
|
|||
private String generateOperationName(ProviderInfo providerInfo, SofaRequest sofaRequest) {
|
||||
StringBuilder operationName = new StringBuilder();
|
||||
operationName.append(sofaRequest.getInterfaceName());
|
||||
operationName.append("." + sofaRequest.getMethodName() + "(");
|
||||
operationName.append(".").append(sofaRequest.getMethodName()).append("(");
|
||||
for (String arg : sofaRequest.getMethodArgSigs()) {
|
||||
operationName.append(arg + ",");
|
||||
operationName.append(arg).append(",");
|
||||
}
|
||||
|
||||
if (sofaRequest.getMethodArgs().length > 0) {
|
||||
|
|
@ -122,9 +119,9 @@ public class SofaRpcConsumerInterceptor implements InstanceMethodsAroundIntercep
|
|||
*/
|
||||
private String generateRequestURL(ProviderInfo providerInfo, SofaRequest sofaRequest) {
|
||||
StringBuilder requestURL = new StringBuilder();
|
||||
requestURL.append(providerInfo.getProtocolType() + "://");
|
||||
requestURL.append(providerInfo.getProtocolType()).append("://");
|
||||
requestURL.append(providerInfo.getHost());
|
||||
requestURL.append(":" + providerInfo.getPort() + "/");
|
||||
requestURL.append(":").append(providerInfo.getPort()).append("/");
|
||||
requestURL.append(generateOperationName(providerInfo, sofaRequest));
|
||||
return requestURL.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,6 @@ public class SofaRpcProviderInterceptor implements InstanceMethodsAroundIntercep
|
|||
MethodInterceptResult result) throws Throwable {
|
||||
SofaRequest sofaRequest = (SofaRequest) allArguments[0];
|
||||
|
||||
AbstractSpan span = null;
|
||||
|
||||
ContextCarrier contextCarrier = new ContextCarrier();
|
||||
CarrierItem next = contextCarrier.items();
|
||||
while (next.hasNext()) {
|
||||
|
|
@ -55,7 +53,7 @@ public class SofaRpcProviderInterceptor implements InstanceMethodsAroundIntercep
|
|||
next.setHeadValue("");
|
||||
}
|
||||
}
|
||||
span = ContextManager.createEntrySpan(generateViewPoint(sofaRequest), contextCarrier);
|
||||
AbstractSpan span = ContextManager.createEntrySpan(generateViewPoint(sofaRequest), contextCarrier);
|
||||
|
||||
span.setComponent(ComponentsDefine.SOFARPC);
|
||||
SpanLayer.asRPCFramework(span);
|
||||
|
|
@ -95,9 +93,9 @@ public class SofaRpcProviderInterceptor implements InstanceMethodsAroundIntercep
|
|||
private String generateViewPoint(SofaRequest sofaRequest) {
|
||||
StringBuilder operationName = new StringBuilder();
|
||||
operationName.append(sofaRequest.getInterfaceName());
|
||||
operationName.append("." + sofaRequest.getMethodName() + "(");
|
||||
operationName.append(".").append(sofaRequest.getMethodName()).append("(");
|
||||
for (String arg : sofaRequest.getMethodArgSigs()) {
|
||||
operationName.append(arg + ",");
|
||||
operationName.append(arg).append(",");
|
||||
}
|
||||
|
||||
if (sofaRequest.getMethodArgs().length > 0) {
|
||||
|
|
|
|||
|
|
@ -25,13 +25,8 @@ import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
|||
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
|
||||
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class ClusterModuleStandaloneProvider extends ModuleProvider {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ClusterModuleStandaloneProvider.class);
|
||||
|
||||
public ClusterModuleStandaloneProvider() {
|
||||
super();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue