This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch extend-indicator
in repository https://gitbox.apache.org/repos/asf/incubator-skywalking.git
The following commit(s) were added to refs/heads/extend-indicator by this push:
new 5010424 Add Pxx indicator.
5010424 is described below
commit 5010424c4a64ca99fdac0645eaa4dbfafb0033f2
Author: Wu Sheng <[email protected]>
AuthorDate: Mon Sep 10 23:53:43 2018 +0800
Add Pxx indicator.
---
.../analysis/generated/all/AllDispatcher.java} | 39 +++---
.../analysis/generated/all/AllP99Indicator.java | 124 +++++++++++++++++++
.../core/analysis/indicator/IntKeyLongValue.java | 75 ++++++++++++
.../core/analysis/indicator/P50Indicator.java} | 31 ++---
.../core/analysis/indicator/P75Indicator.java} | 31 ++---
.../core/analysis/indicator/P90Indicator.java} | 31 ++---
.../core/analysis/indicator/P95Indicator.java} | 31 ++---
.../core/analysis/indicator/P99Indicator.java} | 31 ++---
.../core/analysis/indicator/PxxIndicator.java | 133 +++++++++++++++++++++
.../core/analysis/indicator/annotation/Arg.java} | 33 ++---
.../skywalking/oap/server/core/source/All.java} | 35 +++---
.../server-core/src/main/proto/RemoteService.proto | 6 +
.../core/analysis/indicator/PxxIndicatorTest.java | 114 ++++++++++++++++++
13 files changed, 543 insertions(+), 171 deletions(-)
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllDispatcher.java
similarity index 53%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllDispatcher.java
index ddc9fa1..fbec133 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllDispatcher.java
@@ -16,28 +16,29 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.analysis.generated.all;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
+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.*;
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
+/**
+ * This class is auto generated. Please don't change this class manually.
+ *
+ * @author Observability Analysis Language code generator
+ */
+public class AllDispatcher implements SourceDispatcher<All> {
+
+ @Override public void dispatch(All source) {
+ doAllP99(source);
}
-}
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
+ private void doAllP99(All source) {
+ AllP99Indicator indicator = new AllP99Indicator();
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
-}
-message Empty {
-}
\ No newline at end of file
+ indicator.setTimeBucket(source.getTimeBucket());
+ indicator.combine(source.getLatency(), 10);
+ IndicatorProcess.INSTANCE.in(indicator);
+ }
+}
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP99Indicator.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP99Indicator.java
new file mode 100644
index 0000000..31080ce
--- /dev/null
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP99Indicator.java
@@ -0,0 +1,124 @@
+/*
+ * 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 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 = "all_p99", builder = AllP99Indicator.Builder.class)
+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 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.setDataLongs(0, getTimeBucket());
+
+
+ remoteBuilder.setDataIntegers(0, getValue());
+ remoteBuilder.setDataIntegers(1, 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 ArrayList<>(30));
+ remoteData.getDataIntLongPairListList().forEach(element -> {
+ getDetailGroup().add(new IntKeyLongValue(element.getKey(),
element.getValue()));
+ });
+
+ }
+
+ @Override public AlarmMeta getAlarmMeta() {
+ return new AlarmMeta("All_p99", Scope.All);
+ }
+
+ 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((List)dbMap.get("detail_group"));
+
indicator.setTimeBucket(((Number)dbMap.get("time_bucket")).longValue());
+ return indicator;
+ }
+ }
+}
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValue.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValue.java
new file mode 100644
index 0000000..0537d60
--- /dev/null
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/IntKeyLongValue.java
@@ -0,0 +1,75 @@
+/*
+ * 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 java.util.Objects;
+import lombok.Getter;
+import lombok.Setter;
+import
org.apache.skywalking.oap.server.core.remote.grpc.proto.IntKeyLongValuePair;
+
+/**
+ * IntKeyLongValue is a common bean, with key in Int and value in Long
+ *
+ * @author wusheng
+ */
+@Setter
+@Getter
+public class IntKeyLongValue implements Comparable<IntKeyLongValue> {
+ private int key;
+ private long value;
+
+ public IntKeyLongValue() {
+ }
+
+ public IntKeyLongValue(int key, long value) {
+ this.key = key;
+ this.value = value;
+ }
+
+ public void addValue(long value) {
+ this.value += value;
+ }
+
+ @Override
+ public int compareTo(IntKeyLongValue o) {
+ return key - o.key;
+ }
+
+ @Override public boolean equals(Object o) {
+ if (this == o)
+ return true;
+ if (o == null || getClass() != o.getClass())
+ return false;
+ IntKeyLongValue value = (IntKeyLongValue)o;
+ return key == value.key;
+ }
+
+ @Override public int hashCode() {
+ return Objects.hash(key);
+ }
+
+ public IntKeyLongValuePair serialize() {
+ return
IntKeyLongValuePair.newBuilder().setKey(key).setValue(value).build();
+ }
+
+ public void deserialize(IntKeyLongValuePair pair) {
+ this.key = pair.getKey();
+ this.value = pair.getValue();
+ }
+}
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java
similarity index 61%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java
index ddc9fa1..bb815e0 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java
@@ -16,28 +16,15 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.analysis.indicator;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
-
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
+/**
+ * P50
+ *
+ * @author wusheng
+ */
+public abstract class P50Indicator extends PxxIndicator {
+ public P50Indicator() {
+ super(50);
}
}
-
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
-
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
-}
-
-message Empty {
-}
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java
similarity index 61%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java
index ddc9fa1..cfe4e87 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java
@@ -16,28 +16,15 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.analysis.indicator;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
-
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
+/**
+ * P75
+ *
+ * @author wusheng
+ */
+public abstract class P75Indicator extends PxxIndicator {
+ public P75Indicator() {
+ super(75);
}
}
-
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
-
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
-}
-
-message Empty {
-}
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java
similarity index 61%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java
index ddc9fa1..52c75c7 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java
@@ -16,28 +16,15 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.analysis.indicator;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
-
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
+/**
+ * P90
+ *
+ * @author wusheng
+ */
+public abstract class P90Indicator extends PxxIndicator {
+ public P90Indicator() {
+ super(90);
}
}
-
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
-
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
-}
-
-message Empty {
-}
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java
similarity index 61%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java
index ddc9fa1..9345b20 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java
@@ -16,28 +16,15 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.analysis.indicator;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
-
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
+/**
+ * P95
+ *
+ * @author wusheng
+ */
+public abstract class P95Indicator extends PxxIndicator {
+ public P95Indicator() {
+ super(95);
}
}
-
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
-
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
-}
-
-message Empty {
-}
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java
similarity index 61%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java
index ddc9fa1..761e86f 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java
@@ -16,28 +16,15 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.analysis.indicator;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
-
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
+/**
+ * P99
+ *
+ * @author wusheng
+ */
+public abstract class P99Indicator extends PxxIndicator {
+ public P99Indicator() {
+ super(99);
}
}
-
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
-
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
-}
-
-message Empty {
-}
\ No newline at end of file
diff --git
a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicator.java
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicator.java
new file mode 100644
index 0000000..fab4497
--- /dev/null
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicator.java
@@ -0,0 +1,133 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.analysis.indicator.annotation.Arg;
+import
org.apache.skywalking.oap.server.core.analysis.indicator.annotation.Entrance;
+import
org.apache.skywalking.oap.server.core.analysis.indicator.annotation.IndicatorOperator;
+import
org.apache.skywalking.oap.server.core.analysis.indicator.annotation.SourceFrom;
+import
org.apache.skywalking.oap.server.core.remote.grpc.proto.IntKeyLongValuePair;
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.apache.skywalking.oap.server.core.storage.annotation.Column;
+
+/**
+ * PxxIndicator is a parent indicator for p99/p95/p90/p75/p50 indicators.
P(xx) indicator is also for P(xx) percentile.
+ *
+ * A percentile (or a centile) is a measure used in statistics indicating the
value below which a given percentage of
+ * observations in a group of observations fall. For example, the 20th
percentile is the value (or score) below which
+ * 20% of the observations may be found.
+ *
+ * @author wusheng
+ */
+@IndicatorOperator
+public abstract class PxxIndicator extends Indicator implements IntValueHolder
{
+ protected static final String DETAIL_GROUP = "detail_group";
+ protected static final String VALUE = "value";
+ protected static final String PRECISION = "precision";
+
+ @Getter @Setter @Column(columnName = VALUE) private int value;
+ @Getter @Setter @Column(columnName = PRECISION) private int precision;
+ @Getter @Setter @Column(columnName = DETAIL_GROUP) private
List<IntKeyLongValue> detailGroup;
+
+ private final int percentileRank;
+ private Map<Integer, IntKeyLongValue> detailIndex;
+
+ public PxxIndicator(int percentileRank) {
+ this.percentileRank = percentileRank;
+ detailGroup = new ArrayList<>(30);
+ }
+
+ @Entrance
+ public final void combine(@SourceFrom int value, @Arg int precision) {
+ this.precision = precision;
+
+ this.indexCheckAndInit();
+
+ int index = value / precision;
+ IntKeyLongValue element = detailIndex.get(index);
+ if (element == null) {
+ element = new IntKeyLongValue();
+ element.setKey(index);
+ element.setValue(1);
+ addElement(element);
+ } else {
+ element.addValue(1);
+ }
+ }
+
+ @Override
+ public void combine(Indicator indicator) {
+ PxxIndicator pxxIndicator = (PxxIndicator)indicator;
+ this.indexCheckAndInit();
+ pxxIndicator.indexCheckAndInit();
+
+ pxxIndicator.detailIndex.forEach((key, element) -> {
+ IntKeyLongValue existingElement = this.detailIndex.get(key);
+ if (existingElement == null) {
+ existingElement = new IntKeyLongValue();
+ existingElement.setKey(key);
+ existingElement.setValue(element.getValue());
+ addElement(element);
+ } else {
+ existingElement.addValue(element.getValue());
+ }
+ });
+ }
+
+ @Override
+ public final void calculate() {
+ Collections.sort(detailGroup);
+ int total = detailGroup.stream().mapToInt(element ->
(int)element.getValue()).sum();
+ int roof = Math.round(total * percentileRank * 1.0f / 100);
+
+ int count = 0;
+ for (IntKeyLongValue element : detailGroup) {
+ count += element.getValue();
+ if (count >= roof) {
+ value = element.getKey() * precision;
+ return;
+ }
+ }
+ detailGroup.forEach(element ->
RemoteData.newBuilder().addDataIntLongPairList(element.serialize()));
+ }
+
+ @Override
+ public int getValue() {
+ return value;
+ }
+
+ private void addElement(IntKeyLongValue element) {
+ detailGroup.add(element);
+ detailIndex.put(element.getKey(), element);
+ }
+
+ private void indexCheckAndInit() {
+ if (detailIndex == null) {
+ detailIndex = new HashMap<>();
+ detailGroup.forEach(element -> detailIndex.put(element.getKey(),
element));
+ }
+ }
+}
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java
similarity index 60%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java
index ddc9fa1..fd212f2 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java
@@ -16,28 +16,17 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.analysis.indicator.annotation;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
- }
-}
-
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
-
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
+/**
+ * @author wusheng
+ */
+@Target(ElementType.PARAMETER)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Arg {
}
-
-message Empty {
-}
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/All.java
similarity index 57%
copy from oap-server/server-core/src/main/proto/RemoteService.proto
copy to
oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/All.java
index ddc9fa1..3906145 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++
b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/All.java
@@ -16,28 +16,23 @@
*
*/
-syntax = "proto3";
+package org.apache.skywalking.oap.server.core.source;
-option java_multiple_files = true;
-option java_package =
"org.apache.skywalking.oap.server.core.remote.grpc.proto";
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.skywalking.oap.server.core.source.annotation.SourceType;
-service RemoteService {
- rpc call (stream RemoteMessage) returns (Empty) {
+@SourceType
+public class All extends Source {
+ @Override public Scope scope() {
+ return Scope.All;
}
-}
-
-message RemoteMessage {
- int32 nextWorkerId = 1;
- int32 streamDataId = 2;
- RemoteData remoteData = 3;
-}
-message RemoteData {
- repeated string dataStrings = 1;
- repeated int64 dataLongs = 2;
- repeated double dataDoubles = 3;
- repeated int32 dataIntegers = 4;
+ @Getter @Setter private String name;
+ @Getter @Setter private String serviceInstanceName;
+ @Getter @Setter private String endpointName;
+ @Getter @Setter private int latency;
+ @Getter @Setter private boolean status;
+ @Getter @Setter private int responseCode;
+ @Getter @Setter private RequestType type;
}
-
-message Empty {
-}
\ No newline at end of file
diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto
b/oap-server/server-core/src/main/proto/RemoteService.proto
index ddc9fa1..853ea82 100644
--- a/oap-server/server-core/src/main/proto/RemoteService.proto
+++ b/oap-server/server-core/src/main/proto/RemoteService.proto
@@ -37,6 +37,12 @@ message RemoteData {
repeated int64 dataLongs = 2;
repeated double dataDoubles = 3;
repeated int32 dataIntegers = 4;
+ repeated IntKeyLongValuePair dataIntLongPairList = 5;
+}
+
+message IntKeyLongValuePair {
+ int32 key = 1;
+ int64 value = 2;
}
message Empty {
diff --git
a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicatorTest.java
b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicatorTest.java
new file mode 100644
index 0000000..5644c52
--- /dev/null
+++
b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicatorTest.java
@@ -0,0 +1,114 @@
+/*
+ * 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 org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * @author wusheng
+ */
+public class PxxIndicatorTest {
+ private int precision = 10;//ms
+
+ @Test
+ public void p99Test() {
+ PxxIndicatorMocker indicatorMocker = new PxxIndicatorMocker(99);
+
+ indicatorMocker.combine(110, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(61, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+
+ indicatorMocker.calculate();
+
+ Assert.assertEquals(110, indicatorMocker.getValue());
+ }
+
+ @Test
+ public void p75Test() {
+ PxxIndicatorMocker indicatorMocker = new PxxIndicatorMocker(75);
+
+ indicatorMocker.combine(110, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(61, precision);
+ indicatorMocker.combine(61, precision);
+ indicatorMocker.combine(71, precision);
+ indicatorMocker.combine(100, precision);
+
+ indicatorMocker.calculate();
+
+ // precision = 10, 71 ~= 70
+ Assert.assertEquals(100, indicatorMocker.getValue());
+ }
+
+ @Test
+ public void p50Test() {
+ PxxIndicatorMocker indicatorMocker = new PxxIndicatorMocker(50);
+
+ indicatorMocker.combine(110, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(100, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(50, precision);
+ indicatorMocker.combine(61, precision);
+ indicatorMocker.combine(61, precision);
+ indicatorMocker.combine(71, precision);
+ indicatorMocker.combine(100, precision);
+
+ indicatorMocker.calculate();
+
+ // precision = 10, 71 ~= 70
+ Assert.assertEquals(70, indicatorMocker.getValue());
+ }
+
+ public class PxxIndicatorMocker extends PxxIndicator {
+
+ public PxxIndicatorMocker(int percentileRank) {
+ super(percentileRank);
+ }
+
+ @Override public String id() {
+ return null;
+ }
+
+ @Override public void deserialize(RemoteData remoteData) {
+
+ }
+
+ @Override public RemoteData.Builder serialize() {
+ return null;
+ }
+ }
+}