You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@skywalking.apache.org by wu...@apache.org on 2018/09/06 15:57:06 UTC
[incubator-skywalking-oal-tool] branch master updated: Add sum
indicator operator and fixed a service relation columns factory bug. (#5)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking-oal-tool.git
The following commit(s) were added to refs/heads/master by this push:
new 70b8522 Add sum indicator operator and fixed a service relation columns factory bug. (#5)
70b8522 is described below
commit 70b8522722575f43b19401763718c9cdaa5b9b65
Author: 彭勇升 pengys <80...@qq.com>
AuthorDate: Thu Sep 6 23:57:03 2018 +0800
Add sum indicator operator and fixed a service relation columns factory bug. (#5)
---
.../oal/tool/parser/SourceColumnsFactory.java | 2 +-
.../skywalking/oap/server/core/Indicators.java | 9 ++---
.../core/analysis/indicator/SumIndicator.java | 47 ++++++++++++++++++++++
oal-parser/src/test/resources/oal_test.oal | 4 ++
4 files changed, 55 insertions(+), 7 deletions(-)
diff --git a/oal-parser/src/main/java/org/apache/skywalking/oal/tool/parser/SourceColumnsFactory.java b/oal-parser/src/main/java/org/apache/skywalking/oal/tool/parser/SourceColumnsFactory.java
index 1994f5c..c171290 100644
--- a/oal-parser/src/main/java/org/apache/skywalking/oal/tool/parser/SourceColumnsFactory.java
+++ b/oal-parser/src/main/java/org/apache/skywalking/oal/tool/parser/SourceColumnsFactory.java
@@ -68,7 +68,7 @@ public class SourceColumnsFactory {
SourceColumn destService = new SourceColumn("destServiceId", "dest_service_id", int.class, true);
columnList.add(destService);
SourceColumn callType = new SourceColumn("callType", "call_type", int.class, true);
- columnList.add(destService);
+ columnList.add(callType);
return columnList;
case "ServiceInstanceRelation":
columnList = new LinkedList<>();
diff --git a/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java
index b02f540..0d96cba 100644
--- a/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java
+++ b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/Indicators.java
@@ -18,12 +18,8 @@
package org.apache.skywalking.oap.server.core;
-import java.util.HashMap;
-import java.util.Map;
-import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleAvgIndicator;
-import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator;
-import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
-import org.apache.skywalking.oap.server.core.analysis.indicator.PercentIndicator;
+import java.util.*;
+import org.apache.skywalking.oap.server.core.analysis.indicator.*;
public class Indicators {
private static Map<String, Class<? extends Indicator>> REGISTER = new HashMap<>();
@@ -32,6 +28,7 @@ public class Indicators {
REGISTER.put("longAvg", LongAvgIndicator.class);
REGISTER.put("doubleAvg", DoubleAvgIndicator.class);
REGISTER.put("percent", PercentIndicator.class);
+ REGISTER.put("sum", SumIndicator.class);
}
public static Class<? extends Indicator> find(String functionName) {
diff --git a/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicator.java b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicator.java
new file mode 100644
index 0000000..d5c67d8
--- /dev/null
+++ b/oal-parser/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicator.java
@@ -0,0 +1,47 @@
+/*
+ * 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.indicator;
+
+import lombok.*;
+import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.*;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+/**
+ * @author peng-yongsheng
+ */
+@IndicatorOperator
+public abstract class SumIndicator extends Indicator {
+
+ protected static final String VALUE = "value";
+
+ @Getter @Setter @Column(columnName = VALUE) private long value;
+
+ @Entrance
+ public final void combine(@ConstOne long count) {
+ this.value += count;
+ }
+
+ @Override public final void combine(Indicator indicator) {
+ SumIndicator sumIndicator = (SumIndicator)indicator;
+ combine(sumIndicator.value);
+ }
+
+ @Override public void calculate() {
+ }
+}
diff --git a/oal-parser/src/test/resources/oal_test.oal b/oal-parser/src/test/resources/oal_test.oal
index 9d90647..bbd1893 100644
--- a/oal-parser/src/test/resources/oal_test.oal
+++ b/oal-parser/src/test/resources/oal_test.oal
@@ -20,6 +20,10 @@ Service_Avg = from(Service.latency).longAvg();
ServiceInstance_RespTime= from(ServiceInstance.latency).longAvg();
+Service_Calls_Sum = from(Service.*).sum();
+
+Service_Relation_Calls_Sum = from(ServiceRelation.*).sum();
+
endpoint_Avg = from(Endpoint.latency).longAvg();
// endpoint_Avg_for_prod_serv = from(Endpoint.latency).filter(name == "/product/service").longAvg();