未验证 提交 40eb6512 编写于 作者: wu-sheng's avatar wu-sheng 提交者: GitHub

OAL tool module established (#2015)

* Move oal tool back into main repo, and fix compile issue.

* Fix two bugs.

* Remove all generated codes.

* Make all oal generated codes out of source control.

* Make mvn compile and package work.

* Fix test cases.

* Make compile right and provide new documents.

* Remove an unnecessary tokens file.
上级 c1413765
......@@ -12,4 +12,4 @@ packages/
/skywalking-agent/
/dist/
/docker/snapshot/*.gz
.mvn/wrapper/*.jar
.mvn/wrapper/*.jar
\ No newline at end of file
......@@ -30,6 +30,8 @@ For each official Apache release, there is a complete and independent source cod
* `grpc-java` and `java` folders in **apm-protocol/apm-network/target/generated-sources/protobuf**
* `grpc-java` and `java` folders in **oap-server/server-core/target/generated-sources/protobuf**
* `grpc-java` and `java` folders in **oap-server/server-receiver-plugin/skywalking-istio-telemetry-receiver-plugin/target/generated-sources/protobuf**
* `antlr` folder in **oap-server/generate-tool/target/generated-sources/antlr4**
* `oal` folder in **oap-server/generated-analysis/target/generated-sources/oal**
## Setup your Eclipse IDE
1. Import the project as a maven project
......
......@@ -29,7 +29,7 @@ and private plugin developer should read this.
- If you want to build a new probe or plugin in any language, please read [Component library definition and extension](Component-library-settings.md) document.
- [Storage extension development guide](storage-extention.md). Help potential contributors to build a new
storage implementor besides the official.
-
- [Customize analysis by oal script](write-oal.md). Guide you to use oal script to make your own metric available.
### UI developer
Our UI is constituted by static pages and web container.
......
# Official OAL script
First, read [OAL introduction](../concepts-and-designs/oal.md).
Here is the official scrips is the `server-core-x.y.z.jar/official_analysis.oal` file in distribution,
Here is the official scrips is the `generated-analysis-x.y.z.jar/official_analysis.oal` file in distribution,
also the `server-core` module's **src/main/resources/official_analysis.oal** in source code repository.
**Notice**, this file doesn't effect anything in runtime, although included in distribution.
......
# Write OAL script
Read [OAL overview](../concepts-and-designs/oal.md) to understand the oal script.
## Find oal script in source codes
The official official_analysis.oal is [here](../../../oap-server/generated-analysis/src/main/resources/official_analysis.oal).
## Generate tool
The `oap-server/generate-tool` module includes the source codes of compiling tool. This tool is already integrated
maven compile phase. So, unless you want to change the tool source codes, you don't need to set anything.
Run `./mvnw compile` or `./mvnw package`, the generated codes of the oal script are in `oap-server/generate-tool/target/generated-sources/oal/*`.
## Write and recompile
You could change the `official_analysis.oal` script, then recompile codes.
The generated codes are in **oap-server/generated-analysis/target/generated-sources/oal**.
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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>oap-server</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>6.0.0-beta-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>generate-tool</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>server-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4</artifactId>
<version>4.7.1</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.0</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.28</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
<version>4.7.1</version>
<executions>
<execution>
<id>antlr</id>
<goals>
<goal>antlr4</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
/*
* 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.
*
*/
// Observability Analysis Language lexer
lexer grammar OALLexer;
@Header {package org.apache.skywalking.oal.tool.grammar;}
// Keywords
FROM: 'from';
FILTER: 'filter';
SRC_ALL: 'All';
SRC_SERVICE: 'Service';
SRC_SERVICE_INSTANCE: 'ServiceInstance';
SRC_ENDPOINT: 'Endpoint';
SRC_SERVICE_RELATION: 'ServiceRelation';
SRC_SERVICE_INSTANCE_RELATION: 'ServiceInstanceRelation';
SRC_ENDPOINT_RELATION: 'EndpointRelation';
SRC_SERVICE_INSTANCE_JVM_CPU: 'ServiceInstanceJVMCPU';
SRC_SERVICE_INSTANCE_JVM_MEMORY: 'ServiceInstanceJVMMemory';
SRC_SERVICE_INSTANCE_JVM_MEMORY_POOL: 'ServiceInstanceJVMMemoryPool';
SRC_SERVICE_INSTANCE_JVM_GC: 'ServiceInstanceJVMGC';
// Literals
BOOL_LITERAL: 'true'
| 'false'
;
INT_LITERAL : Digits+;
CHAR_LITERAL: '\'' (~['\\\r\n] | EscapeSequence) '\'';
STRING_LITERAL: '"' (~["\\\r\n] | EscapeSequence)* '"';
DelimitedComment
: '/*' ( DelimitedComment | . )*? '*/'
-> channel(HIDDEN)
;
LineComment
: '//' ~[\u000A\u000D]*
-> channel(HIDDEN)
;
SPACE: [ \t\r\n]+ -> channel(HIDDEN);
// Identifiers
IDENTIFIER: Letter LetterOrDigit*;
// Fragment rules
fragment EscapeSequence
: '\\' [btnfr"'\\]
| '\\' ([0-3]? [0-7])? [0-7]
| '\\' 'u'+ HexDigit HexDigit HexDigit HexDigit
;
fragment HexDigits
: HexDigit ((HexDigit | '_')* HexDigit)?
;
fragment HexDigit
: [0-9a-fA-F]
;
fragment Digits
: [0-9] ([0-9_]* [0-9])?
;
fragment LetterOrDigit
: Letter
| [0-9]
;
fragment Letter
: [a-zA-Z$_] // these are the "java letters" below 0x7F
| ~[\u0000-\u007F\uD800-\uDBFF] // covers all characters above 0x7F which are not a surrogate
| [\uD800-\uDBFF] [\uDC00-\uDFFF] // covers UTF-16 surrogate pairs encodings for U+10000 to U+10FFFF
;
// Constructors symbols
DOT: '.';
LR_BRACKET: '(';
RR_BRACKET: ')';
COMMA: ',';
SEMI: ';';
EQUAL: '=';
DUALEQUALS: '==';
ALL: '*';
\ No newline at end of file
/*
* 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.
*
*/
parser grammar OALParser;
@Header {package org.apache.skywalking.oal.tool.grammar;}
options { tokenVocab=OALLexer; }
// Top Level Description
root
: (aggregationStatement)*
;
aggregationStatement
: variable (SPACE)? EQUAL (SPACE)? metricStatement DelimitedComment? LineComment? (SEMI|EOF)
;
metricStatement
: FROM LR_BRACKET source DOT sourceAttribute RR_BRACKET (filterStatement+)? DOT aggregateFunction
;
filterStatement
: DOT FILTER LR_BRACKET filterExpression RR_BRACKET
;
filterExpression
: expression
;
source
: SRC_ALL | SRC_SERVICE | SRC_SERVICE_INSTANCE | SRC_ENDPOINT |
SRC_SERVICE_RELATION | SRC_SERVICE_INSTANCE_RELATION | SRC_ENDPOINT_RELATION |
SRC_SERVICE_INSTANCE_JVM_CPU | SRC_SERVICE_INSTANCE_JVM_MEMORY | SRC_SERVICE_INSTANCE_JVM_MEMORY_POOL | SRC_SERVICE_INSTANCE_JVM_GC// JVM source of service instance
;
sourceAttribute
: IDENTIFIER | ALL
;
variable
: IDENTIFIER
;
aggregateFunction
: functionName LR_BRACKET (funcParamExpression | (literalExpression (COMMA literalExpression)?))? RR_BRACKET
;
functionName
: IDENTIFIER
;
funcParamExpression
: expression
;
literalExpression
: BOOL_LITERAL | INT_LITERAL
;
expression
: booleanMatch | stringMatch
;
booleanMatch
: conditionAttribute DUALEQUALS booleanConditionValue
;
stringMatch
: conditionAttribute DUALEQUALS (stringConditionValue | enumConditionValue)
;
conditionAttribute
: IDENTIFIER
;
booleanConditionValue
: BOOL_LITERAL
;
stringConditionValue
: STRING_LITERAL
;
enumConditionValue
: IDENTIFIER DOT IDENTIFIER
;
\ No newline at end of file
/*
* 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.oal.tool;
import freemarker.template.TemplateException;
import java.io.*;
import java.util.List;
import org.apache.skywalking.apm.util.StringUtil;
import org.apache.skywalking.oal.tool.output.FileGenerator;
import org.apache.skywalking.oal.tool.parser.*;
public class Main {
public static void main(String[] args) throws IOException, TemplateException {
String modulePath = args[0];
String scriptFilePath = StringUtil.join(File.separatorChar, modulePath, "src", "main", "resources", "official_analysis.oal");
String outputPath = StringUtil.join(File.separatorChar, modulePath, "..", "generated-analysis", "target", "generated-sources", "oal",
"org", "apache", "skywalking", "oap", "server", "core", "analysis");
Indicators.init();
File scriptFile = new File(scriptFilePath);
if (!scriptFile.exists()) {
throw new IllegalArgumentException("OAL script file [" + scriptFilePath + "] doesn't exist");
}
ScriptParser scriptParser = ScriptParser.createFromFile(scriptFilePath);
List<AnalysisResult> analysisResults = scriptParser.parse();
FileGenerator generator = new FileGenerator(analysisResults, outputPath);
generator.generate();
}
}
/*
* 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.oal.tool.output;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oal.tool.parser.AnalysisResult;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class DispatcherContext {
private List<AnalysisResult> allIndicators = new LinkedList<>();
private List<AnalysisResult> serviceIndicators = new LinkedList<>();
private List<AnalysisResult> serviceInstanceIndicators = new LinkedList<>();
private List<AnalysisResult> endpointIndicators = new LinkedList<>();
private List<AnalysisResult> serviceRelationIndicators = new LinkedList<>();
private List<AnalysisResult> serviceInstanceRelationIndicators = new LinkedList<>();
private List<AnalysisResult> endpointRelationIndicators = new LinkedList<>();
private List<AnalysisResult> serviceInstanceJVMCPUIndicators = new LinkedList<>();
private List<AnalysisResult> serviceInstanceJVMMemoryIndicators = new LinkedList<>();
private List<AnalysisResult> serviceInstanceJVMMemoryPoolIndicators = new LinkedList<>();
private List<AnalysisResult> serviceInstanceJVMGCIndicators = new LinkedList<>();
}
/*
* 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.oal.tool.output;
import freemarker.template.*;
import java.io.*;
import java.util.*;
import org.apache.skywalking.oal.tool.parser.AnalysisResult;
public class FileGenerator {
private List<AnalysisResult> results;
private String outputPath;
private Configuration configuration;
private DispatcherContext dispatcherContext;
public FileGenerator(List<AnalysisResult> results, String outputPath) {
this.results = results;
this.outputPath = outputPath;
configuration = new Configuration(new Version("2.3.28"));
configuration.setEncoding(Locale.ENGLISH, "UTF-8");
configuration.setClassLoaderForTemplateLoading(FileGenerator.class.getClassLoader(), "/code-templates");
this.toDispatchers();
}
public void generate() throws IOException, TemplateException {
for (AnalysisResult result : results) {
generate(result, "Indicator.java", writer -> generateIndicatorImplementor(result, writer));
}
File file = new File(outputPath, "generated/all/AllDispatcher.java");
createFile(file);
this.generateAllDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/service/ServiceDispatcher.java");
createFile(file);
this.generateServiceDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/servicerelation/ServiceRelationDispatcher.java");
createFile(file);
this.generateServiceRelationDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/endpoint/EndpointDispatcher.java");
createFile(file);
this.generateEndpointDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/endpointrelation/EndpointRelationDispatcher.java");
createFile(file);
this.generateEndpointRelationDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/serviceinstance/ServiceInstanceDispatcher.java");
createFile(file);
this.generateServiceInstanceDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/serviceinstancerelation/ServiceInstanceRelationDispatcher.java");
createFile(file);
this.generateServiceInstanceRelationDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/serviceinstancejvmcpu/ServiceInstanceJVMCPUDispatcher.java");
createFile(file);
this.generateServiceInstanceJVMCPUDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/serviceinstancejvmmemory/ServiceInstanceJVMMemoryDispatcher.java");
createFile(file);
this.generateServiceInstanceJVMMemoryDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/serviceinstancejvmmemorypool/ServiceInstanceJVMMemoryPoolDispatcher.java");
createFile(file);
this.generateServiceInstanceJVMMemoryPoolDispatcher(new FileWriter(file));
file = new File(outputPath, "generated/serviceinstancejvmgc/ServiceInstanceJVMGCDispatcher.java");
createFile(file);
this.generateServiceInstanceJVMGCDispatcher(new FileWriter(file));
}
private void generate(AnalysisResult result, String fileSuffix,
WriteWrapper writeWrapper) throws IOException, TemplateException {
File file = new File(outputPath, buildSubFolderName(result, fileSuffix));
createFile(file);
FileWriter fileWriter = new FileWriter(file);
try {
writeWrapper.execute(fileWriter);
} finally {
fileWriter.close();
}
}
private void createFile(File file) throws IOException {
if (!file.exists()) {
if (!file.getParentFile().exists()) {
file.getParentFile().mkdirs();
}
file.createNewFile();
}
}
private String buildSubFolderName(AnalysisResult result, String suffix) {
return "generated/"
+ result.getSourceName().toLowerCase() + "/"
+ result.getMetricName() + suffix;
}
void generateIndicatorImplementor(AnalysisResult result, Writer output) throws IOException, TemplateException {
configuration.getTemplate("IndicatorImplementor.ftl").process(result, output);
}
void generateAllDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("AllDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceRelationDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceRelationDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateEndpointDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("EndpointDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateEndpointRelationDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("EndpointRelationDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceInstanceDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceInstanceDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceInstanceRelationDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceInstanceRelationDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceInstanceJVMCPUDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceInstanceJVMCPUDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceInstanceJVMMemoryDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceInstanceJVMMemoryDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceInstanceJVMMemoryPoolDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceInstanceJVMMemoryPoolDispatcherTemplate.ftl").process(dispatcherContext, output);
}
void generateServiceInstanceJVMGCDispatcher(Writer output) throws IOException, TemplateException {
configuration.getTemplate("ServiceInstanceJVMGCDispatcherTemplate.ftl").process(dispatcherContext, output);
}
private void toDispatchers() {
dispatcherContext = new DispatcherContext();
for (AnalysisResult result : results) {
String sourceName = result.getSourceName();
switch (sourceName) {
case "All":
dispatcherContext.getAllIndicators().add(result);
break;
case "Service":
dispatcherContext.getServiceIndicators().add(result);
break;
case "ServiceRelation":
dispatcherContext.getServiceRelationIndicators().add(result);
break;
case "ServiceInstance":
dispatcherContext.getServiceInstanceIndicators().add(result);
break;
case "ServiceInstanceRelation":
dispatcherContext.getServiceInstanceRelationIndicators().add(result);
break;
case "Endpoint":
dispatcherContext.getEndpointIndicators().add(result);
break;
case "EndpointRelation":
dispatcherContext.getEndpointRelationIndicators().add(result);
break;
case "ServiceInstanceJVMCPU":
dispatcherContext.getServiceInstanceJVMCPUIndicators().add(result);
break;
case "ServiceInstanceJVMMemory":
dispatcherContext.getServiceInstanceJVMMemoryIndicators().add(result);
break;
case "ServiceInstanceJVMMemoryPool":
dispatcherContext.getServiceInstanceJVMMemoryPoolIndicators().add(result);
break;
case "ServiceInstanceJVMGC":
dispatcherContext.getServiceInstanceJVMGCIndicators().add(result);
break;
default:
throw new RuntimeException("Unexpected dispatcher");
}
}
}
}
/*
* 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.oal.tool.output;
import freemarker.template.TemplateException;
import java.io.*;
public interface WriteWrapper {
void execute(FileWriter fileWriter) throws IOException, TemplateException;
}
/*
* 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.oal.tool.parser;
import java.util.*;
import lombok.*;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class AnalysisResult {
private String varName;
private String metricName;
private String tableName;
private String packageName;
private String sourceName;
private String sourceAttribute;
private String aggregationFunctionName;
private String indicatorClassName;
private EntryMethod entryMethod;
private List<FilterExpression> filterExpressions;
private List<ConditionExpression> filterExpressionsParserResult;
private List<ConditionExpression> funcConditionExpressions;
private List<String> funcArgs;
private int argGetIdx = 0;
private List<DataColumn> persistentFields;
private List<SourceColumn> fieldsFromSource;
private PersistenceColumns serializeFields;
public void addPersistentField(String fieldName, String columnName, Class<?> type) {
if (persistentFields == null) {
persistentFields = new LinkedList<>();
}
DataColumn dataColumn = new DataColumn(fieldName, columnName, type);
persistentFields.add(dataColumn);
}
public void addFuncConditionExpression(ConditionExpression conditionExpression) {
if (funcConditionExpressions == null) {
funcConditionExpressions = new LinkedList<>();
}
funcConditionExpressions.add(conditionExpression);
}
public void addFilterExpressions(FilterExpression filterExpression) {
if (filterExpressions == null) {
filterExpressions = new LinkedList<>();
}
filterExpressions.add(filterExpression);
}
public void addFilterExpressionsParserResult(ConditionExpression conditionExpression) {
if (filterExpressionsParserResult == null) {
filterExpressionsParserResult = new LinkedList<>();
}
filterExpressionsParserResult.add(conditionExpression);
}
public void addFuncArg(String value) {
if (funcArgs == null) {
funcArgs = new LinkedList<>();
}
funcArgs.add(value);
}
public String getNextFuncArg() {
return funcArgs.get(argGetIdx++);
}
public void generateSerializeFields() {
serializeFields = new PersistenceColumns();
for (SourceColumn sourceColumn : fieldsFromSource) {
String type = sourceColumn.getType().getSimpleName();
switch (type) {
case "int":
serializeFields.addIntField(sourceColumn.getFieldName());
break;
case "double":
serializeFields.addDoubleField(sourceColumn.getFieldName());
break;
case "String":
serializeFields.addStringField(sourceColumn.getFieldName());
break;
case "long":
serializeFields.addLongField(sourceColumn.getFieldName());
break;
default:
throw new IllegalStateException("Unexpected field type [" + type + "] of source sourceColumn [" + sourceColumn.getFieldName() + "]");
}
}
for (DataColumn column : persistentFields) {
String type = column.getType().getSimpleName();
switch (type) {
case "int":
serializeFields.addIntField(column.getFieldName());
break;
case "double":
serializeFields.addDoubleField(column.getFieldName());
break;
case "String":
serializeFields.addStringField(column.getFieldName());
break;
case "long":
serializeFields.addLongField(column.getFieldName());
break;
case "IntKeyLongValueArray":
serializeFields.addIntLongValuePairelistField(column.getFieldName());
break;
default:
throw new IllegalStateException("Unexpected field type [" + type + "] of persistence column [" + column.getFieldName() + "]");
}
}
}
}
/*
* 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.oal.tool.parser;
import lombok.*;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class ConditionExpression {
// original from script
private String expressionType;
private String attribute;
private String value;
}
/*
* 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.oal.tool.parser;
import lombok.*;
import org.apache.skywalking.oal.tool.util.ClassMethodUtil;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class DataColumn {
private String fieldName;
private String columnName;
private Class<?> type;
private String typeName;
private String fieldSetter;
private String fieldGetter;
public DataColumn(String fieldName, String columnName, Class<?> type) {
this.fieldName = fieldName;
this.columnName = columnName;
this.type = type;
this.typeName = type.getName();
this.fieldGetter = ClassMethodUtil.toGetMethod(fieldName);
this.fieldSetter = ClassMethodUtil.toSetMethod(fieldName);
}
}
/*
* 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.oal.tool.parser;
import java.lang.annotation.Annotation;
import java.lang.reflect.*;
import java.util.List;
import org.apache.skywalking.oal.tool.util.ClassMethodUtil;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
import org.apache.skywalking.oap.server.core.storage.annotation.Column;
public class DeepAnalysis {
public AnalysisResult analysis(AnalysisResult result) {
// 1. Set sub package name by source.metric
result.setPackageName(result.getSourceName().toLowerCase());
Class<? extends Indicator> indicatorClass = Indicators.find(result.getAggregationFunctionName());
String indicatorClassSimpleName = indicatorClass.getSimpleName();
result.setIndicatorClassName(indicatorClassSimpleName);
// Optional for filter
List<ConditionExpression> expressions = result.getFilterExpressionsParserResult();
if (expressions != null && expressions.size() > 0) {
for (ConditionExpression expression : expressions) {
FilterExpression filterExpression = new FilterExpression();
if ("booleanMatch".equals(expression.getExpressionType())) {
filterExpression.setExpressionObject("EqualMatch");
filterExpression.setLeft("source." + ClassMethodUtil.toIsMethod(expression.getAttribute()) + "()");
filterExpression.setRight(expression.getValue());
result.addFilterExpressions(filterExpression);
} else if ("stringMatch".equals(expression.getExpressionType())) {
filterExpression.setExpressionObject("EqualMatch");
filterExpression.setLeft("source." + ClassMethodUtil.toGetMethod(expression.getAttribute()) + "()");
filterExpression.setRight(expression.getValue());
result.addFilterExpressions(filterExpression);
} else {
throw new IllegalArgumentException("filter expression [" + expression.getExpressionType() + "] not found");
}
}
}
// 3. Find Entrance method of this indicator
Class c = indicatorClass;
Method entranceMethod = null;
SearchEntrance:
while (!c.equals(Object.class)) {
for (Method method : c.getMethods()) {
Entrance annotation = method.getAnnotation(Entrance.class);
if (annotation != null) {
entranceMethod = method;
break SearchEntrance;
}
}
c = c.getSuperclass();
}
if (entranceMethod == null) {
throw new IllegalArgumentException("Can't find Entrance method in class: " + indicatorClass.getName());
}
EntryMethod entryMethod = new EntryMethod();
result.setEntryMethod(entryMethod);
entryMethod.setMethodName(entranceMethod.getName());
// 4. Use parameter's annotation of entrance method to generate aggregation entrance.
for (Parameter parameter : entranceMethod.getParameters()) {
Annotation[] parameterAnnotations = parameter.getAnnotations();
if (parameterAnnotations == null || parameterAnnotations.length == 0) {
throw new IllegalArgumentException("Entrance method:" + entranceMethod + " doesn't include the annotation.");
}
Annotation annotation = parameterAnnotations[0];
if (annotation instanceof SourceFrom) {
entryMethod.addArg("source." + ClassMethodUtil.toGetMethod(result.getSourceAttribute()) + "()");
} else if (annotation instanceof ConstOne) {
entryMethod.addArg("1");
} else if (annotation instanceof Expression) {
entryMethod.addArg("new " + parameter.getType().getName() + "()");
} else if (annotation instanceof ExpressionArg0) {
if (result.getFuncConditionExpressions().size() == 1) {
ConditionExpression conditionExpression = result.getFuncConditionExpressions().get(0);
if ("booleanMatch".equals(conditionExpression.getExpressionType())) {
entryMethod.addArg("source." + ClassMethodUtil.toIsMethod(conditionExpression.getAttribute()) + "()");
} else if ("stringMatch".equals(conditionExpression.getExpressionType())) {
entryMethod.addArg("source." + ClassMethodUtil.toGetMethod(conditionExpression.getAttribute()) + "()");
} else {
throw new IllegalArgumentException("Entrance method:" + entranceMethod + " argument has @ExpressionArg0, but expression type is not supported");
}
} else {
throw new IllegalArgumentException("Entrance method:" + entranceMethod + " argument has @ExpressionArg0, but can't find funcParamExpression.");
}
} else if (annotation instanceof ExpressionArg1) {
if (result.getFuncConditionExpressions().size() == 1) {
ConditionExpression conditionExpression = result.getFuncConditionExpressions().get(0);
entryMethod.addArg(conditionExpression.getValue());
} else {
throw new IllegalArgumentException("Entrance method:" + entranceMethod + " argument has @ExpressionArg0, but can't find funcParamExpression.");
}
} else if (annotation instanceof Arg) {
entryMethod.addArg(result.getNextFuncArg());
} else {
throw new IllegalArgumentException("Entrance method:" + entranceMethod + " doesn't the expected annotation.");
}
}
// 5. Get all column declared in Indicator class.
c = indicatorClass;
while (!c.equals(Object.class)) {
for (Field field : c.getDeclaredFields()) {
Column column = field.getAnnotation(Column.class);
if (column != null) {
result.addPersistentField(field.getName(), column.columnName(), field.getType());
}
}
c = c.getSuperclass();
}
// 6. Based on Source, generate default columns
List<SourceColumn> columns = SourceColumnsFactory.getColumns(result.getSourceName());
result.setFieldsFromSource(columns);
result.generateSerializeFields();
return result;
}
}
......@@ -16,19 +16,22 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.generated.serviceinstancerelation;
package org.apache.skywalking.oal.tool.parser;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.source.*;
import java.util.*;
import lombok.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceRelationDispatcher implements SourceDispatcher<ServiceInstanceRelation> {
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class EntryMethod {
private String methodName;
@Override public void dispatch(ServiceInstanceRelation source) {
}
private List<String> argsExpressions;
public void addArg(String expression) {
if (argsExpressions == null) {
argsExpressions = new LinkedList<>();
}
argsExpressions.add(expression);
}
}
/*
* 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.oal.tool.parser;
import lombok.*;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class FilterExpression {
private String expressionObject;
private String left;
private String right;
}
/*
* 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.oal.tool.parser;
import com.google.common.collect.ImmutableSet;
import com.google.common.reflect.ClassPath;
import java.io.IOException;
import java.util.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorFunction;
public class Indicators {
private static Map<String, Class<? extends Indicator>> REGISTER = new HashMap<>();
public static void init() throws IOException {
ClassPath classpath = ClassPath.from(Indicators.class.getClassLoader());
ImmutableSet<ClassPath.ClassInfo> classes = classpath.getTopLevelClassesRecursive("org.apache.skywalking");
for (ClassPath.ClassInfo classInfo : classes) {
Class<?> aClass = classInfo.load();
if (aClass.isAnnotationPresent(IndicatorFunction.class)) {
IndicatorFunction indicatorFunction = aClass.getAnnotation(IndicatorFunction.class);
REGISTER.put(indicatorFunction.functionName(), (Class<? extends Indicator>)aClass);
}
}
}
public static Class<? extends Indicator> find(String functionName) {
String func = functionName;
Class<? extends Indicator> indicatorClass = REGISTER.get(func);
if (indicatorClass == null) {
throw new IllegalArgumentException("Can't find indicator.");
}
return indicatorClass;
}
}
/*
* 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.oal.tool.parser;
import java.util.List;
import org.antlr.v4.runtime.misc.NotNull;
import org.apache.skywalking.oal.tool.grammar.*;
public class OALListener extends OALParserBaseListener {
private List<AnalysisResult> results;
private AnalysisResult current;
private ConditionExpression conditionExpression;
public OALListener(List<AnalysisResult> results) {
this.results = results;
}
@Override
public void enterAggregationStatement(@NotNull OALParser.AggregationStatementContext ctx) {
current = new AnalysisResult();
}
@Override
public void exitAggregationStatement(@NotNull OALParser.AggregationStatementContext ctx) {
DeepAnalysis deepAnalysis = new DeepAnalysis();
results.add(deepAnalysis.analysis(current));
current = null;
}
@Override public void enterSource(OALParser.SourceContext ctx) {
current.setSourceName(ctx.getText());
}
@Override
public void enterSourceAttribute(OALParser.SourceAttributeContext ctx) {
current.setSourceAttribute(ctx.getText());
}
@Override public void enterVariable(OALParser.VariableContext ctx) {
}
@Override public void exitVariable(OALParser.VariableContext ctx) {
current.setVarName(ctx.getText());
current.setMetricName(metricNameFormat(ctx.getText()));
current.setTableName(ctx.getText().toLowerCase());
}
@Override public void enterFunctionName(OALParser.FunctionNameContext ctx) {
current.setAggregationFunctionName(ctx.getText());
}
@Override public void enterFilterStatement(OALParser.FilterStatementContext ctx) {
conditionExpression = new ConditionExpression();
}
@Override public void exitFilterStatement(OALParser.FilterStatementContext ctx) {
current.addFilterExpressionsParserResult(conditionExpression);
conditionExpression = null;
}
@Override public void enterFuncParamExpression(OALParser.FuncParamExpressionContext ctx) {
conditionExpression = new ConditionExpression();
}
@Override public void exitFuncParamExpression(OALParser.FuncParamExpressionContext ctx) {
current.addFuncConditionExpression(conditionExpression);
conditionExpression = null;
}
/////////////
// Expression
////////////
@Override public void enterConditionAttribute(OALParser.ConditionAttributeContext ctx) {
conditionExpression.setAttribute(ctx.getText());
}
@Override public void enterBooleanMatch(OALParser.BooleanMatchContext ctx) {
conditionExpression.setExpressionType("booleanMatch");
}
@Override public void enterStringMatch(OALParser.StringMatchContext ctx) {
conditionExpression.setExpressionType("stringMatch");
}
@Override public void enterBooleanConditionValue(OALParser.BooleanConditionValueContext ctx) {
conditionExpression.setValue(ctx.getText());
}
@Override public void enterStringConditionValue(OALParser.StringConditionValueContext ctx) {
conditionExpression.setValue(ctx.getText());
}
@Override public void enterEnumConditionValue(OALParser.EnumConditionValueContext ctx) {
conditionExpression.setValue(ctx.getText());
}
/////////////
// Expression end.
////////////
@Override public void enterLiteralExpression(OALParser.LiteralExpressionContext ctx) {
current.addFuncArg(ctx.getText());
}
private String metricNameFormat(String source) {
source = firstLetterUpper(source);
int idx;
while ((idx = source.indexOf("_")) > -1) {
source = source.substring(0, idx) + firstLetterUpper(source.substring(idx + 1));
}
return source;
}
private String firstLetterUpper(String source) {
return source.substring(0, 1).toUpperCase() + source.substring(1);
}
}
/*
* 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.oal.tool.parser;
import java.util.*;
public class PersistenceColumns {
private List<PersistenceField> stringFields = new LinkedList<>();
private List<PersistenceField> longFields = new LinkedList<>();
private List<PersistenceField> doubleFields = new LinkedList<>();
private List<PersistenceField> intFields = new LinkedList<>();
private List<PersistenceField> intLongValuePairListFields = new LinkedList<>();
public void addStringField(String fieldName) {
stringFields.add(new PersistenceField(fieldName));
}
public void addLongField(String fieldName) {
longFields.add(new PersistenceField(fieldName));
}
public void addDoubleField(String fieldName) {
doubleFields.add(new PersistenceField(fieldName));
}
public void addIntField(String fieldName) {
intFields.add(new PersistenceField(fieldName));
}
public void addIntLongValuePairelistField(String fieldName) {
intLongValuePairListFields.add(new PersistenceField(fieldName));
}
public List<PersistenceField> getStringFields() {
return stringFields;
}
public List<PersistenceField> getLongFields() {
return longFields;
}
public List<PersistenceField> getDoubleFields() {
return doubleFields;
}
public List<PersistenceField> getIntFields() {
return intFields;
}
public List<PersistenceField> getIntLongValuePairListFields() {
return intLongValuePairListFields;
}
}
......@@ -16,19 +16,21 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.generated.serviceinstancejvmmemorypool;
package org.apache.skywalking.oal.tool.parser;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.source.*;
import lombok.*;
import org.apache.skywalking.oal.tool.util.ClassMethodUtil;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMMemoryPoolDispatcher implements SourceDispatcher<ServiceInstanceJVMMemoryPool> {
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class PersistenceField {
private String fieldName;
private String setter;
private String getter;
@Override public void dispatch(ServiceInstanceJVMMemoryPool source) {
public PersistenceField(String fieldName) {
this.fieldName = fieldName;
this.setter = ClassMethodUtil.toSetMethod(fieldName);
this.getter = ClassMethodUtil.toGetMethod(fieldName);
}
}
/*
* 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.oal.tool.parser;
import java.io.IOException;
import java.util.*;
import org.antlr.v4.runtime.*;
import org.antlr.v4.runtime.tree.*;
import org.apache.skywalking.oal.tool.grammar.*;
public class ScriptParser {
private OALLexer lexer;
private ScriptParser() {
}
public static ScriptParser createFromFile(String scriptFilepath) throws IOException {
ScriptParser parser = new ScriptParser();
parser.lexer = new OALLexer(CharStreams.fromFileName(scriptFilepath));
return parser;
}
public static ScriptParser createFromScriptText(String script) throws IOException {
ScriptParser parser = new ScriptParser();
parser.lexer = new OALLexer(CharStreams.fromString(script));
return parser;
}
public List<AnalysisResult> parse() throws IOException {
List<AnalysisResult> results = new LinkedList<>();
CommonTokenStream tokens = new CommonTokenStream(lexer);
OALParser parser = new OALParser(tokens);
ParseTree tree = parser.root();
ParseTreeWalker walker = new ParseTreeWalker();
walker.walk(new OALListener(results), tree);
return results;
}
public void close() {
}
}
/*
* 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.oal.tool.parser;
import lombok.*;
import org.apache.skywalking.oal.tool.util.ClassMethodUtil;
@Getter(AccessLevel.PUBLIC)
@Setter(AccessLevel.PUBLIC)
public class SourceColumn {
private String fieldName;
private String columnName;
private Class<?> type;
private String typeName;
private boolean isID;
private String fieldSetter;
private String fieldGetter;
public SourceColumn(String fieldName, String columnName, Class<?> type, boolean isID) {
this.fieldName = fieldName;
this.columnName = columnName;
this.type = type;
this.typeName = type.getName();
this.isID = isID;
this.fieldGetter = ClassMethodUtil.toGetMethod(fieldName);
this.fieldSetter = ClassMethodUtil.toSetMethod(fieldName);
}
@Override public String toString() {
return "SourceColumn{" +
"fieldName='" + fieldName + '\'' +
", columnName='" + columnName + '\'' +
", type=" + type +
", isID=" + isID +
'}';
}
}
/*
* 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.oal.tool.parser;
import java.util.*;
public class SourceColumnsFactory {
public static List<SourceColumn> getColumns(String source) {
List<SourceColumn> columnList;
SourceColumn idColumn;
switch (source) {
case "All":
return new LinkedList<>();
case "Service":
columnList = new LinkedList<>();
// Service id;
idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
columnList.add(idColumn);
return columnList;
case "ServiceInstance":
columnList = new LinkedList<>();
// Service instance id;
idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
columnList.add(idColumn);
SourceColumn serviceIdColumn = new SourceColumn("serviceId", "service_id", int.class, false);
columnList.add(serviceIdColumn);
return columnList;
case "Endpoint":
columnList = new LinkedList<>();
// Endpoint id;
idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
columnList.add(idColumn);
serviceIdColumn = new SourceColumn("serviceId", "service_id", int.class, false);
columnList.add(serviceIdColumn);
SourceColumn serviceInstanceIdColumn = new SourceColumn("serviceInstanceId", "service_instance_id", int.class, false);
columnList.add(serviceInstanceIdColumn);
return columnList;
case "ServiceInstanceJVMCPU":
case "ServiceInstanceJVMMemory":
case "ServiceInstanceJVMMemoryPool":
case "ServiceInstanceJVMGC":
columnList = new LinkedList<>();
// Service instance id;
idColumn = new SourceColumn("entityId", "entity_id", String.class, true);
columnList.add(idColumn);
serviceInstanceIdColumn = new SourceColumn("serviceInstanceId", "service_instance_id", int.class, false);
columnList.add(serviceInstanceIdColumn);
return columnList;
case "ServiceRelation":
columnList = new LinkedList<>();
SourceColumn sourceService = new SourceColumn("entityId", "entity_id", String.class, true);
columnList.add(sourceService);
return columnList;
case "ServiceInstanceRelation":
columnList = new LinkedList<>();
sourceService = new SourceColumn("entityId", "entity_id", String.class, true);
columnList.add(sourceService);
sourceService = new SourceColumn("sourceServiceId", "source_service_id", int.class, false);
columnList.add(sourceService);
SourceColumn destService = new SourceColumn("destServiceId", "destServiceId", int.class, false);
columnList.add(destService);
return columnList;
case "EndpointRelation":
columnList = new LinkedList<>();
SourceColumn sourceEndpointColumn = new SourceColumn("entityId", "entity_id", String.class, true);
columnList.add(sourceEndpointColumn);
sourceService = new SourceColumn("serviceId", "service_id", int.class, false);
columnList.add(sourceService);
destService = new SourceColumn("childServiceId", "child_service_id", int.class, false);
columnList.add(destService);
SourceColumn sourceServiceInstance = new SourceColumn("serviceInstanceId", "service_instance_id", int.class, false);
columnList.add(sourceServiceInstance);
SourceColumn destServiceInstance = new SourceColumn("childServiceInstanceId", "child_service_instance_id", int.class, false);
columnList.add(destServiceInstance);
return columnList;
default:
throw new IllegalArgumentException("Illegal source :" + source);
}
}
}
/*
* 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.oal.tool.util;
public class ClassMethodUtil {
public static String toGetMethod(String attribute) {
return "get" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
}
public static String toSetMethod(String attribute) {
return "set" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
}
public static String toIsMethod(String attribute) {
return "is" + attribute.substring(0, 1).toUpperCase() + attribute.substring(1);
}
}
......@@ -19,7 +19,15 @@
package org.apache.skywalking.oap.server.core.analysis.generated.all;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (allIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list allIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
......@@ -30,60 +38,29 @@ import org.apache.skywalking.oap.server.core.source.*;
public class AllDispatcher implements SourceDispatcher<All> {
@Override public void dispatch(All source) {
doAllP99(source);
doAllP95(source);
doAllP90(source);
doAllP75(source);
doAllP50(source);
doAllHeatmap(source);
<#list allIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
private void doAllP99(All source) {
AllP99Indicator indicator = new AllP99Indicator();
<#list allIndicators as indicator>
private void do${indicator.metricName}(All source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doAllP95(All source) {
AllP95Indicator indicator = new AllP95Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doAllP90(All source) {
AllP90Indicator indicator = new AllP90Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doAllP75(All source) {
AllP75Indicator indicator = new AllP75Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doAllP50(All source) {
AllP50Indicator indicator = new AllP50Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doAllHeatmap(All source) {
AllHeatmapIndicator indicator = new AllHeatmapIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.combine(source.getLatency(), 100, 20);
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.endpoint;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (endpointIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list endpointIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class EndpointDispatcher implements SourceDispatcher<Endpoint> {
@Override public void dispatch(Endpoint source) {
<#list endpointIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list endpointIndicators as indicator>
private void do${indicator.metricName}(Endpoint source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
......@@ -19,8 +19,15 @@
package org.apache.skywalking.oap.server.core.analysis.generated.endpointrelation;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (endpointRelationIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list endpointRelationIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
......@@ -31,40 +38,29 @@ import org.apache.skywalking.oap.server.core.source.*;
public class EndpointRelationDispatcher implements SourceDispatcher<EndpointRelation> {
@Override public void dispatch(EndpointRelation source) {
doEndpointRelationCpm(source);
doEndpointRelationRespTime(source);
<#list endpointRelationIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
private void doEndpointRelationCpm(EndpointRelation source) {
EndpointRelationCpmIndicator indicator = new EndpointRelationCpmIndicator();
<#list endpointRelationIndicators as indicator>
private void do${indicator.metricName}(EndpointRelation source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
if (!new EqualMatch().setLeft(source.getDetectPoint()).setRight(DetectPoint.SERVER).match()) {
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setChildServiceId(source.getChildServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.setChildServiceInstanceId(source.getChildServiceInstanceId());
indicator.combine(1);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointRelationRespTime(EndpointRelation source) {
EndpointRelationRespTimeIndicator indicator = new EndpointRelationRespTimeIndicator();
if (!new EqualMatch().setLeft(source.getDetectPoint()).setRight(DetectPoint.SERVER).match()) {
return;
}
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setChildServiceId(source.getChildServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.setChildServiceInstanceId(source.getChildServiceInstanceId());
indicator.combine(source.getRpcLatency(), 1);
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.${packageName};
import java.util.*;
<#if (fieldsFromSource?size>0) >
import lombok.*;
</#if>
<#list fieldsFromSource as sourceField>
<#if sourceField.isID()>
import org.apache.skywalking.oap.server.core.Const;
<#break>
</#if>
</#list>
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "${tableName}", builder = ${metricName}Indicator.Builder.class, source = Scope.${sourceName})
public class ${metricName}Indicator extends ${indicatorClassName} implements AlarmSupported {
<#list fieldsFromSource as sourceField>
@Setter @Getter @Column(columnName = "${sourceField.columnName}") <#if sourceField.isID()>@IDColumn</#if> private ${sourceField.typeName} ${sourceField.fieldName};
</#list>
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
<#list fieldsFromSource as sourceField>
<#if sourceField.isID()>
<#if sourceField.getTypeName() == "java.lang.String">
splitJointId += Const.ID_SPLIT + ${sourceField.fieldName};
<#else>
splitJointId += Const.ID_SPLIT + String.valueOf(${sourceField.fieldName});
</#if>
</#if>
</#list>
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
<#list fieldsFromSource as sourceField>
<#if sourceField.isID()>
<#if sourceField.getTypeName() == "java.lang.String">
result = 31 * result + ${sourceField.fieldName}.hashCode();
<#else>
result += Const.ID_SPLIT + ${sourceField.fieldName};
</#if>
</#if>
</#list>
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
<#list fieldsFromSource as sourceField>
<#if sourceField.isID()>
<#if sourceField.getTypeName() == "java.lang.String">
result = 31 * result + ${sourceField.fieldName}.hashCode();
<#else>
result += Const.ID_SPLIT + ${sourceField.fieldName};
</#if>
</#if>
</#list>
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
${metricName}Indicator indicator = (${metricName}Indicator)obj;
<#list fieldsFromSource as sourceField>
<#if sourceField.isID()>
<#if sourceField.getTypeName() == "java.lang.String">
if (!${sourceField.fieldName}.equals(indicator.${sourceField.fieldName}))
<#else>
if (${sourceField.fieldName} != indicator.${sourceField.fieldName})
</#if>
return false;
</#if>
</#list>
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
<#list serializeFields.stringFields as field>
remoteBuilder.addDataStrings(${field.getter}());
</#list>
<#list serializeFields.longFields as field>
remoteBuilder.addDataLongs(${field.getter}());
</#list>
<#list serializeFields.doubleFields as field>
remoteBuilder.addDataDoubles(${field.getter}());
</#list>
<#list serializeFields.intFields as field>
remoteBuilder.addDataIntegers(${field.getter}());
</#list>
<#list serializeFields.intLongValuePairListFields as field>
${field.getter}().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
</#list>
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
<#list serializeFields.stringFields as field>
${field.setter}(remoteData.getDataStrings(${field?index}));
</#list>
<#list serializeFields.longFields as field>
${field.setter}(remoteData.getDataLongs(${field?index}));
</#list>
<#list serializeFields.doubleFields as field>
${field.setter}(remoteData.getDataDoubles(${field?index}));
</#list>
<#list serializeFields.intFields as field>
${field.setter}(remoteData.getDataIntegers(${field?index}));
</#list>
<#list serializeFields.intLongValuePairListFields as field>
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
</#list>
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("${varName}", Scope.${sourceName}<#if (fieldsFromSource?size>0) ><#list fieldsFromSource as field><#if field.isID()>, ${field.fieldName}</#if></#list></#if>);
}
@Override
public Indicator toHour() {
${metricName}Indicator indicator = new ${metricName}Indicator();
<#list fieldsFromSource as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInHour());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
</#if>
</#list>
<#list persistentFields as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInHour());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
</#if>
</#list>
return indicator;
}
@Override
public Indicator toDay() {
${metricName}Indicator indicator = new ${metricName}Indicator();
<#list fieldsFromSource as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInDay());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
</#if>
</#list>
<#list persistentFields as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInDay());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
</#if>
</#list>
return indicator;
}
@Override
public Indicator toMonth() {
${metricName}Indicator indicator = new ${metricName}Indicator();
<#list fieldsFromSource as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInMonth());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
</#if>
</#list>
<#list persistentFields as field>
<#if field.columnName == "time_bucket">
indicator.setTimeBucket(toTimeBucketInMonth());
<#elseif field.typeName == "java.lang.String" || field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(this.${field.fieldGetter}());
<#else>
${field.typeName} newValue = new ${field.typeName}();
newValue.copyFrom(this.${field.fieldGetter}());
indicator.${field.fieldSetter}(newValue);
</#if>
</#list>
return indicator;
}
public static class Builder implements StorageBuilder<${metricName}Indicator> {
@Override public Map<String, Object> data2Map(${metricName}Indicator storageData) {
Map<String, Object> map = new HashMap<>();
<#list fieldsFromSource as field>
map.put("${field.columnName}", storageData.${field.fieldGetter}());
</#list>
<#list persistentFields as field>
map.put("${field.columnName}", storageData.${field.fieldGetter}());
</#list>
return map;
}
@Override public ${metricName}Indicator map2Data(Map<String, Object> dbMap) {
${metricName}Indicator indicator = new ${metricName}Indicator();
<#list fieldsFromSource as field>
<#if field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value());
<#elseif field.typeName == "java.lang.String">
indicator.${field.fieldSetter}((String)dbMap.get("${field.columnName}"));
<#else>
indicator.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}")));
</#if>
</#list>
<#list persistentFields as field>
<#if field.typeName == "long" || field.typeName == "int" || field.typeName == "double" || field.typeName == "float">
indicator.${field.fieldSetter}(((Number)dbMap.get("${field.columnName}")).${field.typeName}Value());
<#elseif field.typeName == "java.lang.String">
indicator.${field.fieldSetter}((String)dbMap.get("${field.columnName}"));
<#else>
indicator.${field.fieldSetter}(new ${field.typeName}((String)dbMap.get("${field.columnName}")));
</#if>
</#list>
return indicator;
}
}
}
/*
* 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.analysis.generated.service;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceDispatcher implements SourceDispatcher<Service> {
@Override public void dispatch(Service source) {
<#list serviceIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list serviceIndicators as indicator>
private void do${indicator.metricName}(Service source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
......@@ -19,7 +19,15 @@
package org.apache.skywalking.oap.server.core.analysis.generated.serviceinstance;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceInstanceIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceInstanceIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
......@@ -30,39 +38,29 @@ import org.apache.skywalking.oap.server.core.source.*;
public class ServiceInstanceDispatcher implements SourceDispatcher<ServiceInstance> {
@Override public void dispatch(ServiceInstance source) {
doServiceInstanceSla(source);
doServiceInstanceRespTime(source);
doServiceInstanceCpm(source);
<#list serviceInstanceIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
private void doServiceInstanceSla(ServiceInstance source) {
ServiceInstanceSlaIndicator indicator = new ServiceInstanceSlaIndicator();
<#list serviceInstanceIndicators as indicator>
private void do${indicator.metricName}(ServiceInstance source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.combine(new org.apache.skywalking.oap.server.core.analysis.indicator.expression.EqualMatch(), source.isStatus(), true);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doServiceInstanceRespTime(ServiceInstance source) {
ServiceInstanceRespTimeIndicator indicator = new ServiceInstanceRespTimeIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.combine(source.getLatency(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doServiceInstanceCpm(ServiceInstance source) {
ServiceInstanceCpmIndicator indicator = new ServiceInstanceCpmIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.combine(1);
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.serviceinstancejvmcpu;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceInstanceJVMCPUIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceInstanceJVMCPUIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMCPUDispatcher implements SourceDispatcher<ServiceInstanceJVMCPU> {
@Override public void dispatch(ServiceInstanceJVMCPU source) {
<#list serviceInstanceJVMCPUIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list serviceInstanceJVMCPUIndicators as indicator>
private void do${indicator.metricName}(ServiceInstanceJVMCPU source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.serviceinstancejvmgc;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceInstanceJVMGCIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceInstanceJVMGCIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMGCDispatcher implements SourceDispatcher<ServiceInstanceJVMGC> {
@Override public void dispatch(ServiceInstanceJVMGC source) {
<#list serviceInstanceJVMGCIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list serviceInstanceJVMGCIndicators as indicator>
private void do${indicator.metricName}(ServiceInstanceJVMGC source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.serviceinstancejvmmemory;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceInstanceJVMMemoryIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceInstanceJVMMemoryIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMMemoryDispatcher implements SourceDispatcher<ServiceInstanceJVMMemory> {
@Override public void dispatch(ServiceInstanceJVMMemory source) {
<#list serviceInstanceJVMMemoryIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list serviceInstanceJVMMemoryIndicators as indicator>
private void do${indicator.metricName}(ServiceInstanceJVMMemory source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.serviceinstancejvmmemorypool;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceInstanceJVMMemoryPoolIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceInstanceJVMMemoryPoolIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMMemoryPoolDispatcher implements SourceDispatcher<ServiceInstanceJVMMemoryPool> {
@Override public void dispatch(ServiceInstanceJVMMemoryPool source) {
<#list serviceInstanceJVMMemoryPoolIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list serviceInstanceJVMMemoryPoolIndicators as indicator>
private void do${indicator.metricName}(ServiceInstanceJVMMemoryPool source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.serviceinstancerelation;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceInstanceRelationIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceInstanceRelationIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceRelationDispatcher implements SourceDispatcher<ServiceInstanceRelation> {
@Override public void dispatch(ServiceInstanceRelation source) {
<#list serviceInstanceRelationIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list serviceInstanceRelationIndicators as indicator>
private void do${indicator.metricName}(ServiceInstanceRelation source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.analysis.generated.servicerelation;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
<#if (serviceRelationIndicators?size>0)>
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
<#list serviceRelationIndicators as indicator>
<#if indicator.filterExpressions??>
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
<#break>
</#if>
</#list>
</#if>
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class ServiceRelationDispatcher implements SourceDispatcher<ServiceRelation> {
@Override public void dispatch(ServiceRelation source) {
<#list serviceRelationIndicators as indicator>
do${indicator.metricName}(source);
</#list>
}
<#list serviceRelationIndicators as indicator>
private void do${indicator.metricName}(ServiceRelation source) {
${indicator.metricName}Indicator indicator = new ${indicator.metricName}Indicator();
<#if indicator.filterExpressions??>
<#list indicator.filterExpressions as filterExpression>
if (!new ${filterExpression.expressionObject}().setLeft(${filterExpression.left}).setRight(${filterExpression.right}).match()) {
return;
}
</#list>
</#if>
indicator.setTimeBucket(source.getTimeBucket());
<#list indicator.fieldsFromSource as field>
indicator.${field.fieldSetter}(source.${field.fieldGetter}());
</#list>
indicator.${indicator.entryMethod.methodName}(<#list indicator.entryMethod.argsExpressions as arg>${arg}<#if arg_has_next>, </#if></#list>);
IndicatorProcess.INSTANCE.in(indicator);
}
</#list>
}
/*
* 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.oal.tool.output;
import freemarker.template.TemplateException;
import java.io.*;
import java.util.*;
import org.apache.skywalking.oal.tool.parser.*;
import org.junit.*;
public class FileGeneratorTest {
private AnalysisResult buildResult() {
AnalysisResult result = new AnalysisResult();
result.setVarName("generate_indicator");
result.setSourceName("Service");
result.setPackageName("service.serviceavg");
result.setTableName("service_avg");
result.setSourceAttribute("latency");
result.setMetricName("ServiceAvg");
result.setAggregationFunctionName("avg");
result.setIndicatorClassName("LongAvgIndicator");
FilterExpression expression = new FilterExpression();
expression.setExpressionObject("EqualMatch");
expression.setLeft("source.getName()");
expression.setRight("\"/service/prod/save\"");
result.addFilterExpressions(expression);
EntryMethod method = new EntryMethod();
method.setMethodName("combine");
method.setArgsExpressions(new LinkedList<>());
method.getArgsExpressions().add("source.getLatency()");
method.getArgsExpressions().add("1");
result.setEntryMethod(method);
result.addPersistentField("summation", "summation", long.class);
result.addPersistentField("count", "count", int.class);
result.addPersistentField("value", "value", long.class);
result.addPersistentField("timeBucket", "time_bucket", long.class);
result.addPersistentField("stringField", "string_field", String.class);
result.setFieldsFromSource(SourceColumnsFactory.getColumns("Service"));
result.generateSerializeFields();
return result;
}
@Test
public void testGenerateIndicatorImplementor() throws IOException, TemplateException {
AnalysisResult result = buildResult();
List<AnalysisResult> results = new LinkedList<>();
results.add(result);
FileGenerator fileGenerator = new FileGenerator(results, ".");
StringWriter writer = new StringWriter();
fileGenerator.generateIndicatorImplementor(result, writer);
Assert.assertEquals(readExpectedFile("IndicatorImplementorExpected.java"), writer.toString());
// fileGenerator.generateIndicatorImplementor(result, new OutputStreamWriter(System.out));
}
@Test
public void testServiceDispatcher() throws IOException, TemplateException {
AnalysisResult result = buildResult();
List<AnalysisResult> results = new LinkedList<>();
results.add(result);
FileGenerator fileGenerator = new FileGenerator(results, ".");
StringWriter writer = new StringWriter();
fileGenerator.generateServiceDispatcher(writer);
Assert.assertEquals(readExpectedFile("ServiceDispatcherExpected.java"), writer.toString());
//fileGenerator.generateServiceDispatcher(new OutputStreamWriter(System.out));
}
private String readExpectedFile(String filename) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(FileGenerator.class.getResourceAsStream("/expectedFiles/" + filename)));
StringBuilder fileContent = new StringBuilder();
String sCurrentLine;
while ((sCurrentLine = reader.readLine()) != null) {
fileContent.append(sCurrentLine).append("\n");
}
return fileContent.toString();
}
}
/*
* 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.oal.tool.parser;
import java.io.IOException;
import java.util.List;
import org.junit.*;
public class DeepAnalysisTest {
@BeforeClass
public static void init() throws IOException {
Indicators.init();
}
@Test
public void testServiceAnalysis() {
AnalysisResult result = new AnalysisResult();
result.setSourceName("Service");
result.setPackageName("service.serviceavg");
result.setSourceAttribute("latency");
result.setMetricName("ServiceAvg");
result.setAggregationFunctionName("longAvg");
DeepAnalysis analysis = new DeepAnalysis();
result = analysis.analysis(result);
EntryMethod method = result.getEntryMethod();
Assert.assertEquals("combine", method.getMethodName());
Assert.assertEquals("source.getLatency()", method.getArgsExpressions().get(0));
Assert.assertEquals("1", method.getArgsExpressions().get(1));
List<SourceColumn> source = result.getFieldsFromSource();
Assert.assertEquals(1, source.size());
List<DataColumn> persistentFields = result.getPersistentFields();
Assert.assertEquals(4, persistentFields.size());
}
@Test
public void testEndpointAnalysis() {
AnalysisResult result = new AnalysisResult();
result.setSourceName("Endpoint");
result.setPackageName("endpoint.endpointavg");
result.setSourceAttribute("latency");
result.setMetricName("EndpointAvg");
result.setAggregationFunctionName("longAvg");
DeepAnalysis analysis = new DeepAnalysis();
result = analysis.analysis(result);
EntryMethod method = result.getEntryMethod();
Assert.assertEquals("combine", method.getMethodName());
Assert.assertEquals("source.getLatency()", method.getArgsExpressions().get(0));
Assert.assertEquals("1", method.getArgsExpressions().get(1));
List<SourceColumn> source = result.getFieldsFromSource();
Assert.assertEquals(3, source.size());
List<DataColumn> persistentFields = result.getPersistentFields();
Assert.assertEquals(4, persistentFields.size());
}
@Test
public void testFilterAnalysis() {
AnalysisResult result = new AnalysisResult();
result.setSourceName("Endpoint");
result.setPackageName("endpoint.endpointavg");
result.setSourceAttribute("latency");
result.setMetricName("EndpointAvg");
result.setAggregationFunctionName("longAvg");
ConditionExpression expression = new ConditionExpression();
expression.setExpressionType("stringMatch");
expression.setAttribute("name");
expression.setValue("\"/service/prod/save\"");
result.addFilterExpressionsParserResult(expression);
DeepAnalysis analysis = new DeepAnalysis();
result = analysis.analysis(result);
EntryMethod method = result.getEntryMethod();
Assert.assertEquals("combine", method.getMethodName());
Assert.assertEquals("source.getLatency()", method.getArgsExpressions().get(0));
Assert.assertEquals("1", method.getArgsExpressions().get(1));
List<SourceColumn> source = result.getFieldsFromSource();
Assert.assertEquals(3, source.size());
List<DataColumn> persistentFields = result.getPersistentFields();
Assert.assertEquals(4, persistentFields.size());
List<FilterExpression> filterExpressions = result.getFilterExpressions();
Assert.assertEquals(1, filterExpressions.size());
FilterExpression filterExpression = filterExpressions.get(0);
Assert.assertEquals("EqualMatch", filterExpression.getExpressionObject());
Assert.assertEquals("source.getName()", filterExpression.getLeft());
Assert.assertEquals("\"/service/prod/save\"", filterExpression.getRight());
}
}
/*
* 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.oal.tool.parser;
import java.io.IOException;
import java.util.List;
import org.junit.*;
public class ScriptParserTest {
@BeforeClass
public static void init() throws IOException {
Indicators.init();
}
@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()"
);
List<AnalysisResult> results = parser.parse();
Assert.assertEquals(2, results.size());
AnalysisResult endpointAvg = results.get(0);
Assert.assertEquals("EndpointAvg", endpointAvg.getMetricName());
Assert.assertEquals("Endpoint", endpointAvg.getSourceName());
Assert.assertEquals("latency", endpointAvg.getSourceAttribute());
Assert.assertEquals("longAvg", endpointAvg.getAggregationFunctionName());
AnalysisResult serviceAvg = results.get(1);
Assert.assertEquals("ServiceAvg", serviceAvg.getMetricName());
Assert.assertEquals("Service", serviceAvg.getSourceName());
Assert.assertEquals("latency", serviceAvg.getSourceAttribute());
Assert.assertEquals("longAvg", serviceAvg.getAggregationFunctionName());
}
@Test
public void testParse2() throws IOException {
ScriptParser parser = ScriptParser.createFromScriptText(
"Endpoint_percent = from(Endpoint.*).percent(status == true);"
);
List<AnalysisResult> results = parser.parse();
AnalysisResult endpointPercent = results.get(0);
Assert.assertEquals("EndpointPercent", endpointPercent.getMetricName());
Assert.assertEquals("Endpoint", endpointPercent.getSourceName());
Assert.assertEquals("*", endpointPercent.getSourceAttribute());
Assert.assertEquals("percent", endpointPercent.getAggregationFunctionName());
EntryMethod entryMethod = endpointPercent.getEntryMethod();
List<String> methodArgsExpressions = entryMethod.getArgsExpressions();
Assert.assertEquals(3, methodArgsExpressions.size());
Assert.assertEquals("source.isStatus()", methodArgsExpressions.get(1));
Assert.assertEquals("true", methodArgsExpressions.get(2));
}
@Test
public void testParse3() throws IOException {
ScriptParser parser = ScriptParser.createFromScriptText(
"Endpoint_percent = from(Endpoint.*).filter(status == true).filter(name == \"/product/abc\").longAvg();"
);
List<AnalysisResult> results = parser.parse();
AnalysisResult endpointPercent = results.get(0);
Assert.assertEquals("EndpointPercent", endpointPercent.getMetricName());
Assert.assertEquals("Endpoint", endpointPercent.getSourceName());
Assert.assertEquals("*", endpointPercent.getSourceAttribute());
Assert.assertEquals("longAvg", endpointPercent.getAggregationFunctionName());
List<ConditionExpression> expressions = endpointPercent.getFilterExpressionsParserResult();
Assert.assertEquals(2, expressions.size());
ConditionExpression booleanMatchExp = expressions.get(0);
Assert.assertEquals("status", booleanMatchExp.getAttribute());
Assert.assertEquals("true", booleanMatchExp.getValue());
Assert.assertEquals("booleanMatch", booleanMatchExp.getExpressionType());
ConditionExpression stringMatchExp = expressions.get(1);
Assert.assertEquals("name", stringMatchExp.getAttribute());
Assert.assertEquals("\"/product/abc\"", stringMatchExp.getValue());
Assert.assertEquals("stringMatch", stringMatchExp.getExpressionType());
}
}
......@@ -16,7 +16,7 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.generated.servicerelation;
package org.apache.skywalking.oap.server.core.analysis.generated.service.serviceavg;
import java.util.*;
import lombok.*;
......@@ -38,8 +38,8 @@ import org.apache.skywalking.oap.server.core.source.Scope;
*/
@IndicatorType
@StreamData
@StorageEntity(name = "service_relation_client_resp_time", builder = ServiceRelationClientRespTimeIndicator.Builder.class, source = Scope.ServiceRelation)
public class ServiceRelationClientRespTimeIndicator extends LongAvgIndicator implements AlarmSupported {
@StorageEntity(name = "service_avg", builder = ServiceAvgIndicator.Builder.class, source = Scope.Service)
public class ServiceAvgIndicator extends LongAvgIndicator implements AlarmSupported {
@Setter @Getter @Column(columnName = "entity_id") @IDColumn private java.lang.String entityId;
......@@ -70,7 +70,7 @@ public class ServiceRelationClientRespTimeIndicator extends LongAvgIndicator imp
if (getClass() != obj.getClass())
return false;
ServiceRelationClientRespTimeIndicator indicator = (ServiceRelationClientRespTimeIndicator)obj;
ServiceAvgIndicator indicator = (ServiceAvgIndicator)obj;
if (!entityId.equals(indicator.entityId))
return false;
......@@ -83,6 +83,7 @@ public class ServiceRelationClientRespTimeIndicator extends LongAvgIndicator imp
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataStrings(getEntityId());
remoteBuilder.addDataStrings(getStringField());
remoteBuilder.addDataLongs(getSummation());
remoteBuilder.addDataLongs(getValue());
......@@ -96,6 +97,7 @@ public class ServiceRelationClientRespTimeIndicator extends LongAvgIndicator imp
@Override public void deserialize(RemoteData remoteData) {
setEntityId(remoteData.getDataStrings(0));
setStringField(remoteData.getDataStrings(1));
setSummation(remoteData.getDataLongs(0));
setValue(remoteData.getDataLongs(1));
......@@ -108,61 +110,66 @@ public class ServiceRelationClientRespTimeIndicator extends LongAvgIndicator imp
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("service_relation_client_resp_time", Scope.ServiceRelation, entityId);
return new AlarmMeta("generate_indicator", Scope.Service, entityId);
}
@Override
public Indicator toHour() {
ServiceRelationClientRespTimeIndicator indicator = new ServiceRelationClientRespTimeIndicator();
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInHour());
indicator.setStringField(this.getStringField());
return indicator;
}
@Override
public Indicator toDay() {
ServiceRelationClientRespTimeIndicator indicator = new ServiceRelationClientRespTimeIndicator();
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInDay());
indicator.setStringField(this.getStringField());
return indicator;
}
@Override
public Indicator toMonth() {
ServiceRelationClientRespTimeIndicator indicator = new ServiceRelationClientRespTimeIndicator();
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInMonth());
indicator.setStringField(this.getStringField());
return indicator;
}
public static class Builder implements StorageBuilder<ServiceRelationClientRespTimeIndicator> {
public static class Builder implements StorageBuilder<ServiceAvgIndicator> {
@Override public Map<String, Object> data2Map(ServiceRelationClientRespTimeIndicator storageData) {
@Override public Map<String, Object> data2Map(ServiceAvgIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("entity_id", storageData.getEntityId());
map.put("summation", storageData.getSummation());
map.put("count", storageData.getCount());
map.put("value", storageData.getValue());
map.put("time_bucket", storageData.getTimeBucket());
map.put("string_field", storageData.getStringField());
return map;
}
@Override public ServiceRelationClientRespTimeIndicator map2Data(Map<String, Object> dbMap) {
ServiceRelationClientRespTimeIndicator indicator = new ServiceRelationClientRespTimeIndicator();
@Override public ServiceAvgIndicator map2Data(Map<String, Object> dbMap) {
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
indicator.setEntityId((String)dbMap.get("entity_id"));
indicator.setSummation(((Number)dbMap.get("summation")).longValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
indicator.setStringField((String)dbMap.get("string_field"));
return indicator;
}
}
......
......@@ -16,10 +16,11 @@
*
*/
package org.apache.skywalking.oap.server.core.analysis.generated.serviceinstancejvmcpu;
package org.apache.skywalking.oap.server.core.analysis.generated.service;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.analysis.indicator.expression.*;
import org.apache.skywalking.oap.server.core.source.*;
/**
......@@ -27,20 +28,22 @@ import org.apache.skywalking.oap.server.core.source.*;
*
* @author Observability Analysis Language code generator
*/
public class ServiceInstanceJVMCPUDispatcher implements SourceDispatcher<ServiceInstanceJVMCPU> {
@Override public void dispatch(ServiceInstanceJVMCPU source) {
doInstanceJvmCpu(source);
public class ServiceDispatcher implements SourceDispatcher<Service> {
@Override public void dispatch(Service source) {
doServiceAvg(source);
}
private void doInstanceJvmCpu(ServiceInstanceJVMCPU source) {
InstanceJvmCpuIndicator indicator = new InstanceJvmCpuIndicator();
private void doServiceAvg(Service source) {
ServiceAvgIndicator indicator = new ServiceAvgIndicator();
if (!new EqualMatch().setLeft(source.getName()).setRight("/service/prod/save").match()) {
return;
}
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getUsePercent(), 1);
indicator.combine(source.getLatency(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
}
/*
* 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.
*
*/
// All scope metric
all_p99 = from(All.latency).p99(10);
all_p95 = from(All.latency).p95(10);
all_p90 = from(All.latency).p90(10);
all_p75 = from(All.latency).p75(10);
all_p50 = from(All.latency).p50(10);
all_heatmap = from(All.latency).thermodynamic(100, 20);
// Service scope metric
service_resp_time = from(Service.latency).longAvg();
service_sla = from(Service.*).percent(status == true);
service_cpm = from(Service.*).cpm();
service_p99 = from(Service.latency).p99(10);
service_p95 = from(Service.latency).p95(10);
service_p90 = from(Service.latency).p90(10);
service_p75 = from(Service.latency).p75(10);
service_p50 = from(Service.latency).p50(10);
// Service relation scope metric for topology
service_relation_client_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).cpm();
service_relation_server_cpm = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm();
service_relation_client_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.CLIENT).percent(status == true);
service_relation_server_call_sla = from(ServiceRelation.*).filter(detectPoint == DetectPoint.SERVER).percent(status == true);
service_relation_client_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.CLIENT).longAvg();
service_relation_server_resp_time = from(ServiceRelation.latency).filter(detectPoint == DetectPoint.SERVER).longAvg();
// Service Instance Scope metric
service_instance_sla = from(ServiceInstance.*).percent(status == true);
service_instance_resp_time= from(ServiceInstance.latency).longAvg();
service_instance_cpm = from(ServiceInstance.*).cpm();
// Endpoint scope metric
endpoint_cpm = from(Endpoint.*).cpm();
endpoint_avg = from(Endpoint.latency).longAvg();
endpoint_sla = from(Endpoint.*).percent(status == true);
endpoint_p99 = from(Endpoint.latency).p99(10);
endpoint_p95 = from(Endpoint.latency).p95(10);
endpoint_p90 = from(Endpoint.latency).p90(10);
endpoint_p75 = from(Endpoint.latency).p75(10);
endpoint_p50 = from(Endpoint.latency).p50(10);
// Endpoint relation scope metric
endpoint_relation_cpm = from(EndpointRelation.*).filter(detectPoint == DetectPoint.SERVER).cpm();
endpoint_relation_resp_time = from(EndpointRelation.rpcLatency).filter(detectPoint == DetectPoint.SERVER).longAvg();
// JVM instance metric
instance_jvm_cpu = from(ServiceInstanceJVMCPU.usePercent).doubleAvg();
instance_jvm_memory_heap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == true).longAvg();
instance_jvm_memory_noheap = from(ServiceInstanceJVMMemory.used).filter(heapStatus == false).longAvg();
instance_jvm_memory_heap_max = from(ServiceInstanceJVMMemory.max).filter(heapStatus == true).longAvg();
instance_jvm_memory_noheap_max = from(ServiceInstanceJVMMemory.max).filter(heapStatus == false).longAvg();
instance_jvm_young_gc_time = from(ServiceInstanceJVMGC.time).filter(phrase == GCPhrase.NEW).longAvg();
instance_jvm_old_gc_time = from(ServiceInstanceJVMGC.time).filter(phrase == GCPhrase.OLD).longAvg();
instance_jvm_young_gc_count = from(ServiceInstanceJVMGC.count).filter(phrase == GCPhrase.NEW).sum();
instance_jvm_old_gc_count = from(ServiceInstanceJVMGC.count).filter(phrase == GCPhrase.OLD).sum();
// endpoint_Avg_for_prod_serv = from(Endpoint.latency).filter(name == "/product/service").longAvg();
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
~
-->
<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>oap-server</artifactId>
<groupId>org.apache.skywalking</groupId>
<version>6.0.0-beta-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>generated-analysis</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>server-core</artifactId>
<version>${project.version}</version>
</dependency>
<!-- This dependency will be excluded in starter pom.xml -->
<!-- Use default scope because `org.apache.skywalking.oal.tool.Main` in this lib, only this could make code generate tool works -->
<dependency>
<groupId>org.apache.skywalking</groupId>
<artifactId>generate-tool</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>target/generated-sources/oal</sourceDirectory>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${exec-maven-plugin.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>java</goal>
</goals>
<configuration>
<mainClass>org.apache.skywalking.oal.tool.Main</mainClass>
<arguments>
<argument>${project.basedir}</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
......@@ -38,6 +38,8 @@
<module>server-query-plugin</module>
<module>server-alarm-plugin</module>
<module>server-testing</module>
<module>generated-analysis</module>
<module>generate-tool</module>
</modules>
<properties>
......
/*
* 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.analysis.generated.all;
import java.util.*;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "all_heatmap", builder = AllHeatmapIndicator.Builder.class, source = Scope.All)
public class AllHeatmapIndicator extends ThermodynamicIndicator implements AlarmSupported {
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AllHeatmapIndicator indicator = (AllHeatmapIndicator)obj;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getStep());
remoteBuilder.addDataIntegers(getNumOfSteps());
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setStep(remoteData.getDataIntegers(0));
setNumOfSteps(remoteData.getDataIntegers(1));
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("all_heatmap", Scope.All);
}
@Override
public Indicator toHour() {
AllHeatmapIndicator indicator = new AllHeatmapIndicator();
indicator.setStep(this.getStep());
indicator.setNumOfSteps(this.getNumOfSteps());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
AllHeatmapIndicator indicator = new AllHeatmapIndicator();
indicator.setStep(this.getStep());
indicator.setNumOfSteps(this.getNumOfSteps());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
AllHeatmapIndicator indicator = new AllHeatmapIndicator();
indicator.setStep(this.getStep());
indicator.setNumOfSteps(this.getNumOfSteps());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<AllHeatmapIndicator> {
@Override public Map<String, Object> data2Map(AllHeatmapIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("step", storageData.getStep());
map.put("num_of_steps", storageData.getNumOfSteps());
map.put("detail_group", storageData.getDetailGroup());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public AllHeatmapIndicator map2Data(Map<String, Object> dbMap) {
AllHeatmapIndicator indicator = new AllHeatmapIndicator();
indicator.setStep(((Number)dbMap.get("step")).intValue());
indicator.setNumOfSteps(((Number)dbMap.get("num_of_steps")).intValue());
indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.all;
import java.util.*;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "all_p50", builder = AllP50Indicator.Builder.class, source = Scope.All)
public class AllP50Indicator extends P50Indicator implements AlarmSupported {
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AllP50Indicator indicator = (AllP50Indicator)obj;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getValue());
remoteBuilder.addDataIntegers(getPrecision());
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setValue(remoteData.getDataIntegers(0));
setPrecision(remoteData.getDataIntegers(1));
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("all_p50", Scope.All);
}
@Override
public Indicator toHour() {
AllP50Indicator indicator = new AllP50Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
AllP50Indicator indicator = new AllP50Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
AllP50Indicator indicator = new AllP50Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<AllP50Indicator> {
@Override public Map<String, Object> data2Map(AllP50Indicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("value", storageData.getValue());
map.put("precision", storageData.getPrecision());
map.put("detail_group", storageData.getDetailGroup());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public AllP50Indicator map2Data(Map<String, Object> dbMap) {
AllP50Indicator indicator = new AllP50Indicator();
indicator.setValue(((Number)dbMap.get("value")).intValue());
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.all;
import java.util.*;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "all_p75", builder = AllP75Indicator.Builder.class, source = Scope.All)
public class AllP75Indicator extends P75Indicator implements AlarmSupported {
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AllP75Indicator indicator = (AllP75Indicator)obj;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getValue());
remoteBuilder.addDataIntegers(getPrecision());
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setValue(remoteData.getDataIntegers(0));
setPrecision(remoteData.getDataIntegers(1));
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("all_p75", Scope.All);
}
@Override
public Indicator toHour() {
AllP75Indicator indicator = new AllP75Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
AllP75Indicator indicator = new AllP75Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
AllP75Indicator indicator = new AllP75Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<AllP75Indicator> {
@Override public Map<String, Object> data2Map(AllP75Indicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("value", storageData.getValue());
map.put("precision", storageData.getPrecision());
map.put("detail_group", storageData.getDetailGroup());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public AllP75Indicator map2Data(Map<String, Object> dbMap) {
AllP75Indicator indicator = new AllP75Indicator();
indicator.setValue(((Number)dbMap.get("value")).intValue());
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.all;
import java.util.*;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "all_p90", builder = AllP90Indicator.Builder.class, source = Scope.All)
public class AllP90Indicator extends P90Indicator implements AlarmSupported {
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AllP90Indicator indicator = (AllP90Indicator)obj;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getValue());
remoteBuilder.addDataIntegers(getPrecision());
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setValue(remoteData.getDataIntegers(0));
setPrecision(remoteData.getDataIntegers(1));
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("all_p90", Scope.All);
}
@Override
public Indicator toHour() {
AllP90Indicator indicator = new AllP90Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
AllP90Indicator indicator = new AllP90Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
AllP90Indicator indicator = new AllP90Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<AllP90Indicator> {
@Override public Map<String, Object> data2Map(AllP90Indicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("value", storageData.getValue());
map.put("precision", storageData.getPrecision());
map.put("detail_group", storageData.getDetailGroup());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public AllP90Indicator map2Data(Map<String, Object> dbMap) {
AllP90Indicator indicator = new AllP90Indicator();
indicator.setValue(((Number)dbMap.get("value")).intValue());
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.all;
import java.util.*;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "all_p95", builder = AllP95Indicator.Builder.class, source = Scope.All)
public class AllP95Indicator extends P95Indicator implements AlarmSupported {
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AllP95Indicator indicator = (AllP95Indicator)obj;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getValue());
remoteBuilder.addDataIntegers(getPrecision());
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setValue(remoteData.getDataIntegers(0));
setPrecision(remoteData.getDataIntegers(1));
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("all_p95", Scope.All);
}
@Override
public Indicator toHour() {
AllP95Indicator indicator = new AllP95Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
AllP95Indicator indicator = new AllP95Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
AllP95Indicator indicator = new AllP95Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<AllP95Indicator> {
@Override public Map<String, Object> data2Map(AllP95Indicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("value", storageData.getValue());
map.put("precision", storageData.getPrecision());
map.put("detail_group", storageData.getDetailGroup());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public AllP95Indicator map2Data(Map<String, Object> dbMap) {
AllP95Indicator indicator = new AllP95Indicator();
indicator.setValue(((Number)dbMap.get("value")).intValue());
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.all;
import java.util.*;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "all_p99", builder = AllP99Indicator.Builder.class, source = Scope.All)
public class AllP99Indicator extends P99Indicator implements AlarmSupported {
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AllP99Indicator indicator = (AllP99Indicator)obj;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getValue());
remoteBuilder.addDataIntegers(getPrecision());
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setTimeBucket(remoteData.getDataLongs(0));
setValue(remoteData.getDataIntegers(0));
setPrecision(remoteData.getDataIntegers(1));
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("all_p99", Scope.All);
}
@Override
public Indicator toHour() {
AllP99Indicator indicator = new AllP99Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
AllP99Indicator indicator = new AllP99Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
AllP99Indicator indicator = new AllP99Indicator();
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<AllP99Indicator> {
@Override public Map<String, Object> data2Map(AllP99Indicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("value", storageData.getValue());
map.put("precision", storageData.getPrecision());
map.put("detail_group", storageData.getDetailGroup());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public AllP99Indicator map2Data(Map<String, Object> dbMap) {
AllP99Indicator indicator = new AllP99Indicator();
indicator.setValue(((Number)dbMap.get("value")).intValue());
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.endpoint;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "endpoint_avg", builder = EndpointAvgIndicator.Builder.class, source = Scope.Endpoint)
public class EndpointAvgIndicator extends LongAvgIndicator implements AlarmSupported {
@Setter @Getter @Column(columnName = "entity_id") @IDColumn private java.lang.String entityId;
@Setter @Getter @Column(columnName = "service_id") private int serviceId;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + entityId;
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + entityId.hashCode();
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
result = 31 * result + entityId.hashCode();
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EndpointAvgIndicator indicator = (EndpointAvgIndicator)obj;
if (!entityId.equals(indicator.entityId))
return false;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataStrings(getEntityId());
remoteBuilder.addDataLongs(getSummation());
remoteBuilder.addDataLongs(getValue());
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getServiceId());
remoteBuilder.addDataIntegers(getServiceInstanceId());
remoteBuilder.addDataIntegers(getCount());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setEntityId(remoteData.getDataStrings(0));
setSummation(remoteData.getDataLongs(0));
setValue(remoteData.getDataLongs(1));
setTimeBucket(remoteData.getDataLongs(2));
setServiceId(remoteData.getDataIntegers(0));
setServiceInstanceId(remoteData.getDataIntegers(1));
setCount(remoteData.getDataIntegers(2));
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("endpoint_avg", Scope.Endpoint, entityId);
}
@Override
public Indicator toHour() {
EndpointAvgIndicator indicator = new EndpointAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
EndpointAvgIndicator indicator = new EndpointAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
EndpointAvgIndicator indicator = new EndpointAvgIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setSummation(this.getSummation());
indicator.setCount(this.getCount());
indicator.setValue(this.getValue());
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<EndpointAvgIndicator> {
@Override public Map<String, Object> data2Map(EndpointAvgIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("entity_id", storageData.getEntityId());
map.put("service_id", storageData.getServiceId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("summation", storageData.getSummation());
map.put("count", storageData.getCount());
map.put("value", storageData.getValue());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public EndpointAvgIndicator map2Data(Map<String, Object> dbMap) {
EndpointAvgIndicator indicator = new EndpointAvgIndicator();
indicator.setEntityId((String)dbMap.get("entity_id"));
indicator.setServiceId(((Number)dbMap.get("service_id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setSummation(((Number)dbMap.get("summation")).longValue());
indicator.setCount(((Number)dbMap.get("count")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.endpoint;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "endpoint_cpm", builder = EndpointCpmIndicator.Builder.class, source = Scope.Endpoint)
public class EndpointCpmIndicator extends CPMIndicator implements AlarmSupported {
@Setter @Getter @Column(columnName = "entity_id") @IDColumn private java.lang.String entityId;
@Setter @Getter @Column(columnName = "service_id") private int serviceId;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + entityId;
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + entityId.hashCode();
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
result = 31 * result + entityId.hashCode();
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EndpointCpmIndicator indicator = (EndpointCpmIndicator)obj;
if (!entityId.equals(indicator.entityId))
return false;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataStrings(getEntityId());
remoteBuilder.addDataLongs(getValue());
remoteBuilder.addDataLongs(getTotal());
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getServiceId());
remoteBuilder.addDataIntegers(getServiceInstanceId());
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setEntityId(remoteData.getDataStrings(0));
setValue(remoteData.getDataLongs(0));
setTotal(remoteData.getDataLongs(1));
setTimeBucket(remoteData.getDataLongs(2));
setServiceId(remoteData.getDataIntegers(0));
setServiceInstanceId(remoteData.getDataIntegers(1));
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("endpoint_cpm", Scope.Endpoint, entityId);
}
@Override
public Indicator toHour() {
EndpointCpmIndicator indicator = new EndpointCpmIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setValue(this.getValue());
indicator.setTotal(this.getTotal());
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
EndpointCpmIndicator indicator = new EndpointCpmIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setValue(this.getValue());
indicator.setTotal(this.getTotal());
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
EndpointCpmIndicator indicator = new EndpointCpmIndicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setValue(this.getValue());
indicator.setTotal(this.getTotal());
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<EndpointCpmIndicator> {
@Override public Map<String, Object> data2Map(EndpointCpmIndicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("entity_id", storageData.getEntityId());
map.put("service_id", storageData.getServiceId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("value", storageData.getValue());
map.put("total", storageData.getTotal());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public EndpointCpmIndicator map2Data(Map<String, Object> dbMap) {
EndpointCpmIndicator indicator = new EndpointCpmIndicator();
indicator.setEntityId((String)dbMap.get("entity_id"));
indicator.setServiceId(((Number)dbMap.get("service_id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setValue(((Number)dbMap.get("value")).longValue());
indicator.setTotal(((Number)dbMap.get("total")).longValue());
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
/*
* 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.analysis.generated.endpoint;
import org.apache.skywalking.oap.server.core.analysis.SourceDispatcher;
import org.apache.skywalking.oap.server.core.analysis.worker.IndicatorProcess;
import org.apache.skywalking.oap.server.core.source.*;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
public class EndpointDispatcher implements SourceDispatcher<Endpoint> {
@Override public void dispatch(Endpoint source) {
doEndpointCpm(source);
doEndpointAvg(source);
doEndpointSla(source);
doEndpointP99(source);
doEndpointP95(source);
doEndpointP90(source);
doEndpointP75(source);
doEndpointP50(source);
}
private void doEndpointCpm(Endpoint source) {
EndpointCpmIndicator indicator = new EndpointCpmIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(1);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointAvg(Endpoint source) {
EndpointAvgIndicator indicator = new EndpointAvgIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getLatency(), 1);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointSla(Endpoint source) {
EndpointSlaIndicator indicator = new EndpointSlaIndicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(new org.apache.skywalking.oap.server.core.analysis.indicator.expression.EqualMatch(), source.isStatus(), true);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointP99(Endpoint source) {
EndpointP99Indicator indicator = new EndpointP99Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointP95(Endpoint source) {
EndpointP95Indicator indicator = new EndpointP95Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointP90(Endpoint source) {
EndpointP90Indicator indicator = new EndpointP90Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointP75(Endpoint source) {
EndpointP75Indicator indicator = new EndpointP75Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
private void doEndpointP50(Endpoint source) {
EndpointP50Indicator indicator = new EndpointP50Indicator();
indicator.setTimeBucket(source.getTimeBucket());
indicator.setEntityId(source.getEntityId());
indicator.setServiceId(source.getServiceId());
indicator.setServiceInstanceId(source.getServiceInstanceId());
indicator.combine(source.getLatency(), 10);
IndicatorProcess.INSTANCE.in(indicator);
}
}
/*
* 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.analysis.generated.endpoint;
import java.util.*;
import lombok.*;
import org.apache.skywalking.oap.server.core.Const;
import org.apache.skywalking.oap.server.core.alarm.AlarmMeta;
import org.apache.skywalking.oap.server.core.alarm.AlarmSupported;
import org.apache.skywalking.oap.server.core.analysis.indicator.*;
import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorType;
import org.apache.skywalking.oap.server.core.remote.annotation.StreamData;
import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
import org.apache.skywalking.oap.server.core.storage.annotation.*;
import org.apache.skywalking.oap.server.core.storage.StorageBuilder;
import org.apache.skywalking.oap.server.core.source.Scope;
/**
* This class is auto generated. Please don't change this class manually.
*
* @author Observability Analysis Language code generator
*/
@IndicatorType
@StreamData
@StorageEntity(name = "endpoint_p50", builder = EndpointP50Indicator.Builder.class, source = Scope.Endpoint)
public class EndpointP50Indicator extends P50Indicator implements AlarmSupported {
@Setter @Getter @Column(columnName = "entity_id") @IDColumn private java.lang.String entityId;
@Setter @Getter @Column(columnName = "service_id") private int serviceId;
@Setter @Getter @Column(columnName = "service_instance_id") private int serviceInstanceId;
@Override public String id() {
String splitJointId = String.valueOf(getTimeBucket());
splitJointId += Const.ID_SPLIT + entityId;
return splitJointId;
}
@Override public int hashCode() {
int result = 17;
result = 31 * result + entityId.hashCode();
result = 31 * result + (int)getTimeBucket();
return result;
}
@Override public int remoteHashCode() {
int result = 17;
result = 31 * result + entityId.hashCode();
return result;
}
@Override public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
EndpointP50Indicator indicator = (EndpointP50Indicator)obj;
if (!entityId.equals(indicator.entityId))
return false;
if (getTimeBucket() != indicator.getTimeBucket())
return false;
return true;
}
@Override public RemoteData.Builder serialize() {
RemoteData.Builder remoteBuilder = RemoteData.newBuilder();
remoteBuilder.addDataStrings(getEntityId());
remoteBuilder.addDataLongs(getTimeBucket());
remoteBuilder.addDataIntegers(getServiceId());
remoteBuilder.addDataIntegers(getServiceInstanceId());
remoteBuilder.addDataIntegers(getValue());
remoteBuilder.addDataIntegers(getPrecision());
getDetailGroup().forEach(element -> remoteBuilder.addDataIntLongPairList(element.serialize()));
return remoteBuilder;
}
@Override public void deserialize(RemoteData remoteData) {
setEntityId(remoteData.getDataStrings(0));
setTimeBucket(remoteData.getDataLongs(0));
setServiceId(remoteData.getDataIntegers(0));
setServiceInstanceId(remoteData.getDataIntegers(1));
setValue(remoteData.getDataIntegers(2));
setPrecision(remoteData.getDataIntegers(3));
setDetailGroup(new IntKeyLongValueArray(30));
remoteData.getDataIntLongPairListList().forEach(element -> {
getDetailGroup().add(new IntKeyLongValue(element.getKey(), element.getValue()));
});
}
@Override public AlarmMeta getAlarmMeta() {
return new AlarmMeta("endpoint_p50", Scope.Endpoint, entityId);
}
@Override
public Indicator toHour() {
EndpointP50Indicator indicator = new EndpointP50Indicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInHour());
return indicator;
}
@Override
public Indicator toDay() {
EndpointP50Indicator indicator = new EndpointP50Indicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInDay());
return indicator;
}
@Override
public Indicator toMonth() {
EndpointP50Indicator indicator = new EndpointP50Indicator();
indicator.setEntityId(this.getEntityId());
indicator.setServiceId(this.getServiceId());
indicator.setServiceInstanceId(this.getServiceInstanceId());
indicator.setValue(this.getValue());
indicator.setPrecision(this.getPrecision());
org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray newValue = new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray();
newValue.copyFrom(this.getDetailGroup());
indicator.setDetailGroup(newValue);
indicator.setTimeBucket(toTimeBucketInMonth());
return indicator;
}
public static class Builder implements StorageBuilder<EndpointP50Indicator> {
@Override public Map<String, Object> data2Map(EndpointP50Indicator storageData) {
Map<String, Object> map = new HashMap<>();
map.put("entity_id", storageData.getEntityId());
map.put("service_id", storageData.getServiceId());
map.put("service_instance_id", storageData.getServiceInstanceId());
map.put("value", storageData.getValue());
map.put("precision", storageData.getPrecision());
map.put("detail_group", storageData.getDetailGroup());
map.put("time_bucket", storageData.getTimeBucket());
return map;
}
@Override public EndpointP50Indicator map2Data(Map<String, Object> dbMap) {
EndpointP50Indicator indicator = new EndpointP50Indicator();
indicator.setEntityId((String)dbMap.get("entity_id"));
indicator.setServiceId(((Number)dbMap.get("service_id")).intValue());
indicator.setServiceInstanceId(((Number)dbMap.get("service_instance_id")).intValue());
indicator.setValue(((Number)dbMap.get("value")).intValue());
indicator.setPrecision(((Number)dbMap.get("precision")).intValue());
indicator.setDetailGroup(new org.apache.skywalking.oap.server.core.analysis.indicator.IntKeyLongValueArray((String)dbMap.get("detail_group")));
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
return indicator;
}
}
}
......@@ -26,7 +26,7 @@ import org.apache.skywalking.oap.server.core.storage.annotation.Column;
/**
* @author wusheng
*/
@IndicatorOperator
@IndicatorFunction(functionName = "cpm")
public abstract class CPMIndicator extends Indicator implements LongValueHolder {
protected static final String VALUE = "value";
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册