Loading skywalking-sniffer/skywalking-agent/src/main/java/com/a/eye/skywalking/agent/SkyWalkingAgent.java +2 −2 Original line number Diff line number Diff line package com.a.eye.skywalking.agent; import com.a.eye.skywalking.agent.junction.SkyWalkingEnhanceMatcher; import com.a.eye.skywalking.api.boot.ServiceStarter; import com.a.eye.skywalking.api.boot.ServiceManager; import com.a.eye.skywalking.api.conf.Config; import com.a.eye.skywalking.api.conf.SnifferConfigInitializer; import com.a.eye.skywalking.api.logging.EasyLogResolver; Loading Loading @@ -54,7 +54,7 @@ public class SkyWalkingAgent { final PluginFinder pluginFinder = new PluginFinder(new PluginBootstrap().loadPlugins()); ServiceStarter.INSTANCE.boot(); ServiceManager.INSTANCE.boot(); new AgentBuilder.Default().type(enhanceClassMatcher(pluginFinder).and(not(isInterface()))).transform(new AgentBuilder.Transformer() { public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader) { Loading skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceStarter.java→skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -8,12 +8,12 @@ import java.util.Map; import java.util.ServiceLoader; /** * The <code>ServiceStarter</code> bases on {@link ServiceLoader}, * The <code>ServiceManager</code> bases on {@link ServiceLoader}, * load all {@link BootService} implementations. * * @author wusheng */ public enum ServiceStarter { public enum ServiceManager { INSTANCE; private static ILog logger = LogManager.getLogger(StatusBootService.class); Loading @@ -31,7 +31,7 @@ public enum ServiceStarter { bootService.bootUp(); bootedServices.put(bootService.getClass(), bootService); } catch (Exception e) { logger.error(e, "ServiceStarter try to start [{}] fail.", bootService.getClass().getName()); logger.error(e, "ServiceManager try to start [{}] fail.", bootService.getClass().getName()); } } } finally { Loading skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/client/CollectorClientService.java +50 −1 Original line number Diff line number Diff line package com.a.eye.skywalking.api.client; import com.a.eye.skywalking.api.boot.BootService; import com.a.eye.skywalking.api.boot.ServiceManager; import com.a.eye.skywalking.api.queue.TraceSegmentProcessQueue; import com.a.eye.skywalking.logging.ILog; import com.a.eye.skywalking.logging.LogManager; import com.a.eye.skywalking.trace.TraceSegment; import java.util.List; /** * @author wusheng */ public class CollectorClientService implements BootService { public class CollectorClientService implements Runnable, BootService { private static ILog logger = LogManager.getLogger(CollectorClientService.class); private static long NO_DATA_SLEEP_TIME_MILLIS = 500; /** * Start a new {@link Thread} to get finished {@link TraceSegment} by {@link TraceSegmentProcessQueue#getCachedTraceSegments()} */ @Override public void bootUp() { Thread collectorClientThread = new Thread(this, "collectorClientThread"); collectorClientThread.start(); } @Override public void run() { while (true) { try { TraceSegmentProcessQueue segmentProcessQueue = ServiceManager.INSTANCE.findService(TraceSegmentProcessQueue.class); List<TraceSegment> cachedTraceSegments = segmentProcessQueue.getCachedTraceSegments(); if (cachedTraceSegments.size() > 0) { for (TraceSegment segment : cachedTraceSegments) { //TODO: wusheng //send data } /** * No sleep, when exist finished {@link TraceSegment}. */ } else { try2Sleep(NO_DATA_SLEEP_TIME_MILLIS); } } catch (Throwable t) { logger.error(t, "Send trace segments to collector failure."); } } } /** * Try to sleep, and ignore the {@link InterruptedException} * * @param millis the length of time to sleep in milliseconds */ private void try2Sleep(long millis) { try { Thread.sleep(millis); } catch (InterruptedException e) { } } } skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/Config.java +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ public class Config { } public static class Disruptor{ public static int BUFFER_SIZE = 1024 * 4; public static int BUFFER_SIZE = 512; } Loading skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentHolder.java +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ public final class TraceSegmentHolder { this.value = value; } public void clear(){ this.value = null; } public enum Factory implements EventFactory<TraceSegmentHolder> { INSTANCE; Loading Loading
skywalking-sniffer/skywalking-agent/src/main/java/com/a/eye/skywalking/agent/SkyWalkingAgent.java +2 −2 Original line number Diff line number Diff line package com.a.eye.skywalking.agent; import com.a.eye.skywalking.agent.junction.SkyWalkingEnhanceMatcher; import com.a.eye.skywalking.api.boot.ServiceStarter; import com.a.eye.skywalking.api.boot.ServiceManager; import com.a.eye.skywalking.api.conf.Config; import com.a.eye.skywalking.api.conf.SnifferConfigInitializer; import com.a.eye.skywalking.api.logging.EasyLogResolver; Loading Loading @@ -54,7 +54,7 @@ public class SkyWalkingAgent { final PluginFinder pluginFinder = new PluginFinder(new PluginBootstrap().loadPlugins()); ServiceStarter.INSTANCE.boot(); ServiceManager.INSTANCE.boot(); new AgentBuilder.Default().type(enhanceClassMatcher(pluginFinder).and(not(isInterface()))).transform(new AgentBuilder.Transformer() { public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader) { Loading
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceStarter.java→skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/boot/ServiceManager.java +3 −3 Original line number Diff line number Diff line Loading @@ -8,12 +8,12 @@ import java.util.Map; import java.util.ServiceLoader; /** * The <code>ServiceStarter</code> bases on {@link ServiceLoader}, * The <code>ServiceManager</code> bases on {@link ServiceLoader}, * load all {@link BootService} implementations. * * @author wusheng */ public enum ServiceStarter { public enum ServiceManager { INSTANCE; private static ILog logger = LogManager.getLogger(StatusBootService.class); Loading @@ -31,7 +31,7 @@ public enum ServiceStarter { bootService.bootUp(); bootedServices.put(bootService.getClass(), bootService); } catch (Exception e) { logger.error(e, "ServiceStarter try to start [{}] fail.", bootService.getClass().getName()); logger.error(e, "ServiceManager try to start [{}] fail.", bootService.getClass().getName()); } } } finally { Loading
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/client/CollectorClientService.java +50 −1 Original line number Diff line number Diff line package com.a.eye.skywalking.api.client; import com.a.eye.skywalking.api.boot.BootService; import com.a.eye.skywalking.api.boot.ServiceManager; import com.a.eye.skywalking.api.queue.TraceSegmentProcessQueue; import com.a.eye.skywalking.logging.ILog; import com.a.eye.skywalking.logging.LogManager; import com.a.eye.skywalking.trace.TraceSegment; import java.util.List; /** * @author wusheng */ public class CollectorClientService implements BootService { public class CollectorClientService implements Runnable, BootService { private static ILog logger = LogManager.getLogger(CollectorClientService.class); private static long NO_DATA_SLEEP_TIME_MILLIS = 500; /** * Start a new {@link Thread} to get finished {@link TraceSegment} by {@link TraceSegmentProcessQueue#getCachedTraceSegments()} */ @Override public void bootUp() { Thread collectorClientThread = new Thread(this, "collectorClientThread"); collectorClientThread.start(); } @Override public void run() { while (true) { try { TraceSegmentProcessQueue segmentProcessQueue = ServiceManager.INSTANCE.findService(TraceSegmentProcessQueue.class); List<TraceSegment> cachedTraceSegments = segmentProcessQueue.getCachedTraceSegments(); if (cachedTraceSegments.size() > 0) { for (TraceSegment segment : cachedTraceSegments) { //TODO: wusheng //send data } /** * No sleep, when exist finished {@link TraceSegment}. */ } else { try2Sleep(NO_DATA_SLEEP_TIME_MILLIS); } } catch (Throwable t) { logger.error(t, "Send trace segments to collector failure."); } } } /** * Try to sleep, and ignore the {@link InterruptedException} * * @param millis the length of time to sleep in milliseconds */ private void try2Sleep(long millis) { try { Thread.sleep(millis); } catch (InterruptedException e) { } } }
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/conf/Config.java +1 −1 Original line number Diff line number Diff line Loading @@ -16,7 +16,7 @@ public class Config { } public static class Disruptor{ public static int BUFFER_SIZE = 1024 * 4; public static int BUFFER_SIZE = 512; } Loading
skywalking-sniffer/skywalking-api/src/main/java/com/a/eye/skywalking/api/queue/TraceSegmentHolder.java +4 −0 Original line number Diff line number Diff line Loading @@ -19,6 +19,10 @@ public final class TraceSegmentHolder { this.value = value; } public void clear(){ this.value = null; } public enum Factory implements EventFactory<TraceSegmentHolder> { INSTANCE; Loading