Merge branch 'feature/high-performance-agent' of https://github.com/wu-sheng/sky-walking into feature/high-performance-agent

* 'feature/high-performance-agent' of https://github.com/wu-sheng/sky-walking:
  add configuration about multiple check interval and fix set peerID of  exit span failed
  independent data carrier project
This commit is contained in:
wusheng 2017-07-14 20:36:58 +08:00
commit 3f3d933365
34 changed files with 101 additions and 191 deletions

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>apm-commons</artifactId>
<groupId>org.skywalking</groupId>
<version>3.2-2017</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apm-datacarrier</artifactId>
</project>

View File

@ -1,11 +1,11 @@
package org.skywalking.apm.agent.core.datacarrier;
package org.skywalking.apm.commons.datacarrier;
import org.skywalking.apm.agent.core.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.agent.core.datacarrier.buffer.Channels;
import org.skywalking.apm.agent.core.datacarrier.consumer.ConsumerPool;
import org.skywalking.apm.agent.core.datacarrier.consumer.IConsumer;
import org.skywalking.apm.agent.core.datacarrier.partition.IDataPartitioner;
import org.skywalking.apm.agent.core.datacarrier.partition.SimpleRollingPartitioner;
import org.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.commons.datacarrier.buffer.Channels;
import org.skywalking.apm.commons.datacarrier.consumer.ConsumerPool;
import org.skywalking.apm.commons.datacarrier.consumer.IConsumer;
import org.skywalking.apm.commons.datacarrier.partition.IDataPartitioner;
import org.skywalking.apm.commons.datacarrier.partition.SimpleRollingPartitioner;
/**
* DataCarrier main class.

View File

@ -1,7 +1,7 @@
package org.skywalking.apm.agent.core.datacarrier.buffer;
package org.skywalking.apm.commons.datacarrier.buffer;
import java.util.LinkedList;
import org.skywalking.apm.agent.core.datacarrier.common.AtomicRangeInteger;
import org.skywalking.apm.commons.datacarrier.common.AtomicRangeInteger;
/**
* Created by wusheng on 2016/10/25.

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.buffer;
package org.skywalking.apm.commons.datacarrier.buffer;
/**
* Created by wusheng on 2016/10/25.

View File

@ -1,6 +1,6 @@
package org.skywalking.apm.agent.core.datacarrier.buffer;
package org.skywalking.apm.commons.datacarrier.buffer;
import org.skywalking.apm.agent.core.datacarrier.partition.IDataPartitioner;
import org.skywalking.apm.commons.datacarrier.partition.IDataPartitioner;
/**
* Channels of Buffer

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.common;
package org.skywalking.apm.commons.datacarrier.common;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger;

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.consumer;
package org.skywalking.apm.commons.datacarrier.consumer;
/**
* Created by wusheng on 2016/11/15.

View File

@ -1,9 +1,9 @@
package org.skywalking.apm.agent.core.datacarrier.consumer;
package org.skywalking.apm.commons.datacarrier.consumer;
import java.util.ArrayList;
import java.util.concurrent.locks.ReentrantLock;
import org.skywalking.apm.agent.core.datacarrier.buffer.Buffer;
import org.skywalking.apm.agent.core.datacarrier.buffer.Channels;
import org.skywalking.apm.commons.datacarrier.buffer.Buffer;
import org.skywalking.apm.commons.datacarrier.buffer.Channels;
/**
* Pool of consumers

View File

@ -1,8 +1,8 @@
package org.skywalking.apm.agent.core.datacarrier.consumer;
package org.skywalking.apm.commons.datacarrier.consumer;
import java.util.LinkedList;
import java.util.List;
import org.skywalking.apm.agent.core.datacarrier.buffer.Buffer;
import org.skywalking.apm.commons.datacarrier.buffer.Buffer;
/**
* Created by wusheng on 2016/10/25.

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.consumer;
package org.skywalking.apm.commons.datacarrier.consumer;
import java.util.List;

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.partition;
package org.skywalking.apm.commons.datacarrier.partition;
/**
* Created by wusheng on 2016/10/25.

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.partition;
package org.skywalking.apm.commons.datacarrier.partition;
/**
* use threadid % total to partition

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.partition;
package org.skywalking.apm.commons.datacarrier.partition;
/**
* use normal int to rolling.

View File

@ -1,16 +1,15 @@
package org.skywalking.apm.agent.core.datacarrier;
package org.skywalking.apm.commons.datacarrier;
import org.skywalking.apm.agent.core.datacarrier.buffer.Buffer;
import org.skywalking.apm.agent.core.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.agent.core.datacarrier.buffer.Channels;
import org.skywalking.apm.agent.core.datacarrier.consumer.IConsumer;
import org.skywalking.apm.agent.core.datacarrier.partition.ProducerThreadPartitioner;
import org.skywalking.apm.agent.core.datacarrier.partition.SimpleRollingPartitioner;
import java.util.List;
import org.junit.Assert;
import org.junit.Test;
import org.powermock.api.support.membermodification.MemberModifier;
import java.util.List;
import org.skywalking.apm.commons.datacarrier.buffer.Buffer;
import org.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.commons.datacarrier.buffer.Channels;
import org.skywalking.apm.commons.datacarrier.consumer.IConsumer;
import org.skywalking.apm.commons.datacarrier.partition.ProducerThreadPartitioner;
import org.skywalking.apm.commons.datacarrier.partition.SimpleRollingPartitioner;
/**
* Created by wusheng on 2016/10/25.

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier;
package org.skywalking.apm.commons.datacarrier;
/**
* Created by wusheng on 2016/10/25.

View File

@ -1,10 +1,12 @@
package org.skywalking.apm.agent.core.datacarrier.common;
package org.skywalking.apm.commons.datacarrier.common;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Created by wusheng on 2016/10/25.
* Created by xin on 2017/7/14.
*/
public class AtomicRangeIntegerTest {
@Test

View File

@ -1,12 +1,12 @@
package org.skywalking.apm.agent.core.datacarrier.consumer;
package org.skywalking.apm.commons.datacarrier.consumer;
import org.junit.Assert;
import org.junit.Test;
import org.powermock.api.support.membermodification.MemberModifier;
import org.skywalking.apm.agent.core.datacarrier.SampleData;
import org.skywalking.apm.agent.core.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.agent.core.datacarrier.buffer.Channels;
import org.skywalking.apm.agent.core.datacarrier.partition.SimpleRollingPartitioner;
import org.skywalking.apm.commons.datacarrier.SampleData;
import org.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.commons.datacarrier.buffer.Channels;
import org.skywalking.apm.commons.datacarrier.partition.SimpleRollingPartitioner;
/**
* Created by wusheng on 2016/10/26.

View File

@ -1,4 +1,4 @@
package org.skywalking.apm.agent.core.datacarrier.consumer;
package org.skywalking.apm.commons.datacarrier.consumer;
import java.util.ArrayList;
import java.util.HashSet;
@ -7,8 +7,8 @@ import java.util.concurrent.LinkedBlockingQueue;
import org.junit.Assert;
import org.junit.Test;
import org.powermock.api.support.membermodification.MemberModifier;
import org.skywalking.apm.agent.core.datacarrier.DataCarrier;
import org.skywalking.apm.agent.core.datacarrier.SampleData;
import org.skywalking.apm.commons.datacarrier.DataCarrier;
import org.skywalking.apm.commons.datacarrier.SampleData;
/**
* Created by wusheng on 2016/10/26.

View File

@ -1,8 +1,7 @@
package org.skywalking.apm.agent.core.datacarrier.consumer;
package org.skywalking.apm.commons.datacarrier.consumer;
import java.util.List;
import org.skywalking.apm.agent.core.datacarrier.SampleData;
import org.skywalking.apm.commons.datacarrier.SampleData;
/**
* Created by wusheng on 2016/10/26.

View File

@ -1,15 +1,15 @@
package org.skywalking.apm.agent.core.datacarrier.partition;
package org.skywalking.apm.commons.datacarrier.partition;
import org.junit.Assert;
import org.junit.Test;
import org.skywalking.apm.agent.core.datacarrier.SampleData;
import org.skywalking.apm.commons.datacarrier.SampleData;
/**
* Created by wusheng on 2016/10/25.
*/
public class ProducerThreadPartitionerTest {
@Test
public void testPartition(){
public void testPartition() {
int partitionNum = (int)Thread.currentThread().getId() % 10;
ProducerThreadPartitioner<SampleData> partitioner = new ProducerThreadPartitioner<SampleData>();
Assert.assertEquals(partitioner.partition(10, new SampleData()), partitionNum);

View File

@ -1,8 +1,8 @@
package org.skywalking.apm.agent.core.datacarrier.partition;
package org.skywalking.apm.commons.datacarrier.partition;
import org.junit.Assert;
import org.junit.Test;
import org.skywalking.apm.agent.core.datacarrier.SampleData;
import org.skywalking.apm.commons.datacarrier.SampleData;
/**
* Created by wusheng on 2016/10/25.

View File

@ -1,31 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>apm-commons</artifactId>
<groupId>org.skywalking</groupId>
<version>3.2-2017</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>apm-logging-log4j2</artifactId>
<dependencies>
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>apm-logging-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
<version>2.8</version>
</dependency>
</dependencies>
</project>

View File

@ -1,76 +0,0 @@
package org.skywalking.apm.logging.log4j2;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.skywalking.apm.logging.ILog;
/**
* @author wusheng
*/
public class Log4j2Logger implements ILog {
private Logger delegateLogger;
Log4j2Logger(Class<?> targetClass) {
delegateLogger = LogManager.getFormatterLogger(targetClass);
}
@Override
public void info(String format) {
delegateLogger.info(format);
}
@Override
public void info(String format, Object... arguments) {
delegateLogger.info(format, arguments);
}
@Override
public void warn(String format, Object... arguments) {
delegateLogger.warn(format, arguments);
}
@Override
public void error(String format, Throwable e) {
delegateLogger.error(format, e);
}
@Override
public void error(Throwable e, String format, Object... arguments) {
delegateLogger.error(format, e, arguments);
}
@Override
public boolean isDebugEnable() {
return delegateLogger.isDebugEnabled();
}
@Override
public boolean isInfoEnable() {
return delegateLogger.isInfoEnabled();
}
@Override
public boolean isWarnEnable() {
return delegateLogger.isWarnEnabled();
}
@Override
public boolean isErrorEnable() {
return delegateLogger.isErrorEnabled();
}
@Override
public void debug(String format) {
delegateLogger.debug(format);
}
@Override
public void debug(String format, Object... arguments) {
delegateLogger.debug(format, arguments);
}
@Override
public void error(String format) {
delegateLogger.error(format);
}
}

View File

@ -1,16 +0,0 @@
package org.skywalking.apm.logging.log4j2;
import org.skywalking.apm.logging.ILog;
import org.skywalking.apm.logging.LogResolver;
/**
* The <code>LogResolver</code> is an implementation of {@link LogResolver},
*
* @author wusheng
*/
public class Log4j2Resolver implements LogResolver {
@Override
public ILog getLogger(Class<?> clazz) {
return new Log4j2Logger(clazz);
}
}

View File

@ -13,7 +13,7 @@
<modules>
<module>apm-util</module>
<module>apm-logging-api</module>
<module>apm-logging-log4j2</module>
<module>apm-datacarrier</module>
</modules>
<name>apm-commons</name>

View File

@ -95,6 +95,11 @@
</exclusions>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.skywalking</groupId>
<artifactId>apm-datacarrier</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<extensions>

View File

@ -34,7 +34,18 @@ public class Config {
}
public static class Collector {
public static long DISCOVERY_CHECK_INTERVAL = 60 * 1000;
/**
* grpc channel status check interval
*/
public static long GRPC_CHANNEL_CHECK_INTERVAL = 30;
/**
* application and service registry check interval
*/
public static long APP_AND_SERVICE_REGISTER_CHECK_INTERVAL = 10;
/**
* discovery rest check interval
*/
public static long DISCOVERY_CHECK_INTERVAL = 60;
/**
* Collector REST-Service address.
* e.g.
@ -46,7 +57,7 @@ public class Config {
/**
* Collector service discovery REST service name
*/
public static String DISCOVERY_SERVICE_NAME = "grpc/addresses";
public static String DISCOVERY_SERVICE_NAME = "/grpc/addresses";
}
public static class Buffer {

View File

@ -108,10 +108,12 @@ public class ExitSpan extends AbstractTracingSpan {
@Override public SpanObject.Builder transform() {
SpanObject.Builder spanBuilder = super.transform();
if (peerId == DictionaryUtil.nullValue()) {
if (peerId != DictionaryUtil.nullValue()) {
spanBuilder.setPeerId(peerId);
} else {
spanBuilder.setPeer(peer);
if (peer != null) {
spanBuilder.setPeer(peer);
}
}
return spanBuilder;
}

View File

@ -69,7 +69,7 @@ public class AppAndServiceRegisterClient implements BootService, GRPCChannelList
public void boot() throws Throwable {
applicationRegisterFuture = Executors
.newSingleThreadScheduledExecutor()
.scheduleAtFixedRate(this, 0, 10, TimeUnit.SECONDS);
.scheduleAtFixedRate(this, 0, Config.Collector.APP_AND_SERVICE_REGISTER_CHECK_INTERVAL, TimeUnit.SECONDS);
}
@Override

View File

@ -20,7 +20,7 @@ public class CollectorDiscoveryService implements BootService {
public void boot() throws Throwable {
Executors.newSingleThreadScheduledExecutor()
.scheduleAtFixedRate(new DiscoveryRestServiceClient(), 0,
Config.Collector.DISCOVERY_CHECK_INTERVAL, TimeUnit.MILLISECONDS);
Config.Collector.DISCOVERY_CHECK_INTERVAL, TimeUnit.SECONDS);
}
@Override

View File

@ -18,6 +18,8 @@ import org.skywalking.apm.agent.core.conf.RemoteDownstreamConfig;
import org.skywalking.apm.logging.ILog;
import org.skywalking.apm.logging.LogManager;
import static org.skywalking.apm.agent.core.conf.Config.Collector.GRPC_CHANNEL_CHECK_INTERVAL;
/**
* @author wusheng
*/
@ -29,7 +31,6 @@ public class GRPCChannelManager implements BootService, Runnable {
private volatile boolean reconnect = true;
private Random random = new Random();
private List<GRPCChannelListener> listeners = Collections.synchronizedList(new LinkedList<GRPCChannelListener>());
private final int retryCycle = 30;
@Override
public void beforeBoot() throws Throwable {
@ -40,7 +41,7 @@ public class GRPCChannelManager implements BootService, Runnable {
public void boot() throws Throwable {
connectCheckFuture = Executors
.newSingleThreadScheduledExecutor()
.scheduleAtFixedRate(this, 0, retryCycle, TimeUnit.SECONDS);
.scheduleAtFixedRate(this, 0, GRPC_CHANNEL_CHECK_INTERVAL, TimeUnit.SECONDS);
}
@Override
@ -75,7 +76,7 @@ public class GRPCChannelManager implements BootService, Runnable {
}
}
logger.debug("Selected collector grpc service is not available. Wait {} seconds to retry", retryCycle);
logger.debug("Selected collector grpc service is not available. Wait {} seconds to retry", GRPC_CHANNEL_CHECK_INTERVAL);
}
}

View File

@ -8,9 +8,9 @@ import org.skywalking.apm.agent.core.boot.ServiceManager;
import org.skywalking.apm.agent.core.context.TracingContext;
import org.skywalking.apm.agent.core.context.TracingContextListener;
import org.skywalking.apm.agent.core.context.trace.TraceSegment;
import org.skywalking.apm.agent.core.datacarrier.DataCarrier;
import org.skywalking.apm.agent.core.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.agent.core.datacarrier.consumer.IConsumer;
import org.skywalking.apm.commons.datacarrier.DataCarrier;
import org.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
import org.skywalking.apm.commons.datacarrier.consumer.IConsumer;
import org.skywalking.apm.logging.ILog;
import org.skywalking.apm.logging.LogManager;
import org.skywalking.apm.network.proto.Downstream;

View File

@ -17,6 +17,7 @@ import org.mockito.Spy;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.reflect.Whitebox;
import org.skywalking.apm.agent.core.conf.Config;
import org.skywalking.apm.agent.core.conf.RemoteDownstreamConfig;
import org.skywalking.apm.agent.core.test.tools.AgentServiceRule;
@ -52,7 +53,7 @@ public class GRPCChannelManagerTest {
List<String> grpcServers = new ArrayList<String>();
grpcServers.add("127.0.0.1:2181");
RemoteDownstreamConfig.Collector.GRPC_SERVERS = grpcServers;
Whitebox.setInternalState(grpcChannelManager, "retryCycle", 1);
Config.Collector.GRPC_CHANNEL_CHECK_INTERVAL = 1;
mockStatic(NettyChannelBuilder.class);
when(NettyChannelBuilder.forAddress(anyString(), anyInt())).thenReturn(mock);

View File

@ -1,6 +1,5 @@
package org.skywalking.apm.plugin.mongodb.v3.define;
import com.mongodb.connection.Cluster;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.matcher.ElementMatcher;
import org.skywalking.apm.agent.core.plugin.interceptor.ConstructorInterceptPoint;
@ -9,7 +8,7 @@ import org.skywalking.apm.agent.core.plugin.interceptor.enhance.ClassInstanceMet
import org.skywalking.apm.agent.core.plugin.match.ClassMatch;
import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import static org.skywalking.apm.agent.core.plugin.bytebuddy.ArgumentTypeNameMatch.takesArgumentWithType;
import static org.skywalking.apm.agent.core.plugin.match.NameMatch.byName;
public class MongoDBInstrumentation extends ClassInstanceMethodsEnhancePluginDefine {
@ -24,7 +23,7 @@ public class MongoDBInstrumentation extends ClassInstanceMethodsEnhancePluginDef
new ConstructorInterceptPoint() {
@Override
public ElementMatcher<MethodDescription> getConstructorMatcher() {
return takesArgument(1, Cluster.class);
return takesArgumentWithType(0, "com.mongodb.connection.Cluster");
}
@Override