Set up more strict code styles and fix existing issues (#4337)
Motivation: Review code styles with some bots automatically. Modifications: Set up ReviewDog in GitHub Action to review code style. Add more check rules to checkstyle plugin. Result: Obvious code styles can be reviewed and commented automatically.
This commit is contained in:
parent
fa526e5227
commit
5b255ba3e3
|
|
@ -16,17 +16,15 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.log4j.v1.x;
|
||||
|
||||
import org.apache.log4j.helpers.PatternConverter;
|
||||
import org.apache.log4j.spi.LoggingEvent;
|
||||
|
||||
/**
|
||||
* Default implementation outputs "TID: N/A".
|
||||
* But, if in sky-walking agent active mode, output will become the real ids.
|
||||
* Default implementation outputs "TID: N/A". But, if in sky-walking agent active mode, output will become the real
|
||||
* ids.
|
||||
* <p>
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
|
||||
public class TraceIdPatternConverter extends PatternConverter {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.log4j.v1.x;
|
||||
|
||||
import org.apache.log4j.PatternLayout;
|
||||
|
|
@ -25,8 +24,6 @@ import org.apache.log4j.helpers.PatternParser;
|
|||
/**
|
||||
* The log4j extend pattern. By using this pattern, if sky-walking agent is also active, {@link
|
||||
* PatternParser#finalizeConverter(char)} method will be override dynamic. <p>
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class TraceIdPatternLayout extends PatternLayout {
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.log4j.v1.x;
|
||||
|
||||
import org.apache.log4j.helpers.PatternParser;
|
||||
|
|
@ -24,7 +23,6 @@ import org.apache.log4j.helpers.PatternParser;
|
|||
/**
|
||||
* Base on '%T', use {@link TraceIdPatternConverter} to convert the '%t' to traceId.
|
||||
* <p>
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
public class TraceIdPatternParser extends PatternParser {
|
||||
public TraceIdPatternParser(String pattern) {
|
||||
|
|
|
|||
|
|
@ -16,16 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.log4j.v2.x;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/11.
|
||||
*/
|
||||
public class Log4j2OutputAppender {
|
||||
/**
|
||||
* As default, append "TID: N/A" to the output message,
|
||||
* if sky-walking agent in active mode, append the real traceId in the recent Context, if existed, or empty String.
|
||||
* As default, append "TID: N/A" to the output message, if sky-walking agent in active mode, append the real traceId
|
||||
* in the recent Context, if existed, or empty String.
|
||||
*
|
||||
* @param toAppendTo origin output message.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.log4j.v2.x;
|
||||
|
||||
import org.apache.logging.log4j.core.LogEvent;
|
||||
|
|
@ -25,12 +24,9 @@ import org.apache.logging.log4j.core.pattern.ConverterKeys;
|
|||
import org.apache.logging.log4j.core.pattern.LogEventPatternConverter;
|
||||
|
||||
/**
|
||||
* {@link TraceIdConverter} is a log4j2 plugin, by annotation as {@link Plugin}.
|
||||
* It convert the pattern key: traceId.
|
||||
* Use '%traceId' in log4j2's config.
|
||||
* '%traceId' will output as TID:xxxx
|
||||
* {@link TraceIdConverter} is a log4j2 plugin, by annotation as {@link Plugin}. It convert the pattern key: traceId.
|
||||
* Use '%traceId' in log4j2's config. '%traceId' will output as TID:xxxx
|
||||
* <p>
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
@Plugin(name = "TraceIdConverter", category = "Converter")
|
||||
@ConverterKeys({"traceId"})
|
||||
|
|
@ -39,7 +35,7 @@ public class TraceIdConverter extends LogEventPatternConverter {
|
|||
/**
|
||||
* Constructs an instance of LoggingEventPatternConverter.
|
||||
*
|
||||
* @param name name of converter.
|
||||
* @param name name of converter.
|
||||
* @param style CSS style for output.
|
||||
*/
|
||||
protected TraceIdConverter(String name, String style) {
|
||||
|
|
|
|||
|
|
@ -16,19 +16,15 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.logback.v1.x;
|
||||
|
||||
import ch.qos.logback.classic.pattern.ClassicConverter;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
public class LogbackPatternConverter extends ClassicConverter {
|
||||
/**
|
||||
* As default, return "TID: N/A" to the output message,
|
||||
* if sky-walking agent in active mode, return the real traceId in the recent Context, if existed.
|
||||
* As default, return "TID: N/A" to the output message, if sky-walking agent in active mode, return the real traceId
|
||||
* in the recent Context, if existed.
|
||||
*
|
||||
* @param iLoggingEvent the event
|
||||
* @return the traceId: N/A, empty String, or the real traceId.
|
||||
|
|
|
|||
|
|
@ -16,17 +16,14 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.logback.v1.x;
|
||||
|
||||
import ch.qos.logback.classic.PatternLayout;
|
||||
|
||||
/**
|
||||
* Based on the logback-compoenent convert register mechanism,
|
||||
* register {@link LogbackPatternConverter} as a new convert, match to "tid".
|
||||
* You can use "%tid" in logback config file, "Pattern" section.
|
||||
* Based on the logback-compoenent convert register mechanism, register {@link LogbackPatternConverter} as a new
|
||||
* convert, match to "tid". You can use "%tid" in logback config file, "Pattern" section.
|
||||
* <p>
|
||||
* Created by wusheng on 2016/12/7.
|
||||
*/
|
||||
public class TraceIdPatternLogbackLayout extends PatternLayout {
|
||||
static {
|
||||
|
|
|
|||
|
|
@ -27,9 +27,6 @@ import net.logstash.logback.composite.FieldNamesAware;
|
|||
import net.logstash.logback.composite.JsonWritingUtils;
|
||||
import net.logstash.logback.fieldnames.LogstashFieldNames;
|
||||
|
||||
/**
|
||||
* @author wuxingye
|
||||
*/
|
||||
public class TraceIdJsonProvider extends AbstractFieldJsonProvider<ILoggingEvent> implements FieldNamesAware<LogstashFieldNames> {
|
||||
|
||||
public static final String TRACING_ID = "TID";
|
||||
|
|
|
|||
|
|
@ -16,20 +16,17 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc;
|
||||
|
||||
import ch.qos.logback.classic.pattern.MDCConverter;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.util.OptionHelper;
|
||||
|
||||
/**
|
||||
* @author zhangkewei
|
||||
*/
|
||||
public class LogbackMDCPatternConverter extends MDCConverter {
|
||||
private static final String CONVERT_KEY = "tid";
|
||||
private static final String CONVERT_KEY = "tid";
|
||||
|
||||
private boolean convert4TID = false;
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
super.start();
|
||||
|
|
@ -38,6 +35,7 @@ public class LogbackMDCPatternConverter extends MDCConverter {
|
|||
convert4TID = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String convert(ILoggingEvent iLoggingEvent) {
|
||||
return convert4TID ? convertTID(iLoggingEvent) : super.convert(iLoggingEvent);
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.log.logback.v1.x.mdc;
|
||||
|
||||
import ch.qos.logback.classic.PatternLayout;
|
||||
|
||||
/**
|
||||
* Override "X",SuperClass run before Subclass.
|
||||
* @author zhangkewei
|
||||
*/
|
||||
public class TraceIdMDCPatternLogbackLayout extends PatternLayout {
|
||||
static {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.SpanContext;
|
||||
|
|
@ -25,9 +24,6 @@ import java.nio.charset.Charset;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/21.
|
||||
*/
|
||||
public class ByteBufferContext implements SpanContext {
|
||||
static final Charset CHARSET = Charset.forName("UTF-8");
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
@ -25,12 +24,13 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* The <code>NeedSnifferActivation</code> annotation is flag for reader and maintainers,
|
||||
* which represents this method should be activated/intercepted in sniffer.
|
||||
*
|
||||
* @author wusheng
|
||||
* The <code>NeedSnifferActivation</code> annotation is flag for reader and maintainers, which represents this method
|
||||
* should be activated/intercepted in sniffer.
|
||||
*/
|
||||
@Target({ElementType.METHOD, ElementType.CONSTRUCTOR})
|
||||
@Target({
|
||||
ElementType.METHOD,
|
||||
ElementType.CONSTRUCTOR
|
||||
})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface NeedSnifferActivation {
|
||||
String value() default "What should interceptor do?";
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.ActiveSpan;
|
||||
|
|
@ -24,10 +23,8 @@ import io.opentracing.SpanContext;
|
|||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* The <code>SkywalkingActiveSpan</code> is an extension of {@link SkywalkingSpan},
|
||||
* but because of Java inheritance restrict, only can do with a facade mode.
|
||||
*
|
||||
* @author wusheng
|
||||
* The <code>SkywalkingActiveSpan</code> is an extension of {@link SkywalkingSpan}, but because of Java inheritance
|
||||
* restrict, only can do with a facade mode.
|
||||
*/
|
||||
public class SkywalkingActiveSpan implements ActiveSpan {
|
||||
private SkywalkingSpan span;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.SpanContext;
|
||||
|
|
@ -25,8 +24,6 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* Skywalking tracer context based on {@link ThreadLocal} auto mechanism.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class SkywalkingContext implements SpanContext {
|
||||
public static final SkywalkingContext INSTANCE = new SkywalkingContext();
|
||||
|
|
|
|||
|
|
@ -16,22 +16,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.ActiveSpan;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class SkywalkingContinuation implements ActiveSpan.Continuation {
|
||||
@NeedSnifferActivation("1. ContextManager#capture" +
|
||||
"2. set ContextSnapshot to the dynamic field")
|
||||
@NeedSnifferActivation("1. ContextManager#capture" + "2. set ContextSnapshot to the dynamic field")
|
||||
public SkywalkingContinuation() {
|
||||
}
|
||||
|
||||
@NeedSnifferActivation("1. get ContextSnapshot from the dynamic field" +
|
||||
"2. ContextManager#continued")
|
||||
@NeedSnifferActivation("1. get ContextSnapshot from the dynamic field" + "2. ContextManager#continued")
|
||||
@Override
|
||||
public ActiveSpan activate() {
|
||||
SkywalkingSpanBuilder builder = new SkywalkingSpanBuilder("Thread/" + Thread.currentThread().getName());
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.Span;
|
||||
|
|
@ -24,23 +23,15 @@ import io.opentracing.SpanContext;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class SkywalkingSpan implements Span {
|
||||
@NeedSnifferActivation(
|
||||
"1.ContextManager#createSpan (Entry,Exit,Local based on builder)." +
|
||||
"2.set the span reference to the dynamic field of enhanced SkywalkingSpan") SkywalkingSpan(
|
||||
SkywalkingSpanBuilder builder) {
|
||||
@NeedSnifferActivation("1.ContextManager#createSpan (Entry,Exit,Local based on builder)." + "2.set the span reference to the dynamic field of enhanced SkywalkingSpan")
|
||||
SkywalkingSpan(SkywalkingSpanBuilder builder) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a shell span for {@link SkywalkingTracer#activeSpan()}
|
||||
*
|
||||
* @param tracer
|
||||
*/
|
||||
@NeedSnifferActivation(
|
||||
"1. set the span reference to the dynamic field of enhanced SkywalkingSpan")
|
||||
@NeedSnifferActivation("1. set the span reference to the dynamic field of enhanced SkywalkingSpan")
|
||||
public SkywalkingSpan(SkywalkingTracer tracer) {
|
||||
|
||||
}
|
||||
|
|
@ -59,12 +50,8 @@ public class SkywalkingSpan implements Span {
|
|||
|
||||
/**
|
||||
* Stop the active span
|
||||
*
|
||||
* @param finishMicros
|
||||
*/
|
||||
@NeedSnifferActivation(
|
||||
"1.ContextManager#stopSpan(AbstractSpan span)" +
|
||||
"2. The parameter of stop methed is from the dynamic field of enhanced SkywalkingSpan")
|
||||
@NeedSnifferActivation("1.ContextManager#stopSpan(AbstractSpan span)" + "2. The parameter of stop methed is from the dynamic field of enhanced SkywalkingSpan")
|
||||
@Override
|
||||
public void finish(long finishMicros) {
|
||||
|
||||
|
|
@ -87,18 +74,19 @@ public class SkywalkingSpan implements Span {
|
|||
return SkywalkingContext.INSTANCE;
|
||||
}
|
||||
|
||||
@NeedSnifferActivation(
|
||||
"1. ContextManager#activeSpan()" +
|
||||
"2. SkywalkingSpan#setTag(String, String)")
|
||||
@Override public Span setTag(String key, String value) {
|
||||
@NeedSnifferActivation("1. ContextManager#activeSpan()" + "2. SkywalkingSpan#setTag(String, String)")
|
||||
@Override
|
||||
public Span setTag(String key, String value) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override public Span setTag(String key, boolean value) {
|
||||
@Override
|
||||
public Span setTag(String key, boolean value) {
|
||||
return setTag(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
@Override public Span setTag(String key, Number value) {
|
||||
@Override
|
||||
public Span setTag(String key, Number value) {
|
||||
return setTag(key, String.valueOf(value));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.ActiveSpan;
|
||||
|
|
@ -30,9 +29,6 @@ import io.opentracing.tag.Tags;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class SkywalkingSpanBuilder implements Tracer.SpanBuilder {
|
||||
private List<Tag> tags = new LinkedList<Tag>();
|
||||
private String operationName;
|
||||
|
|
@ -66,10 +62,6 @@ public class SkywalkingSpanBuilder implements Tracer.SpanBuilder {
|
|||
|
||||
/**
|
||||
* Ignore the reference type. the span always the entry or has a parent span.
|
||||
*
|
||||
* @param referenceType
|
||||
* @param referencedContext
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Tracer.SpanBuilder addReference(String referenceType, SpanContext referencedContext) {
|
||||
|
|
@ -94,8 +86,9 @@ public class SkywalkingSpanBuilder implements Tracer.SpanBuilder {
|
|||
isEntry = false;
|
||||
isExit = false;
|
||||
}
|
||||
} else if (Tags.PEER_HOST_IPV4.getKey().equals(key) || Tags.PEER_HOST_IPV6.getKey().equals(key)
|
||||
|| Tags.PEER_HOSTNAME.getKey().equals(key)) {
|
||||
} else if (Tags.PEER_HOST_IPV4.getKey().equals(key) || Tags.PEER_HOST_IPV6.getKey()
|
||||
.equals(key) || Tags.PEER_HOSTNAME.getKey()
|
||||
.equals(key)) {
|
||||
peer = value;
|
||||
} else if (Tags.PEER_SERVICE.getKey().equals(key)) {
|
||||
operationName = value;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.ActiveSpan;
|
||||
|
|
@ -25,9 +24,6 @@ import io.opentracing.SpanContext;
|
|||
import io.opentracing.Tracer;
|
||||
import io.opentracing.propagation.Format;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class SkywalkingTracer implements Tracer {
|
||||
|
||||
public SpanBuilder buildSpan(String operationName) {
|
||||
|
|
@ -54,7 +50,7 @@ public class SkywalkingTracer implements Tracer {
|
|||
@Override
|
||||
public ActiveSpan makeActive(Span span) {
|
||||
if (span instanceof SkywalkingSpan) {
|
||||
return new SkywalkingActiveSpan((SkywalkingSpan)span);
|
||||
return new SkywalkingActiveSpan((SkywalkingSpan) span);
|
||||
} else {
|
||||
throw new IllegalArgumentException("span must be a type of SkywalkingSpan");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class Tag {
|
||||
private String key;
|
||||
private String value;
|
||||
|
|
|
|||
|
|
@ -16,16 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.opentracing;
|
||||
|
||||
import io.opentracing.SpanContext;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/12/21.
|
||||
*/
|
||||
public class TextMapContext implements SpanContext {
|
||||
public TextMapContext() {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.trace;
|
||||
|
||||
/**
|
||||
* provide custom api that set tag for current active span.
|
||||
*
|
||||
* @author zhangxin
|
||||
*/
|
||||
public class ActiveSpan {
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -15,13 +15,11 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.trace;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
/**
|
||||
* @author carlvine500
|
||||
*/
|
||||
@TraceCrossThread
|
||||
public class CallableWrapper<V> implements Callable<V> {
|
||||
final Callable<V> callable;
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.trace;
|
||||
|
||||
/**
|
||||
* @author lican
|
||||
*/
|
||||
@TraceCrossThread
|
||||
public class RunnableWrapper implements Runnable {
|
||||
final Runnable runnable;
|
||||
|
|
@ -31,7 +29,6 @@ public class RunnableWrapper implements Runnable {
|
|||
return new RunnableWrapper(r);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
this.runnable.run();
|
||||
|
|
|
|||
|
|
@ -15,13 +15,11 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.trace;
|
||||
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
* @author sxzaihua
|
||||
*/
|
||||
@TraceCrossThread
|
||||
public class SupplierWrapper<V> implements Supplier<V> {
|
||||
final Supplier<V> supplier;
|
||||
|
|
|
|||
|
|
@ -24,10 +24,9 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Tag the current active span with key {@link #key()} and value {@link #value()},
|
||||
* if there is no active span, this annotation takes no effect.
|
||||
* Tag the current active span with key {@link #key()} and value {@link #value()}, if there is no active span, this
|
||||
* annotation takes no effect.
|
||||
*
|
||||
* @author kezhenxu94
|
||||
* @see Tags
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
|
|
@ -39,9 +38,8 @@ public @interface Tag {
|
|||
String key();
|
||||
|
||||
/**
|
||||
* @return the value of the tag to be injected into the current active span,
|
||||
* in the form of the customized enhancement rules, for more information,
|
||||
* refer to https://github.com/apache/skywalking/blob/master/docs/en/setup/service-agent/java-agent/Customize-enhance-trace.md#how-to-configure
|
||||
* @return the value of the tag to be injected into the current active span, in the form of the customized
|
||||
* enhancement rules, for more information, refer to https://github.com/apache/skywalking/blob/master/docs/en/setup/service-agent/java-agent/Customize-enhance-trace.md#how-to-configure
|
||||
*/
|
||||
String value();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* A wrapper annotation for {@link Tag} that allows to
|
||||
* apply multiple tags to a single method span,
|
||||
* A wrapper annotation for {@link Tag} that allows to apply multiple tags to a single method span,
|
||||
*
|
||||
* <pre>
|
||||
* @Tag(key = "tag1", value = "arg[0]")
|
||||
|
|
@ -35,7 +34,6 @@ import java.lang.annotation.Target;
|
|||
* }
|
||||
* </pre>
|
||||
*
|
||||
* @author kezhenxu94
|
||||
* @see Tag
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.trace;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
@ -28,8 +27,6 @@ import java.lang.annotation.Target;
|
|||
* The agent create local span if the method that annotation with {@link Trace}. The value of span operation name will
|
||||
* fetch by {@link #operationName()}. if the value of {@link #operationName()} is blank string. the operation name will
|
||||
* be set the class name + method name.
|
||||
*
|
||||
* @author zhangxin
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
|
|
|||
|
|
@ -16,16 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.trace;
|
||||
|
||||
/**
|
||||
* Try to access the sky-walking tracer context.
|
||||
* The context is not existed, always.
|
||||
* only the middleware, component, or rpc-framework are supported in the current invoke stack, in the same thread,
|
||||
* the context will be available.
|
||||
* Try to access the sky-walking tracer context. The context is not existed, always. only the middleware, component, or
|
||||
* rpc-framework are supported in the current invoke stack, in the same thread, the context will be available.
|
||||
* <p>
|
||||
* Created by xin on 2016/12/15.
|
||||
*/
|
||||
public class TraceContext {
|
||||
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.toolkit.trace;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
|
|
@ -22,9 +23,6 @@ import java.lang.annotation.Retention;
|
|||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* @author carlvine500
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface TraceCrossThread {
|
||||
|
|
|
|||
|
|
@ -20,19 +20,31 @@
|
|||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||
"http://checkstyle.org/dtds/configuration_1_3.dtd">
|
||||
<!--Refer http://checkstyle.sourceforge.net/reports/google-java-style.html#s2.2-file-encoding -->
|
||||
<module name="Checker">
|
||||
|
||||
<property name="localeLanguage" value="en"/>
|
||||
|
||||
<!--To configure the check to report on the first instance in each file-->
|
||||
<module name="FileTabCharacter"/>
|
||||
<module name="FileTabCharacter">
|
||||
<property name="eachLine" value="true"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpHeader">
|
||||
<property name="headerFile" value="${checkstyle.header.file}"/>
|
||||
<property name="multiLines" value="1, 2, 3, 18"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="System\.out\.println"/>
|
||||
<property name="message" value="Prohibit invoking System.out.println in source code !"/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="^\s*\*\s*@author"/>
|
||||
<property name="minimum" value="0"/>
|
||||
<property name="maximum" value="0"/>
|
||||
<property name="message" value="ASF project doesn't allow @author copyright."/>
|
||||
</module>
|
||||
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format"
|
||||
value=".*[\u3400-\u4DB5\u4E00-\u9FA5\u9FA6-\u9FBB\uF900-\uFA2D\uFA30-\uFA6A\uFA70-\uFAD9\uFF00-\uFFEF\u2E80-\u2EFF\u3000-\u303F\u31C0-\u31EF]+.*"/>
|
||||
|
|
@ -45,10 +57,11 @@
|
|||
|
||||
<module name="TreeWalker">
|
||||
|
||||
<module name="UnusedImports">
|
||||
<property name="processJavadoc" value="true"/>
|
||||
</module>
|
||||
<module name="UnusedImports"/>
|
||||
<module name="RedundantImport"/>
|
||||
<module name="AvoidStarImport"/>
|
||||
|
||||
<module name="NonEmptyAtclauseDescription"/>
|
||||
|
||||
<!--Checks that classes that override equals() also override hashCode()-->
|
||||
<module name="EqualsHashCode"/>
|
||||
|
|
@ -95,32 +108,25 @@
|
|||
|
||||
<!--whitespace-->
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="NoWhitespaceAfter"/>
|
||||
<module name="WhitespaceAround">
|
||||
<property name="allowEmptyConstructors" value="true"/>
|
||||
<property name="allowEmptyMethods" value="true"/>
|
||||
</module>
|
||||
<module name="Indentation"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="WhitespaceAround"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
|
||||
<module name="ImportControl">
|
||||
<property name="file" value="apm-checkstyle/importControl.xml" />
|
||||
<property name="path" value="apm-sniffer/(apm-sdk-plugin|bootstrap-plugins|optional-plugins)/.+/src/main/.+Instrumentation.java$" />
|
||||
<module name="EmptyLineSeparator">
|
||||
<property name="allowNoEmptyLineBetweenFields" value="true"/>
|
||||
<property name="allowMultipleEmptyLines" value="false"/>
|
||||
<property name="allowMultipleEmptyLinesInsideClassMembers" value="false"/>
|
||||
</module>
|
||||
|
||||
<module name="ImportControl">
|
||||
<property name="file" value="apm-checkstyle/importControl.xml" />
|
||||
<property name="path" value="apm-sniffer/apm-toolkit-activation/.+/src/main/.+Activation.java$" />
|
||||
<property name="file" value="apm-checkstyle/importControl.xml"/>
|
||||
<property name="path" value="apm-sniffer/(apm-sdk-plugin|bootstrap-plugins|optional-plugins)/.+/src/main/.+Instrumentation.java$"/>
|
||||
</module>
|
||||
|
||||
<module name="ImportControl">
|
||||
<property name="file" value="apm-checkstyle/importControl.xml"/>
|
||||
<property name="path" value="apm-sniffer/apm-toolkit-activation/.+/src/main/.+Activation.java$"/>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
<module name="RegexpHeader">
|
||||
<property name="headerFile" value="${checkstyle.header.file}"/>
|
||||
<property name="multiLines" value="1, 2, 3, 18"/>
|
||||
</module>
|
||||
|
||||
</module>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,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">
|
||||
<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.apache.skywalking</groupId>
|
||||
|
|
|
|||
|
|
@ -18,9 +18,14 @@
|
|||
|
||||
package org.apache.skywalking.apm.commons.datacarrier;
|
||||
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.*;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.consumer.*;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.partition.*;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.consumer.ConsumeDriver;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.consumer.ConsumerPool;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.consumer.IConsumer;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.consumer.IDriver;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.partition.IDataPartitioner;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.partition.SimpleRollingPartitioner;
|
||||
|
||||
/**
|
||||
* DataCarrier main class. use this instance to set Producer/Consumer Model.
|
||||
|
|
@ -61,8 +66,6 @@ public class DataCarrier<T> {
|
|||
|
||||
/**
|
||||
* override the strategy at runtime. Notice, {@link Channels} will override several channels one by one.
|
||||
*
|
||||
* @param strategy
|
||||
*/
|
||||
public DataCarrier setBufferStrategy(BufferStrategy strategy) {
|
||||
this.channels.setStrategy(strategy);
|
||||
|
|
@ -72,7 +75,6 @@ public class DataCarrier<T> {
|
|||
/**
|
||||
* produce data to buffer, using the given {@link BufferStrategy}.
|
||||
*
|
||||
* @param data
|
||||
* @return false means produce data failure. The data will not be consumed.
|
||||
*/
|
||||
public boolean produce(T data) {
|
||||
|
|
@ -89,7 +91,7 @@ public class DataCarrier<T> {
|
|||
* set consumeDriver to this Carrier. consumer begin to run when {@link DataCarrier#produce} begin to work.
|
||||
*
|
||||
* @param consumerClass class of consumer
|
||||
* @param num number of consumer threads
|
||||
* @param num number of consumer threads
|
||||
*/
|
||||
public DataCarrier consume(Class<? extends IConsumer<T>> consumerClass, int num, long consumeCycle) {
|
||||
if (driver != null) {
|
||||
|
|
@ -105,7 +107,7 @@ public class DataCarrier<T> {
|
|||
* millis consume cycle.
|
||||
*
|
||||
* @param consumerClass class of consumer
|
||||
* @param num number of consumer threads
|
||||
* @param num number of consumer threads
|
||||
*/
|
||||
public DataCarrier consume(Class<? extends IConsumer<T>> consumerClass, int num) {
|
||||
return this.consume(consumerClass, num, 20);
|
||||
|
|
@ -115,8 +117,7 @@ public class DataCarrier<T> {
|
|||
* set consumeDriver to this Carrier. consumer begin to run when {@link DataCarrier#produce} begin to work.
|
||||
*
|
||||
* @param consumer single instance of consumer, all consumer threads will all use this instance.
|
||||
* @param num number of consumer threads
|
||||
* @return
|
||||
* @param num number of consumer threads
|
||||
*/
|
||||
public DataCarrier consume(IConsumer<T> consumer, int num, long consumeCycle) {
|
||||
if (driver != null) {
|
||||
|
|
@ -132,8 +133,7 @@ public class DataCarrier<T> {
|
|||
* millis consume cycle.
|
||||
*
|
||||
* @param consumer single instance of consumer, all consumer threads will all use this instance.
|
||||
* @param num number of consumer threads
|
||||
* @return
|
||||
* @param num number of consumer threads
|
||||
*/
|
||||
public DataCarrier consume(IConsumer<T> consumer, int num) {
|
||||
return this.consume(consumer, num, 20);
|
||||
|
|
@ -142,9 +142,6 @@ public class DataCarrier<T> {
|
|||
/**
|
||||
* Set a consumer pool to manage the channels of this DataCarrier. Then consumerPool could use its own consuming
|
||||
* model to adjust the consumer thread and throughput.
|
||||
*
|
||||
* @param consumerPool
|
||||
* @return
|
||||
*/
|
||||
public DataCarrier consume(ConsumerPool consumerPool, IConsumer<T> consumer) {
|
||||
driver = consumerPool;
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ package org.apache.skywalking.apm.commons.datacarrier;
|
|||
|
||||
/**
|
||||
* Read value from system env.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class EnvUtil {
|
||||
public static int getInt(String envName, int defaultValue) {
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ import java.util.concurrent.ArrayBlockingQueue;
|
|||
|
||||
/**
|
||||
* The buffer implementation based on JDK ArrayBlockingQueue.
|
||||
*
|
||||
* <p>
|
||||
* This implementation has better performance in server side. We are still trying to research whether this is suitable
|
||||
* for agent side, which is more sensitive about blocks.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class ArrayBlockingQueueBuffer<T> implements QueueBuffer<T> {
|
||||
private BufferStrategy strategy;
|
||||
|
|
@ -40,7 +38,8 @@ public class ArrayBlockingQueueBuffer<T> implements QueueBuffer<T> {
|
|||
this.bufferSize = bufferSize;
|
||||
}
|
||||
|
||||
@Override public boolean save(T data) {
|
||||
@Override
|
||||
public boolean save(T data) {
|
||||
switch (strategy) {
|
||||
case IF_POSSIBLE:
|
||||
return queue.offer(data);
|
||||
|
|
@ -55,15 +54,18 @@ public class ArrayBlockingQueueBuffer<T> implements QueueBuffer<T> {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override public void setStrategy(BufferStrategy strategy) {
|
||||
@Override
|
||||
public void setStrategy(BufferStrategy strategy) {
|
||||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
@Override public void obtain(List<T> consumeList) {
|
||||
@Override
|
||||
public void obtain(List<T> consumeList) {
|
||||
queue.drainTo(consumeList);
|
||||
}
|
||||
|
||||
@Override public int getBufferSize() {
|
||||
@Override
|
||||
public int getBufferSize() {
|
||||
return bufferSize;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ import org.apache.skywalking.apm.commons.datacarrier.common.AtomicRangeInteger;
|
|||
|
||||
/**
|
||||
* Self implementation ring queue.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class Buffer<T> implements QueueBuffer<T> {
|
||||
private final Object[] buffer;
|
||||
|
|
@ -41,7 +39,6 @@ public class Buffer<T> implements QueueBuffer<T> {
|
|||
this.strategy = strategy;
|
||||
}
|
||||
|
||||
|
||||
public boolean save(T data) {
|
||||
int i = index.getAndIncrement();
|
||||
if (buffer[i] != null) {
|
||||
|
|
@ -74,7 +71,7 @@ public class Buffer<T> implements QueueBuffer<T> {
|
|||
void obtain(List<T> consumeList, int start, int end) {
|
||||
for (int i = start; i < end; i++) {
|
||||
if (buffer[i] != null) {
|
||||
consumeList.add((T)buffer[i]);
|
||||
consumeList.add((T) buffer[i]);
|
||||
buffer[i] = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.buffer;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public enum BufferStrategy {
|
||||
BLOCKING,
|
||||
IF_POSSIBLE
|
||||
BLOCKING, IF_POSSIBLE
|
||||
}
|
||||
|
|
|
|||
|
|
@ -68,8 +68,6 @@ public class Channels<T> {
|
|||
/**
|
||||
* override the strategy at runtime. Notice, this will override several channels one by one. So, when running
|
||||
* setStrategy, each channel may use different BufferStrategy
|
||||
*
|
||||
* @param strategy
|
||||
*/
|
||||
public void setStrategy(BufferStrategy strategy) {
|
||||
for (QueueBuffer<T> buffer : bufferChannels) {
|
||||
|
|
@ -79,8 +77,6 @@ public class Channels<T> {
|
|||
|
||||
/**
|
||||
* get channelSize
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getChannelSize() {
|
||||
return this.bufferChannels.length;
|
||||
|
|
|
|||
|
|
@ -22,12 +22,11 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Queue buffer interface.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface QueueBuffer<T> {
|
||||
/**
|
||||
* Save data into the queue;
|
||||
*
|
||||
* @param data to add.
|
||||
* @return true if saved
|
||||
*/
|
||||
|
|
@ -35,13 +34,11 @@ public interface QueueBuffer<T> {
|
|||
|
||||
/**
|
||||
* Set different strategy when queue is full.
|
||||
* @param strategy
|
||||
*/
|
||||
void setStrategy(BufferStrategy strategy);
|
||||
|
||||
/**
|
||||
* Obtain the existing data from the queue
|
||||
* @param consumeList
|
||||
*/
|
||||
void obtain(List<T> consumeList);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,15 +16,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.atomic.AtomicIntegerArray;
|
||||
|
||||
/**
|
||||
* Created by lkxiaolou
|
||||
*/
|
||||
public class AtomicRangeInteger extends Number implements Serializable {
|
||||
private static final long serialVersionUID = -4099792402691141643L;
|
||||
private AtomicIntegerArray values;
|
||||
|
|
@ -48,7 +44,8 @@ public class AtomicRangeInteger extends Number implements Serializable {
|
|||
if (next > endValue && this.values.compareAndSet(VALUE_OFFSET, next, startValue)) {
|
||||
return endValue;
|
||||
}
|
||||
} while (next > endValue);
|
||||
}
|
||||
while (next > endValue);
|
||||
|
||||
return next - 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,8 @@
|
|||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.EnvUtil;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels;
|
||||
|
|
@ -26,10 +27,8 @@ import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels;
|
|||
/**
|
||||
* BulkConsumePool works for consuming data from multiple channels(DataCarrier instances), with multiple {@link
|
||||
* MultipleChannelsConsumer}s.
|
||||
*
|
||||
* <p>
|
||||
* In typical case, the number of {@link MultipleChannelsConsumer} should be less than the number of channels.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class BulkConsumePool implements ConsumerPool {
|
||||
private List<MultipleChannelsConsumer> allConsumers;
|
||||
|
|
@ -45,7 +44,8 @@ public class BulkConsumePool implements ConsumerPool {
|
|||
}
|
||||
}
|
||||
|
||||
@Override synchronized public void add(String name, Channels channels, IConsumer consumer) {
|
||||
@Override
|
||||
synchronized public void add(String name, Channels channels, IConsumer consumer) {
|
||||
MultipleChannelsConsumer multipleChannelsConsumer = getLowestPayload();
|
||||
multipleChannelsConsumer.addNewTarget(channels, consumer);
|
||||
}
|
||||
|
|
@ -67,20 +67,22 @@ public class BulkConsumePool implements ConsumerPool {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param channels
|
||||
* @return
|
||||
*
|
||||
*/
|
||||
@Override public boolean isRunning(Channels channels) {
|
||||
@Override
|
||||
public boolean isRunning(Channels channels) {
|
||||
return isStarted;
|
||||
}
|
||||
|
||||
@Override public void close(Channels channels) {
|
||||
@Override
|
||||
public void close(Channels channels) {
|
||||
for (MultipleChannelsConsumer consumer : allConsumers) {
|
||||
consumer.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void begin(Channels channels) {
|
||||
@Override
|
||||
public void begin(Channels channels) {
|
||||
if (isStarted) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -104,7 +106,8 @@ public class BulkConsumePool implements ConsumerPool {
|
|||
this.consumeCycle = consumeCycle;
|
||||
}
|
||||
|
||||
@Override public ConsumerPool call() {
|
||||
@Override
|
||||
public ConsumerPool call() {
|
||||
return new BulkConsumePool(name, size, consumeCycle);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/11/15.
|
||||
*/
|
||||
public class ConsumerCannotBeCreatedException extends RuntimeException {
|
||||
ConsumerCannotBeCreatedException(Throwable t) {
|
||||
super(t);
|
||||
|
|
|
|||
|
|
@ -22,10 +22,8 @@ import org.apache.skywalking.apm.commons.datacarrier.DataCarrier;
|
|||
import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels;
|
||||
|
||||
/**
|
||||
* The Consumer pool could support data consumer from multiple {@link DataCarrier}s,
|
||||
* by using different consume thread management models.
|
||||
*
|
||||
* @author wusheng
|
||||
* The Consumer pool could support data consumer from multiple {@link DataCarrier}s, by using different consume thread
|
||||
* management models.
|
||||
*/
|
||||
public interface ConsumerPool extends IDriver {
|
||||
void add(String name, Channels channels, IConsumer consumer);
|
||||
|
|
|
|||
|
|
@ -18,14 +18,13 @@
|
|||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels;
|
||||
|
||||
/**
|
||||
* Consumer Pool Factory provides global management for all Consumer Pool.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public enum ConsumerPoolFactory {
|
||||
INSTANCE;
|
||||
|
|
@ -56,7 +55,8 @@ public enum ConsumerPoolFactory {
|
|||
public static final ConsumerPool DEFAULT_POOL = new ConsumerPool() {
|
||||
private Map<Channels, ConsumeDriver> allDrivers = new HashMap<Channels, ConsumeDriver>();
|
||||
|
||||
@Override synchronized public void add(String name, Channels channels, IConsumer consumer) {
|
||||
@Override
|
||||
synchronized public void add(String name, Channels channels, IConsumer consumer) {
|
||||
if (!allDrivers.containsKey(channels)) {
|
||||
ConsumeDriver consumeDriver = new ConsumeDriver(name, channels, consumer, 1, 20);
|
||||
allDrivers.put(channels, consumeDriver);
|
||||
|
|
@ -65,21 +65,22 @@ public enum ConsumerPoolFactory {
|
|||
|
||||
/**
|
||||
* Always return true.
|
||||
* @param channels
|
||||
* @return
|
||||
*/
|
||||
@Override public boolean isRunning(Channels channels) {
|
||||
@Override
|
||||
public boolean isRunning(Channels channels) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override public void close(Channels channels) {
|
||||
@Override
|
||||
public void close(Channels channels) {
|
||||
ConsumeDriver driver = allDrivers.get(channels);
|
||||
if (driver != null) {
|
||||
driver.close(channels);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void begin(Channels channels) {
|
||||
@Override
|
||||
public void begin(Channels channels) {
|
||||
ConsumeDriver driver = allDrivers.get(channels);
|
||||
if (driver != null) {
|
||||
driver.begin(channels);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -24,9 +23,6 @@ import java.util.List;
|
|||
import org.apache.skywalking.apm.commons.datacarrier.buffer.Buffer;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.QueueBuffer;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public class ConsumerThread<T> extends Thread {
|
||||
private volatile boolean running;
|
||||
private IConsumer<T> consumer;
|
||||
|
|
@ -43,8 +39,6 @@ public class ConsumerThread<T> extends Thread {
|
|||
|
||||
/**
|
||||
* add whole buffer to consume
|
||||
*
|
||||
* @param sourceBuffer
|
||||
*/
|
||||
void addDataSource(QueueBuffer<T> sourceBuffer) {
|
||||
this.dataSources.add(new DataSource(sourceBuffer));
|
||||
|
|
|
|||
|
|
@ -16,14 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public interface IConsumer<T> {
|
||||
void init();
|
||||
|
||||
|
|
|
|||
|
|
@ -22,11 +22,11 @@ import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels;
|
|||
|
||||
/**
|
||||
* The driver of consumer.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface IDriver {
|
||||
boolean isRunning(Channels channels);
|
||||
|
||||
void close(Channels channels);
|
||||
|
||||
void begin(Channels channels);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,8 +26,6 @@ import org.apache.skywalking.apm.commons.datacarrier.buffer.QueueBuffer;
|
|||
/**
|
||||
* MultipleChannelsConsumer represent a single consumer thread, but support multiple channels with their {@link
|
||||
* IConsumer}s
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class MultipleChannelsConsumer extends Thread {
|
||||
private volatile boolean running;
|
||||
|
|
@ -91,9 +89,6 @@ public class MultipleChannelsConsumer extends Thread {
|
|||
|
||||
/**
|
||||
* Add a new target channels.
|
||||
*
|
||||
* @param channels
|
||||
* @param consumer
|
||||
*/
|
||||
public void addNewTarget(Channels channels, IConsumer consumer) {
|
||||
Group group = new Group(channels, consumer);
|
||||
|
|
|
|||
|
|
@ -16,20 +16,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.partition;
|
||||
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public interface IDataPartitioner<T> {
|
||||
int partition(int total, T data);
|
||||
|
||||
/**
|
||||
* @return an integer represents how many times should retry when {@link BufferStrategy#IF_POSSIBLE}.
|
||||
*
|
||||
* <p>
|
||||
* Less or equal 1, means not support retry.
|
||||
*/
|
||||
int maxRetryCount();
|
||||
|
|
|
|||
|
|
@ -16,13 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.partition;
|
||||
|
||||
/**
|
||||
* use threadid % total to partition
|
||||
*
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public class ProducerThreadPartitioner<T> implements IDataPartitioner<T> {
|
||||
private int retryTime = 3;
|
||||
|
|
@ -36,7 +33,7 @@ public class ProducerThreadPartitioner<T> implements IDataPartitioner<T> {
|
|||
|
||||
@Override
|
||||
public int partition(int total, T data) {
|
||||
return (int)Thread.currentThread().getId() % total;
|
||||
return (int) Thread.currentThread().getId() % total;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,14 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.partition;
|
||||
|
||||
/**
|
||||
* use normal int to rolling.
|
||||
*
|
||||
*
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public class SimpleRollingPartitioner<T> implements IDataPartitioner<T> {
|
||||
private volatile int i = 0;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -31,17 +30,17 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
import org.powermock.api.support.membermodification.MemberModifier;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
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);
|
||||
Assert.assertEquals(((Integer) (MemberModifier.field(DataCarrier.class, "bufferSize")
|
||||
.get(carrier))).intValue(), 100);
|
||||
Assert.assertEquals(((Integer) (MemberModifier.field(DataCarrier.class, "channelSize")
|
||||
.get(carrier))).intValue(), 5);
|
||||
|
||||
Channels<SampleData> channels = (Channels<SampleData>)(MemberModifier.field(DataCarrier.class, "channels").get(carrier));
|
||||
Channels<SampleData> channels = (Channels<SampleData>) (MemberModifier.field(DataCarrier.class, "channels")
|
||||
.get(carrier));
|
||||
Assert.assertEquals(5, channels.getChannelSize());
|
||||
|
||||
QueueBuffer<SampleData> buffer = channels.getBuffer(0);
|
||||
|
|
@ -49,11 +48,16 @@ public class DataCarrierTest {
|
|||
|
||||
Assert.assertEquals(MemberModifier.field(buffer.getClass(), "strategy").get(buffer), BufferStrategy.BLOCKING);
|
||||
carrier.setBufferStrategy(BufferStrategy.IF_POSSIBLE);
|
||||
Assert.assertEquals(MemberModifier.field(buffer.getClass(), "strategy").get(buffer), BufferStrategy.IF_POSSIBLE);
|
||||
Assert.assertEquals(MemberModifier.field(buffer.getClass(), "strategy")
|
||||
.get(buffer), BufferStrategy.IF_POSSIBLE);
|
||||
|
||||
Assert.assertEquals(MemberModifier.field(Channels.class, "dataPartitioner").get(channels).getClass(), SimpleRollingPartitioner.class);
|
||||
Assert.assertEquals(MemberModifier.field(Channels.class, "dataPartitioner")
|
||||
.get(channels)
|
||||
.getClass(), SimpleRollingPartitioner.class);
|
||||
carrier.setPartitioner(new ProducerThreadPartitioner<SampleData>());
|
||||
Assert.assertEquals(MemberModifier.field(Channels.class, "dataPartitioner").get(channels).getClass(), ProducerThreadPartitioner.class);
|
||||
Assert.assertEquals(MemberModifier.field(Channels.class, "dataPartitioner")
|
||||
.get(channels)
|
||||
.getClass(), ProducerThreadPartitioner.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -64,7 +68,8 @@ public class DataCarrierTest {
|
|||
Assert.assertTrue(carrier.produce(new SampleData().setName("c")));
|
||||
Assert.assertTrue(carrier.produce(new SampleData().setName("d")));
|
||||
|
||||
Channels<SampleData> channels = (Channels<SampleData>)(MemberModifier.field(DataCarrier.class, "channels").get(carrier));
|
||||
Channels<SampleData> channels = (Channels<SampleData>) (MemberModifier.field(DataCarrier.class, "channels")
|
||||
.get(carrier));
|
||||
QueueBuffer<SampleData> buffer1 = channels.getBuffer(0);
|
||||
|
||||
List result = new ArrayList();
|
||||
|
|
@ -91,7 +96,8 @@ public class DataCarrierTest {
|
|||
Assert.assertFalse(carrier.produce(new SampleData().setName("d" + i + "_2")));
|
||||
}
|
||||
|
||||
Channels<SampleData> channels = (Channels<SampleData>)(MemberModifier.field(DataCarrier.class, "channels").get(carrier));
|
||||
Channels<SampleData> channels = (Channels<SampleData>) (MemberModifier.field(DataCarrier.class, "channels")
|
||||
.get(carrier));
|
||||
QueueBuffer<SampleData> buffer1 = channels.getBuffer(0);
|
||||
List result = new ArrayList();
|
||||
buffer1.obtain(result);
|
||||
|
|
|
|||
|
|
@ -28,10 +28,6 @@ import org.powermock.modules.junit4.PowerMockRunner;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/**
|
||||
* @author dengming
|
||||
* 2019-04-20
|
||||
*/
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PrepareForTest(EnvUtil.class)
|
||||
public class EnvUtilTest {
|
||||
|
|
|
|||
|
|
@ -168,12 +168,11 @@ public class LinkedArrayBenchmark {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws RunnerException {
|
||||
Options opt = new OptionsBuilder()
|
||||
.include(LinkedArrayBenchmark.class.getName())
|
||||
.addProfiler(GCProfiler.class)
|
||||
.jvmArgsAppend("-Xmx512m", "-Xms512m")
|
||||
.forks(1)
|
||||
.build();
|
||||
Options opt = new OptionsBuilder().include(LinkedArrayBenchmark.class.getName())
|
||||
.addProfiler(GCProfiler.class)
|
||||
.jvmArgsAppend("-Xmx512m", "-Xms512m")
|
||||
.forks(1)
|
||||
.build();
|
||||
new Runner(opt).run();
|
||||
}
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public class SampleData {
|
||||
private int intValue;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.common;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
|
@ -27,9 +26,6 @@ import org.openjdk.jmh.runner.RunnerException;
|
|||
import org.openjdk.jmh.runner.options.Options;
|
||||
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
||||
|
||||
/**
|
||||
* Created by xin on 2017/7/14.
|
||||
*/
|
||||
public class AtomicRangeIntegerTest {
|
||||
|
||||
private static AtomicRangeInteger ATOMIC_V3 = new AtomicRangeInteger(0, 100);
|
||||
|
|
@ -46,8 +42,8 @@ public class AtomicRangeIntegerTest {
|
|||
Assert.assertEquals(1, atomicI.get());
|
||||
Assert.assertEquals(1, atomicI.intValue());
|
||||
Assert.assertEquals(1, atomicI.longValue());
|
||||
Assert.assertEquals(1, (int)atomicI.floatValue());
|
||||
Assert.assertEquals(1, (int)atomicI.doubleValue());
|
||||
Assert.assertEquals(1, (int) atomicI.floatValue());
|
||||
Assert.assertEquals(1, (int) atomicI.doubleValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -69,15 +65,14 @@ public class AtomicRangeIntegerTest {
|
|||
}
|
||||
|
||||
public static void main(String[] args) throws RunnerException {
|
||||
Options opt = new OptionsBuilder()
|
||||
.include(AtomicRangeIntegerTest.class.getSimpleName())
|
||||
.forks(1)
|
||||
.warmupIterations(3)
|
||||
.threads(128)
|
||||
.syncIterations(false)
|
||||
.output("/tmp/jmh.log")
|
||||
.measurementIterations(5)
|
||||
.build();
|
||||
Options opt = new OptionsBuilder().include(AtomicRangeIntegerTest.class.getSimpleName())
|
||||
.forks(1)
|
||||
.warmupIterations(3)
|
||||
.threads(128)
|
||||
.syncIterations(false)
|
||||
.output("/tmp/jmh.log")
|
||||
.measurementIterations(5)
|
||||
.build();
|
||||
|
||||
new Runner(opt).run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
* This is moved from SkyWalking 6.1
|
||||
*/
|
||||
public class AtomicRangeIntegerV1 extends Number implements Serializable {
|
||||
|
|
|
|||
|
|
@ -16,14 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.common;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* Created by lkxiaolou
|
||||
* This comes from PR#2874
|
||||
*/
|
||||
public class AtomicRangeIntegerV2 extends Number implements Serializable {
|
||||
|
|
@ -45,7 +43,8 @@ public class AtomicRangeIntegerV2 extends Number implements Serializable {
|
|||
if (next > endValue && this.value.compareAndSet(next, startValue)) {
|
||||
return endValue;
|
||||
}
|
||||
} while (next > endValue);
|
||||
}
|
||||
while (next > endValue);
|
||||
|
||||
return next - 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,20 +16,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
import org.apache.skywalking.apm.commons.datacarrier.SampleData;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.Channels;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.partition.SimpleRollingPartitioner;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.powermock.api.support.membermodification.MemberModifier;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.SampleData;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.buffer.BufferStrategy;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/26.
|
||||
*/
|
||||
public class ConsumeDriverTest {
|
||||
@Test
|
||||
public void testBeginConsumeDriver() throws IllegalAccessException {
|
||||
|
|
@ -37,7 +33,8 @@ public class ConsumeDriverTest {
|
|||
ConsumeDriver<SampleData> pool = new ConsumeDriver<SampleData>("default", channels, new SampleConsumer(), 2, 20);
|
||||
pool.begin(channels);
|
||||
|
||||
ConsumerThread[] threads = (ConsumerThread[])MemberModifier.field(ConsumeDriver.class, "consumerThreads").get(pool);
|
||||
ConsumerThread[] threads = (ConsumerThread[]) MemberModifier.field(ConsumeDriver.class, "consumerThreads")
|
||||
.get(pool);
|
||||
Assert.assertEquals(2, threads.length);
|
||||
Assert.assertTrue(threads[0].isAlive());
|
||||
Assert.assertTrue(threads[1].isAlive());
|
||||
|
|
@ -51,10 +48,11 @@ public class ConsumeDriverTest {
|
|||
|
||||
Thread.sleep(5000);
|
||||
pool.close(channels);
|
||||
ConsumerThread[] threads = (ConsumerThread[])MemberModifier.field(ConsumeDriver.class, "consumerThreads").get(pool);
|
||||
ConsumerThread[] threads = (ConsumerThread[]) MemberModifier.field(ConsumeDriver.class, "consumerThreads")
|
||||
.get(pool);
|
||||
|
||||
Assert.assertEquals(2, threads.length);
|
||||
Assert.assertFalse((Boolean)MemberModifier.field(ConsumerThread.class, "running").get(threads[0]));
|
||||
Assert.assertFalse((Boolean)MemberModifier.field(ConsumerThread.class, "running").get(threads[1]));
|
||||
Assert.assertFalse((Boolean) MemberModifier.field(ConsumerThread.class, "running").get(threads[0]));
|
||||
Assert.assertFalse((Boolean) MemberModifier.field(ConsumerThread.class, "running").get(threads[1]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,12 +21,10 @@ package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
* @author dengming
|
||||
* 2019-04-20
|
||||
*/
|
||||
public class ConsumerPoolFactoryTest {
|
||||
|
||||
@Before
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -29,9 +28,6 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
import org.powermock.api.support.membermodification.MemberModifier;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/26.
|
||||
*/
|
||||
public class ConsumerTest {
|
||||
public static LinkedBlockingQueue<SampleData> BUFFER = new LinkedBlockingQueue<SampleData>();
|
||||
|
||||
|
|
@ -48,12 +44,12 @@ public class ConsumerTest {
|
|||
|
||||
consumer.i = 100;
|
||||
carrier.consume(SampleConsumer.class, 1);
|
||||
Assert.assertEquals(1, ((SampleConsumer)getConsumer(carrier)).i);
|
||||
Assert.assertEquals(1, ((SampleConsumer) getConsumer(carrier)).i);
|
||||
|
||||
SampleConsumer2 consumer2 = new SampleConsumer2();
|
||||
consumer2.i = 100;
|
||||
carrier.consume(consumer2, 1);
|
||||
Assert.assertEquals(100, ((SampleConsumer2)getConsumer(carrier)).i);
|
||||
Assert.assertEquals(100, ((SampleConsumer2) getConsumer(carrier)).i);
|
||||
|
||||
carrier.shutdownConsumers();
|
||||
}
|
||||
|
|
@ -129,9 +125,10 @@ public class ConsumerTest {
|
|||
}
|
||||
|
||||
private IConsumer getConsumer(DataCarrier<SampleData> carrier) throws IllegalAccessException {
|
||||
ConsumeDriver pool = (ConsumeDriver)MemberModifier.field(DataCarrier.class, "driver").get(carrier);
|
||||
ConsumerThread[] threads = (ConsumerThread[])MemberModifier.field(ConsumeDriver.class, "consumerThreads").get(pool);
|
||||
ConsumeDriver pool = (ConsumeDriver) MemberModifier.field(DataCarrier.class, "driver").get(carrier);
|
||||
ConsumerThread[] threads = (ConsumerThread[]) MemberModifier.field(ConsumeDriver.class, "consumerThreads")
|
||||
.get(pool);
|
||||
|
||||
return (IConsumer)MemberModifier.field(ConsumerThread.class, "consumer").get(threads[0]);
|
||||
return (IConsumer) MemberModifier.field(ConsumerThread.class, "consumer").get(threads[0]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.consumer;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.skywalking.apm.commons.datacarrier.SampleData;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/26.
|
||||
*/
|
||||
public class SampleConsumer implements IConsumer<SampleData> {
|
||||
public int i = 1;
|
||||
|
||||
|
|
|
|||
|
|
@ -16,20 +16,16 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.partition;
|
||||
|
||||
import org.apache.skywalking.apm.commons.datacarrier.SampleData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public class ProducerThreadPartitionerTest {
|
||||
@Test
|
||||
public void testPartition() {
|
||||
int partitionNum = (int)Thread.currentThread().getId() % 10;
|
||||
int partitionNum = (int) Thread.currentThread().getId() % 10;
|
||||
ProducerThreadPartitioner<SampleData> partitioner = new ProducerThreadPartitioner<SampleData>();
|
||||
Assert.assertEquals(partitioner.partition(10, new SampleData()), partitionNum);
|
||||
Assert.assertEquals(partitioner.partition(10, new SampleData()), partitionNum);
|
||||
|
|
|
|||
|
|
@ -16,16 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.commons.datacarrier.partition;
|
||||
|
||||
import org.apache.skywalking.apm.commons.datacarrier.SampleData;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2016/10/25.
|
||||
*/
|
||||
public class SimpleRollingPartitionerTest {
|
||||
@Test
|
||||
public void testPartition() {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,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">
|
||||
<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.apache.skywalking</groupId>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
|
@ -34,7 +33,6 @@ import java.util.logging.Logger;
|
|||
/**
|
||||
* Init a class's static fields by a {@link Properties}, including static fields and static inner classes.
|
||||
* <p>
|
||||
* Created by wusheng on 2017/1/9.
|
||||
*/
|
||||
public class ConfigInitializer {
|
||||
private static final Logger logger = Logger.getLogger(ConfigInitializer.class.getName());
|
||||
|
|
@ -56,7 +54,7 @@ public class ConfigInitializer {
|
|||
* Such as plugin.opgroup.resttemplate.rule[abc]=/url/path
|
||||
*/
|
||||
// Deduct two generic types of the map
|
||||
ParameterizedType genericType = (ParameterizedType)field.getGenericType();
|
||||
ParameterizedType genericType = (ParameterizedType) field.getGenericType();
|
||||
Type[] argumentTypes = genericType.getActualTypeArguments();
|
||||
|
||||
Type keyType = null;
|
||||
|
|
@ -66,7 +64,7 @@ public class ConfigInitializer {
|
|||
keyType = argumentTypes[0];
|
||||
valueType = argumentTypes[1];
|
||||
}
|
||||
Map map = (Map)field.get(null);
|
||||
Map map = (Map) field.get(null);
|
||||
// Set the map from config key and properties
|
||||
setForMapType(configKey, map, properties, keyType, valueType);
|
||||
} else {
|
||||
|
|
@ -91,7 +89,8 @@ public class ConfigInitializer {
|
|||
|
||||
/**
|
||||
* Convert string value to typical type.
|
||||
* @param type type to convert
|
||||
*
|
||||
* @param type type to convert
|
||||
* @param value string value to be converted
|
||||
* @return converted value or null
|
||||
*/
|
||||
|
|
@ -116,9 +115,9 @@ public class ConfigInitializer {
|
|||
} else if (List.class.equals(type)) {
|
||||
result = convert2List(value);
|
||||
} else if (type instanceof Class) {
|
||||
Class<?> clazz = (Class<?>)type;
|
||||
Class<?> clazz = (Class<?>) type;
|
||||
if (clazz.isEnum()) {
|
||||
result = Enum.valueOf((Class<Enum>)type, value.toUpperCase());
|
||||
result = Enum.valueOf((Class<Enum>) type, value.toUpperCase());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
@ -126,15 +125,15 @@ public class ConfigInitializer {
|
|||
|
||||
/**
|
||||
* Set map items.
|
||||
* @param configKey config key must not be null
|
||||
* @param map map to set must not be null
|
||||
*
|
||||
* @param configKey config key must not be null
|
||||
* @param map map to set must not be null
|
||||
* @param properties properties must not be null
|
||||
* @param keyType key type of the map
|
||||
* @param valueType value type of the map
|
||||
* @param keyType key type of the map
|
||||
* @param valueType value type of the map
|
||||
*/
|
||||
private static void setForMapType(String configKey, Map<Object, Object> map, Properties properties,
|
||||
final Type keyType,
|
||||
final Type valueType) {
|
||||
final Type keyType, final Type valueType) {
|
||||
|
||||
Objects.requireNonNull(configKey);
|
||||
Objects.requireNonNull(map);
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.util;
|
||||
|
||||
import java.lang.management.ManagementFactory;
|
||||
|
|
|
|||
|
|
@ -18,18 +18,21 @@
|
|||
|
||||
package org.apache.skywalking.apm.util;
|
||||
|
||||
/**
|
||||
* @author jian.tan
|
||||
*/
|
||||
public class PlaceholderConfigurerSupport {
|
||||
|
||||
/** Default placeholder prefix: {@value} */
|
||||
/**
|
||||
* Default placeholder prefix: {@value}
|
||||
*/
|
||||
public static final String DEFAULT_PLACEHOLDER_PREFIX = "${";
|
||||
|
||||
/** Default placeholder suffix: {@value} */
|
||||
/**
|
||||
* Default placeholder suffix: {@value}
|
||||
*/
|
||||
public static final String DEFAULT_PLACEHOLDER_SUFFIX = "}";
|
||||
|
||||
/** Default value separator: {@value} */
|
||||
/**
|
||||
* Default value separator: {@value}
|
||||
*/
|
||||
public static final String DEFAULT_VALUE_SEPARATOR = ":";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,9 +31,7 @@ import java.util.Set;
|
|||
*/
|
||||
public enum PropertyPlaceholderHelper {
|
||||
|
||||
INSTANCE(PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX,
|
||||
PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX,
|
||||
PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR, true);
|
||||
INSTANCE(PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_PREFIX, PlaceholderConfigurerSupport.DEFAULT_PLACEHOLDER_SUFFIX, PlaceholderConfigurerSupport.DEFAULT_VALUE_SEPARATOR, true);
|
||||
|
||||
private final String placeholderPrefix;
|
||||
|
||||
|
|
@ -48,15 +46,15 @@ public enum PropertyPlaceholderHelper {
|
|||
/**
|
||||
* Creates a new {@code PropertyPlaceholderHelper} that uses the supplied prefix and suffix.
|
||||
*
|
||||
* @param placeholderPrefix the prefix that denotes the start of a placeholder
|
||||
* @param placeholderSuffix the suffix that denotes the end of a placeholder
|
||||
* @param valueSeparator the separating character between the placeholder variable and the associated default value,
|
||||
* if any
|
||||
* @param placeholderPrefix the prefix that denotes the start of a placeholder
|
||||
* @param placeholderSuffix the suffix that denotes the end of a placeholder
|
||||
* @param valueSeparator the separating character between the placeholder variable and the
|
||||
* associated default value, if any
|
||||
* @param ignoreUnresolvablePlaceholders indicates whether unresolvable placeholders should be ignored ({@code
|
||||
* true}) or cause an exception ({@code false})
|
||||
* true}) or cause an exception ({@code false})
|
||||
*/
|
||||
PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix,
|
||||
String valueSeparator, boolean ignoreUnresolvablePlaceholders) {
|
||||
PropertyPlaceholderHelper(String placeholderPrefix, String placeholderSuffix, String valueSeparator,
|
||||
boolean ignoreUnresolvablePlaceholders) {
|
||||
if (StringUtil.isEmpty(placeholderPrefix) || StringUtil.isEmpty(placeholderSuffix)) {
|
||||
throw new UnsupportedOperationException("'placeholderPrefix or placeholderSuffix' must not be null");
|
||||
}
|
||||
|
|
@ -83,7 +81,7 @@ public enum PropertyPlaceholderHelper {
|
|||
* Replaces all placeholders of format {@code ${name}} with the corresponding property from the supplied {@link
|
||||
* Properties}.
|
||||
*
|
||||
* @param value the value containing the placeholders to be replaced
|
||||
* @param value the value containing the placeholders to be replaced
|
||||
* @param properties the {@code Properties} to use for replacement
|
||||
* @return the supplied value with placeholders replaced inline
|
||||
*/
|
||||
|
|
@ -111,7 +109,7 @@ public enum PropertyPlaceholderHelper {
|
|||
* Replaces all placeholders of format {@code ${name}} with the value returned from the supplied {@link
|
||||
* PlaceholderResolver}.
|
||||
*
|
||||
* @param value the value containing the placeholders to be replaced
|
||||
* @param value the value containing the placeholders to be replaced
|
||||
* @param placeholderResolver the {@code PlaceholderResolver} to use for replacement
|
||||
* @return the supplied value with placeholders replaced inline
|
||||
*/
|
||||
|
|
@ -131,8 +129,7 @@ public enum PropertyPlaceholderHelper {
|
|||
String placeholder = result.substring(startIndex + this.placeholderPrefix.length(), endIndex);
|
||||
String originalPlaceholder = placeholder;
|
||||
if (!visitedPlaceholders.add(originalPlaceholder)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Circular placeholder reference '" + originalPlaceholder + "' in property definitions");
|
||||
throw new IllegalArgumentException("Circular placeholder reference '" + originalPlaceholder + "' in property definitions");
|
||||
}
|
||||
// Recursive invocation, parsing placeholders contained in the placeholder key.
|
||||
placeholder = parseStringValue(placeholder, placeholderResolver, visitedPlaceholders);
|
||||
|
|
@ -159,8 +156,7 @@ public enum PropertyPlaceholderHelper {
|
|||
// Proceed with unprocessed value.
|
||||
startIndex = result.indexOf(this.placeholderPrefix, endIndex + this.placeholderSuffix.length());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Could not resolve placeholder '" +
|
||||
placeholder + "'" + " in value \"" + value + "\"");
|
||||
throw new IllegalArgumentException("Could not resolve placeholder '" + placeholder + "'" + " in value \"" + value + "\"");
|
||||
}
|
||||
visitedPlaceholders.remove(originalPlaceholder);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -18,9 +18,6 @@
|
|||
|
||||
package org.apache.skywalking.apm.util;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class RunnableWithExceptionProtection implements Runnable {
|
||||
private Runnable run;
|
||||
private CallbackWhenException callback;
|
||||
|
|
|
|||
|
|
@ -18,26 +18,29 @@
|
|||
|
||||
package org.apache.skywalking.apm.util;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
/**
|
||||
* Group patterns use {@link java.util.regex.Pattern} as core, could group the input strings to matched group or return
|
||||
* original string.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
@ToString
|
||||
public class StringFormatGroup {
|
||||
private final List<PatternRule> rules;
|
||||
|
||||
public StringFormatGroup() {
|
||||
rules = new ArrayList<PatternRule>();
|
||||
rules = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new match rule. The rule will follow the order of being added.
|
||||
*
|
||||
* @param name will be used when ruleRegex matched.
|
||||
* @param name will be used when ruleRegex matched.
|
||||
* @param ruleRegex to match target string.
|
||||
*/
|
||||
public void addRule(String name, String ruleRegex) {
|
||||
|
|
@ -65,52 +68,22 @@ public class StringFormatGroup {
|
|||
return new FormatResult(false, string);
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "StringFormatGroup{" +
|
||||
"rules=" + rules +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public static class FormatResult {
|
||||
private boolean match;
|
||||
private String name;
|
||||
|
||||
public FormatResult(boolean match, String name) {
|
||||
this.match = match;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isMatch() {
|
||||
return match;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
private final boolean match;
|
||||
private final String name;
|
||||
}
|
||||
|
||||
@Getter
|
||||
@ToString
|
||||
private static class PatternRule {
|
||||
private String name;
|
||||
private Pattern pattern;
|
||||
private final String name;
|
||||
private final Pattern pattern;
|
||||
|
||||
private PatternRule(String name, String ruleRegex) {
|
||||
this.name = name;
|
||||
pattern = Pattern.compile(ruleRegex);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Pattern getPattern() {
|
||||
return pattern;
|
||||
}
|
||||
|
||||
@Override public String toString() {
|
||||
return "PatternRule{" +
|
||||
"name='" + name + '\'' +
|
||||
", pattern=" + pattern +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
|
|
@ -26,9 +25,6 @@ import org.junit.Test;
|
|||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/27.
|
||||
*/
|
||||
public class ConfigInitializerTest {
|
||||
@Test
|
||||
public void testInitialize() throws IllegalAccessException {
|
||||
|
|
@ -47,7 +43,7 @@ public class ConfigInitializerTest {
|
|||
Assert.assertEquals(1000, TestPropertiesObject.Level1Object.Level2Object.INT_ATTR);
|
||||
Assert.assertEquals(1000L, TestPropertiesObject.Level1Object.Level2Object.LONG_ATTR);
|
||||
Assert.assertEquals(true, TestPropertiesObject.Level1Object.Level2Object.BOOLEAN_ATTR);
|
||||
Assert.assertArrayEquals(new String[]{}, TestPropertiesObject.Level1Object.LIST_EMPTY_ATTR.toArray());
|
||||
Assert.assertArrayEquals(new String[] {}, TestPropertiesObject.Level1Object.LIST_EMPTY_ATTR.toArray());
|
||||
Assert.assertEquals(TestColorEnum.RED, TestPropertiesObject.Level1Object.Level2Object.ENUM_ATTR);
|
||||
//make sure that when descs is empty,toString() work right;
|
||||
Assert.assertEquals(new ConfigDesc().toString(), "");
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ package org.apache.skywalking.apm.util;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lican
|
||||
*/
|
||||
public class MachineInfoTest {
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -21,9 +21,6 @@ package org.apache.skywalking.apm.util;
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author lican
|
||||
*/
|
||||
public class RunnableWithExceptionProtectionTest {
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -19,10 +19,16 @@
|
|||
package org.apache.skywalking.apm.util;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import org.junit.*;
|
||||
import org.openjdk.jmh.annotations.*;
|
||||
import org.openjdk.jmh.runner.*;
|
||||
import org.openjdk.jmh.runner.options.*;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.annotations.BenchmarkMode;
|
||||
import org.openjdk.jmh.annotations.Mode;
|
||||
import org.openjdk.jmh.annotations.OutputTimeUnit;
|
||||
import org.openjdk.jmh.runner.Runner;
|
||||
import org.openjdk.jmh.runner.RunnerException;
|
||||
import org.openjdk.jmh.runner.options.Options;
|
||||
import org.openjdk.jmh.runner.options.OptionsBuilder;
|
||||
|
||||
public class StringFormatGroupTest {
|
||||
@Benchmark
|
||||
|
|
@ -49,20 +55,16 @@ public class StringFormatGroupTest {
|
|||
}
|
||||
|
||||
/**
|
||||
* The report below shows this pattern match performance is much about rule numbers.
|
||||
* This is a single thread test.
|
||||
*
|
||||
* @throws RunnerException
|
||||
* The report below shows this pattern match performance is much about rule numbers. This is a single thread test.
|
||||
*/
|
||||
@BenchmarkMode(Mode.AverageTime)
|
||||
@OutputTimeUnit(TimeUnit.MICROSECONDS)
|
||||
public void performanceBenchmark() throws RunnerException {
|
||||
Options opt = new OptionsBuilder()
|
||||
.include(StringFormatGroupTest.class.getSimpleName())
|
||||
.forks(1)
|
||||
.warmupIterations(0)
|
||||
.measurementIterations(5)
|
||||
.build();
|
||||
Options opt = new OptionsBuilder().include(StringFormatGroupTest.class.getSimpleName())
|
||||
.forks(1)
|
||||
.warmupIterations(0)
|
||||
.measurementIterations(5)
|
||||
.build();
|
||||
|
||||
new Runner(opt).run();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,15 +16,11 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* Created by wusheng on 2017/2/27.
|
||||
*/
|
||||
public class StringUtilTest {
|
||||
@Test
|
||||
public void testIsEmpty() {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,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">
|
||||
<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</artifactId>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,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">
|
||||
<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</artifactId>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
|
|
@ -107,7 +108,9 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<copy file="${project.build.directory}/apache-skywalking-apm-bin-es7.tar.gz" tofile="${project.basedir}/../dist/apache-skywalking-apm-bin-es7.tar.gz" overwrite="true" />
|
||||
<copy file="${project.build.directory}/apache-skywalking-apm-bin-es7.tar.gz"
|
||||
tofile="${project.basedir}/../dist/apache-skywalking-apm-bin-es7.tar.gz"
|
||||
overwrite="true"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,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">
|
||||
<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-protocol</artifactId>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
|
|
@ -80,10 +81,12 @@
|
|||
protobuf-java directly, you will be transitively depending on the
|
||||
protobuf-java version that grpc depends on.
|
||||
-->
|
||||
<protocArtifact>com.google.protobuf:protoc:${com.google.protobuf.protoc.version}:exe:${os.detected.classifier}
|
||||
<protocArtifact>
|
||||
com.google.protobuf:protoc:${com.google.protobuf.protoc.version}:exe:${os.detected.classifier}
|
||||
</protocArtifact>
|
||||
<pluginId>grpc-java</pluginId>
|
||||
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${protoc-gen-grpc-java.plugin.version}:exe:${os.detected.classifier}
|
||||
<pluginArtifact>
|
||||
io.grpc:protoc-gen-grpc-java:${protoc-gen-grpc-java.plugin.version}:exe:${os.detected.classifier}
|
||||
</pluginArtifact>
|
||||
</configuration>
|
||||
<executions>
|
||||
|
|
|
|||
|
|
@ -20,8 +20,6 @@ package org.apache.skywalking.apm.network;
|
|||
|
||||
/**
|
||||
* The version of the protocol between agent and backend.
|
||||
*
|
||||
* @author kezhenxu94
|
||||
*/
|
||||
public enum ProtocolVersion {
|
||||
V2(2);
|
||||
|
|
|
|||
|
|
@ -15,12 +15,11 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.network.constants;
|
||||
|
||||
/**
|
||||
* profile task limit constants
|
||||
*
|
||||
* @author MrPro
|
||||
*/
|
||||
public class ProfileConstants {
|
||||
|
||||
|
|
|
|||
|
|
@ -16,16 +16,12 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.network.trace.component;
|
||||
|
||||
/**
|
||||
* The <code>Component</code> represents component library,
|
||||
* which has been supported by skywalking sniffer.
|
||||
*
|
||||
* The <code>Component</code> represents component library, which has been supported by skywalking sniffer.
|
||||
* <p>
|
||||
* The supported list is in {@link ComponentsDefine}.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public interface Component {
|
||||
int getId();
|
||||
|
|
|
|||
|
|
@ -16,13 +16,10 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.network.trace.component;
|
||||
|
||||
/**
|
||||
* The supported list of skywalking java sniffer.
|
||||
*
|
||||
* @author wusheng
|
||||
*/
|
||||
public class ComponentsDefine {
|
||||
|
||||
|
|
@ -64,11 +61,11 @@ public class ComponentsDefine {
|
|||
|
||||
public static final OfficialComponent SERVICECOMB = new OfficialComponent(28, "ServiceComb");
|
||||
|
||||
public static final OfficialComponent HYSTRIX = new OfficialComponent(29, "Hystrix");
|
||||
public static final OfficialComponent HYSTRIX = new OfficialComponent(29, "Hystrix");
|
||||
|
||||
public static final OfficialComponent JEDIS = new OfficialComponent(30, "Jedis");
|
||||
public static final OfficialComponent JEDIS = new OfficialComponent(30, "Jedis");
|
||||
|
||||
public static final OfficialComponent H2_JDBC_DRIVER = new OfficialComponent(32, "jdbc-jdbc-driver");
|
||||
public static final OfficialComponent H2_JDBC_DRIVER = new OfficialComponent(32, "jdbc-jdbc-driver");
|
||||
|
||||
public static final OfficialComponent MYSQL_JDBC_DRIVER = new OfficialComponent(33, "mysql-connector-java");
|
||||
|
||||
|
|
@ -90,39 +87,39 @@ public class ComponentsDefine {
|
|||
|
||||
public static final OfficialComponent MONGO_DRIVER = new OfficialComponent(42, "mongodb-driver");
|
||||
|
||||
public static final OfficialComponent SOFARPC = new OfficialComponent(43, "SOFARPC");
|
||||
public static final OfficialComponent SOFARPC = new OfficialComponent(43, "SOFARPC");
|
||||
|
||||
public static final OfficialComponent ACTIVEMQ_PRODUCER = new OfficialComponent(45,"activemq-producer");
|
||||
public static final OfficialComponent ACTIVEMQ_PRODUCER = new OfficialComponent(45, "activemq-producer");
|
||||
|
||||
public static final OfficialComponent ACTIVEMQ_CONSUMER = new OfficialComponent(46,"activemq-consumer");
|
||||
public static final OfficialComponent ACTIVEMQ_CONSUMER = new OfficialComponent(46, "activemq-consumer");
|
||||
|
||||
public static final OfficialComponent TRANSPORT_CLIENT = new OfficialComponent(48, "transport-client");
|
||||
public static final OfficialComponent TRANSPORT_CLIENT = new OfficialComponent(48, "transport-client");
|
||||
|
||||
public static final OfficialComponent UNDERTOW = new OfficialComponent(49, "Undertow");
|
||||
public static final OfficialComponent UNDERTOW = new OfficialComponent(49, "Undertow");
|
||||
|
||||
public static final OfficialComponent RABBITMQ_PRODUCER = new OfficialComponent(52,"rabbitmq-producer");
|
||||
public static final OfficialComponent RABBITMQ_PRODUCER = new OfficialComponent(52, "rabbitmq-producer");
|
||||
|
||||
public static final OfficialComponent RABBITMQ_CONSUMER = new OfficialComponent(53,"rabbitmq-consumer");
|
||||
public static final OfficialComponent RABBITMQ_CONSUMER = new OfficialComponent(53, "rabbitmq-consumer");
|
||||
|
||||
public static final OfficialComponent CANAL = new OfficialComponent(54,"Canal");
|
||||
|
||||
public static final OfficialComponent GSON = new OfficialComponent(55,"Gson");
|
||||
|
||||
public static final OfficialComponent REDISSON = new OfficialComponent(56, "Redisson");
|
||||
public static final OfficialComponent CANAL = new OfficialComponent(54, "Canal");
|
||||
|
||||
public static final OfficialComponent LETTUCE = new OfficialComponent(57, "Lettuce");
|
||||
public static final OfficialComponent GSON = new OfficialComponent(55, "Gson");
|
||||
|
||||
public static final OfficialComponent ZOOKEEPER = new OfficialComponent(58, "Zookeeper");
|
||||
public static final OfficialComponent REDISSON = new OfficialComponent(56, "Redisson");
|
||||
|
||||
public static final OfficialComponent VERTX = new OfficialComponent(59, "Vert.x");
|
||||
public static final OfficialComponent LETTUCE = new OfficialComponent(57, "Lettuce");
|
||||
|
||||
public static final OfficialComponent ZOOKEEPER = new OfficialComponent(58, "Zookeeper");
|
||||
|
||||
public static final OfficialComponent VERTX = new OfficialComponent(59, "Vert.x");
|
||||
|
||||
public static final OfficialComponent SHARDING_SPHERE = new OfficialComponent(60, "ShardingSphere");
|
||||
|
||||
public static final OfficialComponent SPRING_CLOUD_GATEWAY = new OfficialComponent(61, "spring-cloud-gateway");
|
||||
public static final OfficialComponent SPRING_CLOUD_GATEWAY = new OfficialComponent(61, "spring-cloud-gateway");
|
||||
|
||||
public static final OfficialComponent RESTEASY = new OfficialComponent(62, "RESTEasy");
|
||||
public static final OfficialComponent RESTEASY = new OfficialComponent(62, "RESTEasy");
|
||||
|
||||
public static final OfficialComponent SOLRJ = new OfficialComponent(63, "solrj");
|
||||
public static final OfficialComponent SOLRJ = new OfficialComponent(63, "solrj");
|
||||
|
||||
public static final OfficialComponent SPRING_ASYNC = new OfficialComponent(65, "SpringAsync");
|
||||
|
||||
|
|
@ -133,7 +130,7 @@ public class ComponentsDefine {
|
|||
public static final OfficialComponent PLAY = new OfficialComponent(68, "Play");
|
||||
|
||||
public static final OfficialComponent CASSANDRA_JAVA_DRIVER = new OfficialComponent(69, "cassandra-java-driver");
|
||||
|
||||
|
||||
public static final OfficialComponent LIGHT_4J = new OfficialComponent(71, "Light4J");
|
||||
|
||||
public static final OfficialComponent PULSAR_PRODUCER = new OfficialComponent(73, "pulsar-producer");
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.network.trace.component;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class OfficialComponent implements Component {
|
||||
private int id;
|
||||
private String name;
|
||||
|
|
|
|||
|
|
@ -18,11 +18,9 @@
|
|||
|
||||
package org.apache.skywalking.apm.network.trace.component.command;
|
||||
|
||||
import org.apache.skywalking.apm.network.common.*;
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
import org.apache.skywalking.apm.network.common.KeyStringValuePair;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public abstract class BaseCommand {
|
||||
|
||||
private final String command;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ package org.apache.skywalking.apm.network.trace.component.command;
|
|||
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
|
||||
/**
|
||||
* @author kezhenxu94
|
||||
*/
|
||||
public class CommandDeserializer {
|
||||
|
||||
public static BaseCommand deserialize(final Command command) {
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ package org.apache.skywalking.apm.network.trace.component.command;
|
|||
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface Deserializable<T extends BaseCommand> {
|
||||
T deserialize(Command command);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,12 @@
|
|||
|
||||
package org.apache.skywalking.apm.network.trace.component.command;
|
||||
|
||||
import org.apache.skywalking.apm.network.common.*;
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
import org.apache.skywalking.apm.network.common.KeyStringValuePair;
|
||||
|
||||
/**
|
||||
* Remove the specified endpoint names from endpoint metadata cache, and re-register it.
|
||||
* If not specified, clear whole endpoint metadata cache.
|
||||
*
|
||||
* @author peng-yongsheng
|
||||
* Remove the specified endpoint names from endpoint metadata cache, and re-register it. If not specified, clear whole
|
||||
* endpoint metadata cache.
|
||||
*/
|
||||
public class EndpointResetCommand extends BaseCommand implements Serializable {
|
||||
|
||||
|
|
@ -32,7 +31,8 @@ public class EndpointResetCommand extends BaseCommand implements Serializable {
|
|||
super("EndpointMetadataReset", serialNumber);
|
||||
}
|
||||
|
||||
@Override public Command.Builder serialize() {
|
||||
@Override
|
||||
public Command.Builder serialize() {
|
||||
return commandBuilder();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -22,8 +22,6 @@ import org.apache.skywalking.apm.network.common.Command;
|
|||
|
||||
/**
|
||||
* Clear the service instance metadata cache, and re-register it.
|
||||
*
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class InstanceResetCommand extends BaseCommand implements Serializable {
|
||||
|
||||
|
|
@ -31,7 +29,8 @@ public class InstanceResetCommand extends BaseCommand implements Serializable {
|
|||
super("InstanceMetadataReset", serialNumber);
|
||||
}
|
||||
|
||||
@Override public Command.Builder serialize() {
|
||||
@Override
|
||||
public Command.Builder serialize() {
|
||||
return commandBuilder();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,13 +18,12 @@
|
|||
|
||||
package org.apache.skywalking.apm.network.trace.component.command;
|
||||
|
||||
import org.apache.skywalking.apm.network.common.*;
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
import org.apache.skywalking.apm.network.common.KeyStringValuePair;
|
||||
|
||||
/**
|
||||
* Remove the specified network addresses from network address metadata cache, and re-register it.
|
||||
* If not specified, clear whole network address metadata cache.
|
||||
*
|
||||
* @author peng-yongsheng
|
||||
* Remove the specified network addresses from network address metadata cache, and re-register it. If not specified,
|
||||
* clear whole network address metadata cache.
|
||||
*/
|
||||
public class NetworkResetCommand extends BaseCommand implements Serializable {
|
||||
|
||||
|
|
@ -32,7 +31,8 @@ public class NetworkResetCommand extends BaseCommand implements Serializable {
|
|||
super("NetworkAddressMetadataReset", serialNumber);
|
||||
}
|
||||
|
||||
@Override public Command.Builder serialize() {
|
||||
@Override
|
||||
public Command.Builder serialize() {
|
||||
return commandBuilder();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -23,9 +23,6 @@ import org.apache.skywalking.apm.network.common.KeyStringValuePair;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author MrPro
|
||||
*/
|
||||
public class ProfileTaskCommand extends BaseCommand implements Serializable, Deserializable<ProfileTaskCommand> {
|
||||
public static final Deserializable<ProfileTaskCommand> DESERIALIZER = new ProfileTaskCommand("", "", "", 0, 0, 0, 0, 0, 0);
|
||||
public static final String NAME = "ProfileTaskQuery";
|
||||
|
|
@ -40,7 +37,8 @@ public class ProfileTaskCommand extends BaseCommand implements Serializable, Des
|
|||
private long startTime;
|
||||
private long createTime;
|
||||
|
||||
public ProfileTaskCommand(String serialNumber, String taskId, String endpointName, int duration, int minDurationThreshold, int dumpPeriod, int maxSamplingCount, long startTime, long createTime) {
|
||||
public ProfileTaskCommand(String serialNumber, String taskId, String endpointName, int duration,
|
||||
int minDurationThreshold, int dumpPeriod, int maxSamplingCount, long startTime, long createTime) {
|
||||
super(NAME, serialNumber);
|
||||
this.taskId = taskId;
|
||||
this.endpointName = endpointName;
|
||||
|
|
@ -94,13 +92,17 @@ public class ProfileTaskCommand extends BaseCommand implements Serializable, Des
|
|||
public Command.Builder serialize() {
|
||||
final Command.Builder builder = commandBuilder();
|
||||
builder.addArgs(KeyStringValuePair.newBuilder().setKey("TaskId").setValue(taskId))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("EndpointName").setValue(endpointName))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("Duration").setValue(String.valueOf(duration)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("MinDurationThreshold").setValue(String.valueOf(minDurationThreshold)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("DumpPeriod").setValue(String.valueOf(dumpPeriod)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("MaxSamplingCount").setValue(String.valueOf(maxSamplingCount)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("StartTime").setValue(String.valueOf(startTime)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("CreateTime").setValue(String.valueOf(createTime)));
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("EndpointName").setValue(endpointName))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("Duration").setValue(String.valueOf(duration)))
|
||||
.addArgs(KeyStringValuePair.newBuilder()
|
||||
.setKey("MinDurationThreshold")
|
||||
.setValue(String.valueOf(minDurationThreshold)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("DumpPeriod").setValue(String.valueOf(dumpPeriod)))
|
||||
.addArgs(KeyStringValuePair.newBuilder()
|
||||
.setKey("MaxSamplingCount")
|
||||
.setValue(String.valueOf(maxSamplingCount)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("StartTime").setValue(String.valueOf(startTime)))
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("CreateTime").setValue(String.valueOf(createTime)));
|
||||
return builder;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,6 @@ package org.apache.skywalking.apm.network.trace.component.command;
|
|||
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
|
||||
/**
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public interface Serializable {
|
||||
Command.Builder serialize();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,6 @@ import java.util.List;
|
|||
|
||||
/**
|
||||
* Clear the service metadata cache and other metadata caches belong to it, and re-register them.
|
||||
*
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class ServiceResetCommand extends BaseCommand implements Serializable, Deserializable<ServiceResetCommand> {
|
||||
public static final Deserializable<ServiceResetCommand> DESERIALIZER = new ServiceResetCommand("");
|
||||
|
|
|
|||
|
|
@ -18,12 +18,11 @@
|
|||
|
||||
package org.apache.skywalking.apm.network.trace.component.command;
|
||||
|
||||
import org.apache.skywalking.apm.network.common.*;
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
import org.apache.skywalking.apm.network.common.KeyStringValuePair;
|
||||
|
||||
/**
|
||||
* Trace ignore sync, each configuration downstream is the full amount of data related to the received agent.
|
||||
*
|
||||
* @author peng-yongsheng
|
||||
*/
|
||||
public class TraceIgnoreCommand extends BaseCommand implements Serializable {
|
||||
|
||||
|
|
@ -31,7 +30,8 @@ public class TraceIgnoreCommand extends BaseCommand implements Serializable {
|
|||
super("TraceIgnore", serialNumber);
|
||||
}
|
||||
|
||||
@Override public Command.Builder serialize() {
|
||||
@Override
|
||||
public Command.Builder serialize() {
|
||||
return commandBuilder();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,9 +19,6 @@ package org.apache.skywalking.apm.network.trace.component.command;
|
|||
|
||||
import org.apache.skywalking.apm.network.common.Command;
|
||||
|
||||
/**
|
||||
* @author kezhenxu94
|
||||
*/
|
||||
public class UnsupportedCommandException extends RuntimeException {
|
||||
private final Command command;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,9 +24,6 @@ import org.apache.skywalking.apm.network.trace.component.command.ServiceResetCom
|
|||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* @author jsbxyyx
|
||||
*/
|
||||
public class ServiceResetCommandTest {
|
||||
|
||||
@Test
|
||||
|
|
@ -43,8 +40,8 @@ public class ServiceResetCommandTest {
|
|||
ServiceResetCommand command = new ServiceResetCommand("aa");
|
||||
|
||||
Command command1 = Command.newBuilder()
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("aa").setValue("aa").build())
|
||||
.build();
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("aa").setValue("aa").build())
|
||||
.build();
|
||||
boolean exception = false;
|
||||
try {
|
||||
command.deserialize(command1);
|
||||
|
|
@ -59,8 +56,11 @@ public class ServiceResetCommandTest {
|
|||
ServiceResetCommand command = new ServiceResetCommand("aa");
|
||||
|
||||
Command command2 = Command.newBuilder()
|
||||
.addArgs(KeyStringValuePair.newBuilder().setKey("SerialNumber").setValue("aa").build())
|
||||
.build();
|
||||
.addArgs(KeyStringValuePair.newBuilder()
|
||||
.setKey("SerialNumber")
|
||||
.setValue("aa")
|
||||
.build())
|
||||
.build();
|
||||
ServiceResetCommand deserialize2 = command.deserialize(command2);
|
||||
Assert.assertEquals("aa", deserialize2.getSerialNumber());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.network.trace.proto;
|
||||
|
||||
import io.grpc.ManagedChannel;
|
||||
|
|
@ -27,33 +26,32 @@ import io.grpc.internal.DnsNameResolverProvider;
|
|||
import io.grpc.netty.NettyChannelBuilder;
|
||||
import io.grpc.stub.StreamObserver;
|
||||
import org.apache.skywalking.apm.network.common.Commands;
|
||||
import org.apache.skywalking.apm.network.language.agent.UpstreamSegment;
|
||||
import org.apache.skywalking.apm.network.language.agent.v2.TraceSegmentReportServiceGrpc;
|
||||
import org.junit.Assert;
|
||||
import org.apache.skywalking.apm.network.language.agent.UpstreamSegment;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class GRPCNoServerTest {
|
||||
public static void main(String[] args) throws InterruptedException {
|
||||
ManagedChannelBuilder<?> channelBuilder =
|
||||
NettyChannelBuilder.forAddress("127.0.0.1", 8080)
|
||||
.nameResolverFactory(new DnsNameResolverProvider())
|
||||
.maxInboundMessageSize(1024 * 1024 * 50)
|
||||
.usePlaintext();
|
||||
ManagedChannelBuilder<?> channelBuilder = NettyChannelBuilder.forAddress("127.0.0.1", 8080)
|
||||
.nameResolverFactory(new DnsNameResolverProvider())
|
||||
.maxInboundMessageSize(1024 * 1024 * 50)
|
||||
.usePlaintext();
|
||||
ManagedChannel channel = channelBuilder.build();
|
||||
TraceSegmentReportServiceGrpc.TraceSegmentReportServiceStub serviceStub = TraceSegmentReportServiceGrpc.newStub(channel);
|
||||
final Status[] status = {null};
|
||||
StreamObserver<UpstreamSegment> streamObserver = serviceStub.collect(new StreamObserver<Commands>() {
|
||||
@Override public void onNext(Commands value) {
|
||||
@Override
|
||||
public void onNext(Commands value) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void onError(Throwable t) {
|
||||
status[0] = ((StatusRuntimeException)t).getStatus();
|
||||
@Override
|
||||
public void onError(Throwable t) {
|
||||
status[0] = ((StatusRuntimeException) t).getStatus();
|
||||
}
|
||||
|
||||
@Override public void onCompleted() {
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,7 +17,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">
|
||||
<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</artifactId>
|
||||
<groupId>org.apache.skywalking</groupId>
|
||||
|
|
|
|||
|
|
@ -16,7 +16,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">
|
||||
<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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
|
|
@ -181,7 +182,8 @@
|
|||
</filter>
|
||||
</filters>
|
||||
<transformers>
|
||||
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
|
||||
<transformer
|
||||
implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
|
||||
</transformers>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
@ -197,7 +199,7 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<delete dir="${project.basedir}/../../packages" />
|
||||
<delete dir="${project.basedir}/../../packages"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
|
|
@ -206,14 +208,22 @@
|
|||
<phase>package</phase>
|
||||
<configuration>
|
||||
<target>
|
||||
<echo message="unjar" />
|
||||
<unzip src="${project.build.directory}/${project.artifactId}-${project.version}.jar" dest="${project.build.directory}/unpacked/" />
|
||||
<echo message="rename service providers in META-INF/services" />
|
||||
<move file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_osx_x86_64.jnilib" tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_osx_x86_64.jnilib" />
|
||||
<move file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_linux_x86_64.so" tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_linux_x86_64.so" />
|
||||
<move file="${project.build.directory}/unpacked/META-INF/native/netty_tcnative_windows_x86_64.dll" tofile="${project.build.directory}/unpacked/META-INF/native/org_apache_skywalking_apm_dependencies_netty_tcnative_windows_x86_64.dll" />
|
||||
<echo message="jar back" />
|
||||
<jar destfile="${project.build.directory}/${project.artifactId}-${project.version}.jar" basedir="${project.build.directory}/unpacked" />
|
||||
<echo message="unjar"/>
|
||||
<unzip src="${project.build.directory}/${project.artifactId}-${project.version}.jar"
|
||||
dest="${project.build.directory}/unpacked/"/>
|
||||
<echo message="rename service providers in META-INF/services"/>
|
||||
<move
|
||||
file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_osx_x86_64.jnilib"
|
||||
tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_osx_x86_64.jnilib"/>
|
||||
<move
|
||||
file="${project.build.directory}/unpacked/META-INF/native/libnetty_tcnative_linux_x86_64.so"
|
||||
tofile="${project.build.directory}/unpacked/META-INF/native/liborg_apache_skywalking_apm_dependencies_netty_tcnative_linux_x86_64.so"/>
|
||||
<move
|
||||
file="${project.build.directory}/unpacked/META-INF/native/netty_tcnative_windows_x86_64.dll"
|
||||
tofile="${project.build.directory}/unpacked/META-INF/native/org_apache_skywalking_apm_dependencies_netty_tcnative_windows_x86_64.dll"/>
|
||||
<echo message="jar back"/>
|
||||
<jar destfile="${project.build.directory}/${project.artifactId}-${project.version}.jar"
|
||||
basedir="${project.build.directory}/unpacked"/>
|
||||
</target>
|
||||
</configuration>
|
||||
<goals>
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@
|
|||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.apm.agent.core.base64;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
|
|
|||
|
|
@ -16,12 +16,8 @@
|
|||
*
|
||||
*/
|
||||
|
||||
|
||||
package org.apache.skywalking.apm.agent.core.boot;
|
||||
|
||||
/**
|
||||
* @author wusheng
|
||||
*/
|
||||
public class AgentPackageNotFoundException extends Exception {
|
||||
public AgentPackageNotFoundException(String message) {
|
||||
super(message);
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue