Support define multiple OAL configuration (#4748)
This commit is contained in:
parent
816878897c
commit
d4f3218dea
|
|
@ -47,6 +47,7 @@ import javassist.bytecode.annotation.Annotation;
|
|||
import javassist.bytecode.annotation.ClassMemberValue;
|
||||
import javassist.bytecode.annotation.IntegerMemberValue;
|
||||
import javassist.bytecode.annotation.StringMemberValue;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
import org.apache.skywalking.oal.rt.output.AllDispatcherContext;
|
||||
|
|
@ -63,30 +64,25 @@ import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
|
|||
import org.apache.skywalking.oap.server.core.analysis.Stream;
|
||||
import org.apache.skywalking.oap.server.core.analysis.StreamAnnotationListener;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALCompileException;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALDefine;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngine;
|
||||
import org.apache.skywalking.oap.server.core.storage.StorageException;
|
||||
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
|
||||
import org.apache.skywalking.oap.server.library.util.ResourceUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* OAL Runtime is the class generation engine, which load the generated classes from OAL scrip definitions. This runtime
|
||||
* is loaded dynamically.
|
||||
*/
|
||||
@Slf4j
|
||||
public class OALRuntime implements OALEngine {
|
||||
private static final Logger logger = LoggerFactory.getLogger(OALRuntime.class);
|
||||
|
||||
private static final String CLASS_FILE_CHARSET = "UTF-8";
|
||||
private static final String METRICS_FUNCTION_PACKAGE = "org.apache.skywalking.oap.server.core.analysis.metrics.";
|
||||
private static final String DYNAMIC_METRICS_CLASS_PACKAGE = "org.apache.skywalking.oal.rt.metrics.";
|
||||
private static final String DYNAMIC_METRICS_BUILDER_CLASS_PACKAGE = "org.apache.skywalking.oal.rt.metrics.builder.";
|
||||
private static final String DYNAMIC_DISPATCHER_CLASS_PACKAGE = "org.apache.skywalking.oal.rt.dispatcher.";
|
||||
private static final String WITH_METADATA_INTERFACE = "org.apache.skywalking.oap.server.core.analysis.metrics.WithMetadata";
|
||||
private static final String STORAGE_BUILDER_INTERFACE = "org.apache.skywalking.oap.server.core.storage.StorageBuilder";
|
||||
private static final String DISPATCHER_INTERFACE = "org.apache.skywalking.oap.server.core.analysis.SourceDispatcher";
|
||||
private static final String SOURCE_PACKAGE = "org.apache.skywalking.oap.server.core.source.";
|
||||
private static final String METRICS_STREAM_PROCESSOR = "org.apache.skywalking.oap.server.core.analysis.worker.MetricsStreamProcessor";
|
||||
private static final String[] METRICS_CLASS_METHODS = {
|
||||
"id",
|
||||
|
|
@ -103,6 +99,8 @@ public class OALRuntime implements OALEngine {
|
|||
"data2Map",
|
||||
"map2Data"
|
||||
};
|
||||
|
||||
private final OALDefine oalDefine;
|
||||
private final ClassPool classPool;
|
||||
private ClassLoader currentClassLoader;
|
||||
private Configuration configuration;
|
||||
|
|
@ -113,7 +111,8 @@ public class OALRuntime implements OALEngine {
|
|||
private final List<Class> dispatcherClasses;
|
||||
private final boolean openEngineDebug;
|
||||
|
||||
public OALRuntime() {
|
||||
public OALRuntime(OALDefine define) {
|
||||
oalDefine = define;
|
||||
classPool = ClassPool.getDefault();
|
||||
configuration = new Configuration(new Version("2.3.28"));
|
||||
configuration.setEncoding(Locale.ENGLISH, CLASS_FILE_CHARSET);
|
||||
|
|
@ -121,7 +120,7 @@ public class OALRuntime implements OALEngine {
|
|||
allDispatcherContext = new AllDispatcherContext();
|
||||
metricsClasses = new ArrayList<>();
|
||||
dispatcherClasses = new ArrayList<>();
|
||||
openEngineDebug = !StringUtil.isEmpty(System.getenv("SW_OAL_ENGINE_DEBUG"));
|
||||
openEngineDebug = StringUtil.isNotEmpty(System.getenv("SW_OAL_ENGINE_DEBUG"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -148,14 +147,14 @@ public class OALRuntime implements OALEngine {
|
|||
}
|
||||
|
||||
try {
|
||||
read = ResourceUtils.read("official_analysis.oal");
|
||||
read = ResourceUtils.read(oalDefine.getConfigFile());
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new ModuleStartException("Can't locate official_analysis.oal", e);
|
||||
throw new ModuleStartException("Can't locate " + oalDefine.getConfigFile(), e);
|
||||
}
|
||||
|
||||
OALScripts oalScripts;
|
||||
try {
|
||||
ScriptParser scriptParser = ScriptParser.createFromFile(read);
|
||||
ScriptParser scriptParser = ScriptParser.createFromFile(read, oalDefine.getSourcePackage());
|
||||
oalScripts = scriptParser.parse();
|
||||
} catch (IOException e) {
|
||||
throw new ModuleStartException("OAL script parse analysis failure.", e);
|
||||
|
|
@ -209,14 +208,14 @@ public class OALRuntime implements OALEngine {
|
|||
try {
|
||||
parentMetricsClass = classPool.get(METRICS_FUNCTION_PACKAGE + metricsStmt.getMetricsClassName());
|
||||
} catch (NotFoundException e) {
|
||||
logger.error("Can't find parent class for " + className + ".", e);
|
||||
log.error("Can't find parent class for " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
CtClass metricsClass = classPool.makeClass(metricsClassName(metricsStmt, true), parentMetricsClass);
|
||||
try {
|
||||
metricsClass.addInterface(classPool.get(WITH_METADATA_INTERFACE));
|
||||
} catch (NotFoundException e) {
|
||||
logger.error("Can't find WithMetadata interface for " + className + ".", e);
|
||||
log.error("Can't find WithMetadata interface for " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -230,7 +229,7 @@ public class OALRuntime implements OALEngine {
|
|||
CtConstructor defaultConstructor = CtNewConstructor.make("public " + className + "() {}", metricsClass);
|
||||
metricsClass.addConstructor(defaultConstructor);
|
||||
} catch (CannotCompileException e) {
|
||||
logger.error("Can't add empty constructor in " + className + ".", e);
|
||||
log.error("Can't add empty constructor in " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -264,7 +263,7 @@ public class OALRuntime implements OALEngine {
|
|||
|
||||
newField.getFieldInfo().addAttribute(annotationsAttribute);
|
||||
} catch (CannotCompileException e) {
|
||||
logger.error(
|
||||
log.error(
|
||||
"Can't add field(including set/get) " + field.getFieldName() + " in " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
|
@ -279,7 +278,7 @@ public class OALRuntime implements OALEngine {
|
|||
configuration.getTemplate("metrics/" + method + ".ftl").process(metricsStmt, methodEntity);
|
||||
metricsClass.addMethod(CtNewMethod.make(methodEntity.toString(), metricsClass));
|
||||
} catch (Exception e) {
|
||||
logger.error("Can't generate method " + method + " for " + className + ".", e);
|
||||
log.error("Can't generate method " + method + " for " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
@ -305,11 +304,11 @@ public class OALRuntime implements OALEngine {
|
|||
try {
|
||||
targetClass = metricsClass.toClass(currentClassLoader, null);
|
||||
} catch (CannotCompileException e) {
|
||||
logger.error("Can't compile/load " + className + ".", e);
|
||||
log.error("Can't compile/load " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
logger.debug("Generate metrics class, " + metricsClass.getName());
|
||||
log.debug("Generate metrics class, " + metricsClass.getName());
|
||||
writeGeneratedFile(metricsClass, metricsClass.getSimpleName(), "metrics");
|
||||
|
||||
return targetClass;
|
||||
|
|
@ -324,7 +323,7 @@ public class OALRuntime implements OALEngine {
|
|||
try {
|
||||
metricsBuilderClass.addInterface(classPool.get(STORAGE_BUILDER_INTERFACE));
|
||||
} catch (NotFoundException e) {
|
||||
logger.error("Can't find StorageBuilder interface for " + className + ".", e);
|
||||
log.error("Can't find StorageBuilder interface for " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +335,7 @@ public class OALRuntime implements OALEngine {
|
|||
"public " + className + "() {}", metricsBuilderClass);
|
||||
metricsBuilderClass.addConstructor(defaultConstructor);
|
||||
} catch (CannotCompileException e) {
|
||||
logger.error("Can't add empty constructor in " + className + ".", e);
|
||||
log.error("Can't add empty constructor in " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -349,7 +348,7 @@ public class OALRuntime implements OALEngine {
|
|||
configuration.getTemplate("metrics-builder/" + method + ".ftl").process(metricsStmt, methodEntity);
|
||||
metricsBuilderClass.addMethod(CtNewMethod.make(methodEntity.toString(), metricsBuilderClass));
|
||||
} catch (Exception e) {
|
||||
logger.error("Can't generate method " + method + " for " + className + ".", e);
|
||||
log.error("Can't generate method " + method + " for " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
@ -357,7 +356,7 @@ public class OALRuntime implements OALEngine {
|
|||
try {
|
||||
metricsBuilderClass.toClass(currentClassLoader, null);
|
||||
} catch (CannotCompileException e) {
|
||||
logger.error("Can't compile/load " + className + ".", e);
|
||||
log.error("Can't compile/load " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -380,7 +379,7 @@ public class OALRuntime implements OALEngine {
|
|||
/**
|
||||
* Set generic signature
|
||||
*/
|
||||
String sourceClassName = SOURCE_PACKAGE + dispatcherContext.getSource();
|
||||
String sourceClassName = oalDefine.getSourcePackage() + dispatcherContext.getSource();
|
||||
SignatureAttribute.ClassSignature dispatcherSignature =
|
||||
new SignatureAttribute.ClassSignature(
|
||||
null, null,
|
||||
|
|
@ -400,7 +399,7 @@ public class OALRuntime implements OALEngine {
|
|||
|
||||
dispatcherClass.setGenericSignature(dispatcherSignature.encode());
|
||||
} catch (NotFoundException e) {
|
||||
logger.error("Can't find Dispatcher interface for " + className + ".", e);
|
||||
log.error("Can't find Dispatcher interface for " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -413,11 +412,11 @@ public class OALRuntime implements OALEngine {
|
|||
configuration.getTemplate("dispatcher/doMetrics.ftl").process(dispatcherContextMetric, methodEntity);
|
||||
dispatcherClass.addMethod(CtNewMethod.make(methodEntity.toString(), dispatcherClass));
|
||||
} catch (Exception e) {
|
||||
logger.error(
|
||||
log.error(
|
||||
"Can't generate method do" + dispatcherContextMetric.getMetricsName() + " for " + className + ".",
|
||||
e
|
||||
);
|
||||
logger.error("Method body as following" + System.lineSeparator() + "{}", methodEntity);
|
||||
log.error("Method body as following" + System.lineSeparator() + "{}", methodEntity);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
|
@ -427,7 +426,7 @@ public class OALRuntime implements OALEngine {
|
|||
configuration.getTemplate("dispatcher/dispatch.ftl").process(dispatcherContext, methodEntity);
|
||||
dispatcherClass.addMethod(CtNewMethod.make(methodEntity.toString(), dispatcherClass));
|
||||
} catch (Exception e) {
|
||||
logger.error("Can't generate method dispatch for " + className + ".", e);
|
||||
log.error("Can't generate method dispatch for " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -435,7 +434,7 @@ public class OALRuntime implements OALEngine {
|
|||
try {
|
||||
targetClass = dispatcherClass.toClass(currentClassLoader, null);
|
||||
} catch (CannotCompileException e) {
|
||||
logger.error("Can't compile/load " + className + ".", e);
|
||||
log.error("Can't compile/load " + className + ".", e);
|
||||
throw new OALCompileException(e.getMessage(), e);
|
||||
}
|
||||
|
||||
|
|
@ -444,27 +443,29 @@ public class OALRuntime implements OALEngine {
|
|||
}
|
||||
|
||||
private String metricsClassName(AnalysisResult metricsStmt, boolean fullName) {
|
||||
return (fullName ? DYNAMIC_METRICS_CLASS_PACKAGE : "") + metricsStmt.getMetricsName() + "Metrics";
|
||||
return (fullName ? oalDefine.getDynamicMetricsClassPackage() : "") + metricsStmt.getMetricsName() + "Metrics";
|
||||
}
|
||||
|
||||
private String metricsBuilderClassName(AnalysisResult metricsStmt, boolean fullName) {
|
||||
return (fullName ? DYNAMIC_METRICS_BUILDER_CLASS_PACKAGE : "") + metricsStmt.getMetricsName() + "MetricsBuilder";
|
||||
return (fullName ? oalDefine.getDynamicMetricsBuilderClassPackage() : "") + metricsStmt.getMetricsName() + "MetricsBuilder";
|
||||
}
|
||||
|
||||
private String dispatcherClassName(String scopeName, boolean fullName) {
|
||||
return (fullName ? DYNAMIC_DISPATCHER_CLASS_PACKAGE : "") + scopeName + "Dispatcher";
|
||||
return (fullName ? oalDefine.getDynamicDispatcherClassPackage() : "") + scopeName + "Dispatcher";
|
||||
}
|
||||
|
||||
private void buildDispatcherContext(AnalysisResult metricsStmt) {
|
||||
String sourceName = metricsStmt.getSourceName();
|
||||
|
||||
DispatcherContext context = allDispatcherContext.getAllContext().get(sourceName);
|
||||
if (context == null) {
|
||||
context = new DispatcherContext();
|
||||
context.setSource(sourceName);
|
||||
context.setPackageName(sourceName.toLowerCase());
|
||||
allDispatcherContext.getAllContext().put(sourceName, context);
|
||||
}
|
||||
DispatcherContext context = allDispatcherContext.getAllContext().computeIfAbsent(sourceName, name -> {
|
||||
DispatcherContext absent = new DispatcherContext();
|
||||
absent.setSourcePackage(oalDefine.getSourcePackage());
|
||||
absent.setSource(name);
|
||||
absent.setPackageName(name.toLowerCase());
|
||||
return absent;
|
||||
});
|
||||
metricsStmt.setMetricsClassPackage(oalDefine.getDynamicMetricsClassPackage());
|
||||
metricsStmt.setSourcePackage(oalDefine.getSourcePackage());
|
||||
context.getMetrics().add(metricsStmt);
|
||||
}
|
||||
|
||||
|
|
@ -476,7 +477,7 @@ public class OALRuntime implements OALEngine {
|
|||
try {
|
||||
FileUtils.deleteDirectory(folder);
|
||||
} catch (IOException e) {
|
||||
logger.warn("Can't delete " + folder.getAbsolutePath() + " temp folder.", e);
|
||||
log.warn("Can't delete " + folder.getAbsolutePath() + " temp folder.", e);
|
||||
}
|
||||
}
|
||||
folder.mkdirs();
|
||||
|
|
@ -502,10 +503,10 @@ public class OALRuntime implements OALEngine {
|
|||
metricsClass.toBytecode(printWriter);
|
||||
printWriter.flush();
|
||||
} catch (IOException e) {
|
||||
logger.warn("Can't create " + className + ".txt, ignore.", e);
|
||||
log.warn("Can't create " + className + ".txt, ignore.", e);
|
||||
return;
|
||||
} catch (CannotCompileException e) {
|
||||
logger.warn("Can't compile " + className + ".class(should not happen), ignore.", e);
|
||||
log.warn("Can't compile " + className + ".class(should not happen), ignore.", e);
|
||||
return;
|
||||
} finally {
|
||||
if (printWriter != null) {
|
||||
|
|
@ -517,6 +518,5 @@ public class OALRuntime implements OALEngine {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ import org.apache.skywalking.oal.rt.parser.AnalysisResult;
|
|||
@Getter
|
||||
@Setter
|
||||
public class DispatcherContext {
|
||||
|
||||
private String sourcePackage;
|
||||
private String source;
|
||||
private String packageName;
|
||||
private List<AnalysisResult> metrics = new ArrayList<>();
|
||||
|
|
|
|||
|
|
@ -20,22 +20,25 @@ package org.apache.skywalking.oal.rt.parser;
|
|||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import org.apache.skywalking.oap.server.core.storage.type.StorageDataComplexObject;
|
||||
|
||||
@Getter(AccessLevel.PUBLIC)
|
||||
@Setter(AccessLevel.PUBLIC)
|
||||
@Getter
|
||||
@Setter
|
||||
public class AnalysisResult {
|
||||
private String varName;
|
||||
|
||||
private String metricsName;
|
||||
|
||||
private String metricsClassPackage;
|
||||
|
||||
private String tableName;
|
||||
|
||||
private String packageName;
|
||||
|
||||
private String sourcePackage;
|
||||
|
||||
private String sourceName;
|
||||
|
||||
private int sourceScopeId;
|
||||
|
|
@ -55,6 +58,7 @@ public class AnalysisResult {
|
|||
private List<ConditionExpression> funcConditionExpressions;
|
||||
|
||||
private List<Argument> funcArgs;
|
||||
|
||||
private int argGetIdx = 0;
|
||||
|
||||
private List<DataColumn> persistentFields;
|
||||
|
|
|
|||
|
|
@ -31,9 +31,12 @@ public class OALListener extends OALParserBaseListener {
|
|||
|
||||
private ConditionExpression conditionExpression;
|
||||
|
||||
public OALListener(OALScripts scripts) {
|
||||
private final String sourcePackage;
|
||||
|
||||
public OALListener(OALScripts scripts, String sourcePackage) {
|
||||
this.results = scripts.getMetricsStmts();
|
||||
this.collection = scripts.getDisableCollection();
|
||||
this.sourcePackage = sourcePackage;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -158,7 +161,7 @@ public class OALListener extends OALParserBaseListener {
|
|||
private void enterConditionValue(String value) {
|
||||
if (value.split("\\.").length == 2 && !value.startsWith("\"")) {
|
||||
// Value is an enum.
|
||||
value = "org.apache.skywalking.oap.server.core.source." + value;
|
||||
value = sourcePackage + value;
|
||||
}
|
||||
conditionExpression.setValue(value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,19 +33,23 @@ import org.apache.skywalking.oal.rt.grammar.OALParser;
|
|||
public class ScriptParser {
|
||||
private OALLexer lexer;
|
||||
|
||||
private String sourcePackage;
|
||||
|
||||
private ScriptParser() {
|
||||
|
||||
}
|
||||
|
||||
public static ScriptParser createFromFile(Reader scriptReader) throws IOException {
|
||||
public static ScriptParser createFromFile(Reader scriptReader, String sourcePackage) throws IOException {
|
||||
ScriptParser parser = new ScriptParser();
|
||||
parser.lexer = new OALLexer(CharStreams.fromReader(scriptReader));
|
||||
parser.sourcePackage = sourcePackage;
|
||||
return parser;
|
||||
}
|
||||
|
||||
public static ScriptParser createFromScriptText(String script) throws IOException {
|
||||
public static ScriptParser createFromScriptText(String script, String sourcePackage) throws IOException {
|
||||
ScriptParser parser = new ScriptParser();
|
||||
parser.lexer = new OALLexer(CharStreams.fromString(script));
|
||||
parser.sourcePackage = sourcePackage;
|
||||
return parser;
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +63,7 @@ public class ScriptParser {
|
|||
ParseTree tree = parser.root();
|
||||
ParseTreeWalker walker = new ParseTreeWalker();
|
||||
|
||||
walker.walk(new OALListener(scripts), tree);
|
||||
walker.walk(new OALListener(scripts, sourcePackage), tree);
|
||||
|
||||
return scripts;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
public void dispatch(org.apache.skywalking.oap.server.core.source.Source source) {
|
||||
org.apache.skywalking.oap.server.core.source.${source} _source = (org.apache.skywalking.oap.server.core.source.${source})source;
|
||||
${sourcePackage}${source} _source = (${sourcePackage}${source})source;
|
||||
<#list metrics as metrics>
|
||||
do${metrics.metricsName}(_source);
|
||||
</#list>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
private void do${metricsName}(org.apache.skywalking.oap.server.core.source.${sourceName} source) {
|
||||
org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics metrics = new org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics();
|
||||
private void do${metricsName}(${sourcePackage}${sourceName} source) {
|
||||
${metricsClassPackage}${metricsName}Metrics metrics = new ${metricsClassPackage}${metricsName}Metrics();
|
||||
|
||||
<#if filterExpressions??>
|
||||
<#list filterExpressions as filterExpression>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
public java.util.Map data2Map(org.apache.skywalking.oap.server.core.storage.StorageData input) {
|
||||
org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics storageData = (org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics)input;
|
||||
${metricsClassPackage}${metricsName}Metrics storageData = (${metricsClassPackage}${metricsName}Metrics)input;
|
||||
java.util.Map map = new java.util.HashMap();
|
||||
<#list fieldsFromSource as field>
|
||||
<#if field.typeName == "long">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
public org.apache.skywalking.oap.server.core.storage.StorageData map2Data(java.util.Map dbMap) {
|
||||
org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics metrics = new org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics();
|
||||
${metricsClassPackage}${metricsName}Metrics metrics = new ${metricsClassPackage}${metricsName}Metrics();
|
||||
<#list fieldsFromSource as field>
|
||||
<#if field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
|
||||
metrics.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value());
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ return false;
|
|||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
|
||||
org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics metrics = (org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics)obj;
|
||||
${metricsClassPackage}${metricsName}Metrics metrics = (${metricsClassPackage}${metricsName}Metrics)obj;
|
||||
<#list fieldsFromSource as sourceField>
|
||||
<#if sourceField.isID()>
|
||||
<#if sourceField.getTypeName() == "java.lang.String">
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
public org.apache.skywalking.oap.server.core.analysis.metrics.Metrics toDay() {
|
||||
org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics metrics = new org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics();
|
||||
${metricsClassPackage}${metricsName}Metrics metrics = new ${metricsClassPackage}${metricsName}Metrics();
|
||||
<#list fieldsFromSource as field>
|
||||
<#if field.columnName == "time_bucket">
|
||||
metrics.setTimeBucket(toTimeBucketInDay());
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
public org.apache.skywalking.oap.server.core.analysis.metrics.Metrics toHour() {
|
||||
org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics metrics = new org.apache.skywalking.oal.rt.metrics.${metricsName}Metrics();
|
||||
${metricsClassPackage}${metricsName}Metrics metrics = new ${metricsClassPackage}${metricsName}Metrics();
|
||||
<#list fieldsFromSource as field>
|
||||
<#if field.columnName == "time_bucket">
|
||||
metrics.setTimeBucket(toTimeBucketInHour());
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ import org.junit.BeforeClass;
|
|||
import org.junit.Test;
|
||||
|
||||
public class ScriptParserTest {
|
||||
|
||||
private static final String TEST_SOURCE_PACKAGE = ScriptParserTest.class.getPackage().getName() + ".test.source.";
|
||||
|
||||
@BeforeClass
|
||||
public static void init() throws IOException, StorageException {
|
||||
MetricsHolder.init();
|
||||
|
|
@ -45,7 +48,10 @@ public class ScriptParserTest {
|
|||
|
||||
@Test
|
||||
public void testParse() throws IOException {
|
||||
ScriptParser parser = ScriptParser.createFromScriptText("Endpoint_avg = from(Endpoint.latency).longAvg(); //comment test" + "\n" + "Service_avg = from(Service.latency).longAvg()");
|
||||
ScriptParser parser = ScriptParser.createFromScriptText(
|
||||
"Endpoint_avg = from(Endpoint.latency).longAvg(); //comment test" + "\n" + "Service_avg = from(Service.latency).longAvg()",
|
||||
TEST_SOURCE_PACKAGE
|
||||
);
|
||||
List<AnalysisResult> results = parser.parse().getMetricsStmts();
|
||||
|
||||
Assert.assertEquals(2, results.size());
|
||||
|
|
@ -65,7 +71,8 @@ public class ScriptParserTest {
|
|||
|
||||
@Test
|
||||
public void testParse2() throws IOException {
|
||||
ScriptParser parser = ScriptParser.createFromScriptText("Endpoint_percent = from(Endpoint.*).percent(status == true);");
|
||||
ScriptParser parser = ScriptParser.createFromScriptText(
|
||||
"Endpoint_percent = from(Endpoint.*).percent(status == true);", TEST_SOURCE_PACKAGE);
|
||||
List<AnalysisResult> results = parser.parse().getMetricsStmts();
|
||||
|
||||
AnalysisResult endpointPercent = results.get(0);
|
||||
|
|
@ -80,7 +87,10 @@ public class ScriptParserTest {
|
|||
|
||||
@Test
|
||||
public void testParse3() throws IOException {
|
||||
ScriptParser parser = ScriptParser.createFromScriptText("Endpoint_percent = from(Endpoint.*).filter(status == true).filter(name == \"/product/abc\").longAvg();");
|
||||
ScriptParser parser = ScriptParser.createFromScriptText(
|
||||
"Endpoint_percent = from(Endpoint.*).filter(status == true).filter(name == \"/product/abc\").longAvg();",
|
||||
TEST_SOURCE_PACKAGE
|
||||
);
|
||||
List<AnalysisResult> results = parser.parse().getMetricsStmts();
|
||||
|
||||
AnalysisResult endpointPercent = results.get(0);
|
||||
|
|
@ -105,7 +115,13 @@ public class ScriptParserTest {
|
|||
|
||||
@Test
|
||||
public void testParse4() throws IOException {
|
||||
ScriptParser parser = ScriptParser.createFromScriptText("service_response_s1_summary = from(Service.latency).filter(latency > 1000).sum();" + "\n" + "service_response_s2_summary = from(Service.latency).filter(latency < 2000).sum();" + "\n" + "service_response_s3_summary = from(Service.latency).filter(latency >= 3000).sum();" + "\n" + "service_response_s4_summary = from(Service.latency).filter(latency <= 4000).sum();");
|
||||
ScriptParser parser = ScriptParser.createFromScriptText(
|
||||
"service_response_s1_summary = from(Service.latency).filter(latency > 1000).sum();" + "\n"
|
||||
+ "service_response_s2_summary = from(Service.latency).filter(latency < 2000).sum();" + "\n"
|
||||
+ "service_response_s3_summary = from(Service.latency).filter(latency >= 3000).sum();" + "\n"
|
||||
+ "service_response_s4_summary = from(Service.latency).filter(latency <= 4000).sum();",
|
||||
TEST_SOURCE_PACKAGE
|
||||
);
|
||||
List<AnalysisResult> results = parser.parse().getMetricsStmts();
|
||||
|
||||
AnalysisResult responseSummary = results.get(0);
|
||||
|
|
@ -155,7 +171,7 @@ public class ScriptParserTest {
|
|||
|
||||
@Test
|
||||
public void testDisable() throws IOException {
|
||||
ScriptParser parser = ScriptParser.createFromScriptText("disable(segment);");
|
||||
ScriptParser parser = ScriptParser.createFromScriptText("disable(segment);", TEST_SOURCE_PACKAGE);
|
||||
DisableCollection collection = parser.parse().getDisableCollection();
|
||||
List<String> sources = collection.getAllDisableSources();
|
||||
Assert.assertEquals(1, sources.size());
|
||||
|
|
|
|||
|
|
@ -37,4 +37,5 @@ public class Const {
|
|||
public static final String SEGMENT_SPAN_SPLIT = "S";
|
||||
public static final String UNKNOWN = "Unknown";
|
||||
public static final String EMPTY_STRING = "";
|
||||
public static final String POINT = ".";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import org.apache.skywalking.oap.server.core.config.ConfigService;
|
|||
import org.apache.skywalking.oap.server.core.config.DownSamplingConfigService;
|
||||
import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService;
|
||||
import org.apache.skywalking.oap.server.core.config.NamingLengthControl;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.profile.ProfileTaskMutationService;
|
||||
import org.apache.skywalking.oap.server.core.query.AggregationQueryService;
|
||||
import org.apache.skywalking.oap.server.core.query.AlarmQueryService;
|
||||
|
|
@ -80,6 +81,7 @@ public class CoreModule extends ModuleDefine {
|
|||
addCacheService(classes);
|
||||
addQueryService(classes);
|
||||
addProfileService(classes);
|
||||
addOALService(classes);
|
||||
|
||||
classes.add(CommandService.class);
|
||||
|
||||
|
|
@ -92,6 +94,10 @@ public class CoreModule extends ModuleDefine {
|
|||
classes.add(ProfileTaskCache.class);
|
||||
}
|
||||
|
||||
private void addOALService(List<Class> classes) {
|
||||
classes.add(OALEngineLoaderService.class);
|
||||
}
|
||||
|
||||
private void addQueryService(List<Class> classes) {
|
||||
classes.add(TopologyQueryService.class);
|
||||
classes.add(MetricsMetadataQueryService.class);
|
||||
|
|
|
|||
|
|
@ -42,8 +42,7 @@ import org.apache.skywalking.oap.server.core.config.ConfigService;
|
|||
import org.apache.skywalking.oap.server.core.config.DownSamplingConfigService;
|
||||
import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService;
|
||||
import org.apache.skywalking.oap.server.core.config.NamingLengthControl;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngine;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoader;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.profile.ProfileTaskMutationService;
|
||||
import org.apache.skywalking.oap.server.core.query.AggregationQueryService;
|
||||
import org.apache.skywalking.oap.server.core.query.AlarmQueryService;
|
||||
|
|
@ -104,7 +103,6 @@ public class CoreModuleProvider extends ModuleProvider {
|
|||
private final AnnotationScan annotationScan;
|
||||
private final StorageModels storageModels;
|
||||
private final SourceReceiverImpl receiver;
|
||||
private OALEngine oalEngine;
|
||||
private ApdexThresholdConfig apdexThresholdConfig;
|
||||
|
||||
public CoreModuleProvider() {
|
||||
|
|
@ -147,11 +145,6 @@ public class CoreModuleProvider extends ModuleProvider {
|
|||
scopeScan.registerListener(new DefaultScopeDefine.Listener());
|
||||
try {
|
||||
scopeScan.scan();
|
||||
|
||||
oalEngine = OALEngineLoader.get();
|
||||
oalEngine.setStreamListener(streamAnnotationListener);
|
||||
oalEngine.setDispatcherListener(receiver.getDispatcherManager());
|
||||
oalEngine.start(getClass().getClassLoader());
|
||||
} catch (Exception e) {
|
||||
throw new ModuleStartException(e.getMessage(), e);
|
||||
}
|
||||
|
|
@ -236,6 +229,9 @@ public class CoreModuleProvider extends ModuleProvider {
|
|||
|
||||
this.registerServiceImplementation(CommandService.class, new CommandService(getManager()));
|
||||
|
||||
// add oal engine loader service implementations
|
||||
this.registerServiceImplementation(OALEngineLoaderService.class, new OALEngineLoaderService(getManager()));
|
||||
|
||||
annotationScan.registerListener(streamAnnotationListener);
|
||||
|
||||
if (moduleConfig.isGRPCSslEnabled()) {
|
||||
|
|
@ -263,8 +259,6 @@ public class CoreModuleProvider extends ModuleProvider {
|
|||
try {
|
||||
receiver.scan();
|
||||
annotationScan.scan();
|
||||
|
||||
oalEngine.notifyAllListeners();
|
||||
} catch (IOException | IllegalAccessException | InstantiationException | StorageException e) {
|
||||
throw new ModuleStartException(e.getMessage(), e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.oal.rt;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import org.apache.skywalking.oap.server.core.Const;
|
||||
|
||||
import static java.util.Objects.requireNonNull;
|
||||
|
||||
/**
|
||||
* Define multiple OAL configuration
|
||||
*/
|
||||
@Getter
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
public abstract class OALDefine {
|
||||
|
||||
OALDefine(final String configFile,
|
||||
final String sourcePackage,
|
||||
final String dynamicMetricsClassPackage,
|
||||
final String dynamicMetricsBuilderClassPackage, final String dynamicDispatcherClassPackage) {
|
||||
this.configFile = requireNonNull(configFile);
|
||||
this.sourcePackage = appendPoint(requireNonNull(sourcePackage));
|
||||
this.dynamicMetricsClassPackage = appendPoint(requireNonNull(dynamicMetricsClassPackage));
|
||||
this.dynamicMetricsBuilderClassPackage = appendPoint(requireNonNull(dynamicMetricsBuilderClassPackage));
|
||||
this.dynamicDispatcherClassPackage = appendPoint(requireNonNull(dynamicDispatcherClassPackage));
|
||||
}
|
||||
|
||||
private final String configFile;
|
||||
private final String sourcePackage;
|
||||
private final String dynamicMetricsClassPackage;
|
||||
private final String dynamicMetricsBuilderClassPackage;
|
||||
private final String dynamicDispatcherClassPackage;
|
||||
|
||||
private String appendPoint(String classPackage) {
|
||||
if (classPackage.endsWith(Const.POINT)) {
|
||||
return classPackage;
|
||||
}
|
||||
return classPackage + Const.POINT;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.oal.rt;
|
||||
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
/**
|
||||
* Load the OAL Engine runtime, because runtime module depends on core, so we have to use class::forname to locate it.
|
||||
*/
|
||||
public class OALEngineLoader {
|
||||
private static volatile OALEngine ENGINE = null;
|
||||
private static ReentrantLock INIT_LOCK = new ReentrantLock();
|
||||
|
||||
public static OALEngine get() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
|
||||
if (ENGINE == null) {
|
||||
INIT_LOCK.lock();
|
||||
try {
|
||||
if (ENGINE == null) {
|
||||
init();
|
||||
}
|
||||
} finally {
|
||||
INIT_LOCK.unlock();
|
||||
}
|
||||
}
|
||||
return ENGINE;
|
||||
}
|
||||
|
||||
private static void init() throws ClassNotFoundException, IllegalAccessException, InstantiationException {
|
||||
Class<?> engineRTClass = Class.forName("org.apache.skywalking.oal.rt.OALRuntime");
|
||||
ENGINE = (OALEngine) engineRTClass.newInstance();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.oal.rt;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.analysis.StreamAnnotationListener;
|
||||
import org.apache.skywalking.oap.server.core.source.SourceReceiver;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleManager;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
|
||||
import org.apache.skywalking.oap.server.library.module.Service;
|
||||
|
||||
/**
|
||||
* Activate {@link OALEngine} according to {@link OALDefine}
|
||||
*/
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class OALEngineLoaderService implements Service {
|
||||
|
||||
private final Set<OALDefine> oalDefineSet = new HashSet<>();
|
||||
private final ModuleManager moduleManager;
|
||||
|
||||
/**
|
||||
* Normally it is invoked in the {@link ModuleProvider#start()} of the receiver-plugin module.
|
||||
*/
|
||||
public void load(OALDefine define) throws ModuleStartException {
|
||||
if (oalDefineSet.contains(define)) {
|
||||
// each oal define will only be activated once
|
||||
return;
|
||||
}
|
||||
try {
|
||||
OALEngine engine = loadOALEngine(define);
|
||||
StreamAnnotationListener streamAnnotationListener = new StreamAnnotationListener(moduleManager);
|
||||
engine.setStreamListener(streamAnnotationListener);
|
||||
engine.setDispatcherListener(moduleManager.find(CoreModule.NAME)
|
||||
.provider()
|
||||
.getService(SourceReceiver.class)
|
||||
.getDispatcherDetectorListener());
|
||||
|
||||
engine.start(OALEngineLoaderService.class.getClassLoader());
|
||||
engine.notifyAllListeners();
|
||||
|
||||
oalDefineSet.add(define);
|
||||
} catch (ReflectiveOperationException | OALCompileException e) {
|
||||
throw new ModuleStartException(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the OAL Engine runtime, because runtime module depends on core, so we have to use class::forname to locate
|
||||
* it.
|
||||
*/
|
||||
private static OALEngine loadOALEngine(OALDefine define) throws ReflectiveOperationException {
|
||||
Class<?> engineRTClass = Class.forName("org.apache.skywalking.oal.rt.OALRuntime");
|
||||
Constructor<?> engineRTConstructor = engineRTClass.getConstructor(OALDefine.class);
|
||||
return (OALEngine) engineRTConstructor.newInstance(define);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.apache.skywalking.oap.server.core.oal.rt;
|
||||
|
||||
public class OfficialOALDefine extends OALDefine {
|
||||
|
||||
public static final OfficialOALDefine INSTANCE = new OfficialOALDefine();
|
||||
|
||||
private OfficialOALDefine() {
|
||||
super(
|
||||
"official_analysis.oal",
|
||||
"org.apache.skywalking.oap.server.core.source",
|
||||
"org.apache.skywalking.oal.rt.official.metrics",
|
||||
"org.apache.skywalking.oal.rt.official.metrics.builder",
|
||||
"org.apache.skywalking.oal.rt.official.dispatcher"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.core.source;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.analysis.DispatcherDetectorListener;
|
||||
import org.apache.skywalking.oap.server.library.module.Service;
|
||||
|
||||
/**
|
||||
|
|
@ -26,4 +27,6 @@ import org.apache.skywalking.oap.server.library.module.Service;
|
|||
*/
|
||||
public interface SourceReceiver extends Service {
|
||||
void receive(Source source);
|
||||
|
||||
DispatcherDetectorListener getDispatcherDetectorListener();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ package org.apache.skywalking.oap.server.core.source;
|
|||
|
||||
import java.io.IOException;
|
||||
import lombok.Getter;
|
||||
import org.apache.skywalking.oap.server.core.analysis.DispatcherDetectorListener;
|
||||
import org.apache.skywalking.oap.server.core.analysis.DispatcherManager;
|
||||
|
||||
public class SourceReceiverImpl implements SourceReceiver {
|
||||
|
|
@ -35,6 +36,11 @@ public class SourceReceiverImpl implements SourceReceiver {
|
|||
dispatcherManager.forward(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DispatcherDetectorListener getDispatcherDetectorListener() {
|
||||
return getDispatcherManager();
|
||||
}
|
||||
|
||||
public void scan() throws IOException, InstantiationException, IllegalAccessException {
|
||||
dispatcherManager.scan();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,6 +26,6 @@ public class CoreModuleTest {
|
|||
public void testOpenServiceList() {
|
||||
CoreModule coreModule = new CoreModule();
|
||||
|
||||
Assert.assertEquals(29, coreModule.services().length);
|
||||
Assert.assertEquals(30, coreModule.services().length);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
package org.apache.skywalking.oap.server.receiver.clr.provider;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OfficialOALDefine;
|
||||
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleDefine;
|
||||
|
|
@ -56,6 +58,12 @@ public class CLRModuleProvider extends ModuleProvider {
|
|||
|
||||
@Override
|
||||
public void start() throws ServiceNotProvidedException, ModuleStartException {
|
||||
// load official analysis
|
||||
getManager().find(CoreModule.NAME)
|
||||
.provider()
|
||||
.getService(OALEngineLoaderService.class)
|
||||
.load(OfficialOALDefine.INSTANCE);
|
||||
|
||||
GRPCHandlerRegister grpcHandlerRegister = getManager().find(SharingServerModule.NAME)
|
||||
.provider()
|
||||
.getService(GRPCHandlerRegister.class);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@ package org.apache.skywalking.oap.server.receiver.istio.telemetry.provider;
|
|||
|
||||
import org.apache.skywalking.aop.server.receiver.mesh.MeshReceiverModule;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OfficialOALDefine;
|
||||
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleDefine;
|
||||
|
|
@ -52,6 +54,12 @@ public class IstioTelemetryReceiverProvider extends ModuleProvider {
|
|||
|
||||
@Override
|
||||
public void start() throws ServiceNotProvidedException, ModuleStartException {
|
||||
// load official analysis
|
||||
getManager().find(CoreModule.NAME)
|
||||
.provider()
|
||||
.getService(OALEngineLoaderService.class)
|
||||
.load(OfficialOALDefine.INSTANCE);
|
||||
|
||||
GRPCHandlerRegister service = getManager().find(SharingServerModule.NAME)
|
||||
.provider()
|
||||
.getService(GRPCHandlerRegister.class);
|
||||
|
|
|
|||
|
|
@ -19,10 +19,13 @@
|
|||
package org.apache.skywalking.oap.server.receiver.jvm.provider;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OfficialOALDefine;
|
||||
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleDefine;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleProvider;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleStartException;
|
||||
import org.apache.skywalking.oap.server.receiver.jvm.module.JVMModule;
|
||||
import org.apache.skywalking.oap.server.receiver.jvm.provider.handler.JVMMetricReportServiceHandler;
|
||||
import org.apache.skywalking.oap.server.receiver.sharing.server.SharingServerModule;
|
||||
|
|
@ -49,7 +52,13 @@ public class JVMModuleProvider extends ModuleProvider {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
public void start() throws ModuleStartException {
|
||||
// load official analysis
|
||||
getManager().find(CoreModule.NAME)
|
||||
.provider()
|
||||
.getService(OALEngineLoaderService.class)
|
||||
.load(OfficialOALDefine.INSTANCE);
|
||||
|
||||
GRPCHandlerRegister grpcHandlerRegister = getManager().find(SharingServerModule.NAME)
|
||||
.provider()
|
||||
.getService(GRPCHandlerRegister.class);
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@
|
|||
package org.apache.skywalking.aop.server.receiver.mesh;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OfficialOALDefine;
|
||||
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleDefine;
|
||||
|
|
@ -56,6 +58,12 @@ public class MeshReceiverProvider extends ModuleProvider {
|
|||
|
||||
@Override
|
||||
public void start() throws ServiceNotProvidedException, ModuleStartException {
|
||||
// load official analysis
|
||||
getManager().find(CoreModule.NAME)
|
||||
.provider()
|
||||
.getService(OALEngineLoaderService.class)
|
||||
.load(OfficialOALDefine.INSTANCE);
|
||||
|
||||
TelemetryDataDispatcher.init(getManager());
|
||||
GRPCHandlerRegister service = getManager().find(SharingServerModule.NAME)
|
||||
.provider()
|
||||
|
|
|
|||
|
|
@ -35,10 +35,12 @@ import lombok.ToString;
|
|||
import org.apache.skywalking.apm.util.StringUtil;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.analysis.IDManager;
|
||||
import org.apache.skywalking.oap.server.core.analysis.NodeType;
|
||||
import org.apache.skywalking.oap.server.core.analysis.TimeBucket;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OfficialOALDefine;
|
||||
import org.apache.skywalking.oap.server.core.source.GCPhrase;
|
||||
import org.apache.skywalking.oap.server.core.source.MemoryPoolType;
|
||||
import org.apache.skywalking.oap.server.core.analysis.NodeType;
|
||||
import org.apache.skywalking.oap.server.core.source.ServiceInstanceJVMCPU;
|
||||
import org.apache.skywalking.oap.server.core.source.ServiceInstanceJVMGC;
|
||||
import org.apache.skywalking.oap.server.core.source.ServiceInstanceJVMMemory;
|
||||
|
|
@ -111,6 +113,12 @@ public class So11yReceiverModuleProvider extends ModuleProvider {
|
|||
|
||||
@Override
|
||||
public void start() throws ServiceNotProvidedException, ModuleStartException {
|
||||
// load official analysis
|
||||
getManager().find(CoreModule.NAME)
|
||||
.provider()
|
||||
.getService(OALEngineLoaderService.class)
|
||||
.load(OfficialOALDefine.INSTANCE);
|
||||
|
||||
sourceReceiver = getManager().find(CoreModule.NAME).provider().getService(SourceReceiver.class);
|
||||
MetricsCollector collector = getManager().find(TelemetryModule.NAME)
|
||||
.provider()
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ package org.apache.skywalking.oap.server.receiver.trace.provider;
|
|||
import org.apache.skywalking.oap.server.configuration.api.ConfigurationModule;
|
||||
import org.apache.skywalking.oap.server.configuration.api.DynamicConfigurationService;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OfficialOALDefine;
|
||||
import org.apache.skywalking.oap.server.core.server.GRPCHandlerRegister;
|
||||
import org.apache.skywalking.oap.server.core.server.JettyHandlerRegister;
|
||||
import org.apache.skywalking.oap.server.library.module.ModuleConfig;
|
||||
|
|
@ -82,6 +84,12 @@ public class TraceModuleProvider extends ModuleProvider {
|
|||
|
||||
@Override
|
||||
public void start() throws ModuleStartException {
|
||||
// load official analysis
|
||||
getManager().find(CoreModule.NAME)
|
||||
.provider()
|
||||
.getService(OALEngineLoaderService.class)
|
||||
.load(OfficialOALDefine.INSTANCE);
|
||||
|
||||
DynamicConfigurationService dynamicConfigurationService = getManager().find(ConfigurationModule.NAME)
|
||||
.provider()
|
||||
.getService(
|
||||
|
|
|
|||
|
|
@ -113,10 +113,10 @@ public class InfluxStorageProvider extends ModuleProvider {
|
|||
|
||||
@Override
|
||||
public void start() throws ServiceNotProvidedException, ModuleStartException {
|
||||
client.connect();
|
||||
|
||||
InfluxTableInstaller installer = new InfluxTableInstaller(client, getManager());
|
||||
try {
|
||||
client.connect();
|
||||
|
||||
InfluxTableInstaller installer = new InfluxTableInstaller(client, getManager());
|
||||
getManager().find(CoreModule.NAME).provider().getService(ModelCreator.class).addModelListener(installer);
|
||||
} catch (StorageException e) {
|
||||
throw new ModuleStartException(e.getMessage(), e);
|
||||
|
|
|
|||
|
|
@ -38,11 +38,6 @@ public class JaegerStorageModuleElasticsearchProvider extends StorageModuleElast
|
|||
this.registerServiceImplementation(ITraceQueryDAO.class, traceQueryEsDAO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAfterCompleted() {
|
||||
super.notifyAfterCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] requiredModules() {
|
||||
return new String[] {CoreModule.NAME};
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
package org.apache.skywalking.oap.server.storage.plugin.jdbc.h2;
|
||||
|
||||
import java.util.Properties;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.IBatchDAO;
|
||||
import org.apache.skywalking.oap.server.core.storage.IHistoryDeleteDAO;
|
||||
|
|
@ -60,8 +61,6 @@ import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TableInstal
|
|||
import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopNRecordsQueryDAO;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopologyQueryDAO;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TraceQueryDAO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* H2 Storage provider is for demonstration and preview only. I will find that haven't implemented several interfaces,
|
||||
|
|
@ -69,10 +68,9 @@ import org.slf4j.LoggerFactory;
|
|||
* <p>
|
||||
* If someone wants to implement SQL-style database as storage, please just refer the logic.
|
||||
*/
|
||||
@Slf4j
|
||||
public class H2StorageProvider extends ModuleProvider {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(H2StorageProvider.class);
|
||||
|
||||
private H2StorageConfig config;
|
||||
private JDBCHikariCPClient h2Client;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.jdbc.mysql;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.IBatchDAO;
|
||||
import org.apache.skywalking.oap.server.core.storage.IHistoryDeleteDAO;
|
||||
|
|
@ -54,8 +55,6 @@ import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2ProfileThre
|
|||
import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2StorageDAO;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopNRecordsQueryDAO;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.jdbc.h2.dao.H2TopologyQueryDAO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* MySQL storage provider should be secondary choice for production usage as SkyWalking storage solution. It enhanced
|
||||
|
|
@ -65,10 +64,9 @@ import org.slf4j.LoggerFactory;
|
|||
* this storage implementation, we could also use this in MySQL-compatible projects, such as, Apache ShardingSphere,
|
||||
* TiDB
|
||||
*/
|
||||
@Slf4j
|
||||
public class MySQLStorageProvider extends ModuleProvider {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(MySQLStorageProvider.class);
|
||||
|
||||
private MySQLStorageConfig config;
|
||||
private JDBCHikariCPClient mysqlClient;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,18 +18,15 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.storage.plugin.zipkin.elasticsearch;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.skywalking.oap.server.core.CoreModule;
|
||||
import org.apache.skywalking.oap.server.core.storage.query.ITraceQueryDAO;
|
||||
import org.apache.skywalking.oap.server.library.module.ServiceNotProvidedException;
|
||||
import org.apache.skywalking.oap.server.storage.plugin.elasticsearch.StorageModuleElasticsearchProvider;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Slf4j
|
||||
public class ZipkinStorageModuleElasticsearchProvider extends StorageModuleElasticsearchProvider {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(ZipkinStorageModuleElasticsearchProvider.class);
|
||||
private ZipkinTraceQueryEsDAO traceQueryEsDAO;
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return "zipkin-elasticsearch";
|
||||
|
|
@ -38,15 +35,10 @@ public class ZipkinStorageModuleElasticsearchProvider extends StorageModuleElast
|
|||
@Override
|
||||
public void prepare() throws ServiceNotProvidedException {
|
||||
super.prepare();
|
||||
traceQueryEsDAO = new ZipkinTraceQueryEsDAO(elasticSearchClient);
|
||||
final ZipkinTraceQueryEsDAO traceQueryEsDAO = new ZipkinTraceQueryEsDAO(elasticSearchClient);
|
||||
this.registerServiceImplementation(ITraceQueryDAO.class, traceQueryEsDAO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyAfterCompleted() {
|
||||
super.notifyAfterCompleted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] requiredModules() {
|
||||
return new String[] {CoreModule.NAME};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import org.apache.skywalking.oap.server.core.config.ConfigService;
|
|||
import org.apache.skywalking.oap.server.core.config.DownSamplingConfigService;
|
||||
import org.apache.skywalking.oap.server.core.config.IComponentLibraryCatalogService;
|
||||
import org.apache.skywalking.oap.server.core.config.NamingLengthControl;
|
||||
import org.apache.skywalking.oap.server.core.oal.rt.OALEngineLoaderService;
|
||||
import org.apache.skywalking.oap.server.core.profile.ProfileTaskMutationService;
|
||||
import org.apache.skywalking.oap.server.core.query.AggregationQueryService;
|
||||
import org.apache.skywalking.oap.server.core.query.AlarmQueryService;
|
||||
|
|
@ -156,6 +157,9 @@ public class MockCoreModuleProvider extends CoreModuleProvider {
|
|||
this.registerServiceImplementation(CommandService.class, new CommandService(getManager()));
|
||||
|
||||
this.registerServiceImplementation(RemoteClientManager.class, new MockRemoteClientManager(getManager(), 0));
|
||||
|
||||
// add oal engine loader service implementations
|
||||
this.registerServiceImplementation(OALEngineLoaderService.class, new OALEngineLoaderService(getManager()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
package org.apache.skywalking.oap.server.tool.profile.core.mock;
|
||||
|
||||
import org.apache.skywalking.oap.server.core.analysis.DispatcherDetectorListener;
|
||||
import org.apache.skywalking.oap.server.core.source.Source;
|
||||
import org.apache.skywalking.oap.server.core.source.SourceReceiver;
|
||||
|
||||
|
|
@ -28,4 +29,9 @@ public class MockSourceReceiver implements SourceReceiver {
|
|||
@Override
|
||||
public void receive(Source source) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public DispatcherDetectorListener getDispatcherDetectorListener() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue