diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/DispatcherManager.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/DispatcherManager.java index 6f059c70b..cd6c5084f 100644 --- a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/DispatcherManager.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/DispatcherManager.java @@ -19,6 +19,7 @@ package org.apache.skywalking.oap.server.core.analysis; import java.util.*; +import org.apache.skywalking.oap.server.core.analysis.generated.all.AllDispatcher; import org.apache.skywalking.oap.server.core.analysis.generated.endpoint.EndpointDispatcher; import org.apache.skywalking.oap.server.core.analysis.generated.endpointrelation.EndpointRelationDispatcher; import org.apache.skywalking.oap.server.core.analysis.generated.service.ServiceDispatcher; @@ -45,6 +46,8 @@ public class DispatcherManager { public DispatcherManager() { this.dispatcherMap = new HashMap<>(); + this.dispatcherMap.put(Scope.All, new AllDispatcher()); + this.dispatcherMap.put(Scope.Service, new ServiceDispatcher()); this.dispatcherMap.put(Scope.ServiceInstance, new ServiceInstanceDispatcher()); this.dispatcherMap.put(Scope.Endpoint, new EndpointDispatcher()); diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllDispatcher.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllDispatcher.java new file mode 100644 index 000000000..486e518f8 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllDispatcher.java @@ -0,0 +1,80 @@ +/* + * 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 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 AllDispatcher implements SourceDispatcher { + + @Override public void dispatch(All source) { + doAllP99(source); + doAllP95(source); + doAllP90(source); + doAllP75(source); + doAllP50(source); + } + + private void doAllP99(All source) { + AllP99Indicator indicator = new AllP99Indicator(); + + + 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); + } +} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP50Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP50Indicator.java new file mode 100644 index 000000000..6602815dc --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP50Indicator.java @@ -0,0 +1,122 @@ +/* + * 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) +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 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.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_p50", Scope.All); + } + + public static class Builder implements StorageBuilder { + + @Override public Map data2Map(AllP50Indicator storageData) { + Map 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 dbMap) { + AllP50Indicator indicator = new AllP50Indicator(); + 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/generated/all/AllP75Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP75Indicator.java new file mode 100644 index 000000000..2a36fa267 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP75Indicator.java @@ -0,0 +1,122 @@ +/* + * 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) +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 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.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_p75", Scope.All); + } + + public static class Builder implements StorageBuilder { + + @Override public Map data2Map(AllP75Indicator storageData) { + Map 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 dbMap) { + AllP75Indicator indicator = new AllP75Indicator(); + 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/generated/all/AllP90Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP90Indicator.java new file mode 100644 index 000000000..1384e3538 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP90Indicator.java @@ -0,0 +1,122 @@ +/* + * 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) +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 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.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_p90", Scope.All); + } + + public static class Builder implements StorageBuilder { + + @Override public Map data2Map(AllP90Indicator storageData) { + Map 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 dbMap) { + AllP90Indicator indicator = new AllP90Indicator(); + 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/generated/all/AllP95Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP95Indicator.java new file mode 100644 index 000000000..4f6598a77 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP95Indicator.java @@ -0,0 +1,122 @@ +/* + * 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) +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 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.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_p95", Scope.All); + } + + public static class Builder implements StorageBuilder { + + @Override public Map data2Map(AllP95Indicator storageData) { + Map 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 dbMap) { + AllP95Indicator indicator = new AllP95Indicator(); + 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/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 000000000..1ed147794 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/generated/all/AllP99Indicator.java @@ -0,0 +1,122 @@ +/* + * 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) +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 { + + @Override public Map data2Map(AllP99Indicator storageData) { + Map 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 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 000000000..0537d608f --- /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 { + 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/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/define/TestLongAvgIndicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java similarity index 63% rename from oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/define/TestLongAvgIndicator.java rename to oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java index 737badfa5..bb815e035 100644 --- a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/define/TestLongAvgIndicator.java +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P50Indicator.java @@ -16,27 +16,15 @@ * */ -package org.apache.skywalking.oap.server.core.analysis.indicator.define; - -import lombok.*; -import org.apache.skywalking.oap.server.core.analysis.indicator.LongAvgIndicator; -import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; +package org.apache.skywalking.oap.server.core.analysis.indicator; /** - * @author peng-yongsheng + * P50 + * + * @author wusheng */ -public class TestLongAvgIndicator extends LongAvgIndicator { - - @Setter @Getter private int id; - - @Override public RemoteData.Builder serialize() { - return null; - } - - @Override public void deserialize(RemoteData remoteData) { - } - - @Override public String id() { - return null; +public abstract class P50Indicator extends PxxIndicator { + public P50Indicator() { + super(50); } } diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java new file mode 100644 index 000000000..cfe4e87df --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P75Indicator.java @@ -0,0 +1,30 @@ +/* + * 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; + +/** + * P75 + * + * @author wusheng + */ +public abstract class P75Indicator extends PxxIndicator { + public P75Indicator() { + super(75); + } +} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java new file mode 100644 index 000000000..52c75c78f --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P90Indicator.java @@ -0,0 +1,30 @@ +/* + * 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; + +/** + * P90 + * + * @author wusheng + */ +public abstract class P90Indicator extends PxxIndicator { + public P90Indicator() { + super(90); + } +} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java new file mode 100644 index 000000000..9345b20ec --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P95Indicator.java @@ -0,0 +1,30 @@ +/* + * 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; + +/** + * P95 + * + * @author wusheng + */ +public abstract class P95Indicator extends PxxIndicator { + public P95Indicator() { + super(95); + } +} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java new file mode 100644 index 000000000..761e86f62 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/P99Indicator.java @@ -0,0 +1,30 @@ +/* + * 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; + +/** + * P99 + * + * @author wusheng + */ +public abstract class P99Indicator extends PxxIndicator { + public P99Indicator() { + super(99); + } +} 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 000000000..282b87750 --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/PxxIndicator.java @@ -0,0 +1,130 @@ +/* + * 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.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 detailGroup; + + private final int percentileRank; + private Map 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; + } + } + } + + @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/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java new file mode 100644 index 000000000..fd212f2fd --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/analysis/indicator/annotation/Arg.java @@ -0,0 +1,32 @@ +/* + * 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.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * @author wusheng + */ +@Target(ElementType.PARAMETER) +@Retention(RetentionPolicy.RUNTIME) +public @interface Arg { +} diff --git a/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/All.java b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/All.java new file mode 100644 index 000000000..39061459b --- /dev/null +++ b/oap-server/server-core/src/main/java/org/apache/skywalking/oap/server/core/source/All.java @@ -0,0 +1,38 @@ +/* + * 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.source; + +import lombok.Getter; +import lombok.Setter; +import org.apache.skywalking.oap.server.core.source.annotation.SourceType; + +@SourceType +public class All extends Source { + @Override public Scope scope() { + return Scope.All; + } + + @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; +} diff --git a/oap-server/server-core/src/main/proto/RemoteService.proto b/oap-server/server-core/src/main/proto/RemoteService.proto index ddc9fa129..853ea82f2 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/LongAvgIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicatorTest.java new file mode 100644 index 000000000..bcb12fd63 --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/LongAvgIndicatorTest.java @@ -0,0 +1,69 @@ +/* + * 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 LongAvgIndicatorTest { + @Test + public void testEntranceCombine() { + LongAvgIndicatorImpl impl = new LongAvgIndicatorImpl(); + impl.combine(12, 1); + impl.combine(24, 2); + impl.combine(36, 3); + impl.calculate(); + Assert.assertEquals(12, impl.getValue()); + } + + @Test + public void testSelfCombine() { + LongAvgIndicatorImpl impl = new LongAvgIndicatorImpl(); + impl.combine(12, 1); + impl.combine(24, 2); + + LongAvgIndicatorImpl impl2 = new LongAvgIndicatorImpl(); + impl2.combine(24, 1); + impl2.combine(48, 2); + + impl.combine(impl2); + + impl.calculate(); + Assert.assertEquals(18, impl.getValue()); + } + + public class LongAvgIndicatorImpl extends LongAvgIndicator { + + @Override public String id() { + return null; + } + + @Override public void deserialize(RemoteData remoteData) { + + } + + @Override public RemoteData.Builder serialize() { + return null; + } + } +} diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicatorTest.java new file mode 100644 index 000000000..6ed96a92d --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/PercentIndicatorTest.java @@ -0,0 +1,84 @@ +/* + * 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.analysis.indicator.expression.EqualMatch; +import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author wusheng + */ +public class PercentIndicatorTest { + @Test + public void testEntranceCombine() { + PercentIndicatorImpl impl = new PercentIndicatorImpl(); + impl.combine(new EqualMatch(), true, true); + impl.combine(new EqualMatch(), true, false); + impl.combine(new EqualMatch(), true, false); + + impl.calculate(); + + Assert.assertEquals(33, impl.getValue()); + + impl = new PercentIndicatorImpl(); + impl.combine(new EqualMatch(), true, true); + impl.combine(new EqualMatch(), true, true); + impl.combine(new EqualMatch(), true, false); + + impl.calculate(); + + Assert.assertEquals(66, impl.getValue()); + } + + @Test + public void testSelfCombine() { + PercentIndicatorImpl impl = new PercentIndicatorImpl(); + impl.combine(new EqualMatch(), true, true); + impl.combine(new EqualMatch(), true, false); + impl.combine(new EqualMatch(), true, false); + + PercentIndicatorImpl impl2 = new PercentIndicatorImpl(); + impl2.combine(new EqualMatch(), true, true); + impl2.combine(new EqualMatch(), true, true); + impl2.combine(new EqualMatch(), true, false); + + impl.combine(impl2); + + impl.calculate(); + + Assert.assertEquals(50, impl.getValue()); + } + + public class PercentIndicatorImpl extends PercentIndicator { + + @Override public String id() { + return null; + } + + @Override public void deserialize(RemoteData remoteData) { + + } + + @Override public RemoteData.Builder serialize() { + return null; + } + } +} 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 000000000..5644c52de --- /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; + } + } +} diff --git a/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicatorTest.java b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicatorTest.java new file mode 100644 index 000000000..dc03c05b4 --- /dev/null +++ b/oap-server/server-core/src/test/java/org/apache/skywalking/oap/server/core/analysis/indicator/SumIndicatorTest.java @@ -0,0 +1,73 @@ +/* + * 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 SumIndicatorTest { + @Test + public void testEntranceCombine() { + SumIndicatorImpl impl = new SumIndicatorImpl(); + impl.combine(5); + impl.combine(6); + impl.combine(7); + + impl.calculate(); + + Assert.assertEquals(18, impl.getValue()); + } + + @Test + public void testSelfCombine() { + SumIndicatorImpl impl = new SumIndicatorImpl(); + impl.combine(5); + impl.combine(6); + impl.combine(7); + + SumIndicatorImpl impl2 = new SumIndicatorImpl(); + impl2.combine(5); + impl2.combine(6); + impl2.combine(7); + + impl.combine(impl2); + + impl.calculate(); + + Assert.assertEquals(36, impl.getValue()); + } + + public class SumIndicatorImpl extends SumIndicator { + @Override public String id() { + return null; + } + + @Override public void deserialize(RemoteData remoteData) { + + } + + @Override public RemoteData.Builder serialize() { + return null; + } + } +} diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java index cbbf576ec..ff083b41d 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/MultiScopesSpanListener.java @@ -162,6 +162,7 @@ public class MultiScopesSpanListener implements EntrySpanListener, ExitSpanListe @Override public void build() { entrySourceBuilders.forEach(entrySourceBuilder -> { entrySourceBuilder.setTimeBucket(minuteTimeBucket); + sourceReceiver.receive(entrySourceBuilder.toAll()); sourceReceiver.receive(entrySourceBuilder.toService()); sourceReceiver.receive(entrySourceBuilder.toServiceInstance()); sourceReceiver.receive(entrySourceBuilder.toEndpoint()); diff --git a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java index e5485fee2..3b3200895 100644 --- a/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java +++ b/oap-server/server-receiver-plugin/skywalking-trace-receiver-plugin/src/main/java/org/apache/skywalking/oap/server/receiver/trace/provider/parser/listener/endpoint/SourceBuilder.java @@ -45,6 +45,19 @@ class SourceBuilder { @Getter @Setter private DetectPoint detectPoint; @Getter @Setter private long timeBucket; + All toAll() { + All all = new All(); + all.setName(destServiceName); + all.setServiceInstanceName(destServiceInstanceName); + all.setEndpointName(destEndpointName); + all.setLatency(latency); + all.setStatus(status); + all.setResponseCode(responseCode); + all.setType(type); + all.setTimeBucket(timeBucket); + return all; + } + Service toService() { Service service = new Service(); service.setId(destServiceId);