You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/09/06 15:57:05 UTC

[GitHub] wu-sheng closed pull request #5: Add sum indicator operator and fixed a service relation columns facto…

wu-sheng closed pull request #5: Add sum indicator operator and fixed a service relation columns facto…
URL: https://github.com/apache/incubator-skywalking-oal-tool/pull/5
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 @@
                 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 @@
         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();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services