From 06f675ac9b85c0af3e3519c707c154b600db7b1f Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sat, 20 Jan 2018 22:21:56 +0800 Subject: [PATCH 01/36] Changed dependency graphql-java from 6.0 to 7.0. --- apm-protocol/apm-ui-protocol/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-protocol/apm-ui-protocol/pom.xml b/apm-protocol/apm-ui-protocol/pom.xml index 0e7e75784..ca05ad164 100644 --- a/apm-protocol/apm-ui-protocol/pom.xml +++ b/apm-protocol/apm-ui-protocol/pom.xml @@ -33,7 +33,7 @@ com.graphql-java graphql-java - 6.0 + 7.0 From 1152135a0b0674f061a7c89efa5c05c8b86a7339 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sat, 20 Jan 2018 22:26:08 +0800 Subject: [PATCH 02/36] initialize collector ui graphql module. --- .../collector-ui-graphql/pom.xml | 40 +++++++++++++++++++ .../collector-ui-jetty-provider/pom.xml | 5 +++ apm-collector/apm-collector-ui/pom.xml | 1 + 3 files changed, 46 insertions(+) create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml b/apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml new file mode 100644 index 000000000..1ce46b840 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml @@ -0,0 +1,40 @@ + + + + + + apm-collector-ui + org.apache.skywalking + 5.0.0-alpha + + 4.0.0 + + collector-ui-graphql + jar + + + + com.graphql-java + graphql-java-tools + 4.3.0 + + + diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml index 83086aaa8..94469c388 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/pom.xml @@ -36,6 +36,11 @@ collector-ui-define ${project.version} + + org.apache.skywalking + collector-ui-graphql + ${project.version} + org.apache.skywalking collector-cluster-define diff --git a/apm-collector/apm-collector-ui/pom.xml b/apm-collector/apm-collector-ui/pom.xml index e35d06d3b..a34095e71 100644 --- a/apm-collector/apm-collector-ui/pom.xml +++ b/apm-collector/apm-collector-ui/pom.xml @@ -31,6 +31,7 @@ pom collector-ui-define + collector-ui-graphql collector-ui-jetty-provider From 6b3aa98b82ec93e608b1fe06fb3f5c2a53528305 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sat, 20 Jan 2018 22:33:33 +0800 Subject: [PATCH 03/36] Initialize the java class entity for mapping graphql protocol. --- .../collector-ui-graphql/pom.xml | 5 ++ .../apm/collector/ui/graphql/Mutation.java | 27 +++++++++ .../apm/collector/ui/graphql/Query.java | 27 +++++++++ .../collector/ui/graphql/VersionMutation.java | 26 +++++++++ .../collector/ui/graphql/VersionQuery.java | 26 +++++++++ .../apm/collector/ui/graphql/alarm/Alarm.java | 29 ++++++++++ .../collector/ui/graphql/alarm/AlarmItem.java | 30 ++++++++++ .../ui/graphql/alarm/AlarmQuery.java | 33 +++++++++++ .../collector/ui/graphql/alarm/AlarmType.java | 28 +++++++++ .../collector/ui/graphql/alarm/CauseType.java | 27 +++++++++ .../graphql/application/ApplicationNode.java | 36 ++++++++++++ .../graphql/application/ApplicationQuery.java | 48 +++++++++++++++ .../graphql/application/ConjecturalNode.java | 27 +++++++++ .../apm/collector/ui/graphql/common/Call.java | 31 ++++++++++ .../collector/ui/graphql/common/Duration.java | 30 ++++++++++ .../collector/ui/graphql/common/Mutation.java | 26 +++++++++ .../apm/collector/ui/graphql/common/Node.java | 28 +++++++++ .../ui/graphql/common/Pagination.java | 28 +++++++++ .../ui/graphql/common/ResponseTimeTrend.java | 28 +++++++++ .../collector/ui/graphql/common/SLATrend.java | 28 +++++++++ .../apm/collector/ui/graphql/common/Step.java | 30 ++++++++++ .../ui/graphql/common/ThroughputTrend.java | 28 +++++++++ .../collector/ui/graphql/common/Topology.java | 29 ++++++++++ .../ui/graphql/common/VisualUserNode.java | 25 ++++++++ .../ui/graphql/config/AlarmThreshold.java | 31 ++++++++++ .../ui/graphql/config/ConfigMutation.java | 36 ++++++++++++ .../ui/graphql/config/ConfigQuery.java | 36 ++++++++++++ .../config/ExistedAlarmThresholdItem.java | 29 ++++++++++ .../config/ExistedAlarmThresholds.java | 28 +++++++++ .../ui/graphql/config/ExistedTTLConfigs.java | 28 +++++++++ .../apm/collector/ui/graphql/config/TTL.java | 29 ++++++++++ .../ui/graphql/config/TTLConfigItem.java | 29 ++++++++++ .../ui/graphql/overview/AlarmTrend.java | 28 +++++++++ .../ui/graphql/overview/ClusterBrief.java | 30 ++++++++++ .../ui/graphql/overview/ConjecturalApp.java | 27 +++++++++ .../graphql/overview/ConjecturalAppBrief.java | 28 +++++++++ .../graphql/overview/OverViewLayerQuery.java | 56 ++++++++++++++++++ .../ui/graphql/server/AppServerInfo.java | 33 +++++++++++ .../collector/ui/graphql/server/CPUTrend.java | 28 +++++++++ .../collector/ui/graphql/server/GCTrend.java | 29 ++++++++++ .../ui/graphql/server/MemoryTrend.java | 31 ++++++++++ .../ui/graphql/server/ServerQuery.java | 58 +++++++++++++++++++ .../ui/graphql/service/ServiceInfo.java | 29 ++++++++++ .../ui/graphql/service/ServiceNode.java | 30 ++++++++++ .../ui/graphql/service/ServiceQuery.java | 52 +++++++++++++++++ .../ui/graphql/trace/BasicTrace.java | 30 ++++++++++ .../collector/ui/graphql/trace/KeyValue.java | 27 +++++++++ .../collector/ui/graphql/trace/LogEntity.java | 29 ++++++++++ .../apm/collector/ui/graphql/trace/Ref.java | 29 ++++++++++ .../collector/ui/graphql/trace/RefType.java | 27 +++++++++ .../collector/ui/graphql/trace/Segment.java | 31 ++++++++++ .../apm/collector/ui/graphql/trace/Span.java | 43 ++++++++++++++ .../apm/collector/ui/graphql/trace/Trace.java | 28 +++++++++ .../ui/graphql/trace/TraceBrief.java | 29 ++++++++++ .../ui/graphql/trace/TraceQuery.java | 34 +++++++++++ .../ui/graphql/trace/TraceQueryCondition.java | 36 ++++++++++++ .../ui/graphql/UIGraphQLProtocolTestCase.java | 57 ++++++++++++++++++ 57 files changed, 1785 insertions(+) create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Mutation.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Query.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionMutation.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml b/apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml index 1ce46b840..7e82b5ad6 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/pom.xml @@ -36,5 +36,10 @@ graphql-java-tools 4.3.0 + + org.apache.skywalking + apm-ui-protocol + ${project.version} + diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Mutation.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Mutation.java new file mode 100644 index 000000000..6967911aa --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Mutation.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.ui.graphql; + +import com.coxautodev.graphql.tools.GraphQLMutationResolver; + +/** + * @author peng-yongsheng + */ +public interface Mutation extends GraphQLMutationResolver { +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Query.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Query.java new file mode 100644 index 000000000..735089000 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/Query.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.ui.graphql; + +import com.coxautodev.graphql.tools.GraphQLQueryResolver; + +/** + * @author peng-yongsheng + */ +public interface Query extends GraphQLQueryResolver { +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionMutation.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionMutation.java new file mode 100644 index 000000000..3b4295c18 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionMutation.java @@ -0,0 +1,26 @@ +/* + * 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.apm.collector.ui.graphql; + +/** + * @author peng-yongsheng + */ +public class VersionMutation implements Mutation { + private String version; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionQuery.java new file mode 100644 index 000000000..bba61bc8f --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/VersionQuery.java @@ -0,0 +1,26 @@ +/* + * 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.apm.collector.ui.graphql; + +/** + * @author peng-yongsheng + */ +public class VersionQuery implements Query { + private String version; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java new file mode 100644 index 000000000..2f021b431 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.alarm; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Alarm { + private List items; + private Integer count; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.java new file mode 100644 index 000000000..bae35fba4 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.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.apm.collector.ui.graphql.alarm; + +/** + * @author peng-yongsheng + */ +public class AlarmItem { + private String title; + private String content; + private String startTime; + private AlarmType alertType; + private CauseType causeType; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java new file mode 100644 index 000000000..0dd131eb1 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.ui.graphql.alarm; + +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; +import org.apache.skywalking.apm.collector.ui.graphql.common.Pagination; + +/** + * @author peng-yongsheng + */ +public class AlarmQuery implements Query { + public Alarm loadAlertList(String keyword, AlarmType alarmType, Duration duration, + Pagination pagination) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java new file mode 100644 index 000000000..d36d547c0 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.alarm; + +/** + * @author peng-yongsheng + */ +public enum AlarmType { + APPLICATION, + SERVER, + SERVICE +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java new file mode 100644 index 000000000..5d5986b06 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.ui.graphql.alarm; + +/** + * @author peng-yongsheng + */ +public enum CauseType { + LOW_SUCCESS_RATE, + SLOW_RESPONSE +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java new file mode 100644 index 000000000..45bc62c4a --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java @@ -0,0 +1,36 @@ +/* + * 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.apm.collector.ui.graphql.application; + +import org.apache.skywalking.apm.collector.ui.graphql.common.Node; + +/** + * @author peng-yongsheng + */ +public class ApplicationNode extends Node { + private Float sla; + private Long callsPerSec; + private Integer responseTimePerSec; + private Long calls; + private Float apdex; + private Boolean isAlarm; + private Integer numOfServer; + private Integer numOfServerAlarm; + private Integer numOfServiceAlarm; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java new file mode 100644 index 000000000..44e735152 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java @@ -0,0 +1,48 @@ +/* + * 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.apm.collector.ui.graphql.application; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; +import org.apache.skywalking.apm.collector.ui.graphql.common.Topology; +import org.apache.skywalking.apm.collector.ui.graphql.server.AppServerInfo; +import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceInfo; + +/** + * @author peng-yongsheng + */ +public class ApplicationQuery implements Query { + + public List getAllApplication(Duration duration) { + return null; + } + + public Topology getApplicationTopology(int applicationId, Duration duration) { + return null; + } + + public List getSlowService(int applicationId, Duration duration, Integer top) { + return null; + } + + public List getServerThroughput(int applicationId, Duration duration, Integer top) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java new file mode 100644 index 000000000..8cd678afc --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.ui.graphql.application; + +import org.apache.skywalking.apm.collector.ui.graphql.common.Node; + +/** + * @author peng-yongsheng + */ +public class ConjecturalNode extends Node { +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java new file mode 100644 index 000000000..3c039e036 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.ui.graphql.common; + +/** + * @author peng-yongsheng + */ +public class Call { + private String source; + private String target; + private Boolean isAlert; + private String callType; + private Integer callsPerSec; + private Integer responseTimePerSec; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java new file mode 100644 index 000000000..9bdeda4e7 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.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.apm.collector.ui.graphql.common; + +/** + * @author peng-yongsheng + */ +public class Duration { + + private String start; + private String end; + private Step step; + +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java new file mode 100644 index 000000000..82f21b500 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java @@ -0,0 +1,26 @@ +/* + * 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.apm.collector.ui.graphql.common; + +/** + * @author peng-yongsheng + */ +public class Mutation { + private String version; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java new file mode 100644 index 000000000..388e1f308 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.common; + +/** + * @author peng-yongsheng + */ +public abstract class Node { + private String id; + private String name; + private String type; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java new file mode 100644 index 000000000..6a690678d --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.common; + +/** + * @author peng-yongsheng + */ +public class Pagination { + private Integer pageNum; + private Integer pageSize; + private Boolean needTotal; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java new file mode 100644 index 000000000..21f7967a9 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeTrend { + private List trendList; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java new file mode 100644 index 000000000..4d2526584 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class SLATrend { + private List trendList; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.java new file mode 100644 index 000000000..b4d4c4c56 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.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.apm.collector.ui.graphql.common; + +/** + * @author peng-yongsheng + */ +public enum Step { + MONTH, + DAY, + HOUR, + MINUTE, + SECOND +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java new file mode 100644 index 000000000..504464dde --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ThroughputTrend { + private List trendList; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java new file mode 100644 index 000000000..6f618ef7c --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Topology { + private List nodes; + private List calls; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java new file mode 100644 index 000000000..0ede1446a --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java @@ -0,0 +1,25 @@ +/* + * 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.apm.collector.ui.graphql.common; + +/** + * @author peng-yongsheng + */ +public class VisualUserNode extends Node { +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java new file mode 100644 index 000000000..e4ae4fc08 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmType; +import org.apache.skywalking.apm.collector.ui.graphql.alarm.CauseType; + +/** + * @author peng-yongsheng + */ +public class AlarmThreshold { + private AlarmType type; + private Integer threshold; + private CauseType causeType; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java new file mode 100644 index 000000000..828926c7e --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java @@ -0,0 +1,36 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.Mutation; + +/** + * @author peng-yongsheng + */ +public class ConfigMutation implements Mutation { + + public Boolean setDataTTLConfigs(List ttl) { + return null; + } + + public Boolean setAlarmThreshold(List thresholds) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java new file mode 100644 index 000000000..4959eec6b --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java @@ -0,0 +1,36 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmType; + +/** + * @author peng-yongsheng + */ +public class ConfigQuery implements Query { + + public ExistedTTLConfigs queryAllDataTTLConfigs() { + return null; + } + + public ExistedAlarmThresholds queryAlarmThresholds(AlarmType alarmType) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java new file mode 100644 index 000000000..2efd4c897 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import org.apache.skywalking.apm.collector.ui.graphql.alarm.CauseType; + +/** + * @author peng-yongsheng + */ +public class ExistedAlarmThresholdItem { + private Integer threshold; + private CauseType causeType; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java new file mode 100644 index 000000000..e6c32e618 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ExistedAlarmThresholds { + private List items; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java new file mode 100644 index 000000000..ad76dbd1c --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ExistedTTLConfigs { + private List ttl; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java new file mode 100644 index 000000000..6d65c0384 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import org.apache.skywalking.apm.collector.ui.graphql.common.Step; + +/** + * @author peng-yongsheng + */ +public class TTL { + private Step unit; + private Integer value; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java new file mode 100644 index 000000000..bb16bbf4a --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.config; + +import org.apache.skywalking.apm.collector.ui.graphql.common.Step; + +/** + * @author peng-yongsheng + */ +public class TTLConfigItem { + private Step unit; + private Integer value; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java new file mode 100644 index 000000000..604e5da20 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.overview; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class AlarmTrend { + public List numOfAlarmRate; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.java new file mode 100644 index 000000000..59177bd23 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.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.apm.collector.ui.graphql.overview; + +/** + * @author peng-yongsheng + */ +public class ClusterBrief { + private int numOfApplication; + private int numOfService; + private int numOfDatabase; + private int numOfCache; + private int numOfMQ; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java new file mode 100644 index 000000000..60688bd98 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.ui.graphql.overview; + +/** + * @author peng-yongsheng + */ +public class ConjecturalApp { + private String name; + private int num; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java new file mode 100644 index 000000000..74c9c8a7b --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.overview; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ConjecturalAppBrief { + private List apps; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java new file mode 100644 index 000000000..11c8c610d --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java @@ -0,0 +1,56 @@ +/* + * 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.apm.collector.ui.graphql.overview; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; +import org.apache.skywalking.apm.collector.ui.graphql.common.Topology; +import org.apache.skywalking.apm.collector.ui.graphql.server.AppServerInfo; +import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceInfo; + +/** + * @author peng-yongsheng + */ +public class OverViewLayerQuery implements Query { + + public Topology getClusterTopology(Duration duration) { + return null; + } + + public ClusterBrief getClusterBrief(Duration duration) { + return null; + } + + public AlarmTrend getAlarmTrend(Duration duration) { + return null; + } + + public ConjecturalAppBrief getConjecturalApps(Duration duration) { + return null; + } + + public List getTopNSlowService(Duration duration, int topN) { + return null; + } + + public List getTopNServerThroughput(Duration duration, int topN) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java new file mode 100644 index 000000000..206b5221f --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.ui.graphql.server; + +/** + * @author peng-yongsheng + */ +public class AppServerInfo { + private int id; + private String name; + private int tps; + private String os; + private String host; + private int pid; + private String ipv4; + private String ipv6; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java new file mode 100644 index 000000000..2c1ae10f4 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.server; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class CPUTrend { + private List cost; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java new file mode 100644 index 000000000..47309ad96 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.server; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class GCTrend { + private List youngGC; + private List oldGC; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java new file mode 100644 index 000000000..4dba1d842 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.ui.graphql.server; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class MemoryTrend { + private List heap; + private List maxHeap; + private List noheap; + private List maxNoheap; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java new file mode 100644 index 000000000..96aa50ebb --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java @@ -0,0 +1,58 @@ +/* + * 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.apm.collector.ui.graphql.server; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; +import org.apache.skywalking.apm.collector.ui.graphql.common.ResponseTimeTrend; +import org.apache.skywalking.apm.collector.ui.graphql.common.ThroughputTrend; + +/** + * @author peng-yongsheng + */ +public class ServerQuery implements Query { + public List searchServer(String keyword, Duration duration) { + return null; + } + + public List getAllServer(String applicationId, Duration duration) { + return null; + } + + public ResponseTimeTrend getServerResponseTimeTrend(int serverId, Duration duration) { + return null; + } + + public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) { + return null; + } + + public CPUTrend getCPUTrend(int serverId, Duration duration) { + return null; + } + + public GCTrend getGCTrend(int serverId, Duration duration) { + return null; + } + + public MemoryTrend getMemoryTrend(int serverId, Duration duration) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java new file mode 100644 index 000000000..6a44722d7 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.service; + +/** + * @author peng-yongsheng + */ +public class ServiceInfo { + private int id; + private String name; + private int avgResponseTime; + private int tps; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.java new file mode 100644 index 000000000..c29c0fea1 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.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.apm.collector.ui.graphql.service; + +import org.apache.skywalking.apm.collector.ui.graphql.common.Node; + +/** + * @author peng-yongsheng + */ +public class ServiceNode extends Node { + private Float sla; + private Long calls; + private Integer numOfServiceAlarm; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java new file mode 100644 index 000000000..5ed158f8e --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java @@ -0,0 +1,52 @@ +/* + * 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.apm.collector.ui.graphql.service; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; +import org.apache.skywalking.apm.collector.ui.graphql.common.ResponseTimeTrend; +import org.apache.skywalking.apm.collector.ui.graphql.common.SLATrend; +import org.apache.skywalking.apm.collector.ui.graphql.common.ThroughputTrend; +import org.apache.skywalking.apm.collector.ui.graphql.common.Topology; + +/** + * @author peng-yongsheng + */ +public class ServiceQuery implements Query { + public List searchService(String keyword, Duration duration, Integer topN) { + return null; + } + + public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Duration duration) { + return null; + } + + public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) { + return null; + } + + public SLATrend getServiceSLATrend(int serviceId, Duration duration) { + return null; + } + + public Topology getServiceTopology(int serviceId, Duration duration) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.java new file mode 100644 index 000000000..2b2151906 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.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.apm.collector.ui.graphql.trace; + +/** + * @author peng-yongsheng + */ +public class BasicTrace { + private String operationName; + private int duration; + private String start; + private Boolean isError; + private String traceId; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java new file mode 100644 index 000000000..28710cd0d --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +/** + * @author peng-yongsheng + */ +public class KeyValue { + private String key; + private String value; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java new file mode 100644 index 000000000..d2938d4c1 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class LogEntity { + private String time; + private List data; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java new file mode 100644 index 000000000..ef226f4f7 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +/** + * @author peng-yongsheng + */ +public class Ref { + private String traceId; + private Integer parentSegmentId; + private Integer parentSpanId; + private RefType type; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java new file mode 100644 index 000000000..6c3ce9fe4 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +/** + * @author peng-yongsheng + */ +public enum RefType { + CROSS_PROCESS, + CROSS_THREAD +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java new file mode 100644 index 000000000..50dbe6cf2 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Segment { + private int segmentId; + private String appName; + private Boolean isSizeLimited; + private List spans; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java new file mode 100644 index 000000000..516eba00e --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java @@ -0,0 +1,43 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Span { + private String traceId; + private String segmentId; + private Integer spanId; + private Integer parentSpanId; + private List refs; + private String applicationCode; + private Long startTime; + private Long endTime; + private String operationName; + private String type; + private String peer; + private String component; + private Boolean isError; + private String layer; + private List tags; + private List logs; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java new file mode 100644 index 000000000..05b1ba19d --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Trace { + private List spans; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java new file mode 100644 index 000000000..b9353370a --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class TraceBrief { + private List traces; + private Integer total; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java new file mode 100644 index 000000000..76b370b1b --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java @@ -0,0 +1,34 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +import org.apache.skywalking.apm.collector.ui.graphql.Query; + +/** + * @author peng-yongsheng + */ +public class TraceQuery implements Query { + public TraceBrief queryBasicTraces(TraceQueryCondition condition) { + return null; + } + + public Trace queryTrace(String id) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java new file mode 100644 index 000000000..5dd8fdd01 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java @@ -0,0 +1,36 @@ +/* + * 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.apm.collector.ui.graphql.trace; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; + +/** + * @author peng-yongsheng + */ +public class TraceQueryCondition { + private List applicationCodes; + private String traceId; + private String operationName; + private Duration queryDuration; + private int minTraceDuration; + private int maxTraceDuration; + private Boolean topN; + private int needTotal; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java new file mode 100644 index 000000000..fc0853694 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java @@ -0,0 +1,57 @@ +/* + * 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.apm.collector.ui.graphql; + +import com.coxautodev.graphql.tools.SchemaParser; +import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmQuery; +import org.apache.skywalking.apm.collector.ui.graphql.application.ApplicationQuery; +import org.apache.skywalking.apm.collector.ui.graphql.application.ConjecturalNode; +import org.apache.skywalking.apm.collector.ui.graphql.common.VisualUserNode; +import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigMutation; +import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigQuery; +import org.apache.skywalking.apm.collector.ui.graphql.overview.OverViewLayerQuery; +import org.apache.skywalking.apm.collector.ui.graphql.server.ServerQuery; +import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceQuery; +import org.apache.skywalking.apm.collector.ui.graphql.trace.TraceQuery; +import org.junit.Test; + +/** + * @author peng-yongsheng + */ +public class UIGraphQLProtocolTestCase { + + @Test + public void test() { + SchemaParser.newParser() + .file("ui-graphql/alarm.graphqls") + .file("ui-graphql/application-layer.graphqls") + .file("ui-graphql/common.graphqls") + .file("ui-graphql/config.graphqls") + .file("ui-graphql/overview-layer.graphqls") + .file("ui-graphql/server-layer.graphqls") + .file("ui-graphql/service-layer.graphqls") + .file("ui-graphql/trace.graphqls") + .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery()) + .resolvers(new OverViewLayerQuery(), new ServerQuery(), new ServiceQuery(), new TraceQuery()) + .resolvers(new ConfigQuery(), new ConfigMutation()) + .dictionary(ConjecturalNode.class, VisualUserNode.class) + .build() + .makeExecutableSchema(); + } +} From 96197120b900e79697e031289c4070527e54689f Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sun, 21 Jan 2018 11:44:06 +0800 Subject: [PATCH 04/36] Provide GraphQL jetty servlet do get method. --- .../collector/server/jetty/JettyHandler.java | 7 +- .../collector/ui/graphql/GraphQLCreator.java | 59 ++++++++++++ .../apm/collector/ui/graphql/alarm/Alarm.java | 16 ++++ .../ui/graphql/alarm/AlarmQuery.java | 8 +- .../collector/ui/graphql/common/Duration.java | 23 +++++ .../ui/graphql/common/Pagination.java | 24 +++++ .../ui/graphql/GraphQLCreatorTestCase.java | 34 +++++++ .../ui/jetty/UIModuleJettyProvider.java | 3 + .../ui/jetty/handler/GraphQLHandler.java | 92 +++++++++++++++++++ 9 files changed, 259 insertions(+), 7 deletions(-) create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java diff --git a/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java b/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java index 5113e666b..0c557b026 100644 --- a/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java +++ b/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.server.jetty; import com.google.gson.JsonElement; @@ -61,7 +60,7 @@ public abstract class JettyHandler extends HttpServlet implements ServerHandler } } - protected abstract JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException; + protected abstract JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException, IOException; @Override protected final void doHead(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { @@ -150,7 +149,7 @@ public abstract class JettyHandler extends HttpServlet implements ServerHandler } private void reply(HttpServletResponse response, JsonElement resJson) throws IOException { - response.setContentType("text/json"); + response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); response.setStatus(HttpServletResponse.SC_OK); @@ -163,7 +162,7 @@ public abstract class JettyHandler extends HttpServlet implements ServerHandler } private void replyError(HttpServletResponse response, String errorMessage, int status) throws IOException { - response.setContentType("text/plain"); + response.setContentType("application/json"); response.setCharacterEncoding("utf-8"); response.setStatus(status); response.setHeader("error-message", errorMessage); diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java new file mode 100644 index 000000000..f6df67125 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java @@ -0,0 +1,59 @@ +/* + * 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.apm.collector.ui.graphql; + +import com.coxautodev.graphql.tools.SchemaParser; +import graphql.GraphQL; +import graphql.schema.GraphQLSchema; +import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmQuery; +import org.apache.skywalking.apm.collector.ui.graphql.application.ApplicationQuery; +import org.apache.skywalking.apm.collector.ui.graphql.application.ConjecturalNode; +import org.apache.skywalking.apm.collector.ui.graphql.common.VisualUserNode; +import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigMutation; +import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigQuery; +import org.apache.skywalking.apm.collector.ui.graphql.overview.OverViewLayerQuery; +import org.apache.skywalking.apm.collector.ui.graphql.server.ServerQuery; +import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceQuery; +import org.apache.skywalking.apm.collector.ui.graphql.trace.TraceQuery; + +/** + * @author peng-yongsheng + */ +public class GraphQLCreator { + + public GraphQL create() { + GraphQLSchema schema = SchemaParser.newParser() + .file("ui-graphql/alarm.graphqls") + .file("ui-graphql/application-layer.graphqls") + .file("ui-graphql/common.graphqls") + .file("ui-graphql/config.graphqls") + .file("ui-graphql/overview-layer.graphqls") + .file("ui-graphql/server-layer.graphqls") + .file("ui-graphql/service-layer.graphqls") + .file("ui-graphql/trace.graphqls") + .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery()) + .resolvers(new OverViewLayerQuery(), new ServerQuery(), new ServiceQuery(), new TraceQuery()) + .resolvers(new ConfigQuery(), new ConfigMutation()) + .dictionary(ConjecturalNode.class, VisualUserNode.class) + .build() + .makeExecutableSchema(); + + return GraphQL.newGraphQL(schema).build(); + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java index 2f021b431..40002b7de 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java @@ -26,4 +26,20 @@ import java.util.List; public class Alarm { private List items; private Integer count; + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java index 0dd131eb1..8c213a658 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java @@ -26,8 +26,10 @@ import org.apache.skywalking.apm.collector.ui.graphql.common.Pagination; * @author peng-yongsheng */ public class AlarmQuery implements Query { - public Alarm loadAlertList(String keyword, AlarmType alarmType, Duration duration, - Pagination pagination) { - return null; + + public Alarm loadAlertList(String keyword, AlarmType alarmType, Duration duration, Pagination pagination) { + Alarm alarm = new Alarm(); + alarm.setCount(0); + return alarm; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java index 9bdeda4e7..ad051f150 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java @@ -27,4 +27,27 @@ public class Duration { private String end; private Step step; + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + public String getEnd() { + return end; + } + + public void setEnd(String end) { + this.end = end; + } + + public Step getStep() { + return step; + } + + public void setStep(Step step) { + this.step = step; + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java index 6a690678d..b0cabe5e5 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java @@ -25,4 +25,28 @@ public class Pagination { private Integer pageNum; private Integer pageSize; private Boolean needTotal; + + public Integer getPageNum() { + return pageNum; + } + + public void setPageNum(Integer pageNum) { + this.pageNum = pageNum; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Boolean getNeedTotal() { + return needTotal; + } + + public void setNeedTotal(Boolean needTotal) { + this.needTotal = needTotal; + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java new file mode 100644 index 000000000..a232eb75e --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java @@ -0,0 +1,34 @@ +/* + * 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.apm.collector.ui.graphql; + +import graphql.GraphQL; +import org.junit.Test; + +/** + * @author peng-yongsheng + */ +public class GraphQLCreatorTestCase { + + @Test + public void test() { + GraphQLCreator creator = new GraphQLCreator(); + GraphQL graphQL = creator.create(); + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java index 90bc5af2b..c3876eeb8 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java @@ -33,6 +33,7 @@ import org.apache.skywalking.apm.collector.naming.service.NamingHandlerRegisterS import org.apache.skywalking.apm.collector.server.Server; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.ui.UIModule; +import org.apache.skywalking.apm.collector.ui.jetty.handler.GraphQLHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.SegmentTopGetHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.SpanGetHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.TraceDagGetHandler; @@ -110,5 +111,7 @@ public class UIModuleJettyProvider extends ModuleProvider { jettyServer.addHandler(new SpanGetHandler(getManager())); jettyServer.addHandler(new TraceDagGetHandler(getManager())); jettyServer.addHandler(new TraceStackGetHandler(getManager())); + + jettyServer.addHandler(new GraphQLHandler()); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java new file mode 100644 index 000000000..8e51a36fe --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -0,0 +1,92 @@ +/* + * 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.apm.collector.ui.jetty.handler; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import graphql.ExecutionInput; +import graphql.ExecutionResult; +import graphql.GraphQL; +import graphql.GraphQLError; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.util.List; +import javax.servlet.http.HttpServletRequest; +import org.apache.skywalking.apm.collector.core.util.CollectionUtils; +import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; +import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; +import org.apache.skywalking.apm.collector.ui.graphql.GraphQLCreator; + +/** + * @author peng-yongsheng + */ +public class GraphQLHandler extends JettyHandler { + + private final Gson gson = new Gson(); + private final GraphQL graphQL; + private static final String QUERY = "query"; + private static final String DATA = "data"; + private static final String ERRORS = "errors"; + + public GraphQLHandler() { + GraphQLCreator creator = new GraphQLCreator(); + this.graphQL = creator.create(); + } + + @Override public String pathSpec() { + return "/graphql"; + } + + @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { + return execute(req.getParameter(QUERY)); + } + + @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException, IOException { + BufferedReader reader = new BufferedReader(new InputStreamReader(req.getInputStream())); + String line; + String request = ""; + while ((line = reader.readLine()) != null) { + request += line; + } + + return execute(request); + } + + private JsonObject execute(String request) { + ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(request).build(); + ExecutionResult executionResult = graphQL.execute(executionInput); + + Object data = executionResult.getData(); + List errors = executionResult.getErrors(); + + JsonObject jsonObject = new JsonObject(); + jsonObject.addProperty(DATA, data.toString()); + + if (CollectionUtils.isNotEmpty(errors)) { + String errorJsonStr = gson.toJson(errors, JsonArray.class); + JsonArray errorArray = gson.fromJson(errorJsonStr, JsonArray.class); + jsonObject.add(ERRORS, errorArray); + } + + return jsonObject; + } +} From 843e709faee6ef2ba9271f54e3f87a407d735567 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sun, 21 Jan 2018 11:52:24 +0800 Subject: [PATCH 05/36] Provide GraphQL jetty servlet do post method. --- .../ui/graphql/UIGraphQLProtocolTestCase.java | 57 ------------------- .../ui/jetty/handler/GraphQLHandler.java | 3 +- 2 files changed, 2 insertions(+), 58 deletions(-) delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java deleted file mode 100644 index fc0853694..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/UIGraphQLProtocolTestCase.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * 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.apm.collector.ui.graphql; - -import com.coxautodev.graphql.tools.SchemaParser; -import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmQuery; -import org.apache.skywalking.apm.collector.ui.graphql.application.ApplicationQuery; -import org.apache.skywalking.apm.collector.ui.graphql.application.ConjecturalNode; -import org.apache.skywalking.apm.collector.ui.graphql.common.VisualUserNode; -import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigMutation; -import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigQuery; -import org.apache.skywalking.apm.collector.ui.graphql.overview.OverViewLayerQuery; -import org.apache.skywalking.apm.collector.ui.graphql.server.ServerQuery; -import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceQuery; -import org.apache.skywalking.apm.collector.ui.graphql.trace.TraceQuery; -import org.junit.Test; - -/** - * @author peng-yongsheng - */ -public class UIGraphQLProtocolTestCase { - - @Test - public void test() { - SchemaParser.newParser() - .file("ui-graphql/alarm.graphqls") - .file("ui-graphql/application-layer.graphqls") - .file("ui-graphql/common.graphqls") - .file("ui-graphql/config.graphqls") - .file("ui-graphql/overview-layer.graphqls") - .file("ui-graphql/server-layer.graphqls") - .file("ui-graphql/service-layer.graphqls") - .file("ui-graphql/trace.graphqls") - .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery()) - .resolvers(new OverViewLayerQuery(), new ServerQuery(), new ServiceQuery(), new TraceQuery()) - .resolvers(new ConfigQuery(), new ConfigMutation()) - .dictionary(ConjecturalNode.class, VisualUserNode.class) - .build() - .makeExecutableSchema(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index 8e51a36fe..d5e38df4f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -68,7 +68,8 @@ public class GraphQLHandler extends JettyHandler { request += line; } - return execute(request); + JsonObject requestJson = gson.fromJson(request, JsonObject.class); + return execute(requestJson.get(QUERY).getAsString()); } private JsonObject execute(String request) { From a25e353e2d5a4a2fd973c75f590567f75b014fd3 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 24 Jan 2018 00:12:27 +0800 Subject: [PATCH 06/36] Implement the method named getAllApplication in application layer graphql protocol. --- .../InstanceDiscoveryServiceHandler.java | 4 +- .../test/resources/json/dubbox-consumer.json | 52 +++---- .../test/resources/json/dubbox-provider.json | 40 ++--- .../collector/core/util/TimeBucketUtils.java | 63 +------- .../core/util/TimeBucketUtilsTest.java | 25 ---- .../collector/storage/dao/IInstanceUIDAO.java | 22 +-- .../apm/collector/storage/ui/alarm/Alarm.java | 45 ++++++ .../collector/storage/ui/alarm/AlarmItem.java | 30 ++++ .../collector/storage/ui/alarm/AlarmType.java | 28 ++++ .../collector/storage/ui/alarm/CauseType.java | 27 ++++ .../storage/ui/application/Application.java | 52 +++++++ .../ui/application/ApplicationNode.java | 109 ++++++++++++++ .../ui/application/ConjecturalNode.java | 27 ++++ .../apm/collector/storage/ui/common/Call.java | 31 ++++ .../collector/storage/ui/common/Duration.java | 53 +++++++ .../apm/collector/storage/ui/common/Node.java | 52 +++++++ .../storage/ui/common/Pagination.java | 52 +++++++ .../storage/ui/common/ResponseTimeTrend.java | 28 ++++ .../collector/storage/ui/common/SLATrend.java | 28 ++++ .../apm/collector/storage/ui/common/Step.java | 30 ++++ .../storage/ui/common/ThroughputTrend.java | 28 ++++ .../collector/storage/ui/common/Topology.java | 29 ++++ .../storage/ui/common/VisualUserNode.java} | 5 +- .../storage/ui/config/AlarmThreshold.java | 31 ++++ .../ui/config/ExistedAlarmThresholdItem.java | 29 ++++ .../ui/config/ExistedAlarmThresholds.java | 28 ++++ .../storage/ui/config/ExistedTTLConfigs.java | 28 ++++ .../apm/collector/storage/ui/config/TTL.java | 29 ++++ .../storage/ui/config/TTLConfigItem.java | 29 ++++ .../storage/ui/overview/AlarmTrend.java | 28 ++++ .../storage/ui/overview/ClusterBrief.java | 30 ++++ .../storage/ui/overview/ConjecturalApp.java | 27 ++++ .../ui/overview/ConjecturalAppBrief.java | 28 ++++ .../storage/ui/server/AppServerInfo.java | 33 ++++ .../collector/storage/ui/server/CPUTrend.java | 28 ++++ .../collector/storage/ui/server/GCTrend.java | 29 ++++ .../storage/ui/server/MemoryTrend.java | 31 ++++ .../storage/ui/service/ServiceInfo.java | 29 ++++ .../storage/ui/service/ServiceNode.java} | 12 +- .../storage/ui/trace/BasicTrace.java | 30 ++++ .../collector/storage/ui/trace/KeyValue.java | 27 ++++ .../collector/storage/ui/trace/LogEntity.java | 29 ++++ .../apm/collector/storage/ui/trace/Ref.java | 29 ++++ .../collector/storage/ui/trace/RefType.java | 27 ++++ .../collector/storage/ui/trace/Segment.java | 31 ++++ .../apm/collector/storage/ui/trace/Span.java | 43 ++++++ .../apm/collector/storage/ui/trace/Trace.java | 28 ++++ .../storage/ui/trace/TraceBrief.java | 29 ++++ .../storage/ui/trace/TraceQueryCondition.java | 36 +++++ .../storage/es/dao/CpuMetricEsUIDAO.java | 3 +- .../storage/es/dao/GCMetricEsUIDAO.java | 5 +- .../storage/es/dao/InstanceEsUIDAO.java | 13 +- .../storage/es/dao/InstanceMetricEsUIDAO.java | 7 +- .../storage/es/dao/MemoryMetricEsUIDAO.java | 3 +- .../es/dao/MemoryPoolMetricEsUIDAO.java | 3 +- .../dao/register/InstanceRegisterEsDAO.java | 7 +- .../storage/h2/dao/CpuMetricH2UIDAO.java | 10 +- .../storage/h2/dao/GCMetricH2UIDAO.java | 12 +- .../storage/h2/dao/InstanceH2UIDAO.java | 13 +- .../storage/h2/dao/InstanceMetricH2UIDAO.java | 12 +- .../storage/h2/dao/MemoryMetricH2UIDAO.java | 6 +- .../h2/dao/MemoryPoolMetricH2UIDAO.java | 8 +- .../dao/register/InstanceRegisterH2DAO.java | 7 +- .../collector/ui/graphql/GraphQLCreator.java | 59 -------- .../ui/graphql/utils/DurationUtils.java | 54 +++++++ .../DurationUtilsTestCase.java} | 11 +- .../ui/jetty/UIModuleJettyProvider.java | 27 +--- .../ui/jetty/handler/GraphQLHandler.java | 87 +++++++++-- .../jetty/handler/SegmentTopGetHandler.java | 141 ------------------ .../ui/jetty/handler/SpanGetHandler.java | 66 -------- .../ui/jetty/handler/TraceDagGetHandler.java | 77 ---------- .../jetty/handler/TraceStackGetHandler.java | 58 ------- .../application/ApplicationsGetHandler.java | 77 ---------- .../InstanceHealthGetHandler.java | 85 ----------- ...InstanceMetricGetOneTimeBucketHandler.java | 86 ----------- ...stanceMetricGetRangeTimeBucketHandler.java | 94 ------------ .../InstanceOsInfoGetHandler.java | 65 -------- .../ServiceTreeGetByIdHandler.java | 85 ----------- .../time/AllInstanceLastTimeGetHandler.java | 71 --------- .../time/OneInstanceLastTimeGetHandler.java | 70 --------- .../collector/ui/mutation/ConfigMutation.java | 38 +++++ .../apm/collector/ui/query/AlarmQuery.java | 37 +++++ .../collector/ui/query/ApplicationQuery.java | 94 ++++++++++++ .../apm/collector/ui/query/ConfigQuery.java | 38 +++++ .../ui/query/OverViewLayerQuery.java | 63 ++++++++ .../apm/collector/ui/query/ServerQuery.java | 62 ++++++++ .../apm/collector/ui/query/ServiceQuery.java | 53 +++++++ .../apm/collector/ui/query/TraceQuery.java | 37 +++++ .../ui/service/ApplicationService.java | 17 +-- .../ui/service/InstanceHealthService.java | 102 ++++++------- .../ui/query/ApplicationQueryTestCase.java | 139 +++++++++++++++++ .../ui-graphql/application-layer.graphqls | 8 +- 92 files changed, 2242 insertions(+), 1386 deletions(-) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmType.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/CauseType.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/Application.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ConjecturalNode.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Duration.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Pagination.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Step.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java rename apm-collector/{apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java => apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/VisualUserNode.java} (87%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/AlarmThreshold.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholdItem.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholds.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedTTLConfigs.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTL.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTLConfigItem.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/AlarmTrend.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java rename apm-collector/{apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java => apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java} (71%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/RefType.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Segment.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java rename apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/{GraphQLCreatorTestCase.java => utils/DurationUtilsTestCase.java} (78%) delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SegmentTopGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SpanGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceDagGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceStackGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/AllInstanceLastTimeGetHandler.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/OneInstanceLastTimeGetHandler.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/mutation/ConfigMutation.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ConfigQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java index 682b6c410..cde3e4c69 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/InstanceDiscoveryServiceHandler.java @@ -26,7 +26,6 @@ import org.apache.skywalking.apm.collector.analysis.metric.define.service.IInsta import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule; import org.apache.skywalking.apm.collector.analysis.register.define.service.IInstanceIDService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.server.grpc.GRPCHandler; import org.apache.skywalking.apm.network.proto.ApplicationInstance; import org.apache.skywalking.apm.network.proto.ApplicationInstanceHeartbeat; @@ -55,8 +54,7 @@ public class InstanceDiscoveryServiceHandler extends InstanceDiscoveryServiceGrp @Override public void registerInstance(ApplicationInstance request, StreamObserver responseObserver) { - long timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(request.getRegisterTime()); - int instanceId = instanceIDService.getOrCreateByAgentUUID(request.getApplicationId(), request.getAgentUUID(), timeBucket, buildOsInfo(request.getOsinfo())); + int instanceId = instanceIDService.getOrCreateByAgentUUID(request.getApplicationId(), request.getAgentUUID(), request.getRegisterTime(), buildOsInfo(request.getOsinfo())); ApplicationInstanceMapping.Builder builder = ApplicationInstanceMapping.newBuilder(); builder.setApplicationId(request.getApplicationId()); builder.setApplicationInstanceId(instanceId); diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json index 4c80222bd..02f3ef8b0 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json @@ -1,43 +1,33 @@ [ { - "gt": [ - [ - 230150, - 185809, - 24040000 - ] - ], + "gt": [[230150, 185809, 24040000]], //trace_id 链路编码 "sg": { - "ts": [ - 230150, - 185809, - 24040000 - ], - "ai": -1, - "ii": 2, - "rs": [], - "ss": [ + "ts": [230150, 185809, 24040000], //segment_id 一个应用中的一个实例在链路中产生的编号 + "ai": -1, //应用ID,应用启动注册时产生 + "ii": 2, //实例ID,应用启动注册时产生 + "rs": [], //链路的上下文信息,头节点,所以为空 + "ss": [ //一个埋点(手动埋点或者自动埋点) { - "si": 1, - "tv": 1, - "lv": 1, - "ps": 0, - "st": 1501858094526, - "et": 1501858097004, - "ci": 3, - "cn": "", - "oi": 0, - "on": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", - "pi": 0, - "pn": "172.25.0.4:20880", - "ie": false, - "to": [ + "si": 1, //埋点编号 + "tv": 1, //埋点类型(手动、入口、出口) + "lv": 1, //层(RPCFramework,Database,Http) + "ps": 0, //上级埋点编号 + "st": 1501858094526, //开始时间 + "et": 1501858097004, //结束时间 + "ci": 3, //组件编号(Tomcat、Mysql、Dubbo...) + "cn": "", //组件名称 + "oi": 0, //埋点的服务ID + "on": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", //埋点的服务名 + "pi": 0, //地址注册的ID,调用抓取后注册 + "pn": "172.25.0.4:20880", //地址 + "ie": false, //是否发生错误,是否有Exception + "to": [ //与链路分析关系较小的TAG,SQL也在其中 { "k": "url", "v": "rest://172.25.0.4:20880/org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()" } ], - "lo": [] + "lo": [] //日志,与链路分析完全无关,只作为展示使用,手动埋点时可以任意追加,kv的形式,例如收集一些业务相关的信息 }, { "si": 0, diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json index e446706f2..5add6e2f1 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json @@ -1,18 +1,8 @@ [ { - "gt": [ - [ - 230150, - 185809, - 24040000 - ] - ], + "gt": [[230150, 185809, 24040000]], //trace_id 链路编码,与调用方相同 "sg": { - "ts": [ - 137150, - 185809, - 48780000 - ], + "ts": [137150, 185809, 48780000], //segment_id,新产生 "ai": 2, "ii": 3, "ss": [ @@ -32,21 +22,17 @@ "ie": false, "rs": [ { - "pts": [ - 230150, - 185809, - 24040000 - ], - "pii": 2, - "psp": 0, - "psi": 0, - "psn": "/dubbox-case/case/dubbox-rest", - "ni": 0, - "nn": "172.25.0.4:20880", - "eii": 2, - "esi": 0, - "esn": "/dubbox-case/case/dubbox-rest", - "rn": 0 + "pts": [230150, 185809, 24040000], //上级的segment_id 一个应用中的一个实例在链路中产生的编号 + "pii": 2, //上级的实例编号 + "psp": 0, //上级的埋点编号span_id + "psi": 0, //上级的服务编号(org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()注册后的ID) + "psn": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", //上级的服务名 + "ni": 0, //上级调用时使用的地址注册后的ID + "nn": "172.25.0.4:20880", //上级的地址 + "eii": 2, //入口的实例编号 + "esi": 0, //入口的服务编号 + "esn": "/dubbox-case/case/dubbox-rest", //入口的服务名词 + "rn": 0 //调用方式(CrossProcess,CrossThread) } ], "to": [ diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java index e7f8501cf..a3cf5b2ef 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java @@ -20,8 +20,6 @@ package org.apache.skywalking.apm.collector.core.util; import java.text.SimpleDateFormat; import java.util.Calendar; -import java.util.TimeZone; -import org.apache.skywalking.apm.collector.core.UnexpectedException; /** * @author peng-yongsheng @@ -29,6 +27,7 @@ import org.apache.skywalking.apm.collector.core.UnexpectedException; public enum TimeBucketUtils { INSTANCE; + private final SimpleDateFormat monthDateFormat = new SimpleDateFormat("yyyyMM"); private final SimpleDateFormat dayDateFormat = new SimpleDateFormat("yyyyMMdd"); private final SimpleDateFormat hourDateFormat = new SimpleDateFormat("yyyyMMddHH"); private final SimpleDateFormat minuteDateFormat = new SimpleDateFormat("yyyyMMddHHmm"); @@ -90,65 +89,7 @@ public enum TimeBucketUtils { return secondBucket / 100 / 100 / 100 / 100; } - public long changeTimeBucket2TimeStamp(String timeBucketType, long timeBucket) { - if (TimeBucketType.SECOND.name().toLowerCase().equals(timeBucketType.toLowerCase())) { - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.YEAR, Integer.valueOf(String.valueOf(timeBucket).substring(0, 4))); - calendar.set(Calendar.MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(4, 6)) - 1); - calendar.set(Calendar.DAY_OF_MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(6, 8))); - calendar.set(Calendar.HOUR_OF_DAY, Integer.valueOf(String.valueOf(timeBucket).substring(8, 10))); - calendar.set(Calendar.MINUTE, Integer.valueOf(String.valueOf(timeBucket).substring(10, 12))); - calendar.set(Calendar.SECOND, Integer.valueOf(String.valueOf(timeBucket).substring(12, 14))); - return calendar.getTimeInMillis(); - } else if (TimeBucketType.MINUTE.name().toLowerCase().equals(timeBucketType.toLowerCase())) { - Calendar calendar = Calendar.getInstance(); - calendar.set(Calendar.YEAR, Integer.valueOf(String.valueOf(timeBucket).substring(0, 4))); - calendar.set(Calendar.MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(4, 6)) - 1); - calendar.set(Calendar.DAY_OF_MONTH, Integer.valueOf(String.valueOf(timeBucket).substring(6, 8))); - calendar.set(Calendar.HOUR_OF_DAY, Integer.valueOf(String.valueOf(timeBucket).substring(8, 10))); - calendar.set(Calendar.MINUTE, Integer.valueOf(String.valueOf(timeBucket).substring(10, 12))); - return calendar.getTimeInMillis(); - } else { - throw new UnexpectedException("time bucket type must be second or minute"); - } - } - - public long[] getFiveSecondTimeBuckets(long secondTimeBucket) { - long timeStamp = changeTimeBucket2TimeStamp(TimeBucketType.SECOND.name(), secondTimeBucket); - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(timeStamp); - - long[] timeBuckets = new long[5]; - timeBuckets[0] = secondTimeBucket; - for (int i = 0; i < 4; i++) { - calendar.add(Calendar.SECOND, -1); - timeBuckets[i + 1] = getSecondTimeBucket(calendar.getTimeInMillis()); - } - return timeBuckets; - } - - public long changeToUTCTimeBucket(long timeBucket) { - String timeBucketStr = String.valueOf(timeBucket); - - if (TimeZone.getDefault().getID().equals("GMT+08:00") || timeBucketStr.endsWith("0000")) { - return timeBucket; - } else { - return timeBucket - 800; - } - } - - public long addSecondForSecondTimeBucket(String timeBucketType, long timeBucket, int second) { - if (!TimeBucketType.SECOND.name().equals(timeBucketType)) { - throw new UnexpectedException("time bucket type must be second "); - } - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(changeTimeBucket2TimeStamp(timeBucketType, timeBucket)); - calendar.add(Calendar.SECOND, second); - - return getSecondTimeBucket(calendar.getTimeInMillis()); - } - public enum TimeBucketType { - SECOND, MINUTE, HOUR, DAY + SECOND, MINUTE, HOUR, DAY, MONTH } } diff --git a/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtilsTest.java b/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtilsTest.java index 35f8d2276..dcc659980 100644 --- a/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtilsTest.java +++ b/apm-collector/apm-collector-core/src/test/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtilsTest.java @@ -16,14 +16,10 @@ * */ - package org.apache.skywalking.apm.collector.core.util; import java.util.TimeZone; -import org.junit.After; -import org.junit.Assert; import org.junit.Before; -import org.junit.Test; /** * @author wu-sheng @@ -33,25 +29,4 @@ public class TimeBucketUtilsTest { public void setup() { TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai")); } - - @After - public void teardown() { - - } - - @Test - public void testGetInfoFromATimestamp() { - long timeMillis = 1509521745220L; - Assert.assertArrayEquals(new long[] { - 20171101153545L, - 20171101153544L, - 20171101153543L, - 20171101153542L, - 20171101153541L - }, TimeBucketUtils.INSTANCE.getFiveSecondTimeBuckets(TimeBucketUtils.INSTANCE.getSecondTimeBucket(timeMillis))); - Assert.assertEquals(20171101153545L, TimeBucketUtils.INSTANCE.getSecondTimeBucket(timeMillis)); - Assert.assertEquals(201711011535L, TimeBucketUtils.INSTANCE.getMinuteTimeBucket(timeMillis)); - Assert.assertEquals(201711011500L, TimeBucketUtils.INSTANCE.getHourTimeBucket(timeMillis)); - Assert.assertEquals(201711010000L, TimeBucketUtils.INSTANCE.getDayTimeBucket(timeMillis)); - } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java index be7fe7e14..a2173bd53 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java @@ -18,10 +18,10 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonArray; import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; /** * @author peng-yongsheng @@ -31,27 +31,9 @@ public interface IInstanceUIDAO extends DAO { Long instanceLastHeartBeatTime(long applicationInstanceId); - JsonArray getApplications(long startTime, long endTime); + List getApplications(long startTime, long endTime); Instance getInstance(int instanceId); List getInstances(int applicationId, long timeBucket); - - class Application { - private final int applicationId; - private final long count; - - public Application(int applicationId, long count) { - this.applicationId = applicationId; - this.count = count; - } - - public int getApplicationId() { - return applicationId; - } - - public long getCount() { - return count; - } - } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java new file mode 100644 index 000000000..62c3dc102 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java @@ -0,0 +1,45 @@ +/* + * 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.apm.collector.storage.ui.alarm; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Alarm { + private List items; + private Integer count; + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + public Integer getCount() { + return count; + } + + public void setCount(Integer count) { + this.count = count; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java new file mode 100644 index 000000000..1523ec931 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.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.apm.collector.storage.ui.alarm; + +/** + * @author peng-yongsheng + */ +public class AlarmItem { + private String title; + private String content; + private String startTime; + private AlarmType alertType; + private CauseType causeType; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmType.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmType.java new file mode 100644 index 000000000..75986a5da --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmType.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.alarm; + +/** + * @author peng-yongsheng + */ +public enum AlarmType { + APPLICATION, + SERVER, + SERVICE +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/CauseType.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/CauseType.java new file mode 100644 index 000000000..908ff6482 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/CauseType.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.storage.ui.alarm; + +/** + * @author peng-yongsheng + */ +public enum CauseType { + LOW_SUCCESS_RATE, + SLOW_RESPONSE +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/Application.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/Application.java new file mode 100644 index 000000000..354efb2cf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/Application.java @@ -0,0 +1,52 @@ +/* + * 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.apm.collector.storage.ui.application; + +/** + * @author peng-yongsheng + */ +public class Application { + private int id; + private String name; + private int numOfServer; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getNumOfServer() { + return numOfServer; + } + + public void setNumOfServer(int numOfServer) { + this.numOfServer = numOfServer; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java new file mode 100644 index 000000000..0affa2480 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java @@ -0,0 +1,109 @@ +/* + * 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.apm.collector.storage.ui.application; + +import org.apache.skywalking.apm.collector.storage.ui.common.Node; + +/** + * @author peng-yongsheng + */ +public class ApplicationNode extends Node { + + private Float sla; + private Long callsPerSec; + private Integer responseTimePerSec; + private Long calls; + private Float apdex; + private Boolean isAlarm; + private Integer numOfServer; + private Integer numOfServerAlarm; + private Integer numOfServiceAlarm; + + public Float getSla() { + return sla; + } + + public void setSla(Float sla) { + this.sla = sla; + } + + public Long getCallsPerSec() { + return callsPerSec; + } + + public void setCallsPerSec(Long callsPerSec) { + this.callsPerSec = callsPerSec; + } + + public Integer getResponseTimePerSec() { + return responseTimePerSec; + } + + public void setResponseTimePerSec(Integer responseTimePerSec) { + this.responseTimePerSec = responseTimePerSec; + } + + public Long getCalls() { + return calls; + } + + public void setCalls(Long calls) { + this.calls = calls; + } + + public Float getApdex() { + return apdex; + } + + public void setApdex(Float apdex) { + this.apdex = apdex; + } + + public Boolean getAlarm() { + return isAlarm; + } + + public void setAlarm(Boolean alarm) { + isAlarm = alarm; + } + + public Integer getNumOfServer() { + return numOfServer; + } + + public void setNumOfServer(Integer numOfServer) { + this.numOfServer = numOfServer; + } + + public Integer getNumOfServerAlarm() { + return numOfServerAlarm; + } + + public void setNumOfServerAlarm(Integer numOfServerAlarm) { + this.numOfServerAlarm = numOfServerAlarm; + } + + public Integer getNumOfServiceAlarm() { + return numOfServiceAlarm; + } + + public void setNumOfServiceAlarm(Integer numOfServiceAlarm) { + this.numOfServiceAlarm = numOfServiceAlarm; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ConjecturalNode.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ConjecturalNode.java new file mode 100644 index 000000000..c77c36955 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ConjecturalNode.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.storage.ui.application; + +import org.apache.skywalking.apm.collector.storage.ui.common.Node; + +/** + * @author peng-yongsheng + */ +public class ConjecturalNode extends Node { +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java new file mode 100644 index 000000000..7a388e3ce --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.ui.common; + +/** + * @author peng-yongsheng + */ +public class Call { + private String source; + private String target; + private Boolean isAlert; + private String callType; + private Integer callsPerSec; + private Integer responseTimePerSec; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Duration.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Duration.java new file mode 100644 index 000000000..88ef2fa7f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Duration.java @@ -0,0 +1,53 @@ +/* + * 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.apm.collector.storage.ui.common; + +/** + * @author peng-yongsheng + */ +public class Duration { + + private String start; + private String end; + private Step step; + + public String getStart() { + return start; + } + + public void setStart(String start) { + this.start = start; + } + + public String getEnd() { + return end; + } + + public void setEnd(String end) { + this.end = end; + } + + public Step getStep() { + return step; + } + + public void setStep(Step step) { + this.step = step; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java new file mode 100644 index 000000000..e4d43c379 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java @@ -0,0 +1,52 @@ +/* + * 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.apm.collector.storage.ui.common; + +/** + * @author peng-yongsheng + */ +public abstract class Node { + private String id; + private String name; + private String type; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Pagination.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Pagination.java new file mode 100644 index 000000000..dc4904807 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Pagination.java @@ -0,0 +1,52 @@ +/* + * 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.apm.collector.storage.ui.common; + +/** + * @author peng-yongsheng + */ +public class Pagination { + private Integer pageNum; + private Integer pageSize; + private Boolean needTotal; + + public Integer getPageNum() { + return pageNum; + } + + public void setPageNum(Integer pageNum) { + this.pageNum = pageNum; + } + + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(Integer pageSize) { + this.pageSize = pageSize; + } + + public Boolean getNeedTotal() { + return needTotal; + } + + public void setNeedTotal(Boolean needTotal) { + this.needTotal = needTotal; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java new file mode 100644 index 000000000..018892d64 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ResponseTimeTrend { + private List trendList; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java new file mode 100644 index 000000000..a6204646b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class SLATrend { + private List trendList; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Step.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Step.java new file mode 100644 index 000000000..6a4d83a0b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Step.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.apm.collector.storage.ui.common; + +/** + * @author peng-yongsheng + */ +public enum Step { + MONTH, + DAY, + HOUR, + MINUTE, + SECOND +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java new file mode 100644 index 000000000..e6cf37b99 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ThroughputTrend { + private List trendList; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java new file mode 100644 index 000000000..7e3ac2c57 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.common; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Topology { + private List nodes; + private List calls; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/VisualUserNode.java similarity index 87% rename from apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/VisualUserNode.java index 82f21b500..8207acda2 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Mutation.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/VisualUserNode.java @@ -16,11 +16,10 @@ * */ -package org.apache.skywalking.apm.collector.ui.graphql.common; +package org.apache.skywalking.apm.collector.storage.ui.common; /** * @author peng-yongsheng */ -public class Mutation { - private String version; +public class VisualUserNode extends Node { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/AlarmThreshold.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/AlarmThreshold.java new file mode 100644 index 000000000..e96d329ec --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/AlarmThreshold.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.ui.config; + +import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType; +import org.apache.skywalking.apm.collector.storage.ui.alarm.CauseType; + +/** + * @author peng-yongsheng + */ +public class AlarmThreshold { + private AlarmType type; + private Integer threshold; + private CauseType causeType; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholdItem.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholdItem.java new file mode 100644 index 000000000..e42e70d96 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholdItem.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.config; + +import org.apache.skywalking.apm.collector.storage.ui.alarm.CauseType; + +/** + * @author peng-yongsheng + */ +public class ExistedAlarmThresholdItem { + private Integer threshold; + private CauseType causeType; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholds.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholds.java new file mode 100644 index 000000000..f4d094547 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedAlarmThresholds.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.config; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ExistedAlarmThresholds { + private List items; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedTTLConfigs.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedTTLConfigs.java new file mode 100644 index 000000000..32b29cbe2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/ExistedTTLConfigs.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.config; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ExistedTTLConfigs { + private List ttl; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTL.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTL.java new file mode 100644 index 000000000..3da100ed4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTL.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.config; + +import org.apache.skywalking.apm.collector.storage.ui.common.Step; + +/** + * @author peng-yongsheng + */ +public class TTL { + private Step unit; + private Integer value; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTLConfigItem.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTLConfigItem.java new file mode 100644 index 000000000..8984f1616 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/config/TTLConfigItem.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.config; + +import org.apache.skywalking.apm.collector.storage.ui.common.Step; + +/** + * @author peng-yongsheng + */ +public class TTLConfigItem { + private Step unit; + private Integer value; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/AlarmTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/AlarmTrend.java new file mode 100644 index 000000000..025d27df8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/AlarmTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.overview; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class AlarmTrend { + public List numOfAlarmRate; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.java new file mode 100644 index 000000000..41f3b8d5c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.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.apm.collector.storage.ui.overview; + +/** + * @author peng-yongsheng + */ +public class ClusterBrief { + private int numOfApplication; + private int numOfService; + private int numOfDatabase; + private int numOfCache; + private int numOfMQ; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java new file mode 100644 index 000000000..a1acc0fe7 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.storage.ui.overview; + +/** + * @author peng-yongsheng + */ +public class ConjecturalApp { + private String name; + private int num; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java new file mode 100644 index 000000000..d220623fa --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.overview; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class ConjecturalAppBrief { + private List apps; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java new file mode 100644 index 000000000..4d4c7cc93 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.storage.ui.server; + +/** + * @author peng-yongsheng + */ +public class AppServerInfo { + private int id; + private String name; + private int tps; + private String os; + private String host; + private int pid; + private String ipv4; + private String ipv6; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java new file mode 100644 index 000000000..062cfe213 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.server; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class CPUTrend { + private List cost; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java new file mode 100644 index 000000000..4880a8f44 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.server; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class GCTrend { + private List youngGC; + private List oldGC; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java new file mode 100644 index 000000000..bff93d542 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.ui.server; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class MemoryTrend { + private List heap; + private List maxHeap; + private List noheap; + private List maxNoheap; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java new file mode 100644 index 000000000..f33fbd469 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.service; + +/** + * @author peng-yongsheng + */ +public class ServiceInfo { + private int id; + private String name; + private int avgResponseTime; + private int tps; +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java similarity index 71% rename from apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java index 45bc62c4a..5d2b0cc95 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationNode.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java @@ -16,21 +16,15 @@ * */ -package org.apache.skywalking.apm.collector.ui.graphql.application; +package org.apache.skywalking.apm.collector.storage.ui.service; -import org.apache.skywalking.apm.collector.ui.graphql.common.Node; +import org.apache.skywalking.apm.collector.storage.ui.common.Node; /** * @author peng-yongsheng */ -public class ApplicationNode extends Node { +public class ServiceNode extends Node { private Float sla; - private Long callsPerSec; - private Integer responseTimePerSec; private Long calls; - private Float apdex; - private Boolean isAlarm; - private Integer numOfServer; - private Integer numOfServerAlarm; private Integer numOfServiceAlarm; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.java new file mode 100644 index 000000000..f8829f128 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.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.apm.collector.storage.ui.trace; + +/** + * @author peng-yongsheng + */ +public class BasicTrace { + private String operationName; + private int duration; + private String start; + private Boolean isError; + private String traceId; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java new file mode 100644 index 000000000..03e1d6857 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.storage.ui.trace; + +/** + * @author peng-yongsheng + */ +public class KeyValue { + private String key; + private String value; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java new file mode 100644 index 000000000..61855c8ea --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class LogEntity { + private String time; + private List data; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java new file mode 100644 index 000000000..a013e0c1a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.trace; + +/** + * @author peng-yongsheng + */ +public class Ref { + private String traceId; + private Integer parentSegmentId; + private Integer parentSpanId; + private RefType type; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/RefType.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/RefType.java new file mode 100644 index 000000000..00eca2080 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/RefType.java @@ -0,0 +1,27 @@ +/* + * 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.apm.collector.storage.ui.trace; + +/** + * @author peng-yongsheng + */ +public enum RefType { + CROSS_PROCESS, + CROSS_THREAD +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Segment.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Segment.java new file mode 100644 index 000000000..62fc6ab3d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Segment.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.ui.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Segment { + private int segmentId; + private String appName; + private Boolean isSizeLimited; + private List spans; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java new file mode 100644 index 000000000..1df21844c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java @@ -0,0 +1,43 @@ +/* + * 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.apm.collector.storage.ui.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Span { + private String traceId; + private String segmentId; + private Integer spanId; + private Integer parentSpanId; + private List refs; + private String applicationCode; + private Long startTime; + private Long endTime; + private String operationName; + private String type; + private String peer; + private String component; + private Boolean isError; + private String layer; + private List tags; + private List logs; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java new file mode 100644 index 000000000..a9f03964f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.ui.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Trace { + private List spans; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java new file mode 100644 index 000000000..1ec1987e3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.ui.trace; + +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class TraceBrief { + private List traces; + private Integer total; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java new file mode 100644 index 000000000..62757804d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java @@ -0,0 +1,36 @@ +/* + * 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.apm.collector.storage.ui.trace; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.ui.common.Duration; + +/** + * @author peng-yongsheng + */ +public class TraceQueryCondition { + private List applicationCodes; + private String traceId; + private String operationName; + private Duration queryDuration; + private int minTraceDuration; + private int maxTraceDuration; + private Boolean topN; + private int needTotal; +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java index 9ca846133..788bc5fc1 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java @@ -21,7 +21,6 @@ package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; @@ -54,7 +53,7 @@ public class CpuMetricEsUIDAO extends EsDAO implements ICpuMetricUIDAO { long timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String id = timeBucket + Const.ID_SPLIT + instanceId; prepareMultiGet.add(CpuMetricTable.TABLE, CpuMetricTable.TABLE_TYPE, id); } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java index 068955095..75f2e7cc8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java @@ -22,7 +22,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; @@ -112,7 +111,7 @@ public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO { MultiGetRequestBuilder youngPrepareMultiGet = getClient().prepareMultiGet(); long timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String youngId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.NEW_VALUE; youngPrepareMultiGet.add(GCMetricTable.TABLE, GCMetricTable.TABLE_TYPE, youngId); } @@ -132,7 +131,7 @@ public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO { MultiGetRequestBuilder oldPrepareMultiGet = getClient().prepareMultiGet(); timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String oldId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.OLD_VALUE; oldPrepareMultiGet.add(GCMetricTable.TABLE, GCMetricTable.TABLE_TYPE, oldId); } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java index 358650a76..7148c1704 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java @@ -18,8 +18,6 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; @@ -28,6 +26,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequestBuilder; @@ -95,7 +94,7 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { return heartBeatTime; } - @Override public JsonArray getApplications(long startTime, long endTime) { + @Override public List getApplications(long startTime, long endTime) { logger.debug("application list get, start time: {}, end time: {}", startTime, endTime); SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); @@ -108,16 +107,16 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); Terms genders = searchResponse.getAggregations().get(InstanceTable.COLUMN_APPLICATION_ID); - JsonArray applications = new JsonArray(); + List applications = new LinkedList<>(); for (Terms.Bucket applicationsBucket : genders.getBuckets()) { Integer applicationId = applicationsBucket.getKeyAsNumber().intValue(); logger.debug("applicationId: {}", applicationId); ValueCount instanceCount = applicationsBucket.getAggregations().get(InstanceTable.COLUMN_INSTANCE_ID); - JsonObject application = new JsonObject(); - application.addProperty("applicationId", applicationId); - application.addProperty("instanceCount", instanceCount.getValue()); + Application application = new Application(); + application.setId(applicationId); + application.setNumOfServer((int)instanceCount.getValue()); applications.add(application); } return applications; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java index de6657339..591e8e32d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java @@ -21,7 +21,6 @@ package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; @@ -86,7 +85,7 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO do { String id = timeBucket + Const.ID_SPLIT + instanceId; prepareMultiGet.add(InstanceMetricTable.TABLE, InstanceMetricTable.TABLE_TYPE, id); - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); } while (timeBucket <= endTimeBucket); @@ -118,9 +117,9 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); int i = 0; - long timeBucket; + long timeBucket = 0; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), startTimeBucket, i); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, startTimeBucket, i); String id = timeBucket + Const.ID_SPLIT + instanceId; prepareMultiGet.add(InstanceMetricTable.TABLE, InstanceMetricTable.TABLE_TYPE, id); i++; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java index 8caa326e7..5bcfc5c69 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java @@ -22,7 +22,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; @@ -63,7 +62,7 @@ public class MemoryMetricEsUIDAO extends EsDAO implements IMemoryMetricUIDAO { int i = 0; long timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + isHeap; prepareMultiGet.add(MemoryMetricTable.TABLE, MemoryMetricTable.TABLE_TYPE, id); } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java index dc5b4b333..54a40c738 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java @@ -22,7 +22,6 @@ import com.google.gson.JsonArray; import com.google.gson.JsonObject; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; @@ -62,7 +61,7 @@ public class MemoryPoolMetricEsUIDAO extends EsDAO implements IMemoryPoolMetricU long timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; prepareMultiGet.add(MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.TABLE_TYPE, id); } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/InstanceRegisterEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/InstanceRegisterEsDAO.java index c9b54be66..460b3e3fe 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/InstanceRegisterEsDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/InstanceRegisterEsDAO.java @@ -21,6 +21,7 @@ package org.apache.skywalking.apm.collector.storage.es.dao.register; import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; @@ -57,8 +58,8 @@ public class InstanceRegisterEsDAO extends EsDAO implements IInstanceRegisterDAO source.put(InstanceTable.COLUMN_INSTANCE_ID, instance.getInstanceId()); source.put(InstanceTable.COLUMN_APPLICATION_ID, instance.getApplicationId()); source.put(InstanceTable.COLUMN_AGENT_UUID, instance.getAgentUUID()); - source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime()); - source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime()); + source.put(InstanceTable.COLUMN_REGISTER_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getRegisterTime())); + source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getHeartBeatTime())); source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo()); source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId()); source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress()); @@ -76,7 +77,7 @@ public class InstanceRegisterEsDAO extends EsDAO implements IInstanceRegisterDAO updateRequest.setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE); Map source = new HashMap<>(); - source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, heartbeatTime); + source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(heartbeatTime)); updateRequest.doc(source); client.update(updateRequest); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java index 5f840cb6d..e3ec3d908 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; @@ -24,14 +23,13 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -68,7 +66,7 @@ public class CpuMetricH2UIDAO extends H2DAO implements ICpuMetricUIDAO { long timeBucket = startTimeBucket; List idList = new ArrayList<>(); do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String id = timeBucket + Const.ID_SPLIT + instanceId; idList.add(id); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java index 8cf181341..4c33c3536 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; @@ -25,14 +24,13 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; import org.apache.skywalking.apm.network.proto.GCPhrase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -119,7 +117,7 @@ public class GCMetricH2UIDAO extends H2DAO implements IGCMetricUIDAO { long timeBucket = startTimeBucket; List youngIdsList = new ArrayList<>(); do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String youngId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.NEW_VALUE; youngIdsList.add(youngId); } @@ -132,7 +130,7 @@ public class GCMetricH2UIDAO extends H2DAO implements IGCMetricUIDAO { List oldIdsList = new ArrayList<>(); timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String oldId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.OLD_VALUE; oldIdsList.add(oldId); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java index 674cbee05..a13ed2a2a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java @@ -18,8 +18,6 @@ package org.apache.skywalking.apm.collector.storage.h2.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import java.sql.ResultSet; import java.sql.SQLException; import java.util.LinkedList; @@ -32,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -88,9 +87,9 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { } @Override - public JsonArray getApplications(long startTime, long endTime) { + public List getApplications(long startTime, long endTime) { H2Client client = getClient(); - JsonArray applications = new JsonArray(); + List applications = new LinkedList<>(); String sql = SqlBuilder.buildSql(GET_APPLICATIONS_SQL, InstanceTable.COLUMN_INSTANCE_ID, InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_APPLICATION_ID); Object[] params = new Object[] {startTime}; @@ -98,9 +97,9 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { while (rs.next()) { Integer applicationId = rs.getInt(InstanceTable.COLUMN_APPLICATION_ID); logger.debug("applicationId: {}", applicationId); - JsonObject application = new JsonObject(); - application.addProperty("applicationId", applicationId); - application.addProperty("instanceCount", rs.getInt("cnt")); + Application application = new Application(); + application.setId(applicationId); + application.setNumOfServer(rs.getInt("cnt")); applications.add(application); } } catch (SQLException | H2ClientException e) { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java index 91c23d276..77b3185bb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; @@ -25,12 +24,11 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -100,7 +98,7 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO List idList = new ArrayList<>(); do { String id = timeBucket + Const.ID_SPLIT + instanceId; - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); idList.add(id); } while (timeBucket <= endTimeBucket); @@ -145,7 +143,7 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO List idList = new ArrayList<>(); do { String id = timeBucket + Const.ID_SPLIT + instanceId; - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); idList.add(id); } while (timeBucket <= endTimeBucket); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java index 26f7f5644..01e9e5425 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; @@ -26,12 +25,11 @@ import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,7 +74,7 @@ public class MemoryMetricH2UIDAO extends H2DAO implements IMemoryMetricUIDAO { List idList = new ArrayList<>(); long timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + isHeap; idList.add(id); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java index d4a5b11ae..c7aa20427 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; @@ -25,11 +24,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; @@ -76,7 +74,7 @@ public class MemoryPoolMetricH2UIDAO extends H2DAO implements IMemoryPoolMetricU List idList = new ArrayList<>(); long timeBucket = startTimeBucket; do { - timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, 1); +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; idList.add(id); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/InstanceRegisterH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/InstanceRegisterH2DAO.java index 45edf55a0..e1042f5dc 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/InstanceRegisterH2DAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/InstanceRegisterH2DAO.java @@ -22,6 +22,7 @@ import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.register.IInstanceRegisterDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; @@ -58,8 +59,8 @@ public class InstanceRegisterH2DAO extends H2DAO implements IInstanceRegisterDAO source.put(InstanceTable.COLUMN_INSTANCE_ID, instance.getInstanceId()); source.put(InstanceTable.COLUMN_APPLICATION_ID, instance.getApplicationId()); source.put(InstanceTable.COLUMN_AGENT_UUID, instance.getAgentUUID()); - source.put(InstanceTable.COLUMN_REGISTER_TIME, instance.getRegisterTime()); - source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, instance.getHeartBeatTime()); + source.put(InstanceTable.COLUMN_REGISTER_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getRegisterTime())); + source.put(InstanceTable.COLUMN_HEARTBEAT_TIME, TimeBucketUtils.INSTANCE.getSecondTimeBucket(instance.getHeartBeatTime())); source.put(InstanceTable.COLUMN_OS_INFO, instance.getOsInfo()); source.put(InstanceTable.COLUMN_ADDRESS_ID, instance.getAddressId()); source.put(InstanceTable.COLUMN_IS_ADDRESS, instance.getIsAddress()); @@ -77,7 +78,7 @@ public class InstanceRegisterH2DAO extends H2DAO implements IInstanceRegisterDAO H2Client client = getClient(); String sql = SqlBuilder.buildSql(UPDATE_HEARTBEAT_TIME_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_ID); - Object[] params = new Object[] {heartbeatTime, instanceId}; + Object[] params = new Object[] {TimeBucketUtils.INSTANCE.getSecondTimeBucket(heartbeatTime), instanceId}; try { client.execute(sql, params); } catch (H2ClientException e) { diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java deleted file mode 100644 index f6df67125..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreator.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.apm.collector.ui.graphql; - -import com.coxautodev.graphql.tools.SchemaParser; -import graphql.GraphQL; -import graphql.schema.GraphQLSchema; -import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmQuery; -import org.apache.skywalking.apm.collector.ui.graphql.application.ApplicationQuery; -import org.apache.skywalking.apm.collector.ui.graphql.application.ConjecturalNode; -import org.apache.skywalking.apm.collector.ui.graphql.common.VisualUserNode; -import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigMutation; -import org.apache.skywalking.apm.collector.ui.graphql.config.ConfigQuery; -import org.apache.skywalking.apm.collector.ui.graphql.overview.OverViewLayerQuery; -import org.apache.skywalking.apm.collector.ui.graphql.server.ServerQuery; -import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceQuery; -import org.apache.skywalking.apm.collector.ui.graphql.trace.TraceQuery; - -/** - * @author peng-yongsheng - */ -public class GraphQLCreator { - - public GraphQL create() { - GraphQLSchema schema = SchemaParser.newParser() - .file("ui-graphql/alarm.graphqls") - .file("ui-graphql/application-layer.graphqls") - .file("ui-graphql/common.graphqls") - .file("ui-graphql/config.graphqls") - .file("ui-graphql/overview-layer.graphqls") - .file("ui-graphql/server-layer.graphqls") - .file("ui-graphql/service-layer.graphqls") - .file("ui-graphql/trace.graphqls") - .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery()) - .resolvers(new OverViewLayerQuery(), new ServerQuery(), new ServiceQuery(), new TraceQuery()) - .resolvers(new ConfigQuery(), new ConfigMutation()) - .dictionary(ConjecturalNode.class, VisualUserNode.class) - .build() - .makeExecutableSchema(); - - return GraphQL.newGraphQL(schema).build(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java new file mode 100644 index 000000000..e5f3838f3 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java @@ -0,0 +1,54 @@ +/* + * 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.apm.collector.ui.graphql.utils; + +import java.text.ParseException; + +/** + * @author peng-yongsheng + */ +public enum DurationUtils { + INSTANCE; + + public long exchangeToTimeBucket(String dateStr) throws ParseException { + dateStr = dateStr.replaceAll("-", ""); + dateStr = dateStr.replaceAll(" ", ""); + return Long.valueOf(dateStr); + } + + public long monthDurationToSecondTimeBucket(String dateStr) throws ParseException { + long month = exchangeToTimeBucket(dateStr); + return month * 100 * 100 * 100 * 100; + } + + public long dayDurationToSecondTimeBucket(String dateStr) throws ParseException { + long month = exchangeToTimeBucket(dateStr); + return month * 100 * 100 * 100; + } + + public long hourDurationToSecondTimeBucket(String dateStr) throws ParseException { + long month = exchangeToTimeBucket(dateStr); + return month * 100 * 100; + } + + public long minuteDurationToSecondTimeBucket(String dateStr) throws ParseException { + long month = exchangeToTimeBucket(dateStr); + return month * 100; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtilsTestCase.java similarity index 78% rename from apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java rename to apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtilsTestCase.java index a232eb75e..89d1ee3ba 100644 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/GraphQLCreatorTestCase.java +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtilsTestCase.java @@ -16,19 +16,18 @@ * */ -package org.apache.skywalking.apm.collector.ui.graphql; +package org.apache.skywalking.apm.collector.ui.graphql.utils; -import graphql.GraphQL; +import java.text.ParseException; +import org.junit.Assert; import org.junit.Test; /** * @author peng-yongsheng */ -public class GraphQLCreatorTestCase { +public class DurationUtilsTestCase { @Test - public void test() { - GraphQLCreator creator = new GraphQLCreator(); - GraphQL graphQL = creator.create(); + public void test() throws ParseException { } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java index c3876eeb8..d01cda2b1 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/UIModuleJettyProvider.java @@ -34,20 +34,8 @@ import org.apache.skywalking.apm.collector.server.Server; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.ui.UIModule; import org.apache.skywalking.apm.collector.ui.jetty.handler.GraphQLHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.SegmentTopGetHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.SpanGetHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.TraceDagGetHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.TraceStackGetHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.application.ApplicationsGetHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.instancehealth.InstanceHealthGetHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceMetricGetOneTimeBucketHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceMetricGetRangeTimeBucketHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.instancemetric.InstanceOsInfoGetHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingHandler; import org.apache.skywalking.apm.collector.ui.jetty.handler.naming.UIJettyNamingListener; -import org.apache.skywalking.apm.collector.ui.jetty.handler.servicetree.ServiceTreeGetByIdHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.time.AllInstanceLastTimeGetHandler; -import org.apache.skywalking.apm.collector.ui.jetty.handler.time.OneInstanceLastTimeGetHandler; /** * @author peng-yongsheng @@ -99,19 +87,6 @@ public class UIModuleJettyProvider extends ModuleProvider { } private void addHandlers(Server jettyServer) { - jettyServer.addHandler(new ApplicationsGetHandler(getManager())); - jettyServer.addHandler(new InstanceHealthGetHandler(getManager())); - jettyServer.addHandler(new InstanceMetricGetOneTimeBucketHandler(getManager())); - jettyServer.addHandler(new InstanceMetricGetRangeTimeBucketHandler(getManager())); - jettyServer.addHandler(new InstanceOsInfoGetHandler(getManager())); - jettyServer.addHandler(new ServiceTreeGetByIdHandler(getManager())); - jettyServer.addHandler(new AllInstanceLastTimeGetHandler(getManager())); - jettyServer.addHandler(new OneInstanceLastTimeGetHandler(getManager())); - jettyServer.addHandler(new SegmentTopGetHandler(getManager())); - jettyServer.addHandler(new SpanGetHandler(getManager())); - jettyServer.addHandler(new TraceDagGetHandler(getManager())); - jettyServer.addHandler(new TraceStackGetHandler(getManager())); - - jettyServer.addHandler(new GraphQLHandler()); + jettyServer.addHandler(new GraphQLHandler(getManager())); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index d5e38df4f..3deeb3b1a 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.collector.ui.jetty.handler; +import com.coxautodev.graphql.tools.SchemaParser; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -26,30 +27,67 @@ import graphql.ExecutionInput; import graphql.ExecutionResult; import graphql.GraphQL; import graphql.GraphQLError; +import graphql.schema.GraphQLSchema; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.List; import javax.servlet.http.HttpServletRequest; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.CollectionUtils; import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.graphql.GraphQLCreator; +import org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode; +import org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode; +import org.apache.skywalking.apm.collector.storage.ui.common.VisualUserNode; +import org.apache.skywalking.apm.collector.ui.graphql.VersionMutation; +import org.apache.skywalking.apm.collector.ui.graphql.VersionQuery; +import org.apache.skywalking.apm.collector.ui.mutation.ConfigMutation; +import org.apache.skywalking.apm.collector.ui.query.AlarmQuery; +import org.apache.skywalking.apm.collector.ui.query.ApplicationQuery; +import org.apache.skywalking.apm.collector.ui.query.ConfigQuery; +import org.apache.skywalking.apm.collector.ui.query.OverViewLayerQuery; +import org.apache.skywalking.apm.collector.ui.query.ServerQuery; +import org.apache.skywalking.apm.collector.ui.query.ServiceQuery; +import org.apache.skywalking.apm.collector.ui.query.TraceQuery; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public class GraphQLHandler extends JettyHandler { + private final Logger logger = LoggerFactory.getLogger(GraphQLHandler.class); + + private final ModuleManager moduleManager; private final Gson gson = new Gson(); private final GraphQL graphQL; private static final String QUERY = "query"; private static final String DATA = "data"; private static final String ERRORS = "errors"; + private static final String MESSAGE = "message"; - public GraphQLHandler() { - GraphQLCreator creator = new GraphQLCreator(); - this.graphQL = creator.create(); + public GraphQLHandler(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + + GraphQLSchema schema = SchemaParser.newParser() + .file("ui-graphql/alarm.graphqls") + .file("ui-graphql/application-layer.graphqls") + .file("ui-graphql/common.graphqls") + .file("ui-graphql/config.graphqls") + .file("ui-graphql/overview-layer.graphqls") + .file("ui-graphql/server-layer.graphqls") + .file("ui-graphql/service-layer.graphqls") + .file("ui-graphql/trace.graphqls") + .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery(moduleManager)) + .resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(), new ServiceQuery(), new TraceQuery()) + .resolvers(new ConfigQuery(), new ConfigMutation()) + .dictionary(ConjecturalNode.class, VisualUserNode.class, ApplicationNode.class) + .build() + .makeExecutableSchema(); + + this.graphQL = GraphQL.newGraphQL(schema).build(); } @Override public String pathSpec() { @@ -73,21 +111,40 @@ public class GraphQLHandler extends JettyHandler { } private JsonObject execute(String request) { - ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(request).build(); - ExecutionResult executionResult = graphQL.execute(executionInput); + try { + ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(request).build(); + ExecutionResult executionResult = graphQL.execute(executionInput); + Object data = executionResult.getData(); + List errors = executionResult.getErrors(); - Object data = executionResult.getData(); - List errors = executionResult.getErrors(); + JsonObject jsonObject = new JsonObject(); + if (data != null) { + jsonObject.addProperty(DATA, data.toString()); + } - JsonObject jsonObject = new JsonObject(); - jsonObject.addProperty(DATA, data.toString()); + if (CollectionUtils.isNotEmpty(errors)) { + JsonArray errorArray = new JsonArray(); + errors.forEach(error -> { + JsonObject errorJson = new JsonObject(); + errorJson.addProperty(MESSAGE, error.getMessage()); + errorArray.add(errorJson); + }); + + jsonObject.add(ERRORS, errorArray); + } + + return jsonObject; + } catch (Throwable e) { + logger.error(e.getMessage(), e); + JsonObject jsonObject = new JsonObject(); + + JsonArray errorArray = new JsonArray(); + JsonObject errorJson = new JsonObject(); + errorJson.addProperty(MESSAGE, e.getMessage()); + errorArray.add(errorJson); - if (CollectionUtils.isNotEmpty(errors)) { - String errorJsonStr = gson.toJson(errors, JsonArray.class); - JsonArray errorArray = gson.fromJson(errorJsonStr, JsonArray.class); jsonObject.add(ERRORS, errorArray); + return jsonObject; } - - return jsonObject; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SegmentTopGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SegmentTopGetHandler.java deleted file mode 100644 index 4cdeaf384..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SegmentTopGetHandler.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.SegmentTopService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class SegmentTopGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(SegmentTopGetHandler.class); - - @Override public String pathSpec() { - return "/segment/top"; - } - - private final SegmentTopService service; - - public SegmentTopGetHandler(ModuleManager moduleManager) { - this.service = new SegmentTopService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - if (!req.getParameterMap().containsKey("startTime") || !req.getParameterMap().containsKey("endTime") || !req.getParameterMap().containsKey("from") || !req.getParameterMap().containsKey("limit")) { - throw new ArgumentsParseException("the request parameter must contains startTime, endTime, from, limit"); - } - - if (logger.isDebugEnabled()) { - logger.debug("startTime: {}, endTime: {}, from: {}", req.getParameter("startTime"), req.getParameter("endTime"), req.getParameter("from")); - } - - long startTime; - try { - startTime = Long.valueOf(req.getParameter("startTime")); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("the request parameter startTime must be a long"); - } - - long endTime; - try { - endTime = Long.valueOf(req.getParameter("endTime")); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("the request parameter endTime must be a long"); - } - - int from; - try { - from = Integer.valueOf(req.getParameter("from")); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("the request parameter from must be an integer"); - } - - int limit; - try { - limit = Integer.valueOf(req.getParameter("limit")); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("the request parameter from must be an integer"); - } - - int minCost = -1; - if (req.getParameterMap().containsKey("minCost")) { - minCost = Integer.valueOf(req.getParameter("minCost")); - } - int maxCost = -1; - if (req.getParameterMap().containsKey("maxCost")) { - maxCost = Integer.valueOf(req.getParameter("maxCost")); - } - - String globalTraceId = null; - if (req.getParameterMap().containsKey("globalTraceId")) { - globalTraceId = req.getParameter("globalTraceId"); - } - - String operationName = null; - if (req.getParameterMap().containsKey("operationName")) { - operationName = req.getParameter("operationName"); - } - - int applicationId; - try { - applicationId = Integer.valueOf(req.getParameter("applicationId")); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("the request parameter applicationId must be a int"); - } - - ISegmentCostUIDAO.Error error; - String errorStr = req.getParameter("error"); - if (StringUtils.isNotEmpty(errorStr)) { - if ("true".equals(errorStr)) { - error = ISegmentCostUIDAO.Error.True; - } else if ("false".equals(errorStr)) { - error = ISegmentCostUIDAO.Error.False; - } else { - error = ISegmentCostUIDAO.Error.All; - } - } else { - error = ISegmentCostUIDAO.Error.All; - } - - ISegmentCostUIDAO.Sort sort = ISegmentCostUIDAO.Sort.Cost; - if (req.getParameterMap().containsKey("sort")) { - String sortStr = req.getParameter("sort"); - if (sortStr.toLowerCase().equals(ISegmentCostUIDAO.Sort.Time.name().toLowerCase())) { - sort = ISegmentCostUIDAO.Sort.Time; - } - } - - return service.loadTop(startTime, endTime, minCost, maxCost, operationName, globalTraceId, error, applicationId, limit, from, sort); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SpanGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SpanGetHandler.java deleted file mode 100644 index bb14254b5..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/SpanGetHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.SpanService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class SpanGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(SpanGetHandler.class); - - @Override public String pathSpec() { - return "/span/spanId"; - } - - private final SpanService service; - - public SpanGetHandler(ModuleManager moduleManager) { - this.service = new SpanService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - String segmentId = req.getParameter("segmentId"); - String spanIdStr = req.getParameter("spanId"); - logger.debug("segmentSpanId: {}, spanIdStr: {}", segmentId, spanIdStr); - - int spanId; - try { - spanId = Integer.parseInt(spanIdStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("span id must be integer"); - } - - return service.load(segmentId, spanId); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceDagGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceDagGetHandler.java deleted file mode 100644 index 34143ce3b..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceDagGetHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.TraceDagService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class TraceDagGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(TraceDagGetHandler.class); - - @Override public String pathSpec() { - return "/traceDag"; - } - - private final TraceDagService service; - - public TraceDagGetHandler(ModuleManager moduleManager) { - this.service = new TraceDagService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - if (!req.getParameterMap().containsKey("startTime") || !req.getParameterMap().containsKey("endTime")) { - throw new ArgumentsParseException("the request parameter must contains startTime, endTime"); - } - - String startTimeStr = req.getParameter("startTime"); - String endTimeStr = req.getParameter("endTime"); - logger.debug("startTime: {}, endTimeStr: {}", startTimeStr, endTimeStr); - - long startTime; - try { - startTime = Long.valueOf(req.getParameter("startTime")); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("the request parameter startTime must be a long"); - } - - long endTime; - try { - endTime = Long.valueOf(req.getParameter("endTime")); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("the request parameter endTime must be a long"); - } - - return service.load(startTime, endTime); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceStackGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceStackGetHandler.java deleted file mode 100644 index 368348abd..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/TraceStackGetHandler.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.TraceStackService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class TraceStackGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(TraceStackGetHandler.class); - - @Override public String pathSpec() { - return "/traceStack/globalTraceId"; - } - - private final TraceStackService service; - - public TraceStackGetHandler(ModuleManager moduleManager) { - this.service = new TraceStackService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - String globalTraceId = req.getParameter("globalTraceId"); - logger.debug("globalTraceId: {}", globalTraceId); - - return service.load(globalTraceId); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java deleted file mode 100644 index 51ddcc6ce..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/application/ApplicationsGetHandler.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.application; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.ui.service.ApplicationService; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ApplicationsGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(ApplicationsGetHandler.class); - - @Override public String pathSpec() { - return "/applications"; - } - - private final ApplicationService applicationService; - - public ApplicationsGetHandler(ModuleManager moduleManager) { - this.applicationService = new ApplicationService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - if (!req.getParameterMap().containsKey("startTime") || !req.getParameterMap().containsKey("endTime")) { - throw new ArgumentsParseException("must contains startTime. endTime parameter"); - } - - String startTimeStr = req.getParameter("startTime"); - String endTimeStr = req.getParameter("endTime"); - logger.debug("applications getApplicationIdByCode start time: {}, end time: {}", startTimeStr, endTimeStr); - - long startTime; - try { - startTime = Long.parseLong(startTimeStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("start time must be long"); - } - - long endTime; - try { - endTime = Long.parseLong(endTimeStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("end time must be long"); - } - - return applicationService.getApplications(startTime, endTime); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java deleted file mode 100644 index 008f4e143..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancehealth/InstanceHealthGetHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.instancehealth; - -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.InstanceHealthService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class InstanceHealthGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(InstanceHealthGetHandler.class); - - @Override public String pathSpec() { - return "/instance/health/applicationId"; - } - - private final InstanceHealthService service; - - public InstanceHealthGetHandler(ModuleManager moduleManager) { - this.service = new InstanceHealthService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - String timeBucketStr = req.getParameter("timeBucket"); - String[] applicationIdsStr = req.getParameterValues("applicationIds"); - logger.debug("instance health getApplicationIdByCode timeBucket: {}, applicationIdsStr: {}", timeBucketStr, applicationIdsStr); - - long timeBucket; - try { - timeBucket = Long.parseLong(timeBucketStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("timestamp must be long"); - } - - int[] applicationIds = new int[applicationIdsStr.length]; - for (int i = 0; i < applicationIdsStr.length; i++) { - try { - applicationIds[i] = Integer.parseInt(applicationIdsStr[i]); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("application id must be integer"); - } - } - - JsonObject response = new JsonObject(); - response.addProperty("timeBucket", timeBucket); - JsonArray appInstances = new JsonArray(); - response.add("appInstances", appInstances); - - for (int applicationId : applicationIds) { - appInstances.add(service.getInstances(timeBucket, applicationId)); - } - return response; - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java deleted file mode 100644 index 15e73ce93..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetOneTimeBucketHandler.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.instancemetric; - -import com.google.gson.JsonElement; -import java.util.LinkedHashSet; -import java.util.Set; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.InstanceJVMService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class InstanceMetricGetOneTimeBucketHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(InstanceMetricGetOneTimeBucketHandler.class); - - @Override public String pathSpec() { - return "/instance/jvm/instanceId/oneBucket"; - } - - private final InstanceJVMService service; - - public InstanceMetricGetOneTimeBucketHandler(ModuleManager moduleManager) { - this.service = new InstanceJVMService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - String timeBucketStr = req.getParameter("timeBucket"); - String instanceIdStr = req.getParameter("instanceId"); - String[] metricTypes = req.getParameterValues("metricTypes"); - - logger.debug("instance jvm metric getApplicationIdByCode timeBucket: {}, instance id: {}, metric types: {}", timeBucketStr, instanceIdStr, metricTypes); - - long timeBucket; - try { - timeBucket = Long.parseLong(timeBucketStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("timeBucket must be long"); - } - - int instanceId; - try { - instanceId = Integer.parseInt(instanceIdStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("instance id must be integer"); - } - - if (metricTypes.length == 0) { - throw new ArgumentsParseException("at least one metric type"); - } - - Set metricTypeSet = new LinkedHashSet<>(); - for (String metricType : metricTypes) { - metricTypeSet.add(metricType); - } - - return service.getInstanceJvmMetric(instanceId, metricTypeSet, timeBucket); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java deleted file mode 100644 index a78c63dca..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceMetricGetRangeTimeBucketHandler.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.instancemetric; - -import com.google.gson.JsonElement; -import java.util.LinkedHashSet; -import java.util.Set; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.InstanceJVMService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class InstanceMetricGetRangeTimeBucketHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(InstanceMetricGetRangeTimeBucketHandler.class); - - @Override public String pathSpec() { - return "/instance/jvm/instanceId/rangeBucket"; - } - - private final InstanceJVMService service; - - public InstanceMetricGetRangeTimeBucketHandler(ModuleManager moduleManager) { - this.service = new InstanceJVMService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - String startTimeBucketStr = req.getParameter("startTimeBucket"); - String endTimeBucketStr = req.getParameter("endTimeBucket"); - String instanceIdStr = req.getParameter("instanceId"); - String[] metricTypes = req.getParameterValues("metricTypes"); - - logger.debug("instance jvm metric getApplicationIdByCode start timeBucket: {}, end timeBucket:{} , instance id: {}, metric types: {}", startTimeBucketStr, endTimeBucketStr, instanceIdStr, metricTypes); - - long startTimeBucket; - try { - startTimeBucket = Long.parseLong(startTimeBucketStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("start timeBucket must be long"); - } - - long endTimeBucket; - try { - endTimeBucket = Long.parseLong(endTimeBucketStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("end timeBucket must be long"); - } - - int instanceId; - try { - instanceId = Integer.parseInt(instanceIdStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("instance id must be integer"); - } - - if (metricTypes.length == 0) { - throw new ArgumentsParseException("at least one metric type"); - } - - Set metricTypeSet = new LinkedHashSet<>(); - for (String metricType : metricTypes) { - metricTypeSet.add(metricType); - } - - return service.getInstanceJvmMetrics(instanceId, metricTypeSet, startTimeBucket, endTimeBucket); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java deleted file mode 100644 index 3b035f8eb..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/instancemetric/InstanceOsInfoGetHandler.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.instancemetric; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.InstanceJVMService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class InstanceOsInfoGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(InstanceOsInfoGetHandler.class); - - @Override public String pathSpec() { - return "/instance/os/instanceId"; - } - - private final InstanceJVMService service; - - public InstanceOsInfoGetHandler(ModuleManager moduleManager) { - this.service = new InstanceJVMService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - String instanceIdStr = req.getParameter("instanceId"); - logger.debug("instance os info getApplicationIdByCode, instance id: {}", instanceIdStr); - - int instanceId; - try { - instanceId = Integer.parseInt(instanceIdStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("instance id must be integer"); - } - - return service.getInstanceOsInfo(instanceId); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java deleted file mode 100644 index 27ea8149f..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/servicetree/ServiceTreeGetByIdHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.servicetree; - -import com.google.gson.JsonElement; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.ui.service.ServiceTreeService; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ServiceTreeGetByIdHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(ServiceTreeGetByIdHandler.class); - - @Override public String pathSpec() { - return "/service/tree/entryServiceId"; - } - - private final ServiceTreeService service; - - public ServiceTreeGetByIdHandler(ModuleManager moduleManager) { - this.service = new ServiceTreeService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - if (!req.getParameterMap().containsKey("entryServiceId") || !req.getParameterMap().containsKey("startTime") || !req.getParameterMap().containsKey("endTime")) { - throw new ArgumentsParseException("must contains parameters: entryServiceId, startTime, endTime"); - } - - String entryServiceIdStr = req.getParameter("entryServiceId"); - String startTimeStr = req.getParameter("startTime"); - String endTimeStr = req.getParameter("endTime"); - logger.debug("service entry getApplicationIdByCode entryServiceId: {}, startTime: {}, endTime: {}", entryServiceIdStr, startTimeStr, endTimeStr); - - int entryServiceId; - try { - entryServiceId = Integer.parseInt(entryServiceIdStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("entry service id must be integer"); - } - - long startTime; - try { - startTime = Long.parseLong(startTimeStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("start time must be long"); - } - - long endTime; - try { - endTime = Long.parseLong(endTimeStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("end time must be long"); - } - - return service.loadServiceTree(entryServiceId, startTime, endTime); - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/AllInstanceLastTimeGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/AllInstanceLastTimeGetHandler.java deleted file mode 100644 index f0ea90d7a..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/AllInstanceLastTimeGetHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.time; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import java.util.Calendar; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.TimeSynchronousService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class AllInstanceLastTimeGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(AllInstanceLastTimeGetHandler.class); - - @Override public String pathSpec() { - return "/time/allInstance"; - } - - private final TimeSynchronousService service; - - public AllInstanceLastTimeGetHandler(ModuleManager moduleManager) { - this.service = new TimeSynchronousService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - Long timeBucket = service.allInstanceLastTime(); - logger.debug("all instance last time: {}", timeBucket); - - if (timeBucket == 0) { - timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(System.currentTimeMillis()); - } - Calendar calendar = Calendar.getInstance(); - calendar.setTimeInMillis(TimeBucketUtils.INSTANCE.changeTimeBucket2TimeStamp(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket)); - calendar.add(Calendar.SECOND, -5); - timeBucket = calendar.getTimeInMillis(); - - JsonObject timeJson = new JsonObject(); - timeJson.addProperty("timeBucket", TimeBucketUtils.INSTANCE.getSecondTimeBucket(timeBucket)); - return timeJson; - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/OneInstanceLastTimeGetHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/OneInstanceLastTimeGetHandler.java deleted file mode 100644 index 89aaa7093..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/time/OneInstanceLastTimeGetHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.apm.collector.ui.jetty.handler.time; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import javax.servlet.http.HttpServletRequest; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.server.jetty.ArgumentsParseException; -import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; -import org.apache.skywalking.apm.collector.ui.service.TimeSynchronousService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class OneInstanceLastTimeGetHandler extends JettyHandler { - - private final Logger logger = LoggerFactory.getLogger(OneInstanceLastTimeGetHandler.class); - - @Override public String pathSpec() { - return "/time/oneInstance"; - } - - private final TimeSynchronousService service; - - public OneInstanceLastTimeGetHandler(ModuleManager moduleManager) { - this.service = new TimeSynchronousService(moduleManager); - } - - @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - String instanceIdStr = req.getParameter("instanceId"); - logger.debug("instanceId: {}", instanceIdStr); - - int instanceId; - try { - instanceId = Integer.parseInt(instanceIdStr); - } catch (NumberFormatException e) { - throw new ArgumentsParseException("application instance id must be integer"); - } - - Long time = service.instanceLastTime(instanceId); - logger.debug("application instance id: {}, instance last time: {}", instanceId, time); - JsonObject timeJson = new JsonObject(); - timeJson.addProperty("timeBucket", time); - return timeJson; - } - - @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException { - throw new UnsupportedOperationException(); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/mutation/ConfigMutation.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/mutation/ConfigMutation.java new file mode 100644 index 000000000..ab2d80a09 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/mutation/ConfigMutation.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.apm.collector.ui.mutation; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.ui.config.AlarmThreshold; +import org.apache.skywalking.apm.collector.storage.ui.config.TTLConfigItem; +import org.apache.skywalking.apm.collector.ui.graphql.Mutation; + +/** + * @author peng-yongsheng + */ +public class ConfigMutation implements Mutation { + + public Boolean setDataTTLConfigs(List ttl) { + return null; + } + + public Boolean setAlarmThreshold(List thresholds) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java new file mode 100644 index 000000000..820b41a19 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java @@ -0,0 +1,37 @@ +/* + * 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.apm.collector.ui.query; + +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.storage.ui.alarm.Alarm; +import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType; +import org.apache.skywalking.apm.collector.storage.ui.common.Duration; +import org.apache.skywalking.apm.collector.storage.ui.common.Pagination; + +/** + * @author peng-yongsheng + */ +public class AlarmQuery implements Query { + + public Alarm loadAlertList(String keyword, AlarmType alarmType, Duration duration, Pagination pagination) { + Alarm alarm = new Alarm(); + alarm.setCount(0); + return alarm; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java new file mode 100644 index 000000000..b8f09c622 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java @@ -0,0 +1,94 @@ +/* + * 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.apm.collector.ui.query; + +import java.text.ParseException; +import java.util.List; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.common.Duration; +import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.graphql.utils.DurationUtils; +import org.apache.skywalking.apm.collector.ui.service.ApplicationService; + +/** + * @author peng-yongsheng + */ +public class ApplicationQuery implements Query { + + private final ModuleManager moduleManager; + private ApplicationService applicationService; + + public ApplicationQuery(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + private ApplicationService getApplicationService() { + if (ObjectUtils.isEmpty(applicationService)) { + this.applicationService = new ApplicationService(moduleManager); + } + return applicationService; + } + + public List getAllApplication(Duration duration) throws ParseException { + long start = 0; + long end = 0; + + switch (duration.getStep()) { + case MONTH: + start = DurationUtils.INSTANCE.monthDurationToSecondTimeBucket(duration.getStart()); + end = DurationUtils.INSTANCE.monthDurationToSecondTimeBucket(duration.getEnd()); + break; + case DAY: + start = DurationUtils.INSTANCE.dayDurationToSecondTimeBucket(duration.getStart()); + end = DurationUtils.INSTANCE.dayDurationToSecondTimeBucket(duration.getEnd()); + break; + case HOUR: + start = DurationUtils.INSTANCE.hourDurationToSecondTimeBucket(duration.getStart()); + end = DurationUtils.INSTANCE.hourDurationToSecondTimeBucket(duration.getEnd()); + break; + case MINUTE: + start = DurationUtils.INSTANCE.minuteDurationToSecondTimeBucket(duration.getStart()); + end = DurationUtils.INSTANCE.minuteDurationToSecondTimeBucket(duration.getEnd()); + break; + case SECOND: + start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + break; + } + + return getApplicationService().getApplications(start, end); + } + + public Topology getApplicationTopology(int applicationId, Duration duration) { + return null; + } + + public List getSlowService(int applicationId, Duration duration, Integer top) { + return null; + } + + public List getServerThroughput(int applicationId, Duration duration, Integer top) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ConfigQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ConfigQuery.java new file mode 100644 index 000000000..ce1d8d31f --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ConfigQuery.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.apm.collector.ui.query; + +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType; +import org.apache.skywalking.apm.collector.storage.ui.config.ExistedAlarmThresholds; +import org.apache.skywalking.apm.collector.storage.ui.config.ExistedTTLConfigs; + +/** + * @author peng-yongsheng + */ +public class ConfigQuery implements Query { + + public ExistedTTLConfigs queryAllDataTTLConfigs() { + return null; + } + + public ExistedAlarmThresholds queryAlarmThresholds(AlarmType alarmType) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java new file mode 100644 index 000000000..539b3f1b9 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java @@ -0,0 +1,63 @@ +/* + * 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.apm.collector.ui.query; + +import java.util.List; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.ui.common.Duration; +import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend; +import org.apache.skywalking.apm.collector.storage.ui.overview.ClusterBrief; +import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; +import org.apache.skywalking.apm.collector.ui.graphql.Query; + +/** + * @author peng-yongsheng + */ +public class OverViewLayerQuery implements Query { + + public OverViewLayerQuery(ModuleManager moduleManager) { + } + + public Topology getClusterTopology(Duration duration) { + return null; + } + + public ClusterBrief getClusterBrief(Duration duration) { + return null; + } + + public AlarmTrend getAlarmTrend(Duration duration) { + return null; + } + + public ConjecturalAppBrief getConjecturalApps(Duration duration) { + return null; + } + + public List getTopNSlowService(Duration duration, int topN) { + return null; + } + + public List getTopNServerThroughput(Duration duration, int topN) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java new file mode 100644 index 000000000..7871337dc --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -0,0 +1,62 @@ +/* + * 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.apm.collector.ui.query; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.storage.ui.common.Duration; +import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; +import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.apache.skywalking.apm.collector.storage.ui.server.CPUTrend; +import org.apache.skywalking.apm.collector.storage.ui.server.GCTrend; +import org.apache.skywalking.apm.collector.storage.ui.server.MemoryTrend; + +/** + * @author peng-yongsheng + */ +public class ServerQuery implements Query { + public List searchServer(String keyword, Duration duration) { + return null; + } + + public List getAllServer(String applicationId, Duration duration) { + return null; + } + + public ResponseTimeTrend getServerResponseTimeTrend(int serverId, Duration duration) { + return null; + } + + public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) { + return null; + } + + public CPUTrend getCPUTrend(int serverId, Duration duration) { + return null; + } + + public GCTrend getGCTrend(int serverId, Duration duration) { + return null; + } + + public MemoryTrend getMemoryTrend(int serverId, Duration duration) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java new file mode 100644 index 000000000..ef11c1066 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java @@ -0,0 +1,53 @@ +/* + * 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.apm.collector.ui.query; + +import java.util.List; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.storage.ui.common.Duration; +import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; +import org.apache.skywalking.apm.collector.storage.ui.common.SLATrend; +import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; +import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceNode; + +/** + * @author peng-yongsheng + */ +public class ServiceQuery implements Query { + public List searchService(String keyword, Duration duration, Integer topN) { + return null; + } + + public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Duration duration) { + return null; + } + + public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) { + return null; + } + + public SLATrend getServiceSLATrend(int serviceId, Duration duration) { + return null; + } + + public Topology getServiceTopology(int serviceId, Duration duration) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java new file mode 100644 index 000000000..32eaa7291 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java @@ -0,0 +1,37 @@ +/* + * 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.apm.collector.ui.query; + +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.storage.ui.trace.Trace; +import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief; +import org.apache.skywalking.apm.collector.storage.ui.trace.TraceQueryCondition; + +/** + * @author peng-yongsheng + */ +public class TraceQuery implements Query { + public TraceBrief queryBasicTraces(TraceQueryCondition condition) { + return null; + } + + public Trace queryTrace(String id) { + return null; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java index 1807fc321..d96317dd5 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java @@ -16,16 +16,15 @@ * */ - package org.apache.skywalking.apm.collector.ui.service; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; +import java.util.List; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; /** * @author peng-yongsheng @@ -40,14 +39,12 @@ public class ApplicationService { this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); } - public JsonArray getApplications(long startTime, long endTime) { - JsonArray applications = instanceDAO.getApplications(startTime, endTime); + public List getApplications(long startTime, long endTime) { + List applications = instanceDAO.getApplications(startTime, endTime); - applications.forEach(jsonElement -> { - JsonObject application = jsonElement.getAsJsonObject(); - int applicationId = application.get("applicationId").getAsInt(); - String applicationCode = applicationCacheService.getApplicationCodeById(applicationId); - application.addProperty("applicationCode", applicationCode); + applications.forEach(application -> { + String applicationCode = applicationCacheService.getApplicationCodeById(application.getId()); + application.setName(applicationCode); }); return applications; } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java index 65492c8b1..98ba79884 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java @@ -16,19 +16,15 @@ * */ - package org.apache.skywalking.apm.collector.ui.service; import com.google.gson.JsonArray; import com.google.gson.JsonObject; -import java.util.List; import org.apache.skywalking.apm.collector.cache.CacheModule; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.slf4j.Logger; @@ -56,58 +52,58 @@ public class InstanceHealthService { public JsonObject getInstances(long timeBucket, int applicationId) { JsonObject response = new JsonObject(); - long[] timeBuckets = TimeBucketUtils.INSTANCE.getFiveSecondTimeBuckets(timeBucket); - long halfHourBeforeTimeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket, -60 * 30); - List instanceList = instanceDAO.getInstances(applicationId, halfHourBeforeTimeBucket); +// long[] timeBuckets = TimeBucketUtils.INSTANCE.getFiveSecondTimeBuckets(timeBucket); +// long halfHourBeforeTimeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, -60 * 30); +// List instanceList = instanceDAO.getInstances(applicationId, halfHourBeforeTimeBucket); JsonArray instances = new JsonArray(); response.add("instances", instances); - instanceList.forEach(instance -> { - response.addProperty("applicationCode", applicationCacheService.getApplicationCodeById(applicationId)); - response.addProperty("applicationId", applicationId); +// instanceList.forEach(instance -> { +// response.addProperty("applicationCode", applicationCacheService.getApplicationCodeById(applicationId)); +// response.addProperty("applicationId", applicationId); +// +// IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId()); +// +// JsonObject instanceJson = new JsonObject(); +// instanceJson.addProperty("id", instance.getInstanceId()); +// if (performance != null) { +// instanceJson.addProperty("tps", performance.getCalls()); +// } else { +// instanceJson.addProperty("tps", 0); +// } +// +// int avg = 0; +// if (performance != null && performance.getCalls() != 0) { +// avg = (int)(performance.getDurationSum() / performance.getCalls()); +// } +// instanceJson.addProperty("avg", avg); +// +// if (avg > 5000) { +// instanceJson.addProperty("healthLevel", 0); +// } else if (avg > 3000 && avg <= 5000) { +// instanceJson.addProperty("healthLevel", 1); +// } else if (avg > 1000 && avg <= 3000) { +// instanceJson.addProperty("healthLevel", 2); +// } else { +// instanceJson.addProperty("healthLevel", 3); +// } - IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId()); - - JsonObject instanceJson = new JsonObject(); - instanceJson.addProperty("id", instance.getInstanceId()); - if (performance != null) { - instanceJson.addProperty("tps", performance.getCalls()); - } else { - instanceJson.addProperty("tps", 0); - } - - int avg = 0; - if (performance != null && performance.getCalls() != 0) { - avg = (int)(performance.getDurationSum() / performance.getCalls()); - } - instanceJson.addProperty("avg", avg); - - if (avg > 5000) { - instanceJson.addProperty("healthLevel", 0); - } else if (avg > 3000 && avg <= 5000) { - instanceJson.addProperty("healthLevel", 1); - } else if (avg > 1000 && avg <= 3000) { - instanceJson.addProperty("healthLevel", 2); - } else { - instanceJson.addProperty("healthLevel", 3); - } - - long heartBeatTime = TimeBucketUtils.INSTANCE.changeTimeBucket2TimeStamp(TimeBucketUtils.TimeBucketType.SECOND.name(), instance.getHeartBeatTime()); - long currentTime = TimeBucketUtils.INSTANCE.changeTimeBucket2TimeStamp(TimeBucketUtils.TimeBucketType.SECOND.name(), timeBucket); - - if (currentTime - heartBeatTime < 1000 * 60 * 2) { - instanceJson.addProperty("status", 0); - } else { - instanceJson.addProperty("status", 1); - } - - IGCMetricUIDAO.GCCount gcCount = gcMetricDAO.getGCCount(timeBuckets, instance.getInstanceId()); - instanceJson.addProperty("ygc", gcCount.getYoung()); - instanceJson.addProperty("ogc", gcCount.getOld()); - - instances.add(instanceJson); - }); +// long heartBeatTime = TimeBucketUtils.INSTANCE.changeTimeBucket2TimeStamp(TimeBucketUtils.TimeBucketType.SECOND, instance.getHeartBeatTime()); +// long currentTime = TimeBucketUtils.INSTANCE.changeTimeBucket2TimeStamp(TimeBucketUtils.TimeBucketType.SECOND, timeBucket); +// +// if (currentTime - heartBeatTime < 1000 * 60 * 2) { +// instanceJson.addProperty("status", 0); +// } else { +// instanceJson.addProperty("status", 1); +// } +// +// IGCMetricUIDAO.GCCount gcCount = gcMetricDAO.getGCCount(timeBuckets, instance.getInstanceId()); +// instanceJson.addProperty("ygc", gcCount.getYoung()); +// instanceJson.addProperty("ogc", gcCount.getOld()); +// +// instances.add(instanceJson); +// }); return response; } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java new file mode 100644 index 000000000..c0bddff71 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java @@ -0,0 +1,139 @@ +/* + * 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.apm.collector.ui.query; + +import java.text.ParseException; +import org.apache.skywalking.apm.collector.storage.ui.common.Duration; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.ui.service.ApplicationService; +import org.junit.Assert; +import org.junit.Test; +import org.mockito.Mockito; +import org.mockito.internal.util.reflection.Whitebox; + +/** + * @author peng-yongsheng + */ +public class ApplicationQueryTestCase { + + @Test + public void testGetAllApplicationByMonthDuration() throws ParseException { + ApplicationQuery query = new ApplicationQuery(null); + ApplicationService applicationService = Mockito.mock(ApplicationService.class); + Whitebox.setInternalState(query, "applicationService", applicationService); + + Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { + Object[] arguments = invocation.getArguments(); + Assert.assertEquals(20170100000000l, arguments[0]); + Assert.assertEquals(20170100000000l, arguments[1]); + return null; + }); + + Duration duration = new Duration(); + duration.setStart("2017-01"); + duration.setEnd("2017-01"); + duration.setStep(Step.MONTH); + + query.getAllApplication(duration); + } + + @Test + public void testGetAllApplicationByDayDuration() throws ParseException { + ApplicationQuery query = new ApplicationQuery(null); + ApplicationService applicationService = Mockito.mock(ApplicationService.class); + Whitebox.setInternalState(query, "applicationService", applicationService); + + Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { + Object[] arguments = invocation.getArguments(); + Assert.assertEquals(20170101000000l, arguments[0]); + Assert.assertEquals(20170101000000l, arguments[1]); + return null; + }); + + Duration duration = new Duration(); + duration.setStart("2017-01-01"); + duration.setEnd("2017-01-01"); + duration.setStep(Step.DAY); + + query.getAllApplication(duration); + } + + @Test + public void testGetAllApplicationByHourDuration() throws ParseException { + ApplicationQuery query = new ApplicationQuery(null); + ApplicationService applicationService = Mockito.mock(ApplicationService.class); + Whitebox.setInternalState(query, "applicationService", applicationService); + + Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { + Object[] arguments = invocation.getArguments(); + Assert.assertEquals(20170101010000l, arguments[0]); + Assert.assertEquals(20170101010000l, arguments[1]); + return null; + }); + + Duration duration = new Duration(); + duration.setStart("2017-01-01 01"); + duration.setEnd("2017-01-01 01"); + duration.setStep(Step.HOUR); + + query.getAllApplication(duration); + } + + @Test + public void testGetAllApplicationByMinuteDuration() throws ParseException { + ApplicationQuery query = new ApplicationQuery(null); + ApplicationService applicationService = Mockito.mock(ApplicationService.class); + Whitebox.setInternalState(query, "applicationService", applicationService); + + Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { + Object[] arguments = invocation.getArguments(); + Assert.assertEquals(20170101010100l, arguments[0]); + Assert.assertEquals(20170101010100l, arguments[1]); + return null; + }); + + Duration duration = new Duration(); + duration.setStart("2017-01-01 0101"); + duration.setEnd("2017-01-01 0101"); + duration.setStep(Step.MINUTE); + + query.getAllApplication(duration); + } + + @Test + public void testGetAllApplicationBySecondDuration() throws ParseException { + ApplicationQuery query = new ApplicationQuery(null); + ApplicationService applicationService = Mockito.mock(ApplicationService.class); + Whitebox.setInternalState(query, "applicationService", applicationService); + + Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { + Object[] arguments = invocation.getArguments(); + Assert.assertEquals(20170101010101l, arguments[0]); + Assert.assertEquals(20170101010101l, arguments[1]); + return null; + }); + + Duration duration = new Duration(); + duration.setStart("2017-01-01 010101"); + duration.setEnd("2017-01-01 010101"); + duration.setStep(Step.SECOND); + + query.getAllApplication(duration); + } +} diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls index 91d0b2d79..ba6dde139 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -33,9 +33,15 @@ type ConjecturalNode implements Node { type: String } +type Application { + id: ID! + name: String! + # The number of servers in the application code + numOfServer: Int! +} extend type Query { - getAllApplication(duration: Duration!): [ApplicationNode!]! + getAllApplication(duration: Duration!): [Application!]! getApplicationTopology(applicationId: ID!, duration: Duration!): Topology getSlowService(applicationId: ID!, duration: Duration!, top: Int!): [ServiceInfo!]! getServerThroughput(applicationId: ID!, duration: Duration!, top: Int!): [AppServerInfo!]! From e755bba328cd0bd5a9c6a91ffbd3ceaa88f9abef Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 24 Jan 2018 00:13:19 +0800 Subject: [PATCH 07/36] Move the entity into storage module. --- .../apm/collector/ui/graphql/alarm/Alarm.java | 45 -------------- .../collector/ui/graphql/alarm/AlarmItem.java | 30 ---------- .../ui/graphql/alarm/AlarmQuery.java | 35 ----------- .../collector/ui/graphql/alarm/AlarmType.java | 28 --------- .../collector/ui/graphql/alarm/CauseType.java | 27 --------- .../graphql/application/ApplicationQuery.java | 48 --------------- .../graphql/application/ConjecturalNode.java | 27 --------- .../apm/collector/ui/graphql/common/Call.java | 31 ---------- .../collector/ui/graphql/common/Duration.java | 53 ----------------- .../apm/collector/ui/graphql/common/Node.java | 28 --------- .../ui/graphql/common/Pagination.java | 52 ----------------- .../ui/graphql/common/ResponseTimeTrend.java | 28 --------- .../collector/ui/graphql/common/SLATrend.java | 28 --------- .../apm/collector/ui/graphql/common/Step.java | 30 ---------- .../ui/graphql/common/ThroughputTrend.java | 28 --------- .../collector/ui/graphql/common/Topology.java | 29 ---------- .../ui/graphql/common/VisualUserNode.java | 25 -------- .../ui/graphql/config/AlarmThreshold.java | 31 ---------- .../ui/graphql/config/ConfigMutation.java | 36 ------------ .../ui/graphql/config/ConfigQuery.java | 36 ------------ .../config/ExistedAlarmThresholdItem.java | 29 ---------- .../config/ExistedAlarmThresholds.java | 28 --------- .../ui/graphql/config/ExistedTTLConfigs.java | 28 --------- .../apm/collector/ui/graphql/config/TTL.java | 29 ---------- .../ui/graphql/config/TTLConfigItem.java | 29 ---------- .../ui/graphql/overview/AlarmTrend.java | 28 --------- .../ui/graphql/overview/ClusterBrief.java | 30 ---------- .../ui/graphql/overview/ConjecturalApp.java | 27 --------- .../graphql/overview/ConjecturalAppBrief.java | 28 --------- .../graphql/overview/OverViewLayerQuery.java | 56 ------------------ .../ui/graphql/server/AppServerInfo.java | 33 ----------- .../collector/ui/graphql/server/CPUTrend.java | 28 --------- .../collector/ui/graphql/server/GCTrend.java | 29 ---------- .../ui/graphql/server/MemoryTrend.java | 31 ---------- .../ui/graphql/server/ServerQuery.java | 58 ------------------- .../ui/graphql/service/ServiceInfo.java | 29 ---------- .../ui/graphql/service/ServiceNode.java | 30 ---------- .../ui/graphql/service/ServiceQuery.java | 52 ----------------- .../ui/graphql/trace/BasicTrace.java | 30 ---------- .../collector/ui/graphql/trace/KeyValue.java | 27 --------- .../collector/ui/graphql/trace/LogEntity.java | 29 ---------- .../apm/collector/ui/graphql/trace/Ref.java | 29 ---------- .../collector/ui/graphql/trace/RefType.java | 27 --------- .../collector/ui/graphql/trace/Segment.java | 31 ---------- .../apm/collector/ui/graphql/trace/Span.java | 43 -------------- .../apm/collector/ui/graphql/trace/Trace.java | 28 --------- .../ui/graphql/trace/TraceBrief.java | 29 ---------- .../ui/graphql/trace/TraceQuery.java | 34 ----------- .../ui/graphql/trace/TraceQueryCondition.java | 36 ------------ 49 files changed, 1620 deletions(-) delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java deleted file mode 100644 index 40002b7de..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/Alarm.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.alarm; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class Alarm { - private List items; - private Integer count; - - public List getItems() { - return items; - } - - public void setItems(List items) { - this.items = items; - } - - public Integer getCount() { - return count; - } - - public void setCount(Integer count) { - this.count = count; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.java deleted file mode 100644 index bae35fba4..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmItem.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.alarm; - -/** - * @author peng-yongsheng - */ -public class AlarmItem { - private String title; - private String content; - private String startTime; - private AlarmType alertType; - private CauseType causeType; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java deleted file mode 100644 index 8c213a658..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmQuery.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.alarm; - -import org.apache.skywalking.apm.collector.ui.graphql.Query; -import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; -import org.apache.skywalking.apm.collector.ui.graphql.common.Pagination; - -/** - * @author peng-yongsheng - */ -public class AlarmQuery implements Query { - - public Alarm loadAlertList(String keyword, AlarmType alarmType, Duration duration, Pagination pagination) { - Alarm alarm = new Alarm(); - alarm.setCount(0); - return alarm; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java deleted file mode 100644 index d36d547c0..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/AlarmType.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.alarm; - -/** - * @author peng-yongsheng - */ -public enum AlarmType { - APPLICATION, - SERVER, - SERVICE -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java deleted file mode 100644 index 5d5986b06..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/alarm/CauseType.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.alarm; - -/** - * @author peng-yongsheng - */ -public enum CauseType { - LOW_SUCCESS_RATE, - SLOW_RESPONSE -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java deleted file mode 100644 index 44e735152..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ApplicationQuery.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.application; - -import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.Query; -import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; -import org.apache.skywalking.apm.collector.ui.graphql.common.Topology; -import org.apache.skywalking.apm.collector.ui.graphql.server.AppServerInfo; -import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceInfo; - -/** - * @author peng-yongsheng - */ -public class ApplicationQuery implements Query { - - public List getAllApplication(Duration duration) { - return null; - } - - public Topology getApplicationTopology(int applicationId, Duration duration) { - return null; - } - - public List getSlowService(int applicationId, Duration duration, Integer top) { - return null; - } - - public List getServerThroughput(int applicationId, Duration duration, Integer top) { - return null; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java deleted file mode 100644 index 8cd678afc..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/application/ConjecturalNode.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.application; - -import org.apache.skywalking.apm.collector.ui.graphql.common.Node; - -/** - * @author peng-yongsheng - */ -public class ConjecturalNode extends Node { -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java deleted file mode 100644 index 3c039e036..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Call.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -/** - * @author peng-yongsheng - */ -public class Call { - private String source; - private String target; - private Boolean isAlert; - private String callType; - private Integer callsPerSec; - private Integer responseTimePerSec; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java deleted file mode 100644 index ad051f150..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Duration.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -/** - * @author peng-yongsheng - */ -public class Duration { - - private String start; - private String end; - private Step step; - - public String getStart() { - return start; - } - - public void setStart(String start) { - this.start = start; - } - - public String getEnd() { - return end; - } - - public void setEnd(String end) { - this.end = end; - } - - public Step getStep() { - return step; - } - - public void setStep(Step step) { - this.step = step; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java deleted file mode 100644 index 388e1f308..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Node.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -/** - * @author peng-yongsheng - */ -public abstract class Node { - private String id; - private String name; - private String type; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java deleted file mode 100644 index b0cabe5e5..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Pagination.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -/** - * @author peng-yongsheng - */ -public class Pagination { - private Integer pageNum; - private Integer pageSize; - private Boolean needTotal; - - public Integer getPageNum() { - return pageNum; - } - - public void setPageNum(Integer pageNum) { - this.pageNum = pageNum; - } - - public Integer getPageSize() { - return pageSize; - } - - public void setPageSize(Integer pageSize) { - this.pageSize = pageSize; - } - - public Boolean getNeedTotal() { - return needTotal; - } - - public void setNeedTotal(Boolean needTotal) { - this.needTotal = needTotal; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java deleted file mode 100644 index 21f7967a9..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ResponseTimeTrend.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class ResponseTimeTrend { - private List trendList; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java deleted file mode 100644 index 4d2526584..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/SLATrend.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class SLATrend { - private List trendList; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.java deleted file mode 100644 index b4d4c4c56..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Step.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -/** - * @author peng-yongsheng - */ -public enum Step { - MONTH, - DAY, - HOUR, - MINUTE, - SECOND -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java deleted file mode 100644 index 504464dde..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/ThroughputTrend.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class ThroughputTrend { - private List trendList; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java deleted file mode 100644 index 6f618ef7c..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/Topology.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class Topology { - private List nodes; - private List calls; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java deleted file mode 100644 index 0ede1446a..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/common/VisualUserNode.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.common; - -/** - * @author peng-yongsheng - */ -public class VisualUserNode extends Node { -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java deleted file mode 100644 index e4ae4fc08..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/AlarmThreshold.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmType; -import org.apache.skywalking.apm.collector.ui.graphql.alarm.CauseType; - -/** - * @author peng-yongsheng - */ -public class AlarmThreshold { - private AlarmType type; - private Integer threshold; - private CauseType causeType; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java deleted file mode 100644 index 828926c7e..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigMutation.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.Mutation; - -/** - * @author peng-yongsheng - */ -public class ConfigMutation implements Mutation { - - public Boolean setDataTTLConfigs(List ttl) { - return null; - } - - public Boolean setAlarmThreshold(List thresholds) { - return null; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java deleted file mode 100644 index 4959eec6b..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ConfigQuery.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import org.apache.skywalking.apm.collector.ui.graphql.Query; -import org.apache.skywalking.apm.collector.ui.graphql.alarm.AlarmType; - -/** - * @author peng-yongsheng - */ -public class ConfigQuery implements Query { - - public ExistedTTLConfigs queryAllDataTTLConfigs() { - return null; - } - - public ExistedAlarmThresholds queryAlarmThresholds(AlarmType alarmType) { - return null; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java deleted file mode 100644 index 2efd4c897..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholdItem.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import org.apache.skywalking.apm.collector.ui.graphql.alarm.CauseType; - -/** - * @author peng-yongsheng - */ -public class ExistedAlarmThresholdItem { - private Integer threshold; - private CauseType causeType; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java deleted file mode 100644 index e6c32e618..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedAlarmThresholds.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class ExistedAlarmThresholds { - private List items; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java deleted file mode 100644 index ad76dbd1c..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/ExistedTTLConfigs.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class ExistedTTLConfigs { - private List ttl; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java deleted file mode 100644 index 6d65c0384..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTL.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import org.apache.skywalking.apm.collector.ui.graphql.common.Step; - -/** - * @author peng-yongsheng - */ -public class TTL { - private Step unit; - private Integer value; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java deleted file mode 100644 index bb16bbf4a..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/config/TTLConfigItem.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.config; - -import org.apache.skywalking.apm.collector.ui.graphql.common.Step; - -/** - * @author peng-yongsheng - */ -public class TTLConfigItem { - private Step unit; - private Integer value; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java deleted file mode 100644 index 604e5da20..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/AlarmTrend.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.overview; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class AlarmTrend { - public List numOfAlarmRate; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.java deleted file mode 100644 index 59177bd23..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ClusterBrief.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.overview; - -/** - * @author peng-yongsheng - */ -public class ClusterBrief { - private int numOfApplication; - private int numOfService; - private int numOfDatabase; - private int numOfCache; - private int numOfMQ; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java deleted file mode 100644 index 60688bd98..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalApp.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.overview; - -/** - * @author peng-yongsheng - */ -public class ConjecturalApp { - private String name; - private int num; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java deleted file mode 100644 index 74c9c8a7b..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/ConjecturalAppBrief.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.overview; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class ConjecturalAppBrief { - private List apps; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java deleted file mode 100644 index 11c8c610d..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/overview/OverViewLayerQuery.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.overview; - -import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.Query; -import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; -import org.apache.skywalking.apm.collector.ui.graphql.common.Topology; -import org.apache.skywalking.apm.collector.ui.graphql.server.AppServerInfo; -import org.apache.skywalking.apm.collector.ui.graphql.service.ServiceInfo; - -/** - * @author peng-yongsheng - */ -public class OverViewLayerQuery implements Query { - - public Topology getClusterTopology(Duration duration) { - return null; - } - - public ClusterBrief getClusterBrief(Duration duration) { - return null; - } - - public AlarmTrend getAlarmTrend(Duration duration) { - return null; - } - - public ConjecturalAppBrief getConjecturalApps(Duration duration) { - return null; - } - - public List getTopNSlowService(Duration duration, int topN) { - return null; - } - - public List getTopNServerThroughput(Duration duration, int topN) { - return null; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java deleted file mode 100644 index 206b5221f..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/AppServerInfo.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.server; - -/** - * @author peng-yongsheng - */ -public class AppServerInfo { - private int id; - private String name; - private int tps; - private String os; - private String host; - private int pid; - private String ipv4; - private String ipv6; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java deleted file mode 100644 index 2c1ae10f4..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/CPUTrend.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.server; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class CPUTrend { - private List cost; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java deleted file mode 100644 index 47309ad96..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/GCTrend.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.server; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class GCTrend { - private List youngGC; - private List oldGC; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java deleted file mode 100644 index 4dba1d842..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/MemoryTrend.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.server; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class MemoryTrend { - private List heap; - private List maxHeap; - private List noheap; - private List maxNoheap; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java deleted file mode 100644 index 96aa50ebb..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/server/ServerQuery.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.server; - -import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.Query; -import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; -import org.apache.skywalking.apm.collector.ui.graphql.common.ResponseTimeTrend; -import org.apache.skywalking.apm.collector.ui.graphql.common.ThroughputTrend; - -/** - * @author peng-yongsheng - */ -public class ServerQuery implements Query { - public List searchServer(String keyword, Duration duration) { - return null; - } - - public List getAllServer(String applicationId, Duration duration) { - return null; - } - - public ResponseTimeTrend getServerResponseTimeTrend(int serverId, Duration duration) { - return null; - } - - public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) { - return null; - } - - public CPUTrend getCPUTrend(int serverId, Duration duration) { - return null; - } - - public GCTrend getGCTrend(int serverId, Duration duration) { - return null; - } - - public MemoryTrend getMemoryTrend(int serverId, Duration duration) { - return null; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java deleted file mode 100644 index 6a44722d7..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceInfo.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.service; - -/** - * @author peng-yongsheng - */ -public class ServiceInfo { - private int id; - private String name; - private int avgResponseTime; - private int tps; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.java deleted file mode 100644 index c29c0fea1..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceNode.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.service; - -import org.apache.skywalking.apm.collector.ui.graphql.common.Node; - -/** - * @author peng-yongsheng - */ -public class ServiceNode extends Node { - private Float sla; - private Long calls; - private Integer numOfServiceAlarm; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java deleted file mode 100644 index 5ed158f8e..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/service/ServiceQuery.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.service; - -import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.Query; -import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; -import org.apache.skywalking.apm.collector.ui.graphql.common.ResponseTimeTrend; -import org.apache.skywalking.apm.collector.ui.graphql.common.SLATrend; -import org.apache.skywalking.apm.collector.ui.graphql.common.ThroughputTrend; -import org.apache.skywalking.apm.collector.ui.graphql.common.Topology; - -/** - * @author peng-yongsheng - */ -public class ServiceQuery implements Query { - public List searchService(String keyword, Duration duration, Integer topN) { - return null; - } - - public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Duration duration) { - return null; - } - - public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) { - return null; - } - - public SLATrend getServiceSLATrend(int serviceId, Duration duration) { - return null; - } - - public Topology getServiceTopology(int serviceId, Duration duration) { - return null; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.java deleted file mode 100644 index 2b2151906..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/BasicTrace.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -/** - * @author peng-yongsheng - */ -public class BasicTrace { - private String operationName; - private int duration; - private String start; - private Boolean isError; - private String traceId; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java deleted file mode 100644 index 28710cd0d..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/KeyValue.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -/** - * @author peng-yongsheng - */ -public class KeyValue { - private String key; - private String value; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java deleted file mode 100644 index d2938d4c1..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/LogEntity.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class LogEntity { - private String time; - private List data; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java deleted file mode 100644 index ef226f4f7..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Ref.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -/** - * @author peng-yongsheng - */ -public class Ref { - private String traceId; - private Integer parentSegmentId; - private Integer parentSpanId; - private RefType type; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java deleted file mode 100644 index 6c3ce9fe4..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/RefType.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -/** - * @author peng-yongsheng - */ -public enum RefType { - CROSS_PROCESS, - CROSS_THREAD -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java deleted file mode 100644 index 50dbe6cf2..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Segment.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class Segment { - private int segmentId; - private String appName; - private Boolean isSizeLimited; - private List spans; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java deleted file mode 100644 index 516eba00e..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Span.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class Span { - private String traceId; - private String segmentId; - private Integer spanId; - private Integer parentSpanId; - private List refs; - private String applicationCode; - private Long startTime; - private Long endTime; - private String operationName; - private String type; - private String peer; - private String component; - private Boolean isError; - private String layer; - private List tags; - private List logs; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java deleted file mode 100644 index 05b1ba19d..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/Trace.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class Trace { - private List spans; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java deleted file mode 100644 index b9353370a..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceBrief.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -import java.util.List; - -/** - * @author peng-yongsheng - */ -public class TraceBrief { - private List traces; - private Integer total; -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java deleted file mode 100644 index 76b370b1b..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQuery.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -import org.apache.skywalking.apm.collector.ui.graphql.Query; - -/** - * @author peng-yongsheng - */ -public class TraceQuery implements Query { - public TraceBrief queryBasicTraces(TraceQueryCondition condition) { - return null; - } - - public Trace queryTrace(String id) { - return null; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java deleted file mode 100644 index 5dd8fdd01..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/trace/TraceQueryCondition.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.trace; - -import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.common.Duration; - -/** - * @author peng-yongsheng - */ -public class TraceQueryCondition { - private List applicationCodes; - private String traceId; - private String operationName; - private Duration queryDuration; - private int minTraceDuration; - private int maxTraceDuration; - private Boolean topN; - private int needTotal; -} From 9a6520fbc2494473d6721af5fc689704fa7e4404 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 26 Jan 2018 00:23:58 +0800 Subject: [PATCH 08/36] Provide the application topology query, but only completed es storage. --- .../test/resources/json/dubbox-provider.json | 17 ++ .../provider/worker/AlarmAssertWorker.java | 2 +- .../component/ApplicationComponentCopy.java | 2 +- .../ApplicationComponentSpanListener.java | 17 +- .../mapping/ApplicationMappingCopy.java | 2 +- .../ApplicationMappingSpanListener.java | 16 +- .../ServiceReferenceMetricSpanListener.java | 2 +- .../standardization/ReferenceIdExchanger.java | 3 - .../service/ApplicationCacheService.java | 3 +- .../service/ApplicationCacheGuavaService.java | 21 ++- apm-collector/apm-collector-core/pom.xml | 5 + .../collector/core/util/TimeBucketUtils.java | 18 +-- .../dao/IApplicationComponentUIDAO.java | 27 +++- .../storage/dao/IApplicationMappingUIDAO.java | 26 ++- .../dao/IApplicationReferenceMetricUIDAO.java | 11 +- .../collector/storage/dao/IInstanceUIDAO.java | 2 +- .../dao/cache/IApplicationCacheDAO.java | 3 +- .../collector/storage/table/MetricSource.java | 36 +++++ .../application/ApplicationComponent.java | 8 +- .../ApplicationComponentTable.java | 3 +- .../table/application/ApplicationMapping.java | 8 +- .../application/ApplicationMappingTable.java | 3 +- .../ui/application/ApplicationNode.java | 9 -- .../apm/collector/storage/ui/common/Call.java | 94 ++++++++++- .../apm/collector/storage/ui/common/Node.java | 6 +- .../collector/storage/ui/common/Topology.java | 17 ++ .../utils/TimePyramidTableNameBuilder.java | 50 ++++++ .../es/dao/ApplicationComponentEsUIDAO.java | 45 +++--- .../es/dao/ApplicationMappingEsUIDAO.java | 31 ++-- .../ApplicationReferenceMetricEsUIDAO.java | 126 +++++++++------ .../storage/es/dao/InstanceEsUIDAO.java | 11 +- ...tApplicationComponentEsPersistenceDAO.java | 4 +- ...actApplicationMappingEsPersistenceDAO.java | 4 +- .../es/dao/cache/ApplicationEsCacheDAO.java | 12 +- ...ractApplicationComponentEsTableDefine.java | 2 +- ...stractApplicationMappingEsTableDefine.java | 2 +- .../h2/dao/ApplicationComponentH2UIDAO.java | 41 +++-- .../h2/dao/ApplicationMappingH2UIDAO.java | 38 +++-- .../ApplicationReferenceMetricH2UIDAO.java | 17 +- .../storage/h2/dao/InstanceH2UIDAO.java | 2 +- ...tApplicationComponentH2PersistenceDAO.java | 4 +- ...actApplicationMappingH2PersistenceDAO.java | 4 +- .../h2/dao/cache/ApplicationH2CacheDAO.java | 16 +- ...ractApplicationComponentH2TableDefine.java | 2 +- ...stractApplicationMappingH2TableDefine.java | 2 +- .../ui/utils/DurationUtilsTestCase.java | 32 ++++ .../collector/ui/query/ApplicationQuery.java | 45 ++---- .../ui/service/ApplicationService.java | 6 +- .../service/ApplicationTopologyService.java | 129 +++++++++++++++ .../ui/service/InstanceHealthService.java | 2 +- .../apm/collector/ui/service/SpanService.java | 2 +- .../collector/ui/service/TopologyBuilder.java | 153 ++++++++++++++++++ .../ui/service/TraceDagDataBuilder.java | 153 ------------------ .../ui/service/TraceStackService.java | 2 +- .../apm/collector/ui/utils/DurationUtils.java | 91 +++++++++++ .../ui/query/ApplicationQueryTestCase.java | 20 +-- 56 files changed, 989 insertions(+), 420 deletions(-) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/MetricSource.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json index 5add6e2f1..01c6e76ad 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json @@ -46,6 +46,23 @@ } ], "lo": [] + }, + { + "si": 1, + "tv": 1, + "lv": 1, + "ps": 0, + "st": 1501858094726, + "et": 1501858095804, + "ci": 9, + "cn": "", + "oi": 0, + "on": "mongodb://[username:password@]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]", + "pi": 0, + "pn": "localhost:27017", + "ie": false, + "to": [], + "lo": [] } ] } diff --git a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java index c00db5644..b0d211f75 100644 --- a/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-alarm/alarm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/alarm/provider/worker/AlarmAssertWorker.java @@ -18,7 +18,7 @@ package org.apache.skywalking.apm.collector.analysis.alarm.provider.worker; -import org.apache.skywalking.apm.collector.analysis.metric.define.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.analysis.worker.model.base.AbstractLocalAsyncWorker; import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerException; import org.apache.skywalking.apm.collector.core.data.StreamData; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java index 27cf97272..510ac814e 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentCopy.java @@ -31,7 +31,7 @@ public class ApplicationComponentCopy { newApplicationComponent.setMetricId(applicationComponent.getMetricId()); newApplicationComponent.setComponentId(applicationComponent.getComponentId()); - newApplicationComponent.setPeerId(applicationComponent.getPeerId()); + newApplicationComponent.setApplicationId(applicationComponent.getApplicationId()); newApplicationComponent.setTimeBucket(newApplicationComponent.getTimeBucket()); return newApplicationComponent; } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java index 80e4c7ece..aa9ddee1b 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/component/ApplicationComponentSpanListener.java @@ -27,6 +27,8 @@ import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listen import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.core.graph.Graph; import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -39,17 +41,24 @@ import org.apache.skywalking.apm.collector.storage.table.application.Application */ public class ApplicationComponentSpanListener implements EntrySpanListener, ExitSpanListener, FirstSpanListener { + private final ApplicationCacheService applicationCacheService; private List applicationComponents = new ArrayList<>(); private long timeBucket; + ApplicationComponentSpanListener(ModuleManager moduleManager) { + this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); + } + @Override public void parseExit(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { - String metricId = spanDecorator.getPeerId() + Const.ID_SPLIT + String.valueOf(spanDecorator.getComponentId()); + int applicationIdFromPeerId = applicationCacheService.getApplicationIdByAddressId(spanDecorator.getPeerId()); + + String metricId = applicationIdFromPeerId + Const.ID_SPLIT + String.valueOf(spanDecorator.getComponentId()); ApplicationComponent applicationComponent = new ApplicationComponent(); applicationComponent.setMetricId(metricId); applicationComponent.setComponentId(spanDecorator.getComponentId()); - applicationComponent.setPeerId(spanDecorator.getPeerId()); + applicationComponent.setApplicationId(applicationIdFromPeerId); applicationComponents.add(applicationComponent); } @@ -60,7 +69,7 @@ public class ApplicationComponentSpanListener implements EntrySpanListener, Exit ApplicationComponent applicationComponent = new ApplicationComponent(); applicationComponent.setMetricId(metricId); applicationComponent.setComponentId(spanDecorator.getComponentId()); - applicationComponent.setPeerId(applicationId); + applicationComponent.setApplicationId(applicationId); applicationComponents.add(applicationComponent); } @@ -82,7 +91,7 @@ public class ApplicationComponentSpanListener implements EntrySpanListener, Exit public static class Factory implements SpanListenerFactory { @Override public SpanListener create(ModuleManager moduleManager) { - return new ApplicationComponentSpanListener(); + return new ApplicationComponentSpanListener(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java index aa5aad45f..3797f1d5f 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingCopy.java @@ -32,7 +32,7 @@ public class ApplicationMappingCopy { newApplicationMapping.setTimeBucket(applicationMapping.getTimeBucket()); newApplicationMapping.setApplicationId(applicationMapping.getApplicationId()); - newApplicationMapping.setAddressId(applicationMapping.getAddressId()); + newApplicationMapping.setMappingApplicationId(applicationMapping.getMappingApplicationId()); return newApplicationMapping; } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java index 9433f2d5e..eda62f9fd 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/application/mapping/ApplicationMappingSpanListener.java @@ -26,6 +26,8 @@ import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listen import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.FirstSpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListener; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.listener.SpanListenerFactory; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.core.graph.Graph; import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; @@ -42,18 +44,26 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS private final Logger logger = LoggerFactory.getLogger(ApplicationMappingSpanListener.class); + private final ApplicationCacheService applicationCacheService; private List applicationMappings = new LinkedList<>(); private long timeBucket; + ApplicationMappingSpanListener(ModuleManager moduleManager) { + this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); + } + @Override public void parseEntry(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { logger.debug("application mapping listener parse reference"); if (spanDecorator.getRefsCount() > 0) { for (int i = 0; i < spanDecorator.getRefsCount(); i++) { ApplicationMapping applicationMapping = new ApplicationMapping(); applicationMapping.setApplicationId(applicationId); - applicationMapping.setAddressId(spanDecorator.getRefs(i).getNetworkAddressId()); - String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getAddressId()); + int addressId = spanDecorator.getRefs(i).getNetworkAddressId(); + int mappingApplicationId = applicationCacheService.getApplicationIdByAddressId(addressId); + applicationMapping.setMappingApplicationId(mappingApplicationId); + + String metricId = String.valueOf(applicationId) + Const.ID_SPLIT + String.valueOf(applicationMapping.getMappingApplicationId()); applicationMapping.setMetricId(metricId); applicationMappings.add(applicationMapping); } @@ -79,7 +89,7 @@ public class ApplicationMappingSpanListener implements FirstSpanListener, EntryS public static class Factory implements SpanListenerFactory { @Override public SpanListener create(ModuleManager moduleManager) { - return new ApplicationMappingSpanListener(); + return new ApplicationMappingSpanListener(moduleManager); } } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java index c2b933d72..8c7d04333 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/service/refmetric/ServiceReferenceMetricSpanListener.java @@ -20,7 +20,7 @@ package org.apache.skywalking.apm.collector.analysis.metric.provider.worker.serv import java.util.LinkedList; import java.util.List; -import org.apache.skywalking.apm.collector.analysis.metric.define.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGraphIdDefine; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.SpanDecorator; diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java index ccef9af41..d3e760153 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java @@ -19,7 +19,6 @@ package org.apache.skywalking.apm.collector.analysis.segment.parser.provider.parser.standardization; import org.apache.skywalking.apm.collector.analysis.register.define.AnalysisRegisterModule; -import org.apache.skywalking.apm.collector.analysis.register.define.service.IApplicationIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.INetworkAddressIDService; import org.apache.skywalking.apm.collector.analysis.register.define.service.IServiceNameService; import org.apache.skywalking.apm.collector.analysis.segment.parser.define.decorator.ReferenceDecorator; @@ -39,7 +38,6 @@ public class ReferenceIdExchanger implements IdExchanger { private final Logger logger = LoggerFactory.getLogger(ReferenceIdExchanger.class); private static ReferenceIdExchanger EXCHANGER; - private final IApplicationIDService applicationIDService; private final IServiceNameService serviceNameService; private final InstanceCacheService instanceCacheService; private final INetworkAddressIDService networkAddressIDService; @@ -52,7 +50,6 @@ public class ReferenceIdExchanger implements IdExchanger { } private ReferenceIdExchanger(ModuleManager moduleManager) { - this.applicationIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IApplicationIDService.class); this.serviceNameService = moduleManager.find(AnalysisRegisterModule.NAME).getService(IServiceNameService.class); this.networkAddressIDService = moduleManager.find(AnalysisRegisterModule.NAME).getService(INetworkAddressIDService.class); this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class); diff --git a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java index 57d0c39e3..f576b2830 100644 --- a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java +++ b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ApplicationCacheService.java @@ -19,6 +19,7 @@ package org.apache.skywalking.apm.collector.cache.service; import org.apache.skywalking.apm.collector.core.module.Service; +import org.apache.skywalking.apm.collector.storage.table.register.Application; /** * @author peng-yongsheng @@ -26,7 +27,7 @@ import org.apache.skywalking.apm.collector.core.module.Service; public interface ApplicationCacheService extends Service { int getApplicationIdByCode(String applicationCode); - String getApplicationCodeById(int applicationId); + Application getApplicationById(int applicationId); int getApplicationIdByAddressId(int addressId); } diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java index 530378740..64480c765 100644 --- a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ApplicationCacheGuavaService.java @@ -22,11 +22,10 @@ import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; +import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -70,23 +69,23 @@ public class ApplicationCacheGuavaService implements ApplicationCacheService { return applicationId; } - private final Cache idCache = CacheBuilder.newBuilder().maximumSize(1000).build(); + private final Cache applicationCache = CacheBuilder.newBuilder().maximumSize(1000).build(); - @Override public String getApplicationCodeById(int applicationId) { - String applicationCode = Const.EMPTY_STRING; + @Override public Application getApplicationById(int applicationId) { + Application application = null; try { - applicationCode = idCache.get(applicationId, () -> getApplicationCacheDAO().getApplicationCode(applicationId)); + application = applicationCache.get(applicationId, () -> getApplicationCacheDAO().getApplication(applicationId)); } catch (Throwable e) { logger.error(e.getMessage(), e); } - if (StringUtils.isEmpty(applicationCode)) { - applicationCode = getApplicationCacheDAO().getApplicationCode(applicationId); - if (StringUtils.isNotEmpty(applicationCode)) { - codeCache.put(applicationCode, applicationId); + if (ObjectUtils.isEmpty(application)) { + application = getApplicationCacheDAO().getApplication(applicationId); + if (ObjectUtils.isNotEmpty(application)) { + applicationCache.put(applicationId, application); } } - return applicationCode; + return application; } private final Cache addressIdCache = CacheBuilder.newBuilder().maximumSize(1000).build(); diff --git a/apm-collector/apm-collector-core/pom.xml b/apm-collector/apm-collector-core/pom.xml index 8873a68fe..aef472f42 100644 --- a/apm-collector/apm-collector-core/pom.xml +++ b/apm-collector/apm-collector-core/pom.xml @@ -36,5 +36,10 @@ gson 2.8.1 + + joda-time + joda-time + 2.9.9 + diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java index a3cf5b2ef..8bb4366db 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/TimeBucketUtils.java @@ -27,37 +27,37 @@ import java.util.Calendar; public enum TimeBucketUtils { INSTANCE; - private final SimpleDateFormat monthDateFormat = new SimpleDateFormat("yyyyMM"); - private final SimpleDateFormat dayDateFormat = new SimpleDateFormat("yyyyMMdd"); - private final SimpleDateFormat hourDateFormat = new SimpleDateFormat("yyyyMMddHH"); - private final SimpleDateFormat minuteDateFormat = new SimpleDateFormat("yyyyMMddHHmm"); - private final SimpleDateFormat secondDateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); + public static final SimpleDateFormat MONTH_DATE_FORMAT = new SimpleDateFormat("yyyyMM"); + public static final SimpleDateFormat DAY_DATE_FORMAT = new SimpleDateFormat("yyyyMMdd"); + public static final SimpleDateFormat HOUR_DATE_FORMAT = new SimpleDateFormat("yyyyMMddHH"); + public static final SimpleDateFormat MINUTE_DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmm"); + public static final SimpleDateFormat SECOND_DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss"); public long getMinuteTimeBucket(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); - String timeStr = minuteDateFormat.format(calendar.getTime()); + String timeStr = MINUTE_DATE_FORMAT.format(calendar.getTime()); return Long.valueOf(timeStr); } public long getSecondTimeBucket(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); - String timeStr = secondDateFormat.format(calendar.getTime()); + String timeStr = SECOND_DATE_FORMAT.format(calendar.getTime()); return Long.valueOf(timeStr); } public long getHourTimeBucket(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); - String timeStr = hourDateFormat.format(calendar.getTime()) + "00"; + String timeStr = HOUR_DATE_FORMAT.format(calendar.getTime()) + "00"; return Long.valueOf(timeStr); } public long getDayTimeBucket(long time) { Calendar calendar = Calendar.getInstance(); calendar.setTimeInMillis(time); - String timeStr = dayDateFormat.format(calendar.getTime()) + "0000"; + String timeStr = DAY_DATE_FORMAT.format(calendar.getTime()) + "0000"; return Long.valueOf(timeStr); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java index a003e5ff2..903629e80 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java @@ -18,12 +18,35 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonArray; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; /** * @author peng-yongsheng */ public interface IApplicationComponentUIDAO extends DAO { - JsonArray load(long startTime, long endTime); + + List load(Step step, long startTime, long endTime); + + class ApplicationComponent { + private int componentId; + private int applicationId; + + public int getComponentId() { + return componentId; + } + + public void setComponentId(int componentId) { + this.componentId = componentId; + } + + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java index 5f8e454a4..75e4898f6 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java @@ -18,12 +18,34 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonArray; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; /** * @author peng-yongsheng */ public interface IApplicationMappingUIDAO extends DAO { - JsonArray load(long startTime, long endTime); + List load(Step step, long startTime, long endTime); + + class ApplicationMapping { + private int applicationId; + private int mappingApplicationId; + + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } + + public int getMappingApplicationId() { + return mappingApplicationId; + } + + public void setMappingApplicationId(int mappingApplicationId) { + this.mappingApplicationId = mappingApplicationId; + } + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java index 1c32a17cf..505950b12 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java @@ -18,12 +18,19 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonArray; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; /** * @author peng-yongsheng */ public interface IApplicationReferenceMetricUIDAO extends DAO { - JsonArray load(long startTime, long endTime); + List getFrontApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource); + + List getBehindApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java index a2173bd53..6a2413f1f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java @@ -31,7 +31,7 @@ public interface IInstanceUIDAO extends DAO { Long instanceLastHeartBeatTime(long applicationInstanceId); - List getApplications(long startTime, long endTime); + List getApplications(long startTime, long endTime, int... applicationIds); Instance getInstance(int instanceId); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java index 3b766ef99..972f22905 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IApplicationCacheDAO.java @@ -19,6 +19,7 @@ package org.apache.skywalking.apm.collector.storage.dao.cache; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.register.Application; /** * @author peng-yongsheng @@ -26,7 +27,7 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO; public interface IApplicationCacheDAO extends DAO { int getApplicationIdByCode(String applicationCode); - String getApplicationCode(int applicationId); + Application getApplication(int applicationId); int getApplicationIdByAddressId(int addressId); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/MetricSource.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/MetricSource.java new file mode 100644 index 000000000..26af12fda --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/MetricSource.java @@ -0,0 +1,36 @@ +/* + * 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.apm.collector.storage.table; + +/** + * @author peng-yongsheng + */ +public enum MetricSource { + Caller(0), Callee(1); + + private final int value; + + private MetricSource(int value) { + this.value = value; + } + + public int getValue() { + return value; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java index 4f18fbbd1..cf6e09e69 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponent.java @@ -41,7 +41,7 @@ public class ApplicationComponent extends StreamData { private static final Column[] INTEGER_COLUMNS = { new Column(ApplicationComponentTable.COLUMN_COMPONENT_ID, new CoverOperation()), - new Column(ApplicationComponentTable.COLUMN_PEER_ID, new CoverOperation()), + new Column(ApplicationComponentTable.COLUMN_APPLICATION_ID, new CoverOperation()), }; private static final Column[] BYTE_COLUMNS = {}; @@ -82,11 +82,11 @@ public class ApplicationComponent extends StreamData { setDataInteger(0, componentId); } - public Integer getPeerId() { + public Integer getApplicationId() { return getDataInteger(1); } - public void setPeerId(Integer peerId) { - setDataInteger(1, peerId); + public void setApplicationId(Integer applicationId) { + setDataInteger(1, applicationId); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponentTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponentTable.java index 10b39796d..921398cdf 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponentTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationComponentTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -27,5 +26,5 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable; public class ApplicationComponentTable extends CommonTable { public static final String TABLE = "application_component"; public static final String COLUMN_COMPONENT_ID = "component_id"; - public static final String COLUMN_PEER_ID = "peer_id"; + public static final String COLUMN_APPLICATION_ID = "application_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java index 0d777426c..e1b3fff77 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMapping.java @@ -41,7 +41,7 @@ public class ApplicationMapping extends StreamData { private static final Column[] INTEGER_COLUMNS = { new Column(ApplicationMappingTable.COLUMN_APPLICATION_ID, new CoverOperation()), - new Column(ApplicationMappingTable.COLUMN_ADDRESS_ID, new CoverOperation()), + new Column(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, new CoverOperation()), }; private static final Column[] BYTE_COLUMNS = {}; @@ -74,12 +74,12 @@ public class ApplicationMapping extends StreamData { setDataInteger(0, applicationId); } - public int getAddressId() { + public int getMappingApplicationId() { return getDataInteger(1); } - public void setAddressId(int addressId) { - setDataInteger(1, addressId); + public void setMappingApplicationId(int mappingApplicationId) { + setDataInteger(1, mappingApplicationId); } public long getTimeBucket() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMappingTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMappingTable.java index df9fbbb1d..fbaa49e24 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMappingTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/application/ApplicationMappingTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.application; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -27,5 +26,5 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable; public class ApplicationMappingTable extends CommonTable { public static final String TABLE = "application_mapping"; public static final String COLUMN_APPLICATION_ID = "application_id"; - public static final String COLUMN_ADDRESS_ID = "address_id"; + public static final String COLUMN_MAPPING_APPLICATION_ID = "mapping_application_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java index 0affa2480..88ca7f14f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java @@ -28,7 +28,6 @@ public class ApplicationNode extends Node { private Float sla; private Long callsPerSec; private Integer responseTimePerSec; - private Long calls; private Float apdex; private Boolean isAlarm; private Integer numOfServer; @@ -59,14 +58,6 @@ public class ApplicationNode extends Node { this.responseTimePerSec = responseTimePerSec; } - public Long getCalls() { - return calls; - } - - public void setCalls(Long calls) { - this.calls = calls; - } - public Float getApdex() { return apdex; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java index 7a388e3ce..74151ce0d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java @@ -22,10 +22,94 @@ package org.apache.skywalking.apm.collector.storage.ui.common; * @author peng-yongsheng */ public class Call { - private String source; - private String target; - private Boolean isAlert; + private int source; + private String sourceName; + private int target; + private String targetName; + private boolean isAlert; private String callType; - private Integer callsPerSec; - private Integer responseTimePerSec; + private int calls; + private int callsPerSec; + private long responseTimes; + private int responseTimePerSec; + + public int getSource() { + return source; + } + + public void setSource(int source) { + this.source = source; + } + + public String getSourceName() { + return sourceName; + } + + public void setSourceName(String sourceName) { + this.sourceName = sourceName; + } + + public int getTarget() { + return target; + } + + public void setTarget(int target) { + this.target = target; + } + + public String getTargetName() { + return targetName; + } + + public void setTargetName(String targetName) { + this.targetName = targetName; + } + + public boolean isAlert() { + return isAlert; + } + + public void setAlert(boolean alert) { + isAlert = alert; + } + + public String getCallType() { + return callType; + } + + public void setCallType(String callType) { + this.callType = callType; + } + + public int getCalls() { + return calls; + } + + public void setCalls(int calls) { + this.calls = calls; + } + + public int getCallsPerSec() { + return callsPerSec; + } + + public void setCallsPerSec(int callsPerSec) { + this.callsPerSec = callsPerSec; + } + + public long getResponseTimes() { + return responseTimes; + } + + public void setResponseTimes(long responseTimes) { + this.responseTimes = responseTimes; + } + + public int getResponseTimePerSec() { + return responseTimePerSec; + } + + public void setResponseTimePerSec(int responseTimePerSec) { + this.responseTimePerSec = responseTimePerSec; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java index e4d43c379..b4cf19254 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Node.java @@ -22,15 +22,15 @@ package org.apache.skywalking.apm.collector.storage.ui.common; * @author peng-yongsheng */ public abstract class Node { - private String id; + private int id; private String name; private String type; - public String getId() { + public int getId() { return id; } - public void setId(String id) { + public void setId(int id) { this.id = id; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java index 7e3ac2c57..2f9340f91 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java @@ -24,6 +24,23 @@ import java.util.List; * @author peng-yongsheng */ public class Topology { + private List nodes; private List calls; + + public List getNodes() { + return nodes; + } + + public void setNodes(List nodes) { + this.nodes = nodes; + } + + public List getCalls() { + return calls; + } + + public void setCalls(List calls) { + this.calls = calls; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java new file mode 100644 index 000000000..6bfd365ee --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/TimePyramidTableNameBuilder.java @@ -0,0 +1,50 @@ +/* + * 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.apm.collector.storage.utils; + +import org.apache.skywalking.apm.collector.core.storage.TimePyramid; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; + +/** + * @author peng-yongsheng + */ +public class TimePyramidTableNameBuilder { + + private TimePyramidTableNameBuilder() { + } + + public static String build(Step step, String tableName) { + switch (step) { + case MONTH: + tableName = tableName + Const.ID_SPLIT + TimePyramid.Month.getName(); + break; + case DAY: + tableName = tableName + Const.ID_SPLIT + TimePyramid.Day.getName(); + break; + case HOUR: + tableName = tableName + Const.ID_SPLIT + TimePyramid.Day.getName(); + break; + case MINUTE: + tableName = tableName + Const.ID_SPLIT + TimePyramid.Minute.getName(); + break; + } + return tableName; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java index d77825ec2..d3d8879f4 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java @@ -18,13 +18,14 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMinuteEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; @@ -39,51 +40,47 @@ import org.slf4j.LoggerFactory; */ public class ApplicationComponentEsUIDAO extends EsDAO implements IApplicationComponentUIDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationComponentMinuteEsPersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(ApplicationComponentEsUIDAO.class); public ApplicationComponentEsUIDAO(ElasticSearchClient client) { super(client); } - @Override public JsonArray load(long startTime, long endTime) { + @Override public List load(Step step, long startTime, long endTime) { logger.debug("application component load, start time: {}, end time: {}", startTime, endTime); - JsonArray applicationComponentArray = new JsonArray(); - applicationComponentArray.addAll(aggregationByComponentId(startTime, endTime)); - return applicationComponentArray; - } - - private JsonArray aggregationByComponentId(long startTime, long endTime) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ApplicationComponentTable.TABLE); + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE); + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); searchRequestBuilder.setTypes(ApplicationComponentTable.TABLE_TYPE); searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationComponentTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); searchRequestBuilder.setSize(0); searchRequestBuilder.addAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_COMPONENT_ID).field(ApplicationComponentTable.COLUMN_COMPONENT_ID).size(100) - .subAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_PEER_ID).field(ApplicationComponentTable.COLUMN_PEER_ID).size(100))); + .subAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_APPLICATION_ID).field(ApplicationComponentTable.COLUMN_APPLICATION_ID).size(100))); SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); Terms componentIdTerms = searchResponse.getAggregations().get(ApplicationComponentTable.COLUMN_COMPONENT_ID); - JsonArray applicationComponentArray = new JsonArray(); + + List applicationComponents = new LinkedList<>(); for (Terms.Bucket componentIdBucket : componentIdTerms.getBuckets()) { int componentId = componentIdBucket.getKeyAsNumber().intValue(); - buildComponentArray(componentIdBucket, componentId, applicationComponentArray); + buildApplicationComponents(componentIdBucket, componentId, applicationComponents); } - return applicationComponentArray; + return applicationComponents; } - private void buildComponentArray(Terms.Bucket componentBucket, int componentId, - JsonArray applicationComponentArray) { - Terms peerIdTerms = componentBucket.getAggregations().get(ApplicationComponentTable.COLUMN_PEER_ID); + private void buildApplicationComponents(Terms.Bucket componentBucket, int componentId, + List applicationComponents) { + Terms peerIdTerms = componentBucket.getAggregations().get(ApplicationComponentTable.COLUMN_APPLICATION_ID); for (Terms.Bucket peerIdBucket : peerIdTerms.getBuckets()) { - int peerId = peerIdBucket.getKeyAsNumber().intValue(); + int applicationId = peerIdBucket.getKeyAsNumber().intValue(); - JsonObject applicationComponentObj = new JsonObject(); - applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_COMPONENT_ID, componentId); - applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_PEER_ID, peerId); - applicationComponentArray.add(applicationComponentObj); + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setComponentId(componentId); + applicationComponent.setApplicationId(applicationId); + applicationComponents.add(applicationComponent); } } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java index 4bb7ae6fa..6ffc1876d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java @@ -18,12 +18,14 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; @@ -44,8 +46,10 @@ public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMapp super(client); } - @Override public JsonArray load(long startTime, long endTime) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ApplicationMappingTable.TABLE); + @Override public List load(Step step, long startTime, long endTime) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); searchRequestBuilder.setTypes(ApplicationMappingTable.TABLE_TYPE); searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationMappingTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); @@ -53,24 +57,25 @@ public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMapp searchRequestBuilder.addAggregation( AggregationBuilders.terms(ApplicationMappingTable.COLUMN_APPLICATION_ID).field(ApplicationMappingTable.COLUMN_APPLICATION_ID).size(100) - .subAggregation(AggregationBuilders.terms(ApplicationMappingTable.COLUMN_ADDRESS_ID).field(ApplicationMappingTable.COLUMN_ADDRESS_ID).size(100))); + .subAggregation(AggregationBuilders.terms(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID).field(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID).size(100))); SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); Terms applicationIdTerms = searchResponse.getAggregations().get(ApplicationMappingTable.COLUMN_APPLICATION_ID); - JsonArray applicationMappingArray = new JsonArray(); + List applicationMappings = new LinkedList<>(); for (Terms.Bucket applicationIdBucket : applicationIdTerms.getBuckets()) { int applicationId = applicationIdBucket.getKeyAsNumber().intValue(); - Terms addressIdTerms = applicationIdBucket.getAggregations().get(ApplicationMappingTable.COLUMN_ADDRESS_ID); + Terms addressIdTerms = applicationIdBucket.getAggregations().get(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID); for (Terms.Bucket addressIdBucket : addressIdTerms.getBuckets()) { int addressId = addressIdBucket.getKeyAsNumber().intValue(); - JsonObject applicationMappingObj = new JsonObject(); - applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_APPLICATION_ID, applicationId); - applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_ADDRESS_ID, addressId); - applicationMappingArray.add(applicationMappingObj); + + ApplicationMapping applicationMapping = new ApplicationMapping(); + applicationMapping.setApplicationId(applicationId); + applicationMapping.setMappingApplicationId(addressId); + applicationMappings.add(applicationMapping); } } - logger.debug("application mapping data: {}", applicationMappingArray.toString()); - return applicationMappingArray; + logger.debug("application mapping data: {}", applicationMappings.toString()); + return applicationMappings; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java index a7011b111..8a7ca9816 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java @@ -18,82 +18,114 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; +import org.elasticsearch.search.aggregations.metrics.sum.Sum; /** * @author peng-yongsheng */ public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplicationReferenceMetricUIDAO { - private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricEsUIDAO.class); - public ApplicationReferenceMetricEsUIDAO(ElasticSearchClient client) { super(client); } - @Override public JsonArray load(long startTime, long endTime) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ApplicationReferenceMetricTable.TABLE); + @Override public List getFrontApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE); searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); searchRequestBuilder.setSize(0); TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100); -// aggregationBuilder.subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100) -// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S1_LTE).field(ApplicationReferenceMetricTable.COLUMN_S1_LTE)) -// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S3_LTE).field(ApplicationReferenceMetricTable.COLUMN_S3_LTE)) -// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_LTE).field(ApplicationReferenceMetricTable.COLUMN_S5_LTE)) -// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_S5_GT).field(ApplicationReferenceMetricTable.COLUMN_S5_GT)) -// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_SUMMARY).field(ApplicationReferenceMetricTable.COLUMN_SUMMARY)) -// .subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_ERROR).field(ApplicationReferenceMetricTable.COLUMN_ERROR))); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); searchRequestBuilder.addAggregation(aggregationBuilder); SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - JsonArray applicationReferenceMetricArray = new JsonArray(); -// Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); -// for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) { -// int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue(); -// Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); -// for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) { -// int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue(); -// -// if (behindApplicationId != 0) { -// Sum s1LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S1_LTE); -// Sum s3LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S3_LTE); -// Sum s5LTE = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_LTE); -// Sum s5GT = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_S5_GT); -// Sum summary = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_SUMMARY); -// Sum error = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_ERROR); -// logger.debug("frontApplicationId: {}, behindApplicationId: {}, s1LTE: {}, s3LTE: {}, s5LTE: {}, s5GT: {}, error: {}, summary: {}", frontApplicationId, -// behindApplicationId, s1LTE.getValue(), s3LTE.getValue(), s5LTE.getValue(), s5GT.getValue(), error.getValue(), summary.getValue()); -// -// JsonObject nodeRefResSumObj = new JsonObject(); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), s1LTE.getValue()); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), s3LTE.getValue()); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), s5LTE.getValue()); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), s5GT.getValue()); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), error.getValue()); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), summary.getValue()); -// nodeRefResSumArray.add(nodeRefResSumObj); -// } -// } -// } + List nodes = new LinkedList<>(); + Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); + for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) { + int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue(); + Sum calls = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum responseTimes = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - return applicationReferenceMetricArray; + Call call = new Call(); + call.setSource(frontApplicationId); + call.setTarget(applicationId); + call.setCalls((int)calls.getValue()); + call.setResponseTimes((int)responseTimes.getValue()); + nodes.add(call); + } + + return nodes; + } + + @Override public List getBehindApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List nodes = new LinkedList<>(); + Terms behindApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); + for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) { + int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue(); + Sum calls = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum responseTimes = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + + Call call = new Call(); + call.setTarget(behindApplicationId); + call.setSource(applicationId); + call.setCalls((int)calls.getValue()); + call.setResponseTimes((int)responseTimes.getValue()); + nodes.add(call); + } + + return nodes; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java index 7148c1704..b8b3dd1bc 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java @@ -94,12 +94,19 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { return heartBeatTime; } - @Override public List getApplications(long startTime, long endTime) { + @Override public List getApplications(long startTime, long endTime, int... applicationIds) { logger.debug("application list get, start time: {}, end time: {}", startTime, endTime); SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startTime)); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + boolQueryBuilder.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startTime)); + if (applicationIds.length > 0) { + boolQueryBuilder.must().add(QueryBuilders.termsQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationIds)); + } + + searchRequestBuilder.setQuery(boolQueryBuilder); searchRequestBuilder.setSize(0); searchRequestBuilder.addAggregation(AggregationBuilders.terms(InstanceTable.COLUMN_APPLICATION_ID).field(InstanceTable.COLUMN_APPLICATION_ID).size(100) .subAggregation(AggregationBuilders.count(InstanceTable.COLUMN_INSTANCE_ID).field(InstanceTable.COLUMN_INSTANCE_ID))); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java index e729b4b78..bd405e2ff 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/acp/AbstractApplicationComponentEsPersistenceDAO.java @@ -44,7 +44,7 @@ public abstract class AbstractApplicationComponentEsPersistenceDAO extends Abstr applicationComponent.setMetricId((String)source.get(ApplicationComponentTable.COLUMN_METRIC_ID)); applicationComponent.setComponentId(((Number)source.get(ApplicationComponentTable.COLUMN_COMPONENT_ID)).intValue()); - applicationComponent.setPeerId(((Number)source.get(ApplicationComponentTable.COLUMN_PEER_ID)).intValue()); + applicationComponent.setApplicationId(((Number)source.get(ApplicationComponentTable.COLUMN_APPLICATION_ID)).intValue()); applicationComponent.setTimeBucket(((Number)source.get(ApplicationComponentTable.COLUMN_TIME_BUCKET)).longValue()); return applicationComponent; } @@ -55,7 +55,7 @@ public abstract class AbstractApplicationComponentEsPersistenceDAO extends Abstr source.put(ApplicationComponentTable.COLUMN_METRIC_ID, streamData.getMetricId()); source.put(ApplicationComponentTable.COLUMN_COMPONENT_ID, streamData.getComponentId()); - source.put(ApplicationComponentTable.COLUMN_PEER_ID, streamData.getPeerId()); + source.put(ApplicationComponentTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); source.put(ApplicationComponentTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); return source; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java index 4bea4052e..c53681248 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ampp/AbstractApplicationMappingEsPersistenceDAO.java @@ -44,7 +44,7 @@ public abstract class AbstractApplicationMappingEsPersistenceDAO extends Abstrac applicationMapping.setMetricId((String)source.get(ApplicationMappingTable.COLUMN_METRIC_ID)); applicationMapping.setApplicationId(((Number)source.get(ApplicationMappingTable.COLUMN_APPLICATION_ID)).intValue()); - applicationMapping.setAddressId(((Number)source.get(ApplicationMappingTable.COLUMN_ADDRESS_ID)).intValue()); + applicationMapping.setMappingApplicationId(((Number)source.get(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID)).intValue()); applicationMapping.setTimeBucket(((Number)source.get(ApplicationMappingTable.COLUMN_TIME_BUCKET)).longValue()); return applicationMapping; } @@ -55,7 +55,7 @@ public abstract class AbstractApplicationMappingEsPersistenceDAO extends Abstrac source.put(ApplicationMappingTable.COLUMN_METRIC_ID, streamData.getMetricId()); source.put(ApplicationMappingTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); - source.put(ApplicationMappingTable.COLUMN_ADDRESS_ID, streamData.getAddressId()); + source.put(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, streamData.getMappingApplicationId()); source.put(ApplicationMappingTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); return source; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java index f886b0ff0..ded51ed6c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ApplicationEsCacheDAO.java @@ -20,9 +20,9 @@ package org.apache.skywalking.apm.collector.storage.es.dao.cache; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.BooleanUtils; -import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; @@ -68,16 +68,20 @@ public class ApplicationEsCacheDAO extends EsDAO implements IApplicationCacheDAO return 0; } - @Override public String getApplicationCode(int applicationId) { + @Override public Application getApplication(int applicationId) { logger.debug("get application code, applicationId: {}", applicationId); ElasticSearchClient client = getClient(); GetRequestBuilder getRequestBuilder = client.prepareGet(ApplicationTable.TABLE, String.valueOf(applicationId)); GetResponse getResponse = getRequestBuilder.get(); if (getResponse.isExists()) { - return (String)getResponse.getSource().get(ApplicationTable.COLUMN_APPLICATION_CODE); + Application application = new Application(); + application.setApplicationId(applicationId); + application.setApplicationCode((String)getResponse.getSource().get(ApplicationTable.COLUMN_APPLICATION_CODE)); + application.setIsAddress(((Number)getResponse.getSource().get(ApplicationTable.COLUMN_IS_ADDRESS)).intValue()); + return application; } - return Const.EMPTY_STRING; + return null; } @Override public int getApplicationIdByAddressId(int addressId) { diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java index 1a7bb53d2..52cb83d5e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appcomp/AbstractApplicationComponentEsTableDefine.java @@ -34,7 +34,7 @@ public abstract class AbstractApplicationComponentEsTableDefine extends ElasticS @Override public final void initialize() { addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_COMPONENT_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_PEER_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationComponentTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java index df044ef49..9eea4f1a7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/appmapping/AbstractApplicationMappingEsTableDefine.java @@ -34,7 +34,7 @@ public abstract class AbstractApplicationMappingEsTableDefine extends ElasticSea @Override public final void initialize() { addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_METRIC_ID, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationMappingTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java index cb165ee0f..b783959a2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java @@ -16,19 +16,20 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,31 +45,29 @@ public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationCo super(client); } - @Override public JsonArray load(long startTime, long endTime) { - JsonArray applicationComponentArray = new JsonArray(); - applicationComponentArray.addAll(aggregationComponent(startTime, endTime)); - return applicationComponentArray; - } - - private JsonArray aggregationComponent(long startTime, long endTime) { + @Override public List load(Step step, long startTime, long endTime) { H2Client client = getClient(); - JsonArray applicationComponentArray = new JsonArray(); - String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_PEER_ID, - ApplicationComponentTable.TABLE, ApplicationComponentTable.COLUMN_TIME_BUCKET); + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE); + + List applicationComponents = new LinkedList<>(); + String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_APPLICATION_ID, + tableName, ApplicationComponentTable.COLUMN_TIME_BUCKET); + Object[] params = new Object[] {startTime, endTime}; try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { - int peerId = rs.getInt(ApplicationComponentTable.COLUMN_PEER_ID); + int applicationId = rs.getInt(ApplicationComponentTable.COLUMN_APPLICATION_ID); int componentId = rs.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID); - JsonObject applicationComponentObj = new JsonObject(); - applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_COMPONENT_ID, componentId); - applicationComponentObj.addProperty(ApplicationComponentTable.COLUMN_PEER_ID, peerId); - applicationComponentArray.add(applicationComponentObj); + + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setComponentId(componentId); + applicationComponent.setApplicationId(applicationId); + applicationComponents.add(applicationComponent); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } - return applicationComponentArray; + return applicationComponents; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java index d1dd55677..b060d887c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java @@ -16,19 +16,20 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,26 +45,29 @@ public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMapp super(client); } - @Override public JsonArray load(long startTime, long endTime) { - H2Client client = getClient(); - JsonArray applicationMappingArray = new JsonArray(); - String sql = SqlBuilder.buildSql(APPLICATION_MAPPING_SQL, ApplicationMappingTable.COLUMN_APPLICATION_ID, - ApplicationMappingTable.COLUMN_ADDRESS_ID, ApplicationMappingTable.TABLE, ApplicationMappingTable.COLUMN_TIME_BUCKET); + @Override public List load(Step step, long startTime, long endTime) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(APPLICATION_MAPPING_SQL, ApplicationMappingTable.COLUMN_APPLICATION_ID, + ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, tableName, ApplicationMappingTable.COLUMN_TIME_BUCKET); + + List applicationMappings = new LinkedList<>(); Object[] params = new Object[] {startTime, endTime}; try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { int applicationId = rs.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID); - int addressId = rs.getInt(ApplicationMappingTable.COLUMN_ADDRESS_ID); - JsonObject applicationMappingObj = new JsonObject(); - applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_APPLICATION_ID, applicationId); - applicationMappingObj.addProperty(ApplicationMappingTable.COLUMN_ADDRESS_ID, addressId); - applicationMappingArray.add(applicationMappingObj); + int addressId = rs.getInt(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID); + + ApplicationMapping applicationMapping = new ApplicationMapping(); + applicationMapping.setApplicationId(applicationId); + applicationMapping.setMappingApplicationId(addressId); + applicationMappings.add(applicationMapping); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } - logger.debug("node mapping data: {}", applicationMappingArray.toString()); - return applicationMappingArray; + logger.debug("node mapping data: {}", applicationMappings.toString()); + return applicationMappings; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java index 216485de9..36d9e6e0e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java @@ -16,13 +16,16 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao; import com.google.gson.JsonArray; +import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,7 +42,8 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica super(client); } - @Override public JsonArray load(long startTime, long endTime) { + @Override public List getFrontApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { H2Client client = getClient(); JsonArray applicationReferenceMetricArray = new JsonArray(); // String sql = SqlBuilder.buildSql(APPLICATION_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE, @@ -67,6 +71,11 @@ public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplica // } catch (SQLException | H2ClientException e) { // logger.error(e.getMessage(), e); // } - return applicationReferenceMetricArray; + return null; + } + + @Override public List getBehindApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { + return null; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java index a13ed2a2a..488a08332 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java @@ -87,7 +87,7 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { } @Override - public List getApplications(long startTime, long endTime) { + public List getApplications(long startTime, long endTime, int... applicationIds) { H2Client client = getClient(); List applications = new LinkedList<>(); String sql = SqlBuilder.buildSql(GET_APPLICATIONS_SQL, InstanceTable.COLUMN_INSTANCE_ID, diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java index c08156682..25019b012 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/acp/AbstractApplicationComponentH2PersistenceDAO.java @@ -42,7 +42,7 @@ public abstract class AbstractApplicationComponentH2PersistenceDAO extends Abstr applicationComponent.setMetricId(resultSet.getString(ApplicationComponentTable.COLUMN_METRIC_ID)); applicationComponent.setComponentId(resultSet.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID)); - applicationComponent.setPeerId(resultSet.getInt(ApplicationComponentTable.COLUMN_PEER_ID)); + applicationComponent.setApplicationId(resultSet.getInt(ApplicationComponentTable.COLUMN_APPLICATION_ID)); applicationComponent.setTimeBucket(resultSet.getLong(ApplicationComponentTable.COLUMN_TIME_BUCKET)); return applicationComponent; } @@ -52,7 +52,7 @@ public abstract class AbstractApplicationComponentH2PersistenceDAO extends Abstr source.put(ApplicationComponentTable.COLUMN_METRIC_ID, streamData.getMetricId()); source.put(ApplicationComponentTable.COLUMN_COMPONENT_ID, streamData.getComponentId()); - source.put(ApplicationComponentTable.COLUMN_PEER_ID, streamData.getPeerId()); + source.put(ApplicationComponentTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); source.put(ApplicationComponentTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); return source; diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ampp/AbstractApplicationMappingH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ampp/AbstractApplicationMappingH2PersistenceDAO.java index a2d00ef39..3b6eb25c7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ampp/AbstractApplicationMappingH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ampp/AbstractApplicationMappingH2PersistenceDAO.java @@ -42,7 +42,7 @@ public abstract class AbstractApplicationMappingH2PersistenceDAO extends Abstrac applicationMapping.setMetricId(resultSet.getString(ApplicationMappingTable.COLUMN_METRIC_ID)); applicationMapping.setApplicationId(resultSet.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID)); - applicationMapping.setAddressId(resultSet.getInt(ApplicationMappingTable.COLUMN_ADDRESS_ID)); + applicationMapping.setMappingApplicationId(resultSet.getInt(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID)); applicationMapping.setTimeBucket(resultSet.getLong(ApplicationMappingTable.COLUMN_TIME_BUCKET)); return applicationMapping; } @@ -52,7 +52,7 @@ public abstract class AbstractApplicationMappingH2PersistenceDAO extends Abstrac source.put(ApplicationMappingTable.COLUMN_METRIC_ID, streamData.getMetricId()); source.put(ApplicationMappingTable.COLUMN_APPLICATION_ID, streamData.getApplicationId()); - source.put(ApplicationMappingTable.COLUMN_ADDRESS_ID, streamData.getAddressId()); + source.put(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, streamData.getMappingApplicationId()); source.put(ApplicationMappingTable.COLUMN_TIME_BUCKET, streamData.getTimeBucket()); return source; diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java index 051eb91ff..6d4f612b7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ApplicationH2CacheDAO.java @@ -22,10 +22,10 @@ import java.sql.ResultSet; import java.sql.SQLException; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.cache.IApplicationCacheDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.apache.skywalking.apm.collector.storage.table.register.ApplicationTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,7 +38,7 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO private final Logger logger = LoggerFactory.getLogger(ApplicationH2CacheDAO.class); private static final String GET_APPLICATION_ID_SQL = "select {0} from {1} where {2} = ? and {3} = ?"; - private static final String GET_APPLICATION_CODE_SQL = "select {0} from {1} where {2} = ?"; + private static final String GET_APPLICATION_SQL = "select {0},{1} from {2} where {3} = ?"; public ApplicationH2CacheDAO(H2Client client) { super(client); @@ -61,19 +61,23 @@ public class ApplicationH2CacheDAO extends H2DAO implements IApplicationCacheDAO return 0; } - @Override public String getApplicationCode(int applicationId) { + @Override public Application getApplication(int applicationId) { logger.debug("get application code, applicationId: {}", applicationId); H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_APPLICATION_CODE_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID); + String sql = SqlBuilder.buildSql(GET_APPLICATION_SQL, ApplicationTable.COLUMN_APPLICATION_CODE, ApplicationTable.COLUMN_IS_ADDRESS, ApplicationTable.TABLE, ApplicationTable.COLUMN_APPLICATION_ID); Object[] params = new Object[] {applicationId}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - return rs.getString(1); + Application application = new Application(); + application.setApplicationId(applicationId); + application.setApplicationCode(rs.getString(1)); + application.setIsAddress(rs.getInt(2)); + return application; } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } - return Const.EMPTY_STRING; + return null; } @Override public int getApplicationIdByAddressId(int addressId) { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java index 570dcc7f7..2f0102c6b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appcomp/AbstractApplicationComponentH2TableDefine.java @@ -35,7 +35,7 @@ public abstract class AbstractApplicationComponentH2TableDefine extends H2TableD addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_METRIC_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_COMPONENT_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_PEER_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ApplicationComponentTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appmapping/AbstractApplicationMappingH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appmapping/AbstractApplicationMappingH2TableDefine.java index ee5239fb7..41ba8b8d5 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appmapping/AbstractApplicationMappingH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/appmapping/AbstractApplicationMappingH2TableDefine.java @@ -35,7 +35,7 @@ public abstract class AbstractApplicationMappingH2TableDefine extends H2TableDef addColumn(new H2ColumnDefine(ApplicationMappingTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationMappingTable.COLUMN_METRIC_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationMappingTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(ApplicationMappingTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ApplicationMappingTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java new file mode 100644 index 000000000..28a383dc3 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.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.apm.collector.ui.utils; + +import java.text.ParseException; +import org.junit.Test; + +/** + * @author peng-yongsheng + */ +public class DurationUtilsTestCase { + + @Test + public void test() throws ParseException { + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java index b8f09c622..7a97ee968 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java @@ -28,8 +28,9 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Topology; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.apache.skywalking.apm.collector.ui.graphql.Query; -import org.apache.skywalking.apm.collector.ui.graphql.utils.DurationUtils; import org.apache.skywalking.apm.collector.ui.service.ApplicationService; +import org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** * @author peng-yongsheng @@ -38,6 +39,7 @@ public class ApplicationQuery implements Query { private final ModuleManager moduleManager; private ApplicationService applicationService; + private ApplicationTopologyService applicationTopologyService; public ApplicationQuery(ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -50,38 +52,25 @@ public class ApplicationQuery implements Query { return applicationService; } - public List getAllApplication(Duration duration) throws ParseException { - long start = 0; - long end = 0; - - switch (duration.getStep()) { - case MONTH: - start = DurationUtils.INSTANCE.monthDurationToSecondTimeBucket(duration.getStart()); - end = DurationUtils.INSTANCE.monthDurationToSecondTimeBucket(duration.getEnd()); - break; - case DAY: - start = DurationUtils.INSTANCE.dayDurationToSecondTimeBucket(duration.getStart()); - end = DurationUtils.INSTANCE.dayDurationToSecondTimeBucket(duration.getEnd()); - break; - case HOUR: - start = DurationUtils.INSTANCE.hourDurationToSecondTimeBucket(duration.getStart()); - end = DurationUtils.INSTANCE.hourDurationToSecondTimeBucket(duration.getEnd()); - break; - case MINUTE: - start = DurationUtils.INSTANCE.minuteDurationToSecondTimeBucket(duration.getStart()); - end = DurationUtils.INSTANCE.minuteDurationToSecondTimeBucket(duration.getEnd()); - break; - case SECOND: - start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); - end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); - break; + private ApplicationTopologyService getApplicationTopologyService() { + if (ObjectUtils.isEmpty(applicationTopologyService)) { + this.applicationTopologyService = new ApplicationTopologyService(moduleManager); } + return applicationTopologyService; + } + + public List getAllApplication(Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); + long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); return getApplicationService().getApplications(start, end); } - public Topology getApplicationTopology(int applicationId, Duration duration) { - return null; + public Topology getApplicationTopology(int applicationId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + + return getApplicationTopologyService().getApplicationTopology(duration.getStep(), applicationId, start, end); } public List getSlowService(int applicationId, Duration duration, Integer top) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java index d96317dd5..8008700e2 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java @@ -39,11 +39,11 @@ public class ApplicationService { this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); } - public List getApplications(long startTime, long endTime) { - List applications = instanceDAO.getApplications(startTime, endTime); + public List getApplications(long startTime, long endTime, int... applicationIds) { + List applications = instanceDAO.getApplications(startTime, endTime, applicationIds); applications.forEach(application -> { - String applicationCode = applicationCacheService.getApplicationCodeById(application.getId()); + String applicationCode = applicationCacheService.getApplicationById(application.getId()).getApplicationCode(); application.setName(applicationCode); }); return applications; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java new file mode 100644 index 000000000..e53c52b43 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java @@ -0,0 +1,129 @@ +/* + * 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.apm.collector.ui.service; + +import java.text.ParseException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationTopologyService { + + private final Logger logger = LoggerFactory.getLogger(ApplicationTopologyService.class); + + private final IApplicationComponentUIDAO applicationComponentUIDAO; + private final IApplicationMappingUIDAO applicationMappingUIDAO; + private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO; + private final ModuleManager moduleManager; + + public ApplicationTopologyService(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + this.applicationComponentUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class); + this.applicationMappingUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class); + this.applicationReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class); + } + + public Topology getApplicationTopology(Step step, int applicationId, long startTime, + long endTime) throws ParseException { + logger.debug("startTime: {}, endTime: {}", startTime, endTime); + List applicationComponents = applicationComponentUIDAO.load(step, startTime, endTime); + List applicationMappings = applicationMappingUIDAO.load(step, startTime, endTime); + + Map components = new HashMap<>(); + applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId()))); + + List callerCalls = applicationReferenceMetricUIDAO.getFrontApplications(step, applicationId, startTime, endTime, MetricSource.Caller); + callerCalls.addAll(applicationReferenceMetricUIDAO.getBehindApplications(step, applicationId, startTime, endTime, MetricSource.Caller)); + + callerCalls.forEach(callerCall -> callerCall.setCallType(components.get(callerCall.getTarget()))); + + List calleeCalls = applicationReferenceMetricUIDAO.getFrontApplications(step, applicationId, startTime, endTime, MetricSource.Callee); + calleeCalls.addAll(applicationReferenceMetricUIDAO.getBehindApplications(step, applicationId, startTime, endTime, MetricSource.Callee)); + + calleeCalls.forEach(calleeCall -> calleeCall.setCallType(components.get(calleeCall.getTarget()))); + + Set mappings = new HashSet<>(); + applicationMappings.forEach(mapping -> { + if (applicationId == mapping.getApplicationId()) { + mappings.add(mapping.getMappingApplicationId()); + } + }); + + mappings.forEach(mappingApplicationId -> { + List frontCallerApplications = applicationReferenceMetricUIDAO.getFrontApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Caller); + frontCallerApplications.forEach(call -> { + call.setCallType(components.get(call.getTarget())); + call.setTarget(applicationId); + callerCalls.add(call); + }); + + List behindCallerApplications = applicationReferenceMetricUIDAO.getBehindApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Caller); + behindCallerApplications.forEach(call -> { + call.setCallType(components.get(call.getTarget())); + call.setSource(applicationId); + callerCalls.add(call); + }); + + List frontCalleeApplications = applicationReferenceMetricUIDAO.getFrontApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Callee); + frontCalleeApplications.forEach(call -> { + call.setCallType(components.get(call.getTarget())); + call.setTarget(applicationId); + calleeCalls.add(call); + }); + + List behindCalleeApplications = applicationReferenceMetricUIDAO.getBehindApplications(step, mappingApplicationId, startTime, endTime, MetricSource.Callee); + behindCalleeApplications.forEach(call -> { + call.setCallType(components.get(call.getTarget())); + call.setSource(applicationId); + calleeCalls.add(call); + }); + }); + + TopologyBuilder builder = new TopologyBuilder(moduleManager); + + long secondsBetween = DurationUtils.INSTANCE.secondsBetween(step, startTime, endTime); + Topology topology = builder.build(applicationComponents, applicationMappings, callerCalls, calleeCalls, secondsBetween); + + topology.getCalls().forEach(call -> { + int calls = call.getCalls(); + long responseTimes = call.getResponseTimes(); + call.setCallsPerSec((int)(calls / secondsBetween)); + call.setResponseTimePerSec((int)(responseTimes / secondsBetween)); + }); + return topology; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java index 98ba79884..718941342 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java @@ -60,7 +60,7 @@ public class InstanceHealthService { response.add("instances", instances); // instanceList.forEach(instance -> { -// response.addProperty("applicationCode", applicationCacheService.getApplicationCodeById(applicationId)); +// response.addProperty("applicationCode", applicationCacheService.getApplicationById(applicationId)); // response.addProperty("applicationId", applicationId); // // IInstanceMetricUIDAO.InstanceMetric performance = instanceMetricUIDAO.get(timeBuckets, instance.getInstanceId()); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java index 0e902fe34..57f118c8a 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java @@ -108,7 +108,7 @@ public class SpanService { if (spanObject.getPeerId() == 0) { peerJson.addProperty("value", spanObject.getPeer()); } else { - peerJson.addProperty("value", applicationCacheService.getApplicationCodeById(spanObject.getPeerId())); + peerJson.addProperty("value", applicationCacheService.getApplicationById(spanObject.getPeerId()).getApplicationCode()); } tagsArray.add(peerJson); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java new file mode 100644 index 000000000..97ea1265a --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java @@ -0,0 +1,153 @@ +/* + * 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.apm.collector.ui.service; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.table.register.Application; +import org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode; +import org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Node; +import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.collector.storage.ui.common.VisualUserNode; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; + +/** + * @author peng-yongsheng + */ +class TopologyBuilder { + + private final ApplicationCacheService applicationCacheService; + + TopologyBuilder(ModuleManager moduleManager) { + this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); + } + + Topology build(List applicationComponents, + List applicationMappings, List callerCalls, + List calleeCalls, long secondsBetween) { + Map components = changeNodeComp2Map(applicationComponents); + Map mappings = changeMapping2Map(applicationMappings); + + List calls = buildCalls(callerCalls, calleeCalls); + + Set nodeIds = new HashSet<>(); + calls.forEach(call -> { + String sourceName = applicationCacheService.getApplicationById(call.getSource()).getApplicationCode(); + String targetName = applicationCacheService.getApplicationById(call.getTarget()).getApplicationCode(); + + call.setSourceName(sourceName); + call.setTargetName(targetName); + + nodeIds.add(call.getSource()); + nodeIds.add(call.getTarget()); + }); + + List nodes = new LinkedList<>(); + nodeIds.forEach(nodeId -> { + Application application = applicationCacheService.getApplicationById(nodeId); + if (BooleanUtils.valueToBoolean(application.getAddressId())) { + ConjecturalNode conjecturalNode = new ConjecturalNode(); + conjecturalNode.setId(nodeId); + conjecturalNode.setName(application.getApplicationCode()); + conjecturalNode.setType(components.getOrDefault(application.getApplicationId(), Const.UNKNOWN)); + nodes.add(conjecturalNode); + } else { + if (nodeId == Const.NONE_APPLICATION_ID) { + VisualUserNode node = new VisualUserNode(); + node.setId(nodeId); + node.setName(Const.USER_CODE); + node.setType(Const.USER_CODE.toUpperCase()); + nodes.add(node); + } else { + ApplicationNode applicationNode = new ApplicationNode(); + applicationNode.setId(nodeId); + applicationNode.setName(application.getApplicationCode()); + applicationNode.setType(components.getOrDefault(application.getApplicationId(), Const.UNKNOWN)); + + calleeCalls.forEach(call -> { + if (call.getTarget() == nodeId) { + call.setCallsPerSec((int)(call.getCalls() / secondsBetween)); + call.setResponseTimePerSec((int)(call.getResponseTimes() / secondsBetween)); + } + }); + nodes.add(applicationNode); + } + } + }); + + Topology topology = new Topology(); + topology.setCalls(calls); + topology.setNodes(nodes); + return topology; + } + + private Map changeMapping2Map( + List applicationMappings) { + Map mappings = new HashMap<>(); + applicationMappings.forEach(applicationMapping -> { + String applicationCode = applicationCacheService.getApplicationById(applicationMapping.getApplicationId()).getApplicationCode(); + String address = applicationCacheService.getApplicationById(applicationMapping.getMappingApplicationId()).getApplicationCode(); + mappings.put(address, applicationCode); + }); + return mappings; + } + + private Map changeNodeComp2Map( + List applicationComponents) { + Map components = new HashMap<>(); + applicationComponents.forEach(applicationComponent -> { + String componentName = ComponentsDefine.getInstance().getComponentName(applicationComponent.getComponentId()); + components.put(applicationComponent.getApplicationId(), componentName); + }); + return components; + } + + private List buildCalls(List callerCalls, List calleeCalls) { + List calls = new LinkedList<>(); + + Set distinctCalls = new HashSet<>(); + callerCalls.forEach(callerCall -> { + distinctCalls.add(callerCall.getSource() + Const.ID_SPLIT + callerCall.getTarget()); + calls.add(callerCall); + }); + + calleeCalls.forEach(calleeCall -> { + String call = calleeCall.getSource() + Const.ID_SPLIT + calleeCall.getTarget(); + if (!distinctCalls.contains(call)) { + distinctCalls.add(call); + calls.add(calleeCall); + } + }); + + return calls; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java deleted file mode 100644 index 297c43573..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagDataBuilder.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * 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.apm.collector.ui.service; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.cache.CacheModule; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; -import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class TraceDagDataBuilder { - private final Logger logger = LoggerFactory.getLogger(TraceDagDataBuilder.class); - - private Integer nodeId = -1; - private Map mappingMap = new HashMap<>(); - private Map nodeCompMap = new HashMap<>(); - private Map nodeIdMap = new HashMap<>(); - private JsonArray pointArray = new JsonArray(); - private JsonArray lineArray = new JsonArray(); - private final ApplicationCacheService applicationCacheService; - - public TraceDagDataBuilder(ModuleManager moduleManager) { - this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); - } - - public JsonObject build(JsonArray nodeCompArray, JsonArray nodesMappingArray, JsonArray resSumArray) { - changeNodeComp2Map(nodeCompArray); - changeMapping2Map(nodesMappingArray); - - Map mergedResSumMap = getApplicationCode(resSumArray); - - mergedResSumMap.values().forEach(nodeRefJsonObj -> { - String front = nodeRefJsonObj.get("front").getAsString(); - String behind = nodeRefJsonObj.get("behind").getAsString(); - - if (hasMapping(behind)) { - return; - } - - JsonObject lineJsonObj = new JsonObject(); - lineJsonObj.addProperty("from", findOrCreateNode(front)); - lineJsonObj.addProperty("to", findOrCreateNode(behind)); - lineJsonObj.addProperty("resSum", nodeRefJsonObj.get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).getAsInt()); - - lineArray.add(lineJsonObj); - logger.debug("line: {}", lineJsonObj); - }); - - JsonObject dagJsonObj = new JsonObject(); - dagJsonObj.add("nodes", pointArray); - dagJsonObj.add("nodeRefs", lineArray); - return dagJsonObj; - } - - private Integer findOrCreateNode(String peers) { - if (nodeIdMap.containsKey(peers) && !peers.equals(Const.USER_CODE)) { - return nodeIdMap.get(peers); - } else { - nodeId++; - JsonObject nodeJsonObj = new JsonObject(); - nodeJsonObj.addProperty("id", nodeId); - nodeJsonObj.addProperty("peer", peers); - if (peers.equals(Const.USER_CODE)) { - nodeJsonObj.addProperty("component", Const.USER_CODE); - } else { - nodeJsonObj.addProperty("component", nodeCompMap.get(peers)); - } - pointArray.add(nodeJsonObj); - - nodeIdMap.put(peers, nodeId); - logger.debug("node: {}", nodeJsonObj); - } - return nodeId; - } - - private void changeMapping2Map(JsonArray nodesMappingArray) { - for (int i = 0; i < nodesMappingArray.size(); i++) { - JsonObject nodesMappingJsonObj = nodesMappingArray.get(i).getAsJsonObject(); - int applicationId = nodesMappingJsonObj.get(ApplicationMappingTable.COLUMN_APPLICATION_ID).getAsInt(); - String applicationCode = applicationCacheService.getApplicationCodeById(applicationId); - int addressId = nodesMappingJsonObj.get(ApplicationMappingTable.COLUMN_ADDRESS_ID).getAsInt(); - String address = applicationCacheService.getApplicationCodeById(addressId); - mappingMap.put(address, applicationCode); - } - } - - private void changeNodeComp2Map(JsonArray nodeCompArray) { - for (int i = 0; i < nodeCompArray.size(); i++) { - JsonObject nodesJsonObj = nodeCompArray.get(i).getAsJsonObject(); - logger.debug(nodesJsonObj.toString()); - int componentId = nodesJsonObj.get(ApplicationComponentTable.COLUMN_COMPONENT_ID).getAsInt(); - String componentName = ComponentsDefine.getInstance().getComponentName(componentId); - int peerId = nodesJsonObj.get(ApplicationComponentTable.COLUMN_PEER_ID).getAsInt(); - String peer = applicationCacheService.getApplicationCodeById(peerId); - nodeCompMap.put(peer, componentName); - } - } - - private boolean hasMapping(String peers) { - return mappingMap.containsKey(peers); - } - - private Map getApplicationCode(JsonArray nodeReference) { - Map mergedRef = new LinkedHashMap<>(); - for (int i = 0; i < nodeReference.size(); i++) { - JsonObject nodeRefJsonObj = nodeReference.get(i).getAsJsonObject(); - - int frontApplicationId = nodeRefJsonObj.get(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID)).getAsInt(); - int behindApplicationId = nodeRefJsonObj.get(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)).getAsInt(); - - String front = applicationCacheService.getApplicationCodeById(frontApplicationId); - String behind = applicationCacheService.getApplicationCodeById(behindApplicationId); - - String id = front + Const.ID_SPLIT + behind; - nodeRefJsonObj.addProperty("front", front); - nodeRefJsonObj.addProperty("behind", behind); - mergedRef.put(id, nodeRefJsonObj); - } - - return mergedRef; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java index 16da98b37..0c420e79a 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java @@ -134,7 +134,7 @@ public class TraceStackService { operationName = Const.EMPTY_STRING; } } - String applicationCode = applicationCacheService.getApplicationCodeById(segment.getApplicationId()); + String applicationCode = applicationCacheService.getApplicationById(segment.getApplicationId()).getApplicationCode(); long cost = spanObject.getEndTime() - spanObject.getStartTime(); if (cost == 0) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java new file mode 100644 index 000000000..0bb562220 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java @@ -0,0 +1,91 @@ +/* + * 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.apm.collector.ui.utils; + +import java.text.ParseException; +import java.util.Date; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.joda.time.DateTime; +import org.joda.time.Seconds; + +/** + * @author peng-yongsheng + */ +public enum DurationUtils { + INSTANCE; + + public long exchangeToTimeBucket(String dateStr) throws ParseException { + dateStr = dateStr.replaceAll("-", Const.EMPTY_STRING); + dateStr = dateStr.replaceAll(" ", Const.EMPTY_STRING); + return Long.valueOf(dateStr); + } + + public long durationToSecondTimeBucket(Step step, String dateStr) throws ParseException { + long secondTimeBucket = 0; + switch (step) { + case MONTH: + secondTimeBucket = exchangeToTimeBucket(dateStr) * 100 * 100 * 100 * 100; + break; + case DAY: + secondTimeBucket = exchangeToTimeBucket(dateStr) * 100 * 100 * 100; + break; + case HOUR: + secondTimeBucket = exchangeToTimeBucket(dateStr) * 100 * 100; + break; + case MINUTE: + secondTimeBucket = exchangeToTimeBucket(dateStr) * 100; + break; + case SECOND: + secondTimeBucket = exchangeToTimeBucket(dateStr); + break; + } + return secondTimeBucket; + } + + public long secondsBetween(Step step, long start, long end) throws ParseException { + Date startDate = null; + Date endDate = null; + switch (step) { + case MONTH: + startDate = TimeBucketUtils.MONTH_DATE_FORMAT.parse(String.valueOf(start)); + endDate = TimeBucketUtils.MONTH_DATE_FORMAT.parse(String.valueOf(end)); + break; + case DAY: + startDate = TimeBucketUtils.DAY_DATE_FORMAT.parse(String.valueOf(start)); + endDate = TimeBucketUtils.DAY_DATE_FORMAT.parse(String.valueOf(end)); + break; + case HOUR: + startDate = TimeBucketUtils.HOUR_DATE_FORMAT.parse(String.valueOf(start)); + endDate = TimeBucketUtils.HOUR_DATE_FORMAT.parse(String.valueOf(end)); + break; + case MINUTE: + startDate = TimeBucketUtils.MINUTE_DATE_FORMAT.parse(String.valueOf(start)); + endDate = TimeBucketUtils.MINUTE_DATE_FORMAT.parse(String.valueOf(end)); + break; + case SECOND: + startDate = TimeBucketUtils.SECOND_DATE_FORMAT.parse(String.valueOf(start)); + endDate = TimeBucketUtils.SECOND_DATE_FORMAT.parse(String.valueOf(end)); + break; + } + + return Seconds.secondsBetween(new DateTime(startDate), new DateTime(endDate)).getSeconds(); + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java index c0bddff71..234a9c85d 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQueryTestCase.java @@ -40,8 +40,8 @@ public class ApplicationQueryTestCase { Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { Object[] arguments = invocation.getArguments(); - Assert.assertEquals(20170100000000l, arguments[0]); - Assert.assertEquals(20170100000000l, arguments[1]); + Assert.assertEquals(20170100000000L, arguments[0]); + Assert.assertEquals(20170100000000L, arguments[1]); return null; }); @@ -61,8 +61,8 @@ public class ApplicationQueryTestCase { Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { Object[] arguments = invocation.getArguments(); - Assert.assertEquals(20170101000000l, arguments[0]); - Assert.assertEquals(20170101000000l, arguments[1]); + Assert.assertEquals(20170101000000L, arguments[0]); + Assert.assertEquals(20170101000000L, arguments[1]); return null; }); @@ -82,8 +82,8 @@ public class ApplicationQueryTestCase { Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { Object[] arguments = invocation.getArguments(); - Assert.assertEquals(20170101010000l, arguments[0]); - Assert.assertEquals(20170101010000l, arguments[1]); + Assert.assertEquals(20170101010000L, arguments[0]); + Assert.assertEquals(20170101010000L, arguments[1]); return null; }); @@ -103,8 +103,8 @@ public class ApplicationQueryTestCase { Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { Object[] arguments = invocation.getArguments(); - Assert.assertEquals(20170101010100l, arguments[0]); - Assert.assertEquals(20170101010100l, arguments[1]); + Assert.assertEquals(20170101010100L, arguments[0]); + Assert.assertEquals(20170101010100L, arguments[1]); return null; }); @@ -124,8 +124,8 @@ public class ApplicationQueryTestCase { Mockito.when(applicationService.getApplications(Mockito.anyLong(), Mockito.anyLong())).then(invocation -> { Object[] arguments = invocation.getArguments(); - Assert.assertEquals(20170101010101l, arguments[0]); - Assert.assertEquals(20170101010101l, arguments[1]); + Assert.assertEquals(20170101010101L, arguments[0]); + Assert.assertEquals(20170101010101L, arguments[1]); return null; }); From 953cfbb7253e6c63c05b0c41995c2b33070d32b8 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 26 Jan 2018 00:24:27 +0800 Subject: [PATCH 09/36] no message --- .../analysis/metric/define/MetricSource.java | 36 ----------- .../ui/graphql/utils/DurationUtils.java | 54 ---------------- .../graphql/utils/DurationUtilsTestCase.java | 33 ---------- .../collector/ui/service/TraceDagService.java | 64 ------------------- 4 files changed, 187 deletions(-) delete mode 100644 apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/MetricSource.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtilsTestCase.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagService.java diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/MetricSource.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/MetricSource.java deleted file mode 100644 index 7757e13ec..000000000 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/MetricSource.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.apm.collector.analysis.metric.define; - -/** - * @author peng-yongsheng - */ -public enum MetricSource { - Caller(0), Callee(1); - - private final int value; - - private MetricSource(int value) { - this.value = value; - } - - public int getValue() { - return value; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java deleted file mode 100644 index e5f3838f3..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/main/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtils.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.utils; - -import java.text.ParseException; - -/** - * @author peng-yongsheng - */ -public enum DurationUtils { - INSTANCE; - - public long exchangeToTimeBucket(String dateStr) throws ParseException { - dateStr = dateStr.replaceAll("-", ""); - dateStr = dateStr.replaceAll(" ", ""); - return Long.valueOf(dateStr); - } - - public long monthDurationToSecondTimeBucket(String dateStr) throws ParseException { - long month = exchangeToTimeBucket(dateStr); - return month * 100 * 100 * 100 * 100; - } - - public long dayDurationToSecondTimeBucket(String dateStr) throws ParseException { - long month = exchangeToTimeBucket(dateStr); - return month * 100 * 100 * 100; - } - - public long hourDurationToSecondTimeBucket(String dateStr) throws ParseException { - long month = exchangeToTimeBucket(dateStr); - return month * 100 * 100; - } - - public long minuteDurationToSecondTimeBucket(String dateStr) throws ParseException { - long month = exchangeToTimeBucket(dateStr); - return month * 100; - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtilsTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtilsTestCase.java deleted file mode 100644 index 89d1ee3ba..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/graphql/utils/DurationUtilsTestCase.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.apm.collector.ui.graphql.utils; - -import java.text.ParseException; -import org.junit.Assert; -import org.junit.Test; - -/** - * @author peng-yongsheng - */ -public class DurationUtilsTestCase { - - @Test - public void test() throws ParseException { - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagService.java deleted file mode 100644 index 501ca0e4e..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceDagService.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * 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.apm.collector.ui.service; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class TraceDagService { - - private final Logger logger = LoggerFactory.getLogger(TraceDagService.class); - - private final IApplicationComponentUIDAO applicationComponentUIDAO; - private final IApplicationMappingUIDAO applicationMappingUIDAO; - private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO; - private final ModuleManager moduleManager; - - public TraceDagService(ModuleManager moduleManager) { - this.moduleManager = moduleManager; - this.applicationComponentUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class); - this.applicationMappingUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class); - this.applicationReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class); - } - - public JsonObject load(long startTime, long endTime) { - logger.debug("startTime: {}, endTime: {}", startTime, endTime); - JsonArray applicationComponentArray = applicationComponentUIDAO.load(startTime, endTime); - - JsonArray applicationMappingArray = applicationMappingUIDAO.load(startTime, endTime); - - JsonArray applicationReferenceMetricArray = applicationReferenceMetricUIDAO.load(startTime, endTime); - - TraceDagDataBuilder builder = new TraceDagDataBuilder(moduleManager); - JsonObject traceDag = builder.build(applicationComponentArray, applicationMappingArray, applicationReferenceMetricArray); - - return traceDag; - } -} From 34380713747db25d3dcd820d6dfe44166b8b2c37 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 26 Jan 2018 00:49:37 +0800 Subject: [PATCH 10/36] Catch the exception in doPost and doGet method, make this two method do not throw exception. --- .../collector/server/jetty/JettyHandler.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java b/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java index 0c557b026..15520fc42 100644 --- a/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java +++ b/apm-collector/apm-collector-component/server-component/src/main/java/org/apache/skywalking/apm/collector/server/jetty/JettyHandler.java @@ -32,31 +32,43 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.server.ServerHandler; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public abstract class JettyHandler extends HttpServlet implements ServerHandler { + private final Logger logger = LoggerFactory.getLogger(JettyHandler.class); + public abstract String pathSpec(); @Override - protected final void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected final void doGet(HttpServletRequest req, HttpServletResponse resp) { try { reply(resp, doGet(req)); - } catch (ArgumentsParseException e) { - replyError(resp, e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); + } catch (ArgumentsParseException | IOException e) { + try { + replyError(resp, e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); + } catch (IOException replyException) { + logger.error(replyException.getMessage(), e); + } } } protected abstract JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException; @Override - protected final void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + protected final void doPost(HttpServletRequest req, HttpServletResponse resp) { try { reply(resp, doPost(req)); - } catch (ArgumentsParseException e) { - replyError(resp, e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); + } catch (ArgumentsParseException | IOException e) { + try { + replyError(resp, e.getMessage(), HttpServletResponse.SC_BAD_REQUEST); + } catch (IOException replyException) { + logger.error(replyException.getMessage(), e); + } } } From 1510f7059d686f5943dd75126f0d9aad2bc0cc15 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 26 Jan 2018 08:55:55 +0800 Subject: [PATCH 11/36] Change the data type from int to long which attributes named responseTimePerSec and callsPerSec. --- .../src/main/resources/ui-graphql/application-layer.graphqls | 2 +- .../src/main/resources/ui-graphql/common.graphqls | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls index ba6dde139..bb99a4910 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -10,7 +10,7 @@ type ApplicationNode implements Node { # The number of incoming calls callsPerSec: Long! # Unit: millisecond - responseTimePerSec: Int! + responseTimePerSec: Long! # ref: http://www.apdex.org/ # Max value is 1 # 2 Digits after floating point. diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls index 04f21eeb3..21d9becd1 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/common.graphqls @@ -104,7 +104,7 @@ type Call { isAlert: Boolean # The protocol and tech stack used in this distributed call callType: String! - callsPerSec: Int! + callsPerSec: Long! # Unit: millisecond - responseTimePerSec: Int! + responseTimePerSec: Long! } From f177ebd909d1dbe5efd84adb10d0dbf6da83b4d7 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sat, 27 Jan 2018 09:13:48 +0800 Subject: [PATCH 12/36] Provide the search server query, but only completed es storage and non tps. --- .../json/instance-register-consumer.json | 9 ++- .../json/instance-register-provider.json | 9 ++- .../collector/storage/dao/IInstanceUIDAO.java | 3 +- .../ui/application/ApplicationNode.java | 6 +- .../apm/collector/storage/ui/common/Call.java | 18 ++--- .../storage/ui/server/AppServerInfo.java | 63 ++++++++++++++- .../storage/es/dao/InstanceEsUIDAO.java | 28 ++++--- .../storage/h2/dao/InstanceH2UIDAO.java | 27 +++---- .../ui/jetty/handler/GraphQLHandler.java | 5 +- .../apm/collector/ui/query/ServerQuery.java | 28 ++++++- .../service/ApplicationTopologyService.java | 6 +- .../collector/ui/service/ServerService.java | 80 +++++++++++++++++++ .../collector/ui/service/TopologyBuilder.java | 6 +- .../ui-graphql/server-layer.graphqls | 4 +- 14 files changed, 231 insertions(+), 61 deletions(-) create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-consumer.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-consumer.json index 139dc5743..e2cb6e068 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-consumer.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-consumer.json @@ -3,7 +3,12 @@ "au": "dubbox-consumer", "rt": 1501858094526, "oi": { - "any_name": "any_value", - "any_name1": "any_value1" + "osName": "MacOS XX", + "hostName": "pengys", + "processId": "1001", + "ipv4s": [ + "10.0.0.3", + "10.0.0.4" + ] } } \ No newline at end of file diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-provider.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-provider.json index 976928f9c..304de7c4f 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-provider.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/instance-register-provider.json @@ -3,7 +3,12 @@ "au": "dubbox-provider", "rt": 1501858094526, "oi": { - "any_name": "any_value", - "any_name1": "any_value1" + "osName": "MacOS X", + "hostName": "peng-yongsheng", + "processId": "1000", + "ipv4s": [ + "10.0.0.1", + "10.0.0.2" + ] } } \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java index 6a2413f1f..9db7121f3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java @@ -22,6 +22,7 @@ import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; /** * @author peng-yongsheng @@ -35,5 +36,5 @@ public interface IInstanceUIDAO extends DAO { Instance getInstance(int instanceId); - List getInstances(int applicationId, long timeBucket); + List getInstances(String keyword, long start, long end); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java index 88ca7f14f..66f3a8d82 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/application/ApplicationNode.java @@ -27,7 +27,7 @@ public class ApplicationNode extends Node { private Float sla; private Long callsPerSec; - private Integer responseTimePerSec; + private Long responseTimePerSec; private Float apdex; private Boolean isAlarm; private Integer numOfServer; @@ -50,11 +50,11 @@ public class ApplicationNode extends Node { this.callsPerSec = callsPerSec; } - public Integer getResponseTimePerSec() { + public Long getResponseTimePerSec() { return responseTimePerSec; } - public void setResponseTimePerSec(Integer responseTimePerSec) { + public void setResponseTimePerSec(Long responseTimePerSec) { this.responseTimePerSec = responseTimePerSec; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java index 74151ce0d..70956ef73 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Call.java @@ -28,10 +28,10 @@ public class Call { private String targetName; private boolean isAlert; private String callType; - private int calls; - private int callsPerSec; + private long calls; + private long callsPerSec; private long responseTimes; - private int responseTimePerSec; + private long responseTimePerSec; public int getSource() { return source; @@ -81,19 +81,19 @@ public class Call { this.callType = callType; } - public int getCalls() { + public long getCalls() { return calls; } - public void setCalls(int calls) { + public void setCalls(long calls) { this.calls = calls; } - public int getCallsPerSec() { + public long getCallsPerSec() { return callsPerSec; } - public void setCallsPerSec(int callsPerSec) { + public void setCallsPerSec(long callsPerSec) { this.callsPerSec = callsPerSec; } @@ -105,11 +105,11 @@ public class Call { this.responseTimes = responseTimes; } - public int getResponseTimePerSec() { + public long getResponseTimePerSec() { return responseTimePerSec; } - public void setResponseTimePerSec(int responseTimePerSec) { + public void setResponseTimePerSec(long responseTimePerSec) { this.responseTimePerSec = responseTimePerSec; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java index 4d4c7cc93..9989ecbbc 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java @@ -18,16 +18,73 @@ package org.apache.skywalking.apm.collector.storage.ui.server; +import java.util.List; + /** * @author peng-yongsheng */ public class AppServerInfo { private int id; + private String osInfo; private String name; private int tps; - private String os; private String host; private int pid; - private String ipv4; - private String ipv6; + private List ipv4; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getOsInfo() { + return osInfo; + } + + public void setOsInfo(String osInfo) { + this.osInfo = osInfo; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getTps() { + return tps; + } + + public void setTps(int tps) { + this.tps = tps; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPid() { + return pid; + } + + public void setPid(int pid) { + this.pid = pid; + } + + public List getIpv4() { + return ipv4; + } + + public void setIpv4(List ipv4) { + this.ipv4 = ipv4; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java index b8b3dd1bc..50d88250c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java @@ -21,12 +21,15 @@ package org.apache.skywalking.apm.collector.storage.es.dao; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.search.SearchRequestBuilder; @@ -146,30 +149,31 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { return null; } - @Override public List getInstances(int applicationId, long timeBucket) { - logger.debug("get instances info, application id: {}, timeBucket: {}", applicationId, timeBucket); + @Override public List getInstances(String keyword, long start, long end) { + logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); searchRequestBuilder.setSize(1000); BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(timeBucket)); - boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end)); + if (StringUtils.isNotEmpty(keyword)) { + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_OS_INFO, keyword)); + } + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); searchRequestBuilder.setQuery(boolQuery); SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); SearchHit[] searchHits = searchResponse.getHits().getHits(); - List instanceList = new LinkedList<>(); + List appServerInfos = new LinkedList<>(); for (SearchHit searchHit : searchHits) { - Instance instance = new Instance(); - instance.setId(searchHit.getId()); - instance.setApplicationId(((Number)searchHit.getSource().get(InstanceTable.COLUMN_APPLICATION_ID)).intValue()); - instance.setHeartBeatTime(((Number)searchHit.getSource().get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue()); - instance.setInstanceId(((Number)searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID)).intValue()); - instanceList.add(instance); + AppServerInfo appServerInfo = new AppServerInfo(); + appServerInfo.setId(((Number)searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID)).intValue()); + appServerInfo.setOsInfo((String)searchHit.getSource().get(InstanceTable.COLUMN_OS_INFO)); + appServerInfos.add(appServerInfo); } - return instanceList; + return appServerInfos; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java index 488a08332..62a9762e7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java @@ -24,6 +24,7 @@ import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; @@ -31,6 +32,7 @@ import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -48,7 +50,7 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { private static final String GET_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? limit 1"; private static final String GET_INST_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? and {3} = ? limit 1"; private static final String GET_INSTANCE_SQL = "select * from {0} where {1} = ?"; - private static final String GET_INSTANCES_SQL = "select * from {0} where {1} = ? and {2} >= ?"; + private static final String GET_INSTANCES_SQL = "select * from {0} where {1} like ? and {2} >= ? and {2} <= ? and {3} = ?"; private static final String GET_APPLICATIONS_SQL = "select {3}, count({0}) as cnt from {1} where {2} >= ? group by {3} limit 100"; @Override @@ -130,25 +132,22 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { return null; } - @Override - public List getInstances(int applicationId, long timeBucket) { - logger.debug("get instances info, application id: {}, timeBucket: {}", applicationId, timeBucket); - List instanceList = new LinkedList<>(); + @Override public List getInstances(String keyword, long start, long end) { + logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); + List appServerInfos = new LinkedList<>(); H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_INSTANCES_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.COLUMN_HEARTBEAT_TIME); - Object[] params = new Object[] {applicationId, timeBucket}; + String sql = SqlBuilder.buildSql(GET_INSTANCES_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_OS_INFO, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {keyword, start, end, BooleanUtils.FALSE}; try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { - Instance instance = new Instance(); - instance.setId(rs.getString(InstanceTable.COLUMN_ID)); - instance.setApplicationId(rs.getInt(InstanceTable.COLUMN_APPLICATION_ID)); - instance.setHeartBeatTime(rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME)); - instance.setInstanceId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID)); - instanceList.add(instance); + AppServerInfo appServerInfo = new AppServerInfo(); + appServerInfo.setId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID)); + appServerInfo.setOsInfo(rs.getString(InstanceTable.COLUMN_OS_INFO)); + appServerInfos.add(appServerInfo); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } - return instanceList; + return appServerInfos; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index 3deeb3b1a..82f7cdf44 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -60,7 +60,6 @@ public class GraphQLHandler extends JettyHandler { private final Logger logger = LoggerFactory.getLogger(GraphQLHandler.class); - private final ModuleManager moduleManager; private final Gson gson = new Gson(); private final GraphQL graphQL; private static final String QUERY = "query"; @@ -69,8 +68,6 @@ public class GraphQLHandler extends JettyHandler { private static final String MESSAGE = "message"; public GraphQLHandler(ModuleManager moduleManager) { - this.moduleManager = moduleManager; - GraphQLSchema schema = SchemaParser.newParser() .file("ui-graphql/alarm.graphqls") .file("ui-graphql/application-layer.graphqls") @@ -81,7 +78,7 @@ public class GraphQLHandler extends JettyHandler { .file("ui-graphql/service-layer.graphqls") .file("ui-graphql/trace.graphqls") .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery(moduleManager)) - .resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(), new ServiceQuery(), new TraceQuery()) + .resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(moduleManager), new ServiceQuery(), new TraceQuery()) .resolvers(new ConfigQuery(), new ConfigMutation()) .dictionary(ConjecturalNode.class, VisualUserNode.class, ApplicationNode.class) .build() diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java index 7871337dc..be03305f7 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -18,8 +18,10 @@ package org.apache.skywalking.apm.collector.ui.query; +import java.text.ParseException; import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.ui.common.Duration; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; @@ -27,13 +29,33 @@ import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.ui.server.CPUTrend; import org.apache.skywalking.apm.collector.storage.ui.server.GCTrend; import org.apache.skywalking.apm.collector.storage.ui.server.MemoryTrend; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.service.ServerService; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** * @author peng-yongsheng */ public class ServerQuery implements Query { - public List searchServer(String keyword, Duration duration) { - return null; + + private final ModuleManager moduleManager; + private ServerService serverService; + + public ServerQuery(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + private ServerService getServerService() { + if (ObjectUtils.isEmpty(serverService)) { + this.serverService = new ServerService(moduleManager); + } + return serverService; + } + + public List searchServer(String keyword, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); + long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); + return getServerService().searchServer(keyword, start, end); } public List getAllServer(String applicationId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java index e53c52b43..821a435a4 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java @@ -119,10 +119,10 @@ public class ApplicationTopologyService { Topology topology = builder.build(applicationComponents, applicationMappings, callerCalls, calleeCalls, secondsBetween); topology.getCalls().forEach(call -> { - int calls = call.getCalls(); + long calls = call.getCalls(); long responseTimes = call.getResponseTimes(); - call.setCallsPerSec((int)(calls / secondsBetween)); - call.setResponseTimePerSec((int)(responseTimes / secondsBetween)); + call.setCallsPerSec(calls / secondsBetween); + call.setResponseTimePerSec(responseTimes / secondsBetween); }); return topology; } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java new file mode 100644 index 000000000..85b5af80d --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.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.apm.collector.ui.service; + +import com.google.gson.Gson; +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; + +/** + * @author peng-yongsheng + */ +public class ServerService { + + private final Gson gson = new Gson(); + private final IInstanceUIDAO instanceDAO; + + public ServerService(ModuleManager moduleManager) { + this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); + } + + public List searchServer(String keyword, long start, long end) { + List serverInfos = instanceDAO.getInstances(keyword, start, end); + serverInfos.forEach(serverInfo -> { + if (serverInfo.getId() == Const.NONE_INSTANCE_ID) { + serverInfos.remove(serverInfo); + } + }); + + serverInfos.forEach(serverInfo -> { + if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { + JsonObject osInfoJson = gson.fromJson(serverInfo.getOsInfo(), JsonObject.class); + if (osInfoJson.has("osName")) { + serverInfo.setName(osInfoJson.get("osName").getAsString()); + } + if (osInfoJson.has("hostName")) { + serverInfo.setHost(osInfoJson.get("hostName").getAsString()); + } + if (osInfoJson.has("processId")) { + serverInfo.setPid(osInfoJson.get("processId").getAsInt()); + } + + if (osInfoJson.has("ipv4s")) { + JsonArray ipv4Array = osInfoJson.get("ipv4s").getAsJsonArray(); + + List ipv4s = new LinkedList<>(); + ipv4Array.forEach(ipv4 -> { + ipv4s.add(ipv4.getAsString()); + }); + serverInfo.setIpv4(ipv4s); + } + } + }); + + return serverInfos; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java index 97ea1265a..fabdf601e 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java @@ -95,10 +95,12 @@ class TopologyBuilder { calleeCalls.forEach(call -> { if (call.getTarget() == nodeId) { - call.setCallsPerSec((int)(call.getCalls() / secondsBetween)); - call.setResponseTimePerSec((int)(call.getResponseTimes() / secondsBetween)); + call.setCallsPerSec(call.getCalls() / secondsBetween); + call.setResponseTimePerSec(call.getResponseTimes() / secondsBetween); } }); + applicationNode.setCallsPerSec(100L); + applicationNode.setResponseTimePerSec(100L); nodes.add(applicationNode); } } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls index ddd41c680..fdf1d1bcd 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls @@ -7,11 +7,9 @@ type AppServerInfo { id: ID! name: String! tps: Int! - os: String host: String pid: Int - ipv4: String - ipv6: String + ipv4: [String!]! } type CPUTrend { From 0ee4b1c30d2309b54444c336060d2d355d1d2bd1 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sat, 27 Jan 2018 09:37:30 +0800 Subject: [PATCH 13/36] Provide the getAllServer query, but only completed es storage and non tps. --- .../collector/storage/dao/IInstanceUIDAO.java | 4 ++- .../storage/es/dao/InstanceEsUIDAO.java | 25 ++++++++++++++++++- .../storage/h2/dao/InstanceH2UIDAO.java | 23 +++++++++++++---- .../apm/collector/ui/query/ServerQuery.java | 6 +++-- .../collector/ui/service/ServerService.java | 15 ++++++++--- 5 files changed, 61 insertions(+), 12 deletions(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java index 9db7121f3..51177357f 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java @@ -36,5 +36,7 @@ public interface IInstanceUIDAO extends DAO { Instance getInstance(int instanceId); - List getInstances(String keyword, long start, long end); + List searchServer(String keyword, long start, long end); + + List getAllServer(int applicationId, long start, long end); } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java index 50d88250c..93291e09a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java @@ -149,7 +149,7 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { return null; } - @Override public List getInstances(String keyword, long start, long end) { + @Override public List searchServer(String keyword, long start, long end) { logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); @@ -167,6 +167,29 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); SearchHit[] searchHits = searchResponse.getHits().getHits(); + return buildAppServerInfo(searchHits); + } + + @Override public List getAllServer(int applicationId, long start, long end) { + logger.debug("get instances info, applicationId: {}, start: {}, end: {}", applicationId, start, end); + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); + searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setSize(1000); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end)); + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); + searchRequestBuilder.setQuery(boolQuery); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + + return buildAppServerInfo(searchHits); + } + + private List buildAppServerInfo(SearchHit[] searchHits) { List appServerInfos = new LinkedList<>(); for (SearchHit searchHit : searchHits) { AppServerInfo appServerInfo = new AppServerInfo(); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java index 62a9762e7..aeecc3989 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java @@ -50,7 +50,6 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { private static final String GET_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? limit 1"; private static final String GET_INST_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? and {3} = ? limit 1"; private static final String GET_INSTANCE_SQL = "select * from {0} where {1} = ?"; - private static final String GET_INSTANCES_SQL = "select * from {0} where {1} like ? and {2} >= ? and {2} <= ? and {3} = ?"; private static final String GET_APPLICATIONS_SQL = "select {3}, count({0}) as cnt from {1} where {2} >= ? group by {3} limit 100"; @Override @@ -132,12 +131,26 @@ public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { return null; } - @Override public List getInstances(String keyword, long start, long end) { + @Override public List searchServer(String keyword, long start, long end) { logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); - List appServerInfos = new LinkedList<>(); - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_INSTANCES_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_OS_INFO, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); + String dynamicSql = "select * from {0} where {1} like ? and {2} >= ? and {2} <= ? and {3} = ?"; + String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_OS_INFO, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); Object[] params = new Object[] {keyword, start, end, BooleanUtils.FALSE}; + return buildAppServerInfo(sql, params); + } + + @Override public List getAllServer(int applicationId, long start, long end) { + logger.debug("get instances info, applicationId: {}, start: {}, end: {}", applicationId, start, end); + String dynamicSql = "select * from {0} where {1} = ? and {2} >= ? and {2} <= ? and {3} = ?"; + String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {applicationId, start, end, BooleanUtils.FALSE}; + return buildAppServerInfo(sql, params); + } + + private List buildAppServerInfo(String sql, Object[] params) { + H2Client client = getClient(); + + List appServerInfos = new LinkedList<>(); try (ResultSet rs = client.executeQuery(sql, params)) { while (rs.next()) { AppServerInfo appServerInfo = new AppServerInfo(); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java index be03305f7..9a6f32135 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -58,8 +58,10 @@ public class ServerQuery implements Query { return getServerService().searchServer(keyword, start, end); } - public List getAllServer(String applicationId, Duration duration) { - return null; + public List getAllServer(int applicationId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); + long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); + return getServerService().getAllServer(applicationId, start, end); } public ResponseTimeTrend getServerResponseTimeTrend(int serverId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index 85b5af80d..6df24adf4 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -43,13 +43,24 @@ public class ServerService { } public List searchServer(String keyword, long start, long end) { - List serverInfos = instanceDAO.getInstances(keyword, start, end); + List serverInfos = instanceDAO.searchServer(keyword, start, end); serverInfos.forEach(serverInfo -> { if (serverInfo.getId() == Const.NONE_INSTANCE_ID) { serverInfos.remove(serverInfo); } }); + + buildAppServerInfo(serverInfos); + return serverInfos; + } + public List getAllServer(int applicationId, long start, long end) { + List serverInfos = instanceDAO.getAllServer(applicationId, start, end); + buildAppServerInfo(serverInfos); + return serverInfos; + } + + private void buildAppServerInfo(List serverInfos) { serverInfos.forEach(serverInfo -> { if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { JsonObject osInfoJson = gson.fromJson(serverInfo.getOsInfo(), JsonObject.class); @@ -74,7 +85,5 @@ public class ServerService { } } }); - - return serverInfos; } } From 4a933e183224335c146da43f837bbc6fa0eb27f8 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 31 Jan 2018 11:00:25 +0800 Subject: [PATCH 14/36] Provide the getResponseTimeTrend query. --- .../storage/dao/IInstanceMetricUIDAO.java | 4 +- .../storage/ui/common/ResponseTimeTrend.java | 8 ++ .../storage/es/dao/InstanceMetricEsUIDAO.java | 31 ++++---- .../storage/h2/dao/InstanceMetricH2UIDAO.java | 34 ++++---- .../apm/collector/ui/query/ServerQuery.java | 6 +- .../ui/service/InstanceJVMService.java | 1 - .../collector/ui/service/ServerService.java | 18 ++++- .../apm/collector/ui/utils/DurationUtils.java | 77 +++++++++++++++++++ .../ui/utils/DurationUtilsTestCase.java | 58 ++++++++++++++ 9 files changed, 201 insertions(+), 36 deletions(-) create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java index e1b1d850b..a2df9ff98 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java @@ -19,7 +19,9 @@ package org.apache.skywalking.apm.collector.storage.dao; import com.google.gson.JsonArray; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; /** * @author peng-yongsheng @@ -33,7 +35,7 @@ public interface IInstanceMetricUIDAO extends DAO { long getRespTimeMetric(int instanceId, long timeBucket); - JsonArray getRespTimeMetric(int instanceId, long startTimeBucket, long endTimeBucket); + List getResponseTimeTrend(int instanceId, Step step, Long[] timeBuckets); class InstanceMetric { private final int instanceId; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java index 018892d64..dc08516c0 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ResponseTimeTrend.java @@ -25,4 +25,12 @@ import java.util.List; */ public class ResponseTimeTrend { private List trendList; + + public List getTrendList() { + return trendList; + } + + public void setTrendList(List trendList) { + this.trendList = trendList; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java index 591e8e32d..d997d0314 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java @@ -19,11 +19,16 @@ package org.apache.skywalking.apm.collector.storage.es.dao; import com.google.gson.JsonArray; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; @@ -113,30 +118,28 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO return 0; } - @Override public JsonArray getRespTimeMetric(int instanceId, long startTimeBucket, long endTimeBucket) { + @Override public List getResponseTimeTrend(int instanceId, Step step, Long[] timeBuckets) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - int i = 0; - long timeBucket = 0; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, startTimeBucket, i); - String id = timeBucket + Const.ID_SPLIT + instanceId; - prepareMultiGet.add(InstanceMetricTable.TABLE, InstanceMetricTable.TABLE_TYPE, id); - i++; + for (long timeBucket : timeBuckets) { + String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + prepareMultiGet.add(tableName, InstanceMetricTable.TABLE_TYPE, id); } - while (timeBucket <= endTimeBucket); - JsonArray metrics = new JsonArray(); + List responseTimeTrends = new LinkedList<>(); MultiGetResponse multiGetResponse = prepareMultiGet.get(); for (MultiGetItemResponse response : multiGetResponse.getResponses()) { if (response.getResponse().isExists()) { long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); - long costTotal = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue(); - metrics.add(costTotal / callTimes); + long errorCallTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue(); + long durationSum = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue(); + long errorDurationSum = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue(); + responseTimeTrends.add((int)((durationSum - errorDurationSum) / (callTimes - errorCallTimes))); } else { - metrics.add(0); + responseTimeTrends.add(0); } } - return metrics; + return responseTimeTrends; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java index 77b3185bb..d52f8f9ee 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java @@ -22,6 +22,7 @@ import com.google.gson.JsonArray; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; @@ -29,7 +30,10 @@ import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -135,33 +139,29 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO return 0; } - @Override public JsonArray getRespTimeMetric(int instanceId, long startTimeBucket, long endTimeBucket) { + @Override public List getResponseTimeTrend(int instanceId, Step step, Long[] timeBuckets) { H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_ID); - long timeBucket = startTimeBucket; - List idList = new ArrayList<>(); - do { - String id = timeBucket + Const.ID_SPLIT + instanceId; -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - idList.add(id); - } - while (timeBucket <= endTimeBucket); + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); + String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID); - JsonArray metrics = new JsonArray(); - idList.forEach(id -> { + List responseTimeTrends = new LinkedList<>(); + for (long timeBucket : timeBuckets) { + String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) { if (rs.next()) { long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - long costTotal = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - metrics.add(costTotal / callTimes); + long errorCallTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + long durationSum = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + long errorDurationSum = rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM); + responseTimeTrends.add((int)((durationSum - errorDurationSum) / (callTimes - errorCallTimes))); } else { - metrics.add(0); + responseTimeTrends.add(0); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } - }); - return metrics; + } + return responseTimeTrends; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java index 9a6f32135..e7a6f604b 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -64,8 +64,10 @@ public class ServerQuery implements Query { return getServerService().getAllServer(applicationId, start, end); } - public ResponseTimeTrend getServerResponseTimeTrend(int serverId, Duration duration) { - return null; + public ResponseTimeTrend getServerResponseTimeTrend(int serverId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getServerResponseTimeTrend(serverId, duration.getStep(), start, end); } public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java index bf14afd97..182388026 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java @@ -114,7 +114,6 @@ public class InstanceJVMService { } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { metrics.add(MetricType.tps.name(), instanceMetricUIDAO.getTpsMetric(instanceId, startTimeBucket, endTimeBucket)); } else if (metricType.toLowerCase().equals(MetricType.resptime.name())) { - metrics.add(MetricType.resptime.name(), instanceMetricUIDAO.getRespTimeMetric(instanceId, startTimeBucket, endTimeBucket)); } else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) { metrics.add(MetricType.heapmemory.name(), memoryMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, true)); } else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index 6df24adf4..d7b3af08b 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -21,14 +21,19 @@ package org.apache.skywalking.apm.collector.ui.service; import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonObject; +import java.text.ParseException; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** * @author peng-yongsheng @@ -37,9 +42,11 @@ public class ServerService { private final Gson gson = new Gson(); private final IInstanceUIDAO instanceDAO; + private final IInstanceMetricUIDAO instanceMetricUIDAO; public ServerService(ModuleManager moduleManager) { this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); + this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class); } public List searchServer(String keyword, long start, long end) { @@ -49,7 +56,7 @@ public class ServerService { serverInfos.remove(serverInfo); } }); - + buildAppServerInfo(serverInfos); return serverInfos; } @@ -60,6 +67,15 @@ public class ServerService { return serverInfos; } + public ResponseTimeTrend getServerResponseTimeTrend(int instanceId, Step step, long start, + long end) throws ParseException { + ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend(); + Long[] timeBuckets = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List trends = instanceMetricUIDAO.getResponseTimeTrend(instanceId, step, timeBuckets); + responseTimeTrend.setTrendList(trends); + return responseTimeTrend; + } + private void buildAppServerInfo(List serverInfos) { serverInfos.forEach(serverInfo -> { if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java index 0bb562220..53a7b3793 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java @@ -20,6 +20,9 @@ package org.apache.skywalking.apm.collector.ui.utils; import java.text.ParseException; import java.util.Date; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.core.UnexpectedException; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.ui.common.Step; @@ -88,4 +91,78 @@ public enum DurationUtils { return Seconds.secondsBetween(new DateTime(startDate), new DateTime(endDate)).getSeconds(); } + + public DateTime parseToDateTime(Step step, long time) throws ParseException { + DateTime dateTime = null; + + switch (step) { + case MONTH: + Date date = TimeBucketUtils.MONTH_DATE_FORMAT.parse(String.valueOf(time)); + dateTime = new DateTime(date); + break; + case DAY: + date = TimeBucketUtils.DAY_DATE_FORMAT.parse(String.valueOf(time)); + dateTime = new DateTime(date); + break; + case HOUR: + date = TimeBucketUtils.HOUR_DATE_FORMAT.parse(String.valueOf(time)); + dateTime = new DateTime(date); + break; + case MINUTE: + date = TimeBucketUtils.MINUTE_DATE_FORMAT.parse(String.valueOf(time)); + dateTime = new DateTime(date); + break; + case SECOND: + date = TimeBucketUtils.SECOND_DATE_FORMAT.parse(String.valueOf(time)); + dateTime = new DateTime(date); + break; + } + + return dateTime; + } + + public Long[] getDurationPoints(Step step, long start, long end) throws ParseException { + DateTime dateTime = parseToDateTime(step, start); + + List durations = new LinkedList<>(); + durations.add(start); + + int i = 0; + do { + switch (step) { + case MONTH: + dateTime = dateTime.plusMonths(1); + String timeBucket = TimeBucketUtils.MONTH_DATE_FORMAT.format(dateTime.toDate()); + durations.add(Long.valueOf(timeBucket)); + break; + case DAY: + dateTime = dateTime.plusDays(1); + timeBucket = TimeBucketUtils.DAY_DATE_FORMAT.format(dateTime.toDate()); + durations.add(Long.valueOf(timeBucket)); + break; + case HOUR: + dateTime = dateTime.plusHours(1); + timeBucket = TimeBucketUtils.HOUR_DATE_FORMAT.format(dateTime.toDate()); + durations.add(Long.valueOf(timeBucket)); + break; + case MINUTE: + dateTime = dateTime.plusMinutes(1); + timeBucket = TimeBucketUtils.MINUTE_DATE_FORMAT.format(dateTime.toDate()); + durations.add(Long.valueOf(timeBucket)); + break; + case SECOND: + dateTime = dateTime.plusSeconds(1); + timeBucket = TimeBucketUtils.SECOND_DATE_FORMAT.format(dateTime.toDate()); + durations.add(Long.valueOf(timeBucket)); + break; + } + i++; + if (i > 500) { + throw new UnexpectedException("Duration data error, step: " + step.name() + ", start: " + start + ", end: " + end); + } + } + while (end != durations.get(durations.size() - 1)); + + return durations.toArray(new Long[durations.size()]); + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java new file mode 100644 index 000000000..30abe75be --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java @@ -0,0 +1,58 @@ +/* + * 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.apm.collector.ui.utils; + +import java.text.ParseException; +import org.apache.skywalking.apm.collector.core.UnexpectedException; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author peng-yongsheng + */ +public class DurationUtilsTestCase { + + @Test + public void test() throws ParseException { + } + + @Test + public void testGetDurationPoints() throws ParseException { + Long[] durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.MONTH, 201710, 201803); + Assert.assertArrayEquals(new Long[] {201710L, 201711L, 201712L, 201801L, 201802L, 201803L}, durationPoints); + + durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.DAY, 20180129, 20180202); + Assert.assertArrayEquals(new Long[] {20180129L, 20180130L, 20180131L, 20180201L, 20180202L}, durationPoints); + + durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.HOUR, 2018012922, 2018013002); + Assert.assertArrayEquals(new Long[] {2018012922L, 2018012923L, 2018013000L, 2018013001L, 2018013002L}, durationPoints); + + durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.MINUTE, 201801292258L, 201801292302L); + Assert.assertArrayEquals(new Long[] {201801292258L, 201801292259L, 201801292300L, 201801292301L, 201801292302L}, durationPoints); + + durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.SECOND, 20180129225858L, 20180129225902L); + Assert.assertArrayEquals(new Long[] {20180129225858L, 20180129225859L, 20180129225900L, 20180129225901L, 20180129225902L}, durationPoints); + } + + @Test(expected = UnexpectedException.class) + public void testGetDurationPointsErrorDuration() throws ParseException { + DurationUtils.INSTANCE.getDurationPoints(Step.MONTH, 20171001, 20180301); + } +} From 703a591bec3fae54199691aaa2e17b730b0795a8 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 31 Jan 2018 11:01:17 +0800 Subject: [PATCH 15/36] Move DurationUtilsTestCase to ui provider module. --- .../ui/utils/DurationUtilsTestCase.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java diff --git a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java b/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java deleted file mode 100644 index 28a383dc3..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-graphql/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * 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.apm.collector.ui.utils; - -import java.text.ParseException; -import org.junit.Test; - -/** - * @author peng-yongsheng - */ -public class DurationUtilsTestCase { - - @Test - public void test() throws ParseException { - } -} From 86e05bc381b811c5245ae6aea83f7da6353f1ca2 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 31 Jan 2018 14:57:44 +0800 Subject: [PATCH 16/36] Provide the getServerTPSTrend query. --- .../storage/dao/IInstanceMetricUIDAO.java | 6 +- .../storage/ui/common/ThroughputTrend.java | 8 +++ .../storage/utils/DurationPoint.java | 40 +++++++++++ .../storage/es/dao/InstanceMetricEsUIDAO.java | 37 ++++++----- .../storage/h2/dao/InstanceMetricH2UIDAO.java | 42 +++++------- .../apm/collector/ui/query/ServerQuery.java | 6 +- .../ui/service/InstanceJVMService.java | 1 - .../collector/ui/service/ServerService.java | 14 +++- .../apm/collector/ui/utils/DurationUtils.java | 38 ++++++++--- .../ui/utils/DurationUtilsTestCase.java | 66 +++++++++++++++++-- 10 files changed, 192 insertions(+), 66 deletions(-) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/DurationPoint.java diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java index a2df9ff98..5d8603ecf 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java @@ -18,10 +18,10 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonArray; import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; /** * @author peng-yongsheng @@ -31,11 +31,11 @@ public interface IInstanceMetricUIDAO extends DAO { long getTpsMetric(int instanceId, long timeBucket); - JsonArray getTpsMetric(int instanceId, long startTimeBucket, long endTimeBucket); + List getServerTPSTrend(int instanceId, Step step, List durationPoints); long getRespTimeMetric(int instanceId, long timeBucket); - List getResponseTimeTrend(int instanceId, Step step, Long[] timeBuckets); + List getResponseTimeTrend(int instanceId, Step step, List durationPoints); class InstanceMetric { private final int instanceId; diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java index e6cf37b99..f20866964 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ThroughputTrend.java @@ -25,4 +25,12 @@ import java.util.List; */ public class ThroughputTrend { private List trendList; + + public List getTrendList() { + return trendList; + } + + public void setTrendList(List trendList) { + this.trendList = trendList; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/DurationPoint.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/DurationPoint.java new file mode 100644 index 000000000..a8f5ecebf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/utils/DurationPoint.java @@ -0,0 +1,40 @@ +/* + * 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.apm.collector.storage.utils; + +/** + * @author peng-yongsheng + */ +public class DurationPoint { + private long point; + private long secondsBetween; + + public DurationPoint(long point, long secondsBetween) { + this.point = point; + this.secondsBetween = secondsBetween; + } + + public long getPoint() { + return point; + } + + public long getSecondsBetween() { + return secondsBetween; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java index d997d0314..d0bf73f1c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java @@ -18,7 +18,6 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; @@ -28,6 +27,7 @@ import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; @@ -83,27 +83,28 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO return 0; } - @Override public JsonArray getTpsMetric(int instanceId, long startTimeBucket, long endTimeBucket) { + @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - long timeBucket = startTimeBucket; - do { - String id = timeBucket + Const.ID_SPLIT + instanceId; - prepareMultiGet.add(InstanceMetricTable.TABLE, InstanceMetricTable.TABLE_TYPE, id); -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - } - while (timeBucket <= endTimeBucket); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + prepareMultiGet.add(tableName, InstanceMetricTable.TABLE_TYPE, id); + }); - JsonArray metrics = new JsonArray(); + List throughputTrend = new LinkedList<>(); MultiGetResponse multiGetResponse = prepareMultiGet.get(); - for (MultiGetItemResponse response : multiGetResponse.getResponses()) { + + for (int i = 0; i < multiGetResponse.getResponses().length; i++) { + MultiGetItemResponse response = multiGetResponse.getResponses()[i]; if (response.getResponse().isExists()) { - metrics.add(((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue()); + long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); + throughputTrend.add((int)(callTimes / durationPoints.get(i).getSecondsBetween())); } else { - metrics.add(0); + throughputTrend.add(0); } } - return metrics; + return throughputTrend; } @Override public long getRespTimeMetric(int instanceId, long timeBucket) { @@ -118,14 +119,14 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO return 0; } - @Override public List getResponseTimeTrend(int instanceId, Step step, Long[] timeBuckets) { + @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - for (long timeBucket : timeBuckets) { - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); prepareMultiGet.add(tableName, InstanceMetricTable.TABLE_TYPE, id); - } + }); List responseTimeTrends = new LinkedList<>(); MultiGetResponse multiGetResponse = prepareMultiGet.get(); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java index d52f8f9ee..21d5b5bb3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java @@ -18,10 +18,8 @@ package org.apache.skywalking.apm.collector.storage.h2.dao; -import com.google.gson.JsonArray; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; @@ -33,6 +31,7 @@ import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -55,7 +54,7 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO logger.info("the inst performance inst id = {}", instanceId); String sql = SqlBuilder.buildSql(GET_INSTANCE_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_INSTANCE_ID, InstanceMetricTable.COLUMN_TIME_BUCKET); StringBuilder builder = new StringBuilder(); - for (int i = 0; i < timeBuckets.length; i++) { + for (long timeBucket : timeBuckets) { builder.append("?,"); } builder.delete(builder.length() - 1, builder.length()); @@ -93,34 +92,29 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO return 0; } - @Override public JsonArray getTpsMetric(int instanceId, long startTimeBucket, long endTimeBucket) { - logger.info("getTpsMetric instanceId = {}, startTimeBucket = {}, endTimeBucket = {}", instanceId, startTimeBucket, endTimeBucket); + @Override + public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_ID); + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - long timeBucket = startTimeBucket; - List idList = new ArrayList<>(); - do { - String id = timeBucket + Const.ID_SPLIT + instanceId; -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - idList.add(id); - } - while (timeBucket <= endTimeBucket); + String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID); - JsonArray metrics = new JsonArray(); - idList.forEach(id -> { + List throughputTrend = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) { if (rs.next()) { - long calls = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - metrics.add(calls); + long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); + throughputTrend.add((int)(callTimes / durationPoint.getSecondsBetween())); } else { - metrics.add(0); + throughputTrend.add(0); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } }); - return metrics; + + return throughputTrend; } @Override public long getRespTimeMetric(int instanceId, long timeBucket) { @@ -139,15 +133,15 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO return 0; } - @Override public List getResponseTimeTrend(int instanceId, Step step, Long[] timeBuckets) { + @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { H2Client client = getClient(); String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID); List responseTimeTrends = new LinkedList<>(); - for (long timeBucket : timeBuckets) { - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) { if (rs.next()) { long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); @@ -161,7 +155,7 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } - } + }); return responseTimeTrends; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java index e7a6f604b..c3c4af039 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -70,8 +70,10 @@ public class ServerQuery implements Query { return getServerService().getServerResponseTimeTrend(serverId, duration.getStep(), start, end); } - public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) { - return null; + public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getServerTPSTrend(serverId, duration.getStep(), start, end); } public CPUTrend getCPUTrend(int serverId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java index 182388026..779a31fbd 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java @@ -112,7 +112,6 @@ public class InstanceJVMService { } else if (metricType.toLowerCase().equals(MetricType.gc.name())) { metrics.add(MetricType.gc.name(), gcMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket)); } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { - metrics.add(MetricType.tps.name(), instanceMetricUIDAO.getTpsMetric(instanceId, startTimeBucket, endTimeBucket)); } else if (metricType.toLowerCase().equals(MetricType.resptime.name())) { } else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) { metrics.add(MetricType.heapmemory.name(), memoryMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, true)); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index d7b3af08b..739760780 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -32,7 +32,9 @@ import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** @@ -70,12 +72,20 @@ public class ServerService { public ResponseTimeTrend getServerResponseTimeTrend(int instanceId, Step step, long start, long end) throws ParseException { ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend(); - Long[] timeBuckets = DurationUtils.INSTANCE.getDurationPoints(step, start, end); - List trends = instanceMetricUIDAO.getResponseTimeTrend(instanceId, step, timeBuckets); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List trends = instanceMetricUIDAO.getResponseTimeTrend(instanceId, step, durationPoints); responseTimeTrend.setTrendList(trends); return responseTimeTrend; } + public ThroughputTrend getServerTPSTrend(int instanceId, Step step, long start, long end) throws ParseException { + ThroughputTrend throughputTrend = new ThroughputTrend(); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List trends = instanceMetricUIDAO.getServerTPSTrend(instanceId, step, durationPoints); + throughputTrend.setTrendList(trends); + return throughputTrend; + } + private void buildAppServerInfo(List serverInfos) { serverInfos.forEach(serverInfo -> { if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java index 53a7b3793..ffeb3322c 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java @@ -26,6 +26,7 @@ import org.apache.skywalking.apm.collector.core.UnexpectedException; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.joda.time.DateTime; import org.joda.time.Seconds; @@ -92,6 +93,23 @@ public enum DurationUtils { return Seconds.secondsBetween(new DateTime(startDate), new DateTime(endDate)).getSeconds(); } + public long secondsBetween(Step step, DateTime dateTime) throws ParseException { + switch (step) { + case MONTH: + return dateTime.dayOfMonth().getMaximumValue() * 24 * 60 * 60; + case DAY: + return 24 * 60 * 60; + case HOUR: + return 60 * 60; + case MINUTE: + return 60; + case SECOND: + return 1; + default: + return 1; + } + } + public DateTime parseToDateTime(Step step, long time) throws ParseException { DateTime dateTime = null; @@ -121,11 +139,11 @@ public enum DurationUtils { return dateTime; } - public Long[] getDurationPoints(Step step, long start, long end) throws ParseException { + public List getDurationPoints(Step step, long start, long end) throws ParseException { DateTime dateTime = parseToDateTime(step, start); - List durations = new LinkedList<>(); - durations.add(start); + List durations = new LinkedList<>(); + durations.add(new DurationPoint(start, secondsBetween(step, dateTime))); int i = 0; do { @@ -133,27 +151,27 @@ public enum DurationUtils { case MONTH: dateTime = dateTime.plusMonths(1); String timeBucket = TimeBucketUtils.MONTH_DATE_FORMAT.format(dateTime.toDate()); - durations.add(Long.valueOf(timeBucket)); + durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case DAY: dateTime = dateTime.plusDays(1); timeBucket = TimeBucketUtils.DAY_DATE_FORMAT.format(dateTime.toDate()); - durations.add(Long.valueOf(timeBucket)); + durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case HOUR: dateTime = dateTime.plusHours(1); timeBucket = TimeBucketUtils.HOUR_DATE_FORMAT.format(dateTime.toDate()); - durations.add(Long.valueOf(timeBucket)); + durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case MINUTE: dateTime = dateTime.plusMinutes(1); timeBucket = TimeBucketUtils.MINUTE_DATE_FORMAT.format(dateTime.toDate()); - durations.add(Long.valueOf(timeBucket)); + durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case SECOND: dateTime = dateTime.plusSeconds(1); timeBucket = TimeBucketUtils.SECOND_DATE_FORMAT.format(dateTime.toDate()); - durations.add(Long.valueOf(timeBucket)); + durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; } i++; @@ -161,8 +179,8 @@ public enum DurationUtils { throw new UnexpectedException("Duration data error, step: " + step.name() + ", start: " + start + ", end: " + end); } } - while (end != durations.get(durations.size() - 1)); + while (end != durations.get(durations.size() - 1).getPoint()); - return durations.toArray(new Long[durations.size()]); + return durations; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java index 30abe75be..1ab46eaab 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/test/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtilsTestCase.java @@ -19,8 +19,10 @@ package org.apache.skywalking.apm.collector.ui.utils; import java.text.ParseException; +import java.util.List; import org.apache.skywalking.apm.collector.core.UnexpectedException; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.junit.Assert; import org.junit.Test; @@ -35,20 +37,72 @@ public class DurationUtilsTestCase { @Test public void testGetDurationPoints() throws ParseException { - Long[] durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.MONTH, 201710, 201803); - Assert.assertArrayEquals(new Long[] {201710L, 201711L, 201712L, 201801L, 201802L, 201803L}, durationPoints); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.MONTH, 201710, 201803); + Assert.assertEquals(6, durationPoints.size()); + Assert.assertEquals(201710L, durationPoints.get(0).getPoint()); + Assert.assertEquals(2678400, durationPoints.get(0).getSecondsBetween()); + Assert.assertEquals(201711L, durationPoints.get(1).getPoint()); + Assert.assertEquals(2592000, durationPoints.get(1).getSecondsBetween()); + Assert.assertEquals(201712L, durationPoints.get(2).getPoint()); + Assert.assertEquals(2678400, durationPoints.get(2).getSecondsBetween()); + Assert.assertEquals(201801L, durationPoints.get(3).getPoint()); + Assert.assertEquals(2678400, durationPoints.get(3).getSecondsBetween()); + Assert.assertEquals(201802L, durationPoints.get(4).getPoint()); + Assert.assertEquals(2419200, durationPoints.get(4).getSecondsBetween()); + Assert.assertEquals(201803L, durationPoints.get(5).getPoint()); + Assert.assertEquals(2678400, durationPoints.get(5).getSecondsBetween()); durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.DAY, 20180129, 20180202); - Assert.assertArrayEquals(new Long[] {20180129L, 20180130L, 20180131L, 20180201L, 20180202L}, durationPoints); + Assert.assertEquals(5, durationPoints.size()); + Assert.assertEquals(20180129L, durationPoints.get(0).getPoint()); + Assert.assertEquals(86400, durationPoints.get(0).getSecondsBetween()); + Assert.assertEquals(20180130L, durationPoints.get(1).getPoint()); + Assert.assertEquals(86400, durationPoints.get(1).getSecondsBetween()); + Assert.assertEquals(20180131L, durationPoints.get(2).getPoint()); + Assert.assertEquals(86400, durationPoints.get(2).getSecondsBetween()); + Assert.assertEquals(20180201L, durationPoints.get(3).getPoint()); + Assert.assertEquals(86400, durationPoints.get(3).getSecondsBetween()); + Assert.assertEquals(20180202L, durationPoints.get(4).getPoint()); + Assert.assertEquals(86400, durationPoints.get(4).getSecondsBetween()); durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.HOUR, 2018012922, 2018013002); - Assert.assertArrayEquals(new Long[] {2018012922L, 2018012923L, 2018013000L, 2018013001L, 2018013002L}, durationPoints); + Assert.assertEquals(5, durationPoints.size()); + Assert.assertEquals(2018012922L, durationPoints.get(0).getPoint()); + Assert.assertEquals(3600, durationPoints.get(0).getSecondsBetween()); + Assert.assertEquals(2018012923L, durationPoints.get(1).getPoint()); + Assert.assertEquals(3600, durationPoints.get(1).getSecondsBetween()); + Assert.assertEquals(2018013000L, durationPoints.get(2).getPoint()); + Assert.assertEquals(3600, durationPoints.get(2).getSecondsBetween()); + Assert.assertEquals(2018013001L, durationPoints.get(3).getPoint()); + Assert.assertEquals(3600, durationPoints.get(3).getSecondsBetween()); + Assert.assertEquals(2018013002L, durationPoints.get(4).getPoint()); + Assert.assertEquals(3600, durationPoints.get(4).getSecondsBetween()); durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.MINUTE, 201801292258L, 201801292302L); - Assert.assertArrayEquals(new Long[] {201801292258L, 201801292259L, 201801292300L, 201801292301L, 201801292302L}, durationPoints); + Assert.assertEquals(5, durationPoints.size()); + Assert.assertEquals(201801292258L, durationPoints.get(0).getPoint()); + Assert.assertEquals(60, durationPoints.get(0).getSecondsBetween()); + Assert.assertEquals(201801292259L, durationPoints.get(1).getPoint()); + Assert.assertEquals(60, durationPoints.get(1).getSecondsBetween()); + Assert.assertEquals(201801292300L, durationPoints.get(2).getPoint()); + Assert.assertEquals(60, durationPoints.get(2).getSecondsBetween()); + Assert.assertEquals(201801292301L, durationPoints.get(3).getPoint()); + Assert.assertEquals(60, durationPoints.get(3).getSecondsBetween()); + Assert.assertEquals(201801292302L, durationPoints.get(4).getPoint()); + Assert.assertEquals(60, durationPoints.get(4).getSecondsBetween()); durationPoints = DurationUtils.INSTANCE.getDurationPoints(Step.SECOND, 20180129225858L, 20180129225902L); - Assert.assertArrayEquals(new Long[] {20180129225858L, 20180129225859L, 20180129225900L, 20180129225901L, 20180129225902L}, durationPoints); + Assert.assertEquals(5, durationPoints.size()); + Assert.assertEquals(20180129225858L, durationPoints.get(0).getPoint()); + Assert.assertEquals(1, durationPoints.get(0).getSecondsBetween()); + Assert.assertEquals(20180129225859L, durationPoints.get(1).getPoint()); + Assert.assertEquals(1, durationPoints.get(1).getSecondsBetween()); + Assert.assertEquals(20180129225900L, durationPoints.get(2).getPoint()); + Assert.assertEquals(1, durationPoints.get(2).getSecondsBetween()); + Assert.assertEquals(20180129225901L, durationPoints.get(3).getPoint()); + Assert.assertEquals(1, durationPoints.get(3).getSecondsBetween()); + Assert.assertEquals(20180129225902L, durationPoints.get(4).getPoint()); + Assert.assertEquals(1, durationPoints.get(4).getSecondsBetween()); } @Test(expected = UnexpectedException.class) From 8585e42c8621c2100fb92a791241cbc5a6d6863a Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 31 Jan 2018 21:14:51 +0800 Subject: [PATCH 17/36] Provide the getCPUTrend query. --- .../storage/dao/ICpuMetricUIDAO.java | 8 +-- .../storage/dao/IInstanceMetricUIDAO.java | 29 --------- .../collector/storage/ui/server/CPUTrend.java | 8 +++ .../storage/es/dao/CpuMetricEsUIDAO.java | 40 +++++------- .../storage/es/dao/InstanceMetricEsUIDAO.java | 53 ---------------- .../storage/h2/dao/CpuMetricH2UIDAO.java | 46 +++++--------- .../storage/h2/dao/InstanceMetricH2UIDAO.java | 63 +------------------ .../apm/collector/ui/query/ServerQuery.java | 6 +- .../ui/service/InstanceJVMService.java | 11 +--- .../collector/ui/service/ServerService.java | 20 ++++-- 10 files changed, 66 insertions(+), 218 deletions(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java index e1d3f9672..592e58e14 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java @@ -18,14 +18,14 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonArray; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; /** * @author peng-yongsheng */ public interface ICpuMetricUIDAO extends DAO { - int getMetric(int instanceId, long timeBucket); - - JsonArray getMetric(int instanceId, long startTimeBucket, long endTimeBucket); + List getCPUTrend(int instanceId, Step step, List durationPoints); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java index 5d8603ecf..5410d71fa 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java @@ -27,37 +27,8 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; * @author peng-yongsheng */ public interface IInstanceMetricUIDAO extends DAO { - InstanceMetric get(long[] timeBuckets, int instanceId); - - long getTpsMetric(int instanceId, long timeBucket); List getServerTPSTrend(int instanceId, Step step, List durationPoints); - long getRespTimeMetric(int instanceId, long timeBucket); - List getResponseTimeTrend(int instanceId, Step step, List durationPoints); - - class InstanceMetric { - private final int instanceId; - private final long calls; - private final long durationSum; - - public InstanceMetric(int instanceId, long calls, long durationSum) { - this.instanceId = instanceId; - this.calls = calls; - this.durationSum = durationSum; - } - - public int getInstanceId() { - return instanceId; - } - - public long getCalls() { - return calls; - } - - public long getDurationSum() { - return durationSum; - } - } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java index 062cfe213..5f894f76c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/CPUTrend.java @@ -25,4 +25,12 @@ import java.util.List; */ public class CPUTrend { private List cost; + + public List getCost() { + return cost; + } + + public void setCost(List cost) { + this.cost = cost; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java index 788bc5fc1..21aef52d0 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java @@ -18,13 +18,16 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; -import org.elasticsearch.action.get.GetResponse; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; @@ -38,37 +41,26 @@ public class CpuMetricEsUIDAO extends EsDAO implements ICpuMetricUIDAO { super(client); } - @Override public int getMetric(int instanceId, long timeBucket) { - String id = timeBucket + Const.ID_SPLIT + instanceId; - GetResponse getResponse = getClient().prepareGet(CpuMetricTable.TABLE, id).get(); - - if (getResponse.isExists()) { - return ((Number)getResponse.getSource().get(CpuMetricTable.COLUMN_USAGE_PERCENT)).intValue(); - } - return 0; - } - - @Override public JsonArray getMetric(int instanceId, long startTimeBucket, long endTimeBucket) { + @Override public List getCPUTrend(int instanceId, Step step, List durationPoints) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, CpuMetricTable.TABLE); - long timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String id = timeBucket + Const.ID_SPLIT + instanceId; - prepareMultiGet.add(CpuMetricTable.TABLE, CpuMetricTable.TABLE_TYPE, id); - } - while (timeBucket <= endTimeBucket); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId; + prepareMultiGet.add(tableName, CpuMetricTable.TABLE_TYPE, id); + }); - JsonArray metrics = new JsonArray(); + List cpuTrends = new LinkedList<>(); MultiGetResponse multiGetResponse = prepareMultiGet.get(); for (MultiGetItemResponse response : multiGetResponse.getResponses()) { if (response.getResponse().isExists()) { double cpuUsed = ((Number)response.getResponse().getSource().get(CpuMetricTable.COLUMN_USAGE_PERCENT)).doubleValue(); - metrics.add((int)(cpuUsed * 100)); + long times = ((Number)response.getResponse().getSource().get(CpuMetricTable.COLUMN_TIMES)).longValue(); + cpuTrends.add((int)((cpuUsed / times) * 100)); } else { - metrics.add(0); + cpuTrends.add(0); } } - return metrics; + return cpuTrends; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java index d0bf73f1c..89459ab5e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java @@ -29,18 +29,9 @@ import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetric import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.elasticsearch.search.sort.SortOrder; /** * @author peng-yongsheng @@ -51,38 +42,6 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO super(client); } - @Override public InstanceMetric get(long[] timeBuckets, int instanceId) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceMetricTable.TABLE); - searchRequestBuilder.setTypes(InstanceMetricTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.termQuery(InstanceMetricTable.COLUMN_INSTANCE_ID, instanceId)); - boolQuery.must().add(QueryBuilders.termsQuery(InstanceMetricTable.COLUMN_TIME_BUCKET, timeBuckets)); - - searchRequestBuilder.setQuery(boolQuery); - searchRequestBuilder.setSize(0); - searchRequestBuilder.addSort(InstanceMetricTable.COLUMN_INSTANCE_ID, SortOrder.ASC); - - searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_CALLS).field(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)); - searchRequestBuilder.addAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - Sum sumCalls = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - Sum sumCostTotal = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - return new InstanceMetric(instanceId, (long)sumCalls.getValue(), (long)sumCostTotal.getValue()); - } - - @Override public long getTpsMetric(int instanceId, long timeBucket) { - String id = timeBucket + Const.ID_SPLIT + instanceId; - GetResponse getResponse = getClient().prepareGet(InstanceMetricTable.TABLE, id).get(); - - if (getResponse.isExists()) { - return ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); - } - return 0; - } - @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); @@ -107,18 +66,6 @@ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO return throughputTrend; } - @Override public long getRespTimeMetric(int instanceId, long timeBucket) { - String id = timeBucket + Const.ID_SPLIT + instanceId; - GetResponse getResponse = getClient().prepareGet(InstanceMetricTable.TABLE, id).get(); - - if (getResponse.isExists()) { - long callTimes = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); - long costTotal = ((Number)getResponse.getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue(); - return costTotal / callTimes; - } - return 0; - } - @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java index e3ec3d908..0d4267925 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java @@ -18,10 +18,9 @@ package org.apache.skywalking.apm.collector.storage.h2.dao; -import com.google.gson.JsonArray; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; @@ -30,6 +29,9 @@ import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -44,48 +46,28 @@ public class CpuMetricH2UIDAO extends H2DAO implements ICpuMetricUIDAO { super(client); } - @Override public int getMetric(int instanceId, long timeBucket) { - String id = timeBucket + Const.ID_SPLIT + instanceId; + @Override public List getCPUTrend(int instanceId, Step step, List durationPoints) { H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_CPU_METRIC_SQL, CpuMetricTable.TABLE, CpuMetricTable.COLUMN_ID); - Object[] params = new Object[] {id}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - return rs.getInt(CpuMetricTable.COLUMN_USAGE_PERCENT); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return 0; - } + String tableName = TimePyramidTableNameBuilder.build(step, CpuMetricTable.TABLE); + String sql = SqlBuilder.buildSql(GET_CPU_METRIC_SQL, tableName, CpuMetricTable.COLUMN_ID); - @Override public JsonArray getMetric(int instanceId, long startTimeBucket, long endTimeBucket) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_CPU_METRIC_SQL, CpuMetricTable.TABLE, CpuMetricTable.COLUMN_ID); + List cpuTrends = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId; - long timeBucket = startTimeBucket; - List idList = new ArrayList<>(); - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String id = timeBucket + Const.ID_SPLIT + instanceId; - idList.add(id); - } - while (timeBucket <= endTimeBucket); - - JsonArray metrics = new JsonArray(); - idList.forEach(id -> { try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { if (rs.next()) { double cpuUsed = rs.getDouble(CpuMetricTable.COLUMN_USAGE_PERCENT); - metrics.add((int)(cpuUsed * 100)); + long times = rs.getLong(CpuMetricTable.COLUMN_TIMES); + cpuTrends.add((int)((cpuUsed / times) * 100)); } else { - metrics.add(0); + cpuTrends.add(0); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } }); - return metrics; + return cpuTrends; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java index 21d5b5bb3..f1ea9d9c2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java @@ -42,58 +42,13 @@ import org.slf4j.LoggerFactory; public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO { private final Logger logger = LoggerFactory.getLogger(InstanceMetricH2UIDAO.class); - private static final String GET_INSTANCE_METRIC_SQL = "select * from {0} where {1} = ? and {2} in ("; private static final String GET_TPS_METRIC_SQL = "select * from {0} where {1} = ?"; public InstanceMetricH2UIDAO(H2Client client) { super(client); } - @Override public InstanceMetric get(long[] timeBuckets, int instanceId) { - H2Client client = getClient(); - logger.info("the inst performance inst id = {}", instanceId); - String sql = SqlBuilder.buildSql(GET_INSTANCE_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_INSTANCE_ID, InstanceMetricTable.COLUMN_TIME_BUCKET); - StringBuilder builder = new StringBuilder(); - for (long timeBucket : timeBuckets) { - builder.append("?,"); - } - builder.delete(builder.length() - 1, builder.length()); - builder.append(")"); - sql = sql + builder; - Object[] params = new Object[timeBuckets.length + 1]; - for (int i = 0; i < timeBuckets.length; i++) { - params[i + 1] = timeBuckets[i]; - } - params[0] = instanceId; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - long callTimes = rs.getInt(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - long costTotal = rs.getInt(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - return new InstanceMetric(instanceId, callTimes, costTotal); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return null; - } - - @Override public long getTpsMetric(int instanceId, long timeBucket) { - logger.info("getTpMetric instanceId = {}, startTimeBucket = {}", instanceId, timeBucket); - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_ID); - Object[] params = new Object[] {instanceId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - return rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return 0; - } - - @Override - public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { + @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { H2Client client = getClient(); String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); @@ -117,22 +72,6 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO return throughputTrend; } - @Override public long getRespTimeMetric(int instanceId, long timeBucket) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, InstanceMetricTable.TABLE, InstanceMetricTable.COLUMN_ID); - Object[] params = new Object[] {instanceId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - long costTotal = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - return costTotal / callTimes; - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return 0; - } - @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { H2Client client = getClient(); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java index c3c4af039..965848baa 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -76,8 +76,10 @@ public class ServerQuery implements Query { return getServerService().getServerTPSTrend(serverId, duration.getStep(), start, end); } - public CPUTrend getCPUTrend(int serverId, Duration duration) { - return null; + public CPUTrend getCPUTrend(int serverId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getCPUTrend(serverId, duration.getStep(), start, end); } public GCTrend getGCTrend(int serverId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java index 779a31fbd..ca1b03c7f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.ui.service; import com.google.gson.Gson; @@ -25,14 +24,14 @@ import java.util.Set; import org.apache.skywalking.apm.collector.core.UnexpectedException; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; +import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.table.register.Instance; -import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.network.proto.PoolType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,13 +74,10 @@ public class InstanceJVMService { JsonObject metrics = new JsonObject(); for (String metricType : metricTypes) { if (metricType.toLowerCase().equals(MetricType.cpu.name())) { - metrics.addProperty(MetricType.cpu.name(), cpuMetricDAO.getMetric(instanceId, timeBucket)); } else if (metricType.toLowerCase().equals(MetricType.gc.name())) { metrics.add(MetricType.gc.name(), gcMetricDAO.getMetric(instanceId, timeBucket)); } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { - metrics.addProperty(MetricType.tps.name(), instanceMetricUIDAO.getTpsMetric(instanceId, timeBucket)); } else if (metricType.toLowerCase().equals(MetricType.resptime.name())) { - metrics.addProperty(MetricType.resptime.name(), instanceMetricUIDAO.getRespTimeMetric(instanceId, timeBucket)); } else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) { metrics.add(MetricType.heapmemory.name(), memoryMetricDAO.getMetric(instanceId, timeBucket, true)); } else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) { @@ -108,7 +104,6 @@ public class InstanceJVMService { JsonObject metrics = new JsonObject(); for (String metricType : metricTypes) { if (metricType.toLowerCase().equals(MetricType.cpu.name())) { - metrics.add(MetricType.cpu.name(), cpuMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket)); } else if (metricType.toLowerCase().equals(MetricType.gc.name())) { metrics.add(MetricType.gc.name(), gcMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket)); } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index 739760780..dbe4e1b83 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -28,12 +28,14 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.apache.skywalking.apm.collector.storage.ui.server.CPUTrend; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; @@ -43,16 +45,18 @@ import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; public class ServerService { private final Gson gson = new Gson(); - private final IInstanceUIDAO instanceDAO; + private final IInstanceUIDAO instanceUIDAO; + private final ICpuMetricUIDAO cpuMetricUIDAO; private final IInstanceMetricUIDAO instanceMetricUIDAO; public ServerService(ModuleManager moduleManager) { - this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); + this.instanceUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); + this.cpuMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class); this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class); } public List searchServer(String keyword, long start, long end) { - List serverInfos = instanceDAO.searchServer(keyword, start, end); + List serverInfos = instanceUIDAO.searchServer(keyword, start, end); serverInfos.forEach(serverInfo -> { if (serverInfo.getId() == Const.NONE_INSTANCE_ID) { serverInfos.remove(serverInfo); @@ -64,7 +68,7 @@ public class ServerService { } public List getAllServer(int applicationId, long start, long end) { - List serverInfos = instanceDAO.getAllServer(applicationId, start, end); + List serverInfos = instanceUIDAO.getAllServer(applicationId, start, end); buildAppServerInfo(serverInfos); return serverInfos; } @@ -86,6 +90,14 @@ public class ServerService { return throughputTrend; } + public CPUTrend getCPUTrend(int instanceId, Step step, long start, long end) throws ParseException { + CPUTrend cpuTrend = new CPUTrend(); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List trends = cpuMetricUIDAO.getCPUTrend(instanceId, step, durationPoints); + cpuTrend.setCost(trends); + return cpuTrend; + } + private void buildAppServerInfo(List serverInfos) { serverInfos.forEach(serverInfo -> { if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { From 06d5b88ee129903153388e78023016e1149cf3c0 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 31 Jan 2018 21:32:21 +0800 Subject: [PATCH 18/36] Provide the getGCTrend query. --- .../collector/storage/dao/IGCMetricUIDAO.java | 41 +----- .../collector/storage/ui/server/GCTrend.java | 16 +++ .../storage/es/dao/GCMetricEsUIDAO.java | 120 +++--------------- .../storage/h2/dao/GCMetricH2UIDAO.java | 118 +++-------------- .../apm/collector/ui/query/ServerQuery.java | 6 +- .../ui/service/InstanceJVMService.java | 2 - .../collector/ui/service/ServerService.java | 18 ++- 7 files changed, 83 insertions(+), 238 deletions(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java index 823a0f20a..66891bf96 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java @@ -18,47 +18,16 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonObject; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; /** * @author peng-yongsheng */ public interface IGCMetricUIDAO extends DAO { + List getYoungGCTrend(int instanceId, Step step, List durationPoints); - GCCount getGCCount(long[] timeBuckets, int instanceId); - - JsonObject getMetric(int instanceId, long timeBucket); - - JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket); - - class GCCount { - private int young; - private int old; - private int full; - - public int getYoung() { - return young; - } - - public int getOld() { - return old; - } - - public int getFull() { - return full; - } - - public void setYoung(int young) { - this.young = young; - } - - public void setOld(int old) { - this.old = old; - } - - public void setFull(int full) { - this.full = full; - } - } + List getOldGCTrend(int instanceId, Step step, List durationPoints); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java index 4880a8f44..458319479 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/GCTrend.java @@ -26,4 +26,20 @@ import java.util.List; public class GCTrend { private List youngGC; private List oldGC; + + public List getYoungGC() { + return youngGC; + } + + public void setYoungGC(List youngGC) { + this.youngGC = youngGC; + } + + public List getOldGC() { + return oldGC; + } + + public void setOldGC(List oldGC) { + this.oldGC = oldGC; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java index 75f2e7cc8..d0f921e79 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java @@ -18,137 +18,59 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.apache.skywalking.apm.network.proto.GCPhrase; -import org.elasticsearch.action.get.GetResponse; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO { - private final Logger logger = LoggerFactory.getLogger(GCMetricEsUIDAO.class); - public GCMetricEsUIDAO(ElasticSearchClient client) { super(client); } - @Override public GCCount getGCCount(long[] timeBuckets, int instanceId) { - logger.debug("get gc count, timeBuckets: {}, instanceId: {}", timeBuckets, instanceId); - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(GCMetricTable.TABLE); - searchRequestBuilder.setTypes(GCMetricTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.termQuery(GCMetricTable.COLUMN_INSTANCE_ID, instanceId)); - boolQuery.must().add(QueryBuilders.termsQuery(GCMetricTable.COLUMN_TIME_BUCKET, timeBuckets)); - - searchRequestBuilder.setQuery(boolQuery); - searchRequestBuilder.setSize(0); - searchRequestBuilder.addAggregation( - AggregationBuilders.terms(GCMetricTable.COLUMN_PHRASE).field(GCMetricTable.COLUMN_PHRASE) - .subAggregation(AggregationBuilders.sum(GCMetricTable.COLUMN_COUNT).field(GCMetricTable.COLUMN_COUNT))); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - GCCount gcCount = new GCCount(); - Terms phraseAggregation = searchResponse.getAggregations().get(GCMetricTable.COLUMN_PHRASE); - for (Terms.Bucket phraseBucket : phraseAggregation.getBuckets()) { - int phrase = phraseBucket.getKeyAsNumber().intValue(); - Sum sumAggregation = phraseBucket.getAggregations().get(GCMetricTable.COLUMN_COUNT); - int count = (int)sumAggregation.getValue(); - - if (phrase == GCPhrase.NEW_VALUE) { - gcCount.setYoung(count); - } else if (phrase == GCPhrase.OLD_VALUE) { - gcCount.setOld(count); - } - } - - return gcCount; + @Override public List getYoungGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE); } - @Override public JsonObject getMetric(int instanceId, long timeBucket) { - JsonObject response = new JsonObject(); - - String youngId = timeBucket + Const.ID_SPLIT + GCPhrase.NEW_VALUE + instanceId; - GetResponse youngResponse = getClient().prepareGet(GCMetricTable.TABLE, youngId).get(); - if (youngResponse.isExists()) { - response.addProperty("ygc", ((Number)youngResponse.getSource().get(GCMetricTable.COLUMN_COUNT)).intValue()); - } - - String oldId = timeBucket + Const.ID_SPLIT + GCPhrase.OLD_VALUE + instanceId; - GetResponse oldResponse = getClient().prepareGet(GCMetricTable.TABLE, oldId).get(); - if (oldResponse.isExists()) { - response.addProperty("ogc", ((Number)oldResponse.getSource().get(GCMetricTable.COLUMN_COUNT)).intValue()); - } - - return response; + @Override public List getOldGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE); } - @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket) { - JsonObject response = new JsonObject(); + private List getGCTrend(int instanceId, Step step, List durationPoints, int gcPhrase) { + String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE); MultiGetRequestBuilder youngPrepareMultiGet = getClient().prepareMultiGet(); - long timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String youngId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.NEW_VALUE; - youngPrepareMultiGet.add(GCMetricTable.TABLE, GCMetricTable.TABLE_TYPE, youngId); - } - while (timeBucket <= endTimeBucket); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase; + youngPrepareMultiGet.add(tableName, GCMetricTable.TABLE_TYPE, id); + }); - JsonArray youngArray = new JsonArray(); + List gcTrends = new LinkedList<>(); MultiGetResponse multiGetResponse = youngPrepareMultiGet.get(); for (MultiGetItemResponse itemResponse : multiGetResponse.getResponses()) { if (itemResponse.getResponse().isExists()) { - youngArray.add(((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_COUNT)).intValue()); + long count = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_COUNT)).longValue(); + long times = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_TIMES)).intValue(); + gcTrends.add((int)(count / times)); } else { - youngArray.add(0); + gcTrends.add(0); } } - response.add("ygc", youngArray); - MultiGetRequestBuilder oldPrepareMultiGet = getClient().prepareMultiGet(); - timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String oldId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.OLD_VALUE; - oldPrepareMultiGet.add(GCMetricTable.TABLE, GCMetricTable.TABLE_TYPE, oldId); - } - while (timeBucket <= endTimeBucket); - - JsonArray oldArray = new JsonArray(); - - multiGetResponse = oldPrepareMultiGet.get(); - for (MultiGetItemResponse itemResponse : multiGetResponse.getResponses()) { - if (itemResponse.getResponse().isExists()) { - oldArray.add(((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_COUNT)).intValue()); - } else { - oldArray.add(0); - } - } - response.add("ogc", oldArray); - - return response; + return gcTrends; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java index 4c33c3536..b8e01eccb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java @@ -18,11 +18,9 @@ package org.apache.skywalking.apm.collector.storage.h2.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; @@ -31,6 +29,9 @@ import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.apache.skywalking.apm.network.proto.GCPhrase; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,119 +42,42 @@ import org.slf4j.LoggerFactory; public class GCMetricH2UIDAO extends H2DAO implements IGCMetricUIDAO { private final Logger logger = LoggerFactory.getLogger(GCMetricH2UIDAO.class); - private static final String GET_GC_COUNT_SQL = "select {1}, sum({0}) as cnt, {1} from {2} where {3} = ? and {4} in ("; private static final String GET_GC_METRIC_SQL = "select * from {0} where {1} = ?"; public GCMetricH2UIDAO(H2Client client) { super(client); } - @Override public GCCount getGCCount(long[] timeBuckets, int instanceId) { - GCCount gcCount = new GCCount(); - H2Client client = getClient(); - String sql = GET_GC_COUNT_SQL; - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < timeBuckets.length; i++) { - builder.append("?,"); - } - builder.delete(builder.length() - 1, builder.length()); - builder.append(")"); - sql = sql + builder + " group by {1}"; - sql = SqlBuilder.buildSql(sql, GCMetricTable.COLUMN_COUNT, GCMetricTable.COLUMN_PHRASE, - GCMetricTable.TABLE, GCMetricTable.COLUMN_INSTANCE_ID, GCMetricTable.COLUMN_ID); - Object[] params = new Object[timeBuckets.length + 1]; - for (int i = 0; i < timeBuckets.length; i++) { - params[i + 1] = timeBuckets[i]; - } - params[0] = instanceId; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - int phrase = rs.getInt(GCMetricTable.COLUMN_PHRASE); - int count = rs.getInt("cnt"); - - if (phrase == GCPhrase.NEW_VALUE) { - gcCount.setYoung(count); - } else if (phrase == GCPhrase.OLD_VALUE) { - gcCount.setOld(count); - } - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return gcCount; + @Override public List getYoungGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE); } - @Override public JsonObject getMetric(int instanceId, long timeBucket) { - JsonObject response = new JsonObject(); - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_GC_METRIC_SQL, GCMetricTable.TABLE, GCMetricTable.COLUMN_ID); - String youngId = timeBucket + Const.ID_SPLIT + GCPhrase.NEW_VALUE + instanceId; - Object[] params = new Object[] {youngId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - response.addProperty("ygc", rs.getInt(GCMetricTable.COLUMN_COUNT)); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - String oldId = timeBucket + Const.ID_SPLIT + GCPhrase.OLD_VALUE + instanceId; - Object[] params1 = new Object[] {oldId}; - try (ResultSet rs = client.executeQuery(sql, params1)) { - if (rs.next()) { - response.addProperty("ogc", rs.getInt(GCMetricTable.COLUMN_COUNT)); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - - return response; + @Override public List getOldGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE); } - @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket) { - JsonObject response = new JsonObject(); + private List getGCTrend(int instanceId, Step step, List durationPoints, int gcPhrase) { + String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE); + H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_GC_METRIC_SQL, GCMetricTable.TABLE, GCMetricTable.COLUMN_ID); - long timeBucket = startTimeBucket; - List youngIdsList = new ArrayList<>(); - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String youngId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.NEW_VALUE; - youngIdsList.add(youngId); - } - while (timeBucket <= endTimeBucket); + String sql = SqlBuilder.buildSql(GET_GC_METRIC_SQL, tableName, GCMetricTable.COLUMN_ID); - JsonArray youngArray = new JsonArray(); - forEachRs(client, youngIdsList, sql, youngArray); - response.add("ygc", youngArray); - - List oldIdsList = new ArrayList<>(); - timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String oldId = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + GCPhrase.OLD_VALUE; - oldIdsList.add(oldId); - } - while (timeBucket <= endTimeBucket); - - JsonArray oldArray = new JsonArray(); - forEachRs(client, oldIdsList, sql, oldArray); - response.add("ogc", oldArray); - - return response; - } - - private void forEachRs(H2Client client, List idsList, String sql, JsonArray metricArray) { - idsList.forEach(id -> { + List gcTrends = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase; try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { if (rs.next()) { - metricArray.add(rs.getInt(GCMetricTable.COLUMN_COUNT)); + long count = rs.getLong(GCMetricTable.COLUMN_COUNT); + long times = rs.getLong(GCMetricTable.COLUMN_TIMES); + gcTrends.add((int)(count / times)); } else { - metricArray.add(0); + gcTrends.add(0); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } }); + + return gcTrends; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java index 965848baa..c5dcf4654 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -82,8 +82,10 @@ public class ServerQuery implements Query { return getServerService().getCPUTrend(serverId, duration.getStep(), start, end); } - public GCTrend getGCTrend(int serverId, Duration duration) { - return null; + public GCTrend getGCTrend(int serverId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getGCTrend(serverId, duration.getStep(), start, end); } public MemoryTrend getMemoryTrend(int serverId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java index ca1b03c7f..a49564726 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java @@ -75,7 +75,6 @@ public class InstanceJVMService { for (String metricType : metricTypes) { if (metricType.toLowerCase().equals(MetricType.cpu.name())) { } else if (metricType.toLowerCase().equals(MetricType.gc.name())) { - metrics.add(MetricType.gc.name(), gcMetricDAO.getMetric(instanceId, timeBucket)); } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { } else if (metricType.toLowerCase().equals(MetricType.resptime.name())) { } else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) { @@ -105,7 +104,6 @@ public class InstanceJVMService { for (String metricType : metricTypes) { if (metricType.toLowerCase().equals(MetricType.cpu.name())) { } else if (metricType.toLowerCase().equals(MetricType.gc.name())) { - metrics.add(MetricType.gc.name(), gcMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket)); } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { } else if (metricType.toLowerCase().equals(MetricType.resptime.name())) { } else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index dbe4e1b83..bc3cac1da 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -29,6 +29,7 @@ import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; @@ -36,6 +37,7 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.ui.server.CPUTrend; +import org.apache.skywalking.apm.collector.storage.ui.server.GCTrend; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; @@ -46,13 +48,15 @@ public class ServerService { private final Gson gson = new Gson(); private final IInstanceUIDAO instanceUIDAO; - private final ICpuMetricUIDAO cpuMetricUIDAO; private final IInstanceMetricUIDAO instanceMetricUIDAO; + private final ICpuMetricUIDAO cpuMetricUIDAO; + private final IGCMetricUIDAO gcMetricUIDAO; public ServerService(ModuleManager moduleManager) { this.instanceUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); - this.cpuMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class); this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class); + this.cpuMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class); + this.gcMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class); } public List searchServer(String keyword, long start, long end) { @@ -98,6 +102,16 @@ public class ServerService { return cpuTrend; } + public GCTrend getGCTrend(int instanceId, Step step, long start, long end) throws ParseException { + GCTrend gcTrend = new GCTrend(); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List youngGCTrend = gcMetricUIDAO.getYoungGCTrend(instanceId, step, durationPoints); + gcTrend.setYoungGC(youngGCTrend); + List oldGCTrend = gcMetricUIDAO.getOldGCTrend(instanceId, step, durationPoints); + gcTrend.setOldGC(oldGCTrend); + return gcTrend; + } + private void buildAppServerInfo(List serverInfos) { serverInfos.forEach(serverInfo -> { if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { From 474e47c9671449944fc1fa56248681683b316bc6 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 31 Jan 2018 22:00:02 +0800 Subject: [PATCH 19/36] Provide the getMemoryTrend query. --- .../provider/service/MemoryMetricService.java | 2 +- .../storage/dao/IMemoryMetricUIDAO.java | 35 ++++++++- .../storage/ui/server/MemoryTrend.java | 32 +++++++++ .../storage/es/dao/MemoryMetricEsUIDAO.java | 65 ++++++++--------- .../storage/h2/dao/MemoryMetricH2UIDAO.java | 71 +++++++------------ .../apm/collector/ui/query/ServerQuery.java | 6 +- .../ui/service/InstanceJVMService.java | 4 -- .../collector/ui/service/ServerService.java | 22 +++++- 8 files changed, 142 insertions(+), 95 deletions(-) diff --git a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java index 97e1d7fd0..f1fedb22e 100644 --- a/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java +++ b/apm-collector/apm-collector-analysis/analysis-jvm/jvm-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/jvm/provider/service/MemoryMetricService.java @@ -47,7 +47,7 @@ public class MemoryMetricService implements IMemoryMetricService { @Override public void send(int instanceId, long timeBucket, boolean isHeap, long init, long max, long used, long committed) { - String metricId = instanceId + Const.ID_SPLIT + String.valueOf(isHeap); + String metricId = instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap); String id = timeBucket + Const.ID_SPLIT + metricId; MemoryMetric memoryMetric = new MemoryMetric(); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java index d2932f314..7ad16e5c5 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java @@ -18,14 +18,43 @@ package org.apache.skywalking.apm.collector.storage.dao; -import com.google.gson.JsonObject; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; /** * @author peng-yongsheng */ public interface IMemoryMetricUIDAO extends DAO { - JsonObject getMetric(int instanceId, long timeBucket, boolean isHeap); + Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints); - JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, boolean isHeap); + Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints); + + class Trend { + private List metrics; + private List maxMetrics; + + public Trend() { + this.metrics = new LinkedList<>(); + this.maxMetrics = new LinkedList<>(); + } + + public List getMetrics() { + return metrics; + } + + public void setMetrics(List metrics) { + this.metrics = metrics; + } + + public List getMaxMetrics() { + return maxMetrics; + } + + public void setMaxMetrics(List maxMetrics) { + this.maxMetrics = maxMetrics; + } + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java index bff93d542..5b7027c02 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/MemoryTrend.java @@ -28,4 +28,36 @@ public class MemoryTrend { private List maxHeap; private List noheap; private List maxNoheap; + + public List getHeap() { + return heap; + } + + public void setHeap(List heap) { + this.heap = heap; + } + + public List getMaxHeap() { + return maxHeap; + } + + public void setMaxHeap(List maxHeap) { + this.maxHeap = maxHeap; + } + + public List getNoheap() { + return noheap; + } + + public void setNoheap(List noheap) { + this.noheap = noheap; + } + + public List getMaxNoheap() { + return maxNoheap; + } + + public void setMaxNoheap(List maxNoheap) { + this.maxNoheap = maxNoheap; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java index 5bcfc5c69..628332cbc 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java @@ -18,14 +18,16 @@ package org.apache.skywalking.apm.collector.storage.es.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; -import org.elasticsearch.action.get.GetResponse; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; @@ -39,50 +41,39 @@ public class MemoryMetricEsUIDAO extends EsDAO implements IMemoryMetricUIDAO { super(client); } - @Override public JsonObject getMetric(int instanceId, long timeBucket, boolean isHeap) { - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + isHeap; - GetResponse getResponse = getClient().prepareGet(MemoryMetricTable.TABLE, id).get(); - - JsonObject metric = new JsonObject(); - if (getResponse.isExists()) { - metric.addProperty("max", ((Number)getResponse.getSource().get(MemoryMetricTable.COLUMN_MAX)).intValue()); - metric.addProperty("init", ((Number)getResponse.getSource().get(MemoryMetricTable.COLUMN_INIT)).intValue()); - metric.addProperty("used", ((Number)getResponse.getSource().get(MemoryMetricTable.COLUMN_USED)).intValue()); - } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - metric.addProperty("used", 0); - } - return metric; + @Override public Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, true); } - @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, boolean isHeap) { + @Override public Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, false); + } + + private Trend getMemoryTrend(int instanceId, Step step, List durationPoints, + boolean isHeap) { + String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE); MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); - int i = 0; - long timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + isHeap; - prepareMultiGet.add(MemoryMetricTable.TABLE, MemoryMetricTable.TABLE_TYPE, id); - } - while (timeBucket <= endTimeBucket); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap); + prepareMultiGet.add(tableName, MemoryMetricTable.TABLE_TYPE, id); + }); - JsonObject metric = new JsonObject(); - JsonArray usedMetric = new JsonArray(); + Trend trend = new Trend(); MultiGetResponse multiGetResponse = prepareMultiGet.get(); for (MultiGetItemResponse response : multiGetResponse.getResponses()) { if (response.getResponse().isExists()) { - metric.addProperty("max", ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_MAX)).longValue()); - metric.addProperty("init", ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_INIT)).longValue()); - usedMetric.add(((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_USED)).longValue()); + long max = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_MAX)).longValue(); + long used = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_USED)).longValue(); + long times = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_TIMES)).longValue(); + trend.getMetrics().add((int)(used / times)); + trend.getMaxMetrics().add((int)(max / times)); } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - usedMetric.add(0); + trend.getMetrics().add(0); + trend.getMaxMetrics().add(0); } } - metric.add("used", usedMetric); - return metric; + + return trend; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java index 01e9e5425..1bfbcfd1d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java @@ -18,19 +18,20 @@ package org.apache.skywalking.apm.collector.storage.h2.dao; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import java.sql.ResultSet; import java.sql.SQLException; -import java.util.ArrayList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -46,60 +47,40 @@ public class MemoryMetricH2UIDAO extends H2DAO implements IMemoryMetricUIDAO { super(client); } - @Override public JsonObject getMetric(int instanceId, long timeBucket, boolean isHeap) { - H2Client client = getClient(); - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + isHeap; - String sql = SqlBuilder.buildSql(GET_MEMORY_METRIC_SQL, MemoryMetricTable.TABLE, MemoryMetricTable.COLUMN_ID); - Object[] params = new Object[] {id}; - JsonObject metric = new JsonObject(); - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - metric.addProperty("max", rs.getInt(MemoryMetricTable.COLUMN_MAX)); - metric.addProperty("init", rs.getInt(MemoryMetricTable.COLUMN_INIT)); - metric.addProperty("used", rs.getInt(MemoryMetricTable.COLUMN_USED)); - } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - metric.addProperty("used", 0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return metric; + @Override public Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, true); } - @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, boolean isHeap) { + @Override public Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, false); + } + + private Trend getMemoryTrend(int instanceId, Step step, List durationPoints, + boolean isHeap) { + String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE); + H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_MEMORY_METRIC_SQL, MemoryMetricTable.TABLE, MemoryMetricTable.COLUMN_ID); - List idList = new ArrayList<>(); - long timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + isHeap; - idList.add(id); - } - while (timeBucket <= endTimeBucket); + String sql = SqlBuilder.buildSql(GET_MEMORY_METRIC_SQL, tableName, MemoryMetricTable.COLUMN_ID); - JsonObject metric = new JsonObject(); - JsonArray usedMetric = new JsonArray(); - - idList.forEach(id -> { + Trend trend = new Trend(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap); try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { if (rs.next()) { - metric.addProperty("max", rs.getLong(MemoryMetricTable.COLUMN_MAX)); - metric.addProperty("init", rs.getLong(MemoryMetricTable.COLUMN_INIT)); - usedMetric.add(rs.getLong(MemoryMetricTable.COLUMN_USED)); + long max = rs.getLong(MemoryMetricTable.COLUMN_MAX); + long used = rs.getLong(MemoryMetricTable.COLUMN_USED); + long times = rs.getLong(MemoryMetricTable.COLUMN_TIMES); + trend.getMetrics().add((int)(used / times)); + trend.getMaxMetrics().add((int)(max / times)); } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - usedMetric.add(0); + trend.getMetrics().add(0); + trend.getMaxMetrics().add(0); } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } }); - metric.add("used", usedMetric); - return metric; + return trend; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java index c5dcf4654..23e9a60a7 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServerQuery.java @@ -88,7 +88,9 @@ public class ServerQuery implements Query { return getServerService().getGCTrend(serverId, duration.getStep(), start, end); } - public MemoryTrend getMemoryTrend(int serverId, Duration duration) { - return null; + public MemoryTrend getMemoryTrend(int serverId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getMemoryTrend(serverId, duration.getStep(), start, end); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java index a49564726..7d8c4dce5 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java @@ -78,9 +78,7 @@ public class InstanceJVMService { } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { } else if (metricType.toLowerCase().equals(MetricType.resptime.name())) { } else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) { - metrics.add(MetricType.heapmemory.name(), memoryMetricDAO.getMetric(instanceId, timeBucket, true)); } else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) { - metrics.add(MetricType.nonheapmemory.name(), memoryMetricDAO.getMetric(instanceId, timeBucket, false)); } else if (metricType.toLowerCase().equals(MetricType.permgen.name())) { metrics.add(MetricType.permgen.name(), memoryPoolMetricDAO.getMetric(instanceId, timeBucket, PoolType.PERMGEN_USAGE_VALUE)); } else if (metricType.toLowerCase().equals(MetricType.metaspace.name())) { @@ -107,9 +105,7 @@ public class InstanceJVMService { } else if (metricType.toLowerCase().equals(MetricType.tps.name())) { } else if (metricType.toLowerCase().equals(MetricType.resptime.name())) { } else if (metricType.toLowerCase().equals(MetricType.heapmemory.name())) { - metrics.add(MetricType.heapmemory.name(), memoryMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, true)); } else if (metricType.toLowerCase().equals(MetricType.nonheapmemory.name())) { - metrics.add(MetricType.nonheapmemory.name(), memoryMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, false)); } else if (metricType.toLowerCase().equals(MetricType.permgen.name())) { metrics.add(MetricType.permgen.name(), memoryPoolMetricDAO.getMetric(instanceId, startTimeBucket, endTimeBucket, PoolType.PERMGEN_USAGE_VALUE)); } else if (metricType.toLowerCase().equals(MetricType.metaspace.name())) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index bc3cac1da..aafc395b3 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -32,12 +32,14 @@ import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.ui.server.CPUTrend; import org.apache.skywalking.apm.collector.storage.ui.server.GCTrend; +import org.apache.skywalking.apm.collector.storage.ui.server.MemoryTrend; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; @@ -51,12 +53,14 @@ public class ServerService { private final IInstanceMetricUIDAO instanceMetricUIDAO; private final ICpuMetricUIDAO cpuMetricUIDAO; private final IGCMetricUIDAO gcMetricUIDAO; + private final IMemoryMetricUIDAO memoryMetricUIDAO; public ServerService(ModuleManager moduleManager) { this.instanceUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); this.instanceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceMetricUIDAO.class); this.cpuMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class); this.gcMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class); + this.memoryMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricUIDAO.class); } public List searchServer(String keyword, long start, long end) { @@ -112,6 +116,20 @@ public class ServerService { return gcTrend; } + public MemoryTrend getMemoryTrend(int instanceId, Step step, long start, long end) throws ParseException { + MemoryTrend memoryTrend = new MemoryTrend(); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + IMemoryMetricUIDAO.Trend heapMemoryTrend = memoryMetricUIDAO.getHeapMemoryTrend(instanceId, step, durationPoints); + memoryTrend.setHeap(heapMemoryTrend.getMetrics()); + memoryTrend.setMaxHeap(heapMemoryTrend.getMaxMetrics()); + + IMemoryMetricUIDAO.Trend noHeapMemoryTrend = memoryMetricUIDAO.getNoHeapMemoryTrend(instanceId, step, durationPoints); + memoryTrend.setNoheap(noHeapMemoryTrend.getMetrics()); + memoryTrend.setMaxNoheap(noHeapMemoryTrend.getMaxMetrics()); + + return memoryTrend; + } + private void buildAppServerInfo(List serverInfos) { serverInfos.forEach(serverInfo -> { if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { @@ -130,9 +148,7 @@ public class ServerService { JsonArray ipv4Array = osInfoJson.get("ipv4s").getAsJsonArray(); List ipv4s = new LinkedList<>(); - ipv4Array.forEach(ipv4 -> { - ipv4s.add(ipv4.getAsString()); - }); + ipv4Array.forEach(ipv4 -> ipv4s.add(ipv4.getAsString())); serverInfo.setIpv4(ipv4s); } } From c70b1324673b80d389e11ebcda016cfb322e47da Mon Sep 17 00:00:00 2001 From: hanahmily Date: Fri, 2 Feb 2018 14:55:02 +0800 Subject: [PATCH 20/36] Add variables parse --- .../apm/collector/ui/jetty/handler/GraphQLHandler.java | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index 82f7cdf44..18799e375 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -32,6 +32,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.CollectionUtils; @@ -92,7 +93,7 @@ public class GraphQLHandler extends JettyHandler { } @Override protected JsonElement doGet(HttpServletRequest req) throws ArgumentsParseException { - return execute(req.getParameter(QUERY)); + return execute(req.getParameter(QUERY), null); } @Override protected JsonElement doPost(HttpServletRequest req) throws ArgumentsParseException, IOException { @@ -104,13 +105,14 @@ public class GraphQLHandler extends JettyHandler { } JsonObject requestJson = gson.fromJson(request, JsonObject.class); - return execute(requestJson.get(QUERY).getAsString()); + return execute(requestJson.get(QUERY).getAsString(), gson.fromJson(requestJson.get("variables"), Map.class)); } - private JsonObject execute(String request) { + private JsonObject execute(String request, Map variables) { try { - ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(request).build(); + ExecutionInput executionInput = ExecutionInput.newExecutionInput().query(request).variables(variables).build(); ExecutionResult executionResult = graphQL.execute(executionInput); + logger.info("Execution result is {}", executionResult); Object data = executionResult.getData(); List errors = executionResult.getErrors(); From cff48719754ef7992e006b21729f5e1652eb4655 Mon Sep 17 00:00:00 2001 From: hanahmily Date: Fri, 2 Feb 2018 17:09:36 +0800 Subject: [PATCH 21/36] Convert the type of data node from String to JsonObject --- .../apm/collector/ui/jetty/handler/GraphQLHandler.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index 18799e375..c66a5052c 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -118,7 +118,7 @@ public class GraphQLHandler extends JettyHandler { JsonObject jsonObject = new JsonObject(); if (data != null) { - jsonObject.addProperty(DATA, data.toString()); + jsonObject.add(DATA, gson.fromJson(gson.toJson(data), JsonObject.class)); } if (CollectionUtils.isNotEmpty(errors)) { From 7925c7b6238683b97585921e43612e6b25fbbd88 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sat, 3 Feb 2018 14:17:32 +0800 Subject: [PATCH 22/36] Provide the getClusterBrief query. --- .../NetworkAddressRegisterServiceHandler.java | 5 +- .../NetworkAddressRegisterServletHandler.java | 2 +- .../test/resources/json/dubbox-consumer.json | 2 +- .../service/INetworkAddressIDService.java | 4 +- .../NetworkAddressRegisterSerialWorker.java | 2 + .../service/NetworkAddressIDService.java | 11 +- .../standardization/ReferenceIdExchanger.java | 2 +- .../standardization/SpanIdExchanger.java | 2 +- .../apm/collector/core/util/BooleanUtils.java | 12 +- .../apm/collector/storage/StorageModule.java | 30 +-- .../dao/ui/IApplicationComponentUIDAO.java | 52 +++++ .../dao/ui/IApplicationMappingUIDAO.java | 51 +++++ .../ui/IApplicationReferenceMetricUIDAO.java | 38 ++++ .../storage/dao/ui/ICpuMetricUIDAO.java | 31 +++ .../storage/dao/ui/IGCMetricUIDAO.java | 33 +++ .../storage/dao/ui/IGlobalTraceUIDAO.java | 31 +++ .../storage/dao/ui/IInstanceMetricUIDAO.java | 34 +++ .../storage/dao/ui/IInstanceUIDAO.java | 42 ++++ .../storage/dao/ui/IMemoryMetricUIDAO.java | 60 ++++++ .../dao/ui/IMemoryPoolMetricUIDAO.java | 31 +++ .../storage/dao/ui/INetworkAddressUIDAO.java | 28 +++ .../storage/dao/ui/ISegmentCostUIDAO.java | 39 ++++ .../storage/dao/ui/ISegmentUIDAO.java | 29 +++ .../dao/ui/IServiceNameServiceUIDAO.java | 28 +++ .../dao/ui/IServiceReferenceUIDAO.java | 30 +++ .../storage/table/register/Application.java | 19 +- .../table/register/ApplicationTable.java | 1 + .../table/register/NetworkAddress.java | 9 + .../table/register/NetworkAddressTable.java | 1 + .../storage/ui/overview/ClusterBrief.java | 40 ++++ .../storage/es/StorageModuleEsProvider.java | 58 ++--- .../register/NetworkAddressRegisterEsDAO.java | 1 + .../dao/ui/ApplicationComponentEsUIDAO.java | 86 ++++++++ .../es/dao/ui/ApplicationMappingEsUIDAO.java | 81 +++++++ .../ui/ApplicationReferenceMetricEsUIDAO.java | 177 +++++++++++++++ .../storage/es/dao/ui/CpuMetricEsUIDAO.java | 66 ++++++ .../storage/es/dao/ui/GCMetricEsUIDAO.java | 76 +++++++ .../storage/es/dao/ui/GlobalTraceEsUIDAO.java | 83 +++++++ .../storage/es/dao/ui/InstanceEsUIDAO.java | 203 ++++++++++++++++++ .../es/dao/ui/InstanceMetricEsUIDAO.java | 93 ++++++++ .../es/dao/ui/MemoryMetricEsUIDAO.java | 79 +++++++ .../es/dao/ui/MemoryPoolMetricEsUIDAO.java | 87 ++++++++ .../es/dao/ui/NetworkAddressEsUIDAO.java | 49 +++++ .../storage/es/dao/ui/SegmentCostEsUIDAO.java | 122 +++++++++++ .../storage/es/dao/ui/SegmentEsUIDAO.java | 59 +++++ .../es/dao/ui/ServiceNameServiceEsUIDAO.java | 47 ++++ .../es/dao/ui/ServiceReferenceEsUIDAO.java | 115 ++++++++++ .../register/ApplicationEsTableDefine.java | 1 + .../storage/h2/StorageModuleH2Provider.java | 58 ++--- .../register/NetworkAddressRegisterH2DAO.java | 1 + .../dao/ui/ApplicationComponentH2UIDAO.java | 73 +++++++ .../h2/dao/ui/ApplicationMappingH2UIDAO.java | 73 +++++++ .../ui/ApplicationReferenceMetricH2UIDAO.java | 85 ++++++++ .../storage/h2/dao/ui/CpuMetricH2UIDAO.java | 73 +++++++ .../storage/h2/dao/ui/GCMetricH2UIDAO.java | 83 +++++++ .../storage/h2/dao/ui/GlobalTraceH2UIDAO.java | 84 ++++++++ .../storage/h2/dao/ui/InstanceH2UIDAO.java | 166 ++++++++++++++ .../h2/dao/ui/InstanceMetricH2UIDAO.java | 100 +++++++++ .../h2/dao/ui/MemoryMetricH2UIDAO.java | 86 ++++++++ .../h2/dao/ui/MemoryPoolMetricH2UIDAO.java | 105 +++++++++ .../h2/dao/ui/NetworkAddressH2UIDAO.java | 57 +++++ .../storage/h2/dao/ui/SegmentCostH2UIDAO.java | 155 +++++++++++++ .../storage/h2/dao/ui/SegmentH2UIDAO.java | 65 ++++++ .../h2/dao/ui/ServiceNameServiceH2UIDAO.java | 57 +++++ .../h2/dao/ui/ServiceReferenceH2UIDAO.java | 103 +++++++++ .../register/ApplicationH2TableDefine.java | 1 + .../ui/query/OverViewLayerQuery.java | 62 +++++- .../ui/service/ApplicationService.java | 2 +- .../service/ApplicationTopologyService.java | 6 +- .../ui/service/ClusterTopologyService.java | 86 ++++++++ .../ui/service/InstanceHealthService.java | 6 +- .../ui/service/InstanceJVMService.java | 12 +- .../ui/service/NetworkAddressService.java | 48 +++++ .../ui/service/SegmentTopService.java | 4 +- .../collector/ui/service/ServerService.java | 10 +- .../ui/service/ServiceNameService.java | 39 ++++ .../ui/service/ServiceTreeService.java | 2 +- .../apm/collector/ui/service/SpanService.java | 2 +- .../ui/service/TimeSynchronousService.java | 2 +- .../collector/ui/service/TopologyBuilder.java | 4 +- .../ui/service/TraceStackService.java | 4 +- 81 files changed, 3776 insertions(+), 120 deletions(-) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationComponentUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationMappingUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationReferenceMetricUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ICpuMetricUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGlobalTraceUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryMetricUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryPoolMetricUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/INetworkAddressUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentCostUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationComponentEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationMappingEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationReferenceMetricEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/CpuMetricEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GlobalTraceEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryMetricEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryPoolMetricEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/NetworkAddressEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationComponentH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationMappingH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationReferenceMetricH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/CpuMetricH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GlobalTraceH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryMetricH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryPoolMetricH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/NetworkAddressH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/NetworkAddressService.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java diff --git a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/NetworkAddressRegisterServiceHandler.java b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/NetworkAddressRegisterServiceHandler.java index a00de671c..c7b562514 100644 --- a/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/NetworkAddressRegisterServiceHandler.java +++ b/apm-collector/apm-collector-agent/agent-grpc/agent-grpc-provider/src/main/java/org/apache/skywalking/apm/collector/agent/grpc/provider/handler/NetworkAddressRegisterServiceHandler.java @@ -50,9 +50,8 @@ public class NetworkAddressRegisterServiceHandler extends NetworkAddressRegister ProtocolStringList addressesList = request.getAddressesList(); NetworkAddressMappings.Builder builder = NetworkAddressMappings.newBuilder(); - for (int i = 0; i < addressesList.size(); i++) { - String networkAddress = addressesList.get(i); - int addressId = networkAddressIDService.getOrCreate(networkAddress); + for (String networkAddress : addressesList) { + int addressId = networkAddressIDService.get(networkAddress); if (addressId != 0) { KeyWithIntegerValue value = KeyWithIntegerValue.newBuilder().setKey(networkAddress).setValue(addressId).build(); diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/NetworkAddressRegisterServletHandler.java b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/NetworkAddressRegisterServletHandler.java index c5768e767..14dc1efe3 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/NetworkAddressRegisterServletHandler.java +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/agent/jetty/provider/handler/NetworkAddressRegisterServletHandler.java @@ -63,7 +63,7 @@ public class NetworkAddressRegisterServletHandler extends JettyHandler { for (int i = 0; i < networkAddresses.size(); i++) { String networkAddress = networkAddresses.get(i).getAsString(); logger.debug("network address register, network address: {}", networkAddress); - int addressId = networkAddressIDService.getOrCreate(networkAddress); + int addressId = networkAddressIDService.get(networkAddress); JsonObject mapping = new JsonObject(); mapping.addProperty(ADDRESS_ID, addressId); mapping.addProperty(NETWORK_ADDRESS, networkAddress); diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json index 02f3ef8b0..1b3958992 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-consumer.json @@ -10,7 +10,7 @@ { "si": 1, //埋点编号 "tv": 1, //埋点类型(手动、入口、出口) - "lv": 1, //层(RPCFramework,Database,Http) + "lv": 2, //层(RPCFramework,Database,Http) "ps": 0, //上级埋点编号 "st": 1501858094526, //开始时间 "et": 1501858097004, //结束时间 diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/INetworkAddressIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/INetworkAddressIDService.java index 427f605bc..faa1ea16a 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/INetworkAddressIDService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-define/src/main/java/org/apache/skywalking/apm/collector/analysis/register/define/service/INetworkAddressIDService.java @@ -24,5 +24,7 @@ import org.apache.skywalking.apm.collector.core.module.Service; * @author peng-yongsheng */ public interface INetworkAddressIDService extends Service { - int getOrCreate(String networkAddress); + int create(String networkAddress, int spanLayer); + + int get(String networkAddress); } diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/NetworkAddressRegisterSerialWorker.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/NetworkAddressRegisterSerialWorker.java index 9ec551498..f11b7f7bf 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/NetworkAddressRegisterSerialWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/register/NetworkAddressRegisterSerialWorker.java @@ -62,6 +62,7 @@ public class NetworkAddressRegisterSerialWorker extends AbstractLocalAsyncWorker newNetworkAddress = new NetworkAddress(); newNetworkAddress.setId("-1"); newNetworkAddress.setAddressId(-1); + newNetworkAddress.setSpanLayer(networkAddress.getSpanLayer()); newNetworkAddress.setNetworkAddress(networkAddress.getNetworkAddress()); } else { int max = networkAddressRegisterDAO.getMaxNetworkAddressId(); @@ -70,6 +71,7 @@ public class NetworkAddressRegisterSerialWorker extends AbstractLocalAsyncWorker newNetworkAddress = new NetworkAddress(); newNetworkAddress.setId(String.valueOf(addressId)); newNetworkAddress.setAddressId(addressId); + newNetworkAddress.setSpanLayer(networkAddress.getSpanLayer()); newNetworkAddress.setNetworkAddress(networkAddress.getNetworkAddress()); } networkAddressRegisterDAO.save(newNetworkAddress); diff --git a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/NetworkAddressIDService.java b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/NetworkAddressIDService.java index ad5fc4c8b..bdf37b1bb 100644 --- a/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/NetworkAddressIDService.java +++ b/apm-collector/apm-collector-analysis/analysis-register/register-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/register/provider/service/NetworkAddressIDService.java @@ -30,16 +30,12 @@ import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddress; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ public class NetworkAddressIDService implements INetworkAddressIDService { - private final Logger logger = LoggerFactory.getLogger(NetworkAddressIDService.class); - private final ModuleManager moduleManager; private NetworkAddressCacheService networkAddressCacheService; private IApplicationIDService applicationIDService; @@ -78,7 +74,7 @@ public class NetworkAddressIDService implements INetworkAddressIDService { return this.networkAddressGraph; } - @Override public int getOrCreate(String networkAddress) { + @Override public int create(String networkAddress, int spanLayer) { int addressId = getNetworkAddressCacheService().getAddressId(networkAddress); if (addressId != 0) { @@ -95,6 +91,7 @@ public class NetworkAddressIDService implements INetworkAddressIDService { NetworkAddress newNetworkAddress = new NetworkAddress(); newNetworkAddress.setId("0"); newNetworkAddress.setNetworkAddress(networkAddress); + newNetworkAddress.setSpanLayer(spanLayer); newNetworkAddress.setAddressId(0); getNetworkAddressGraph().start(newNetworkAddress); @@ -102,4 +99,8 @@ public class NetworkAddressIDService implements INetworkAddressIDService { return 0; } + + @Override public int get(String networkAddress) { + return getNetworkAddressCacheService().getAddressId(networkAddress); + } } diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java index d3e760153..90bcbc364 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/ReferenceIdExchanger.java @@ -89,7 +89,7 @@ public class ReferenceIdExchanger implements IdExchanger { } if (standardBuilder.getNetworkAddressId() == 0 && StringUtils.isNotEmpty(standardBuilder.getNetworkAddress())) { - int networkAddressId = networkAddressIDService.getOrCreate(standardBuilder.getNetworkAddress()); + int networkAddressId = networkAddressIDService.get(standardBuilder.getNetworkAddress()); if (networkAddressId == 0) { if (logger.isDebugEnabled()) { logger.debug("network address: {} from application id: {} exchange failed", standardBuilder.getNetworkAddress(), applicationId); diff --git a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java index 13f8d6a6d..c5389a44f 100644 --- a/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java +++ b/apm-collector/apm-collector-analysis/analysis-segment-parser/segment-parser-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/segment/parser/provider/parser/standardization/SpanIdExchanger.java @@ -53,7 +53,7 @@ public class SpanIdExchanger implements IdExchanger { @Override public boolean exchange(SpanDecorator standardBuilder, int applicationId) { if (standardBuilder.getPeerId() == 0 && StringUtils.isNotEmpty(standardBuilder.getPeer())) { - int peerId = networkAddressIDService.getOrCreate(standardBuilder.getPeer()); + int peerId = networkAddressIDService.create(standardBuilder.getPeer(), standardBuilder.getSpanLayer().getNumber()); if (peerId == 0) { logger.debug("peer: {} in application: {} exchange failed", standardBuilder.getPeer(), applicationId); diff --git a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java index 24341aea0..14a767cfc 100644 --- a/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java +++ b/apm-collector/apm-collector-core/src/main/java/org/apache/skywalking/apm/collector/core/util/BooleanUtils.java @@ -25,20 +25,20 @@ import org.apache.skywalking.apm.collector.core.UnexpectedException; */ public class BooleanUtils { - public static final Integer TRUE = 1; - public static final Integer FALSE = 0; + public static final int TRUE = 1; + public static final int FALSE = 0; - public static boolean valueToBoolean(Integer value) { - if (TRUE.equals(value)) { + public static boolean valueToBoolean(int value) { + if (TRUE == value) { return true; - } else if (FALSE.equals(value)) { + } else if (FALSE == value) { return false; } else { throw new UnexpectedException("Boolean value error, must be 0 or 1"); } } - public static Integer booleanToValue(Boolean booleanValue) { + public static int booleanToValue(Boolean booleanValue) { if (booleanValue) { return TRUE; } else { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java index 769b8154f..c98f4c1e3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java @@ -22,23 +22,10 @@ import java.util.ArrayList; import java.util.List; import org.apache.skywalking.apm.collector.core.module.Module; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; @@ -115,6 +102,21 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDay import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; /** * @author peng-yongsheng @@ -232,6 +234,8 @@ public class StorageModule extends Module { private void addUiDAO(List classes) { classes.add(IInstanceUIDAO.class); + classes.add(INetworkAddressUIDAO.class); + classes.add(IServiceNameServiceUIDAO.class); classes.add(ICpuMetricUIDAO.class); classes.add(IGCMetricUIDAO.class); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationComponentUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationComponentUIDAO.java new file mode 100644 index 000000000..cfcf1dfb2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationComponentUIDAO.java @@ -0,0 +1,52 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; + +/** + * @author peng-yongsheng + */ +public interface IApplicationComponentUIDAO extends DAO { + + List load(Step step, long startTime, long endTime); + + class ApplicationComponent { + private int componentId; + private int applicationId; + + public int getComponentId() { + return componentId; + } + + public void setComponentId(int componentId) { + this.componentId = componentId; + } + + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationMappingUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationMappingUIDAO.java new file mode 100644 index 000000000..d98ca7339 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationMappingUIDAO.java @@ -0,0 +1,51 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; + +/** + * @author peng-yongsheng + */ +public interface IApplicationMappingUIDAO extends DAO { + List load(Step step, long startTime, long endTime); + + class ApplicationMapping { + private int applicationId; + private int mappingApplicationId; + + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } + + public int getMappingApplicationId() { + return mappingApplicationId; + } + + public void setMappingApplicationId(int mappingApplicationId) { + this.mappingApplicationId = mappingApplicationId; + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationReferenceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationReferenceMetricUIDAO.java new file mode 100644 index 000000000..64c984c71 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IApplicationReferenceMetricUIDAO.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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; + +/** + * @author peng-yongsheng + */ +public interface IApplicationReferenceMetricUIDAO extends DAO { + List getFrontApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource); + + List getBehindApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource); + + List getApplications(Step step, long startTime, long endTime, MetricSource metricSource); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ICpuMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ICpuMetricUIDAO.java new file mode 100644 index 000000000..30c5f4ce3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ICpuMetricUIDAO.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; + +/** + * @author peng-yongsheng + */ +public interface ICpuMetricUIDAO extends DAO { + List getCPUTrend(int instanceId, Step step, List durationPoints); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java new file mode 100644 index 000000000..062ee6814 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGCMetricUIDAO.java @@ -0,0 +1,33 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; + +/** + * @author peng-yongsheng + */ +public interface IGCMetricUIDAO extends DAO { + List getYoungGCTrend(int instanceId, Step step, List durationPoints); + + List getOldGCTrend(int instanceId, Step step, List durationPoints); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGlobalTraceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGlobalTraceUIDAO.java new file mode 100644 index 000000000..9a95a81b3 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IGlobalTraceUIDAO.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; + +/** + * @author peng-yongsheng + */ +public interface IGlobalTraceUIDAO extends DAO { + List getGlobalTraceId(String segmentId); + + List getSegmentIds(String globalTraceId); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java new file mode 100644 index 000000000..a62c07116 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java @@ -0,0 +1,34 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; + +/** + * @author peng-yongsheng + */ +public interface IInstanceMetricUIDAO extends DAO { + + List getServerTPSTrend(int instanceId, Step step, List durationPoints); + + List getResponseTimeTrend(int instanceId, Step step, List durationPoints); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceUIDAO.java new file mode 100644 index 000000000..2f713e654 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceUIDAO.java @@ -0,0 +1,42 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; + +/** + * @author peng-yongsheng + */ +public interface IInstanceUIDAO extends DAO { + Long lastHeartBeatTime(); + + Long instanceLastHeartBeatTime(long applicationInstanceId); + + List getApplications(long startTime, long endTime, int... applicationIds); + + Instance getInstance(int instanceId); + + List searchServer(String keyword, long start, long end); + + List getAllServer(int applicationId, long start, long end); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryMetricUIDAO.java new file mode 100644 index 000000000..e1da59f8b --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryMetricUIDAO.java @@ -0,0 +1,60 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; + +/** + * @author peng-yongsheng + */ +public interface IMemoryMetricUIDAO extends DAO { + Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints); + + Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints); + + class Trend { + private List metrics; + private List maxMetrics; + + public Trend() { + this.metrics = new LinkedList<>(); + this.maxMetrics = new LinkedList<>(); + } + + public List getMetrics() { + return metrics; + } + + public void setMetrics(List metrics) { + this.metrics = metrics; + } + + public List getMaxMetrics() { + return maxMetrics; + } + + public void setMaxMetrics(List maxMetrics) { + this.maxMetrics = maxMetrics; + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryPoolMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryPoolMetricUIDAO.java new file mode 100644 index 000000000..f643299b8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IMemoryPoolMetricUIDAO.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import com.google.gson.JsonObject; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; + +/** + * @author peng-yongsheng + */ +public interface IMemoryPoolMetricUIDAO extends DAO { + JsonObject getMetric(int instanceId, long timeBucket, int poolType); + + JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, int poolType); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/INetworkAddressUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/INetworkAddressUIDAO.java new file mode 100644 index 000000000..7ec591128 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/INetworkAddressUIDAO.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; + +/** + * @author peng-yongsheng + */ +public interface INetworkAddressUIDAO extends DAO { + int getNumOfSpanLayer(int spanLayer); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentCostUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentCostUIDAO.java new file mode 100644 index 000000000..7304fc768 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentCostUIDAO.java @@ -0,0 +1,39 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import com.google.gson.JsonObject; +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; + +/** + * @author peng-yongsheng + */ +public interface ISegmentCostUIDAO extends DAO { + JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, + Error error, int applicationId, List segmentIds, int limit, int from, Sort sort); + + enum Sort { + Cost, Time + } + + enum Error { + All, True, False + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentUIDAO.java new file mode 100644 index 000000000..4dbd59768 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentUIDAO.java @@ -0,0 +1,29 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.network.proto.TraceSegmentObject; + +/** + * @author peng-yongsheng + */ +public interface ISegmentUIDAO extends DAO { + TraceSegmentObject load(String segmentId); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java new file mode 100644 index 000000000..8f39dda9a --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java @@ -0,0 +1,28 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; + +/** + * @author peng-yongsheng + */ +public interface IServiceNameServiceUIDAO extends DAO { + int getCount(); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.java new file mode 100644 index 000000000..3aec0ce57 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.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.apm.collector.storage.dao.ui; + +import com.google.gson.JsonObject; +import java.util.Map; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; + +/** + * @author peng-yongsheng + */ +public interface IServiceReferenceUIDAO extends DAO { + Map load(int entryServiceId, long startTime, long endTime); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java index 3b68ddbce..f5107a163 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/Application.java @@ -39,6 +39,7 @@ public class Application extends StreamData { private static final Column[] INTEGER_COLUMNS = { new Column(ApplicationTable.COLUMN_APPLICATION_ID, new CoverOperation()), + new Column(ApplicationTable.COLUMN_LAYER, new CoverOperation()), new Column(ApplicationTable.COLUMN_ADDRESS_ID, new CoverOperation()), new Column(ApplicationTable.COLUMN_IS_ADDRESS, new CoverOperation()), }; @@ -81,19 +82,27 @@ public class Application extends StreamData { setDataInteger(0, applicationId); } - public int getAddressId() { + public int getLayer() { return getDataInteger(1); } - public void setAddressId(int addressId) { - setDataInteger(1, addressId); + public void setLayer(int layer) { + setDataInteger(1, layer); } - public int getIsAddress() { + public int getAddressId() { return getDataInteger(2); } + public void setAddressId(int addressId) { + setDataInteger(2, addressId); + } + + public int getIsAddress() { + return getDataInteger(3); + } + public void setIsAddress(int isAddress) { - setDataInteger(2, isAddress); + setDataInteger(3, isAddress); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java index abb5b5905..faa33741b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/ApplicationTable.java @@ -27,6 +27,7 @@ public class ApplicationTable extends CommonTable { public static final String TABLE = "application"; public static final String COLUMN_APPLICATION_CODE = "application_code"; public static final String COLUMN_APPLICATION_ID = "application_id"; + public static final String COLUMN_LAYER = "layer"; public static final String COLUMN_IS_ADDRESS = "is_address"; public static final String COLUMN_ADDRESS_ID = "address_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddress.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddress.java index d20c29a44..b6e6c7129 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddress.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddress.java @@ -39,6 +39,7 @@ public class NetworkAddress extends StreamData { private static final Column[] INTEGER_COLUMNS = { new Column(NetworkAddressTable.COLUMN_ADDRESS_ID, new NonOperation()), + new Column(NetworkAddressTable.COLUMN_SPAN_LAYER, new NonOperation()), }; private static final Column[] BYTE_COLUMNS = {}; @@ -78,4 +79,12 @@ public class NetworkAddress extends StreamData { public void setAddressId(Integer addressId) { setDataInteger(0, addressId); } + + public Integer getSpanLayer() { + return getDataInteger(1); + } + + public void setSpanLayer(Integer spanLayer) { + setDataInteger(1, spanLayer); + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddressTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddressTable.java index 97ffe2e76..5374fb34b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddressTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/register/NetworkAddressTable.java @@ -26,5 +26,6 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable; public class NetworkAddressTable extends CommonTable { public static final String TABLE = "network_address"; public static final String COLUMN_NETWORK_ADDRESS = "network_address"; + public static final String COLUMN_SPAN_LAYER = "span_layer"; public static final String COLUMN_ADDRESS_ID = "address_id"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.java index 41f3b8d5c..0dce69e8c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ClusterBrief.java @@ -27,4 +27,44 @@ public class ClusterBrief { private int numOfDatabase; private int numOfCache; private int numOfMQ; + + public int getNumOfApplication() { + return numOfApplication; + } + + public void setNumOfApplication(int numOfApplication) { + this.numOfApplication = numOfApplication; + } + + public int getNumOfService() { + return numOfService; + } + + public void setNumOfService(int numOfService) { + this.numOfService = numOfService; + } + + public int getNumOfDatabase() { + return numOfDatabase; + } + + public void setNumOfDatabase(int numOfDatabase) { + this.numOfDatabase = numOfDatabase; + } + + public int getNumOfCache() { + return numOfCache; + } + + public void setNumOfCache(int numOfCache) { + this.numOfCache = numOfCache; + } + + public int getNumOfMQ() { + return numOfMQ; + } + + public void setNumOfMQ(int numOfMQ) { + this.numOfMQ = numOfMQ; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index ffe10f056..7a8ec4a9d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -31,23 +31,10 @@ import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedExcepti import org.apache.skywalking.apm.collector.storage.StorageException; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; @@ -124,25 +111,27 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDay import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationComponentEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationMappingEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ApplicationReferenceMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.CpuMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.GCMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.InstanceEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.InstanceMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.MemoryMetricEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.MemoryPoolMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.SegmentCostEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.SegmentCostEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ServiceReferenceEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentDayEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentHourEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentMinuteEsPersistenceDAO; @@ -219,6 +208,21 @@ import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceD import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceHourMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceMinuteMetricEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.srmp.ServiceReferenceMonthMetricEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationComponentEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationMappingEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.ApplicationReferenceMetricEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.CpuMetricEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.GCMetricEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.GlobalTraceEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.InstanceEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.InstanceMetricEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryMetricEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryPoolMetricEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.NetworkAddressEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentCostEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceNameServiceEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -388,6 +392,8 @@ public class StorageModuleEsProvider extends ModuleProvider { private void registerUiDAO() throws ServiceNotProvidedException { this.registerServiceImplementation(IInstanceUIDAO.class, new InstanceEsUIDAO(elasticSearchClient)); + this.registerServiceImplementation(INetworkAddressUIDAO.class, new NetworkAddressEsUIDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceNameServiceUIDAO.class, new ServiceNameServiceEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(ICpuMetricUIDAO.class, new CpuMetricEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(IGCMetricUIDAO.class, new GCMetricEsUIDAO(elasticSearchClient)); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/NetworkAddressRegisterEsDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/NetworkAddressRegisterEsDAO.java index 051a8ea30..a59b6c66b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/NetworkAddressRegisterEsDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/register/NetworkAddressRegisterEsDAO.java @@ -55,6 +55,7 @@ public class NetworkAddressRegisterEsDAO extends EsDAO implements INetworkAddres Map source = new HashMap<>(); source.put(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress.getNetworkAddress()); source.put(NetworkAddressTable.COLUMN_ADDRESS_ID, networkAddress.getAddressId()); + source.put(NetworkAddressTable.COLUMN_SPAN_LAYER, networkAddress.getSpanLayer()); IndexResponse response = client.prepareIndex(NetworkAddressTable.TABLE, networkAddress.getId()).setSource(source).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE).get(); logger.debug("save network address register info, address getId: {}, network address code: {}, status: {}", networkAddress.getAddressId(), networkAddress.getNetworkAddress(), response.status().name()); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationComponentEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationComponentEsUIDAO.java new file mode 100644 index 000000000..be40e5ee2 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationComponentEsUIDAO.java @@ -0,0 +1,86 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationComponentEsUIDAO extends EsDAO implements IApplicationComponentUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationComponentEsUIDAO.class); + + public ApplicationComponentEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List load(Step step, long startTime, long endTime) { + logger.debug("application component load, start time: {}, end time: {}", startTime, endTime); + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE); + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ApplicationComponentTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationComponentTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + searchRequestBuilder.setSize(0); + + searchRequestBuilder.addAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_COMPONENT_ID).field(ApplicationComponentTable.COLUMN_COMPONENT_ID).size(100) + .subAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_APPLICATION_ID).field(ApplicationComponentTable.COLUMN_APPLICATION_ID).size(100))); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + Terms componentIdTerms = searchResponse.getAggregations().get(ApplicationComponentTable.COLUMN_COMPONENT_ID); + + List applicationComponents = new LinkedList<>(); + for (Terms.Bucket componentIdBucket : componentIdTerms.getBuckets()) { + int componentId = componentIdBucket.getKeyAsNumber().intValue(); + buildApplicationComponents(componentIdBucket, componentId, applicationComponents); + } + + return applicationComponents; + } + + private void buildApplicationComponents(Terms.Bucket componentBucket, int componentId, + List applicationComponents) { + Terms peerIdTerms = componentBucket.getAggregations().get(ApplicationComponentTable.COLUMN_APPLICATION_ID); + for (Terms.Bucket peerIdBucket : peerIdTerms.getBuckets()) { + int applicationId = peerIdBucket.getKeyAsNumber().intValue(); + + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setComponentId(componentId); + applicationComponent.setApplicationId(applicationId); + applicationComponents.add(applicationComponent); + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationMappingEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationMappingEsUIDAO.java new file mode 100644 index 000000000..227e1094f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationMappingEsUIDAO.java @@ -0,0 +1,81 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMappingUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationMappingEsUIDAO.class); + + public ApplicationMappingEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List load(Step step, long startTime, long endTime) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ApplicationMappingTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationMappingTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + searchRequestBuilder.setSize(0); + + searchRequestBuilder.addAggregation( + AggregationBuilders.terms(ApplicationMappingTable.COLUMN_APPLICATION_ID).field(ApplicationMappingTable.COLUMN_APPLICATION_ID).size(100) + .subAggregation(AggregationBuilders.terms(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID).field(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID).size(100))); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + Terms applicationIdTerms = searchResponse.getAggregations().get(ApplicationMappingTable.COLUMN_APPLICATION_ID); + + List applicationMappings = new LinkedList<>(); + for (Terms.Bucket applicationIdBucket : applicationIdTerms.getBuckets()) { + int applicationId = applicationIdBucket.getKeyAsNumber().intValue(); + Terms addressIdTerms = applicationIdBucket.getAggregations().get(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID); + for (Terms.Bucket addressIdBucket : addressIdTerms.getBuckets()) { + int addressId = addressIdBucket.getKeyAsNumber().intValue(); + + ApplicationMapping applicationMapping = new ApplicationMapping(); + applicationMapping.setApplicationId(applicationId); + applicationMapping.setMappingApplicationId(addressId); + applicationMappings.add(applicationMapping); + } + } + logger.debug("application mapping data: {}", applicationMappings.toString()); + return applicationMappings; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationReferenceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationReferenceMetricEsUIDAO.java new file mode 100644 index 000000000..8ea887e85 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ApplicationReferenceMetricEsUIDAO.java @@ -0,0 +1,177 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; +import org.elasticsearch.search.aggregations.metrics.sum.Sum; + +/** + * @author peng-yongsheng + */ +public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplicationReferenceMetricUIDAO { + + public ApplicationReferenceMetricEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List getFrontApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List nodes = new LinkedList<>(); + Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); + for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) { + int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue(); + Sum calls = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum responseTimes = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + + Call call = new Call(); + call.setSource(frontApplicationId); + call.setTarget(applicationId); + call.setCalls((int)calls.getValue()); + call.setResponseTimes((int)responseTimes.getValue()); + nodes.add(call); + } + + return nodes; + } + + @Override public List getBehindApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List nodes = new LinkedList<>(); + Terms behindApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); + for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) { + int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue(); + Sum calls = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum responseTimes = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + + Call call = new Call(); + call.setTarget(behindApplicationId); + call.setSource(applicationId); + call.setCalls((int)calls.getValue()); + call.setResponseTimes((int)responseTimes.getValue()); + nodes.add(call); + } + + return nodes; + } + + @Override public List getApplications(Step step, long startTime, long endTime, MetricSource metricSource) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100) + .subAggregation(AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List nodes = new LinkedList<>(); + Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); + for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) { + int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue(); + + Terms behindApplicationIdTerms = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); + for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) { + int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue(); + + Sum calls = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum responseTimes = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + + Call call = new Call(); + call.setResponseTimes((int)responseTimes.getValue()); + call.setSource(frontApplicationId); + call.setTarget(behindApplicationId); + call.setCalls((int)calls.getValue()); + nodes.add(call); + } + } + + return nodes; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/CpuMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/CpuMetricEsUIDAO.java new file mode 100644 index 000000000..bd07a4862 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/CpuMetricEsUIDAO.java @@ -0,0 +1,66 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.get.MultiGetItemResponse; +import org.elasticsearch.action.get.MultiGetRequestBuilder; +import org.elasticsearch.action.get.MultiGetResponse; + +/** + * @author peng-yongsheng + */ +public class CpuMetricEsUIDAO extends EsDAO implements ICpuMetricUIDAO { + + public CpuMetricEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List getCPUTrend(int instanceId, Step step, List durationPoints) { + MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, CpuMetricTable.TABLE); + + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId; + prepareMultiGet.add(tableName, CpuMetricTable.TABLE_TYPE, id); + }); + + List cpuTrends = new LinkedList<>(); + MultiGetResponse multiGetResponse = prepareMultiGet.get(); + for (MultiGetItemResponse response : multiGetResponse.getResponses()) { + if (response.getResponse().isExists()) { + double cpuUsed = ((Number)response.getResponse().getSource().get(CpuMetricTable.COLUMN_USAGE_PERCENT)).doubleValue(); + long times = ((Number)response.getResponse().getSource().get(CpuMetricTable.COLUMN_TIMES)).longValue(); + cpuTrends.add((int)((cpuUsed / times) * 100)); + } else { + cpuTrends.add(0); + } + } + return cpuTrends; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java new file mode 100644 index 000000000..d983bcd7e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GCMetricEsUIDAO.java @@ -0,0 +1,76 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.apache.skywalking.apm.network.proto.GCPhrase; +import org.elasticsearch.action.get.MultiGetItemResponse; +import org.elasticsearch.action.get.MultiGetRequestBuilder; +import org.elasticsearch.action.get.MultiGetResponse; + +/** + * @author peng-yongsheng + */ +public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO { + + public GCMetricEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List getYoungGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE); + } + + @Override public List getOldGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE); + } + + private List getGCTrend(int instanceId, Step step, List durationPoints, int gcPhrase) { + String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE); + + MultiGetRequestBuilder youngPrepareMultiGet = getClient().prepareMultiGet(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase; + youngPrepareMultiGet.add(tableName, GCMetricTable.TABLE_TYPE, id); + }); + + List gcTrends = new LinkedList<>(); + MultiGetResponse multiGetResponse = youngPrepareMultiGet.get(); + for (MultiGetItemResponse itemResponse : multiGetResponse.getResponses()) { + if (itemResponse.getResponse().isExists()) { + long count = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_COUNT)).longValue(); + long times = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_TIMES)).intValue(); + gcTrends.add((int)(count / times)); + } else { + gcTrends.add(0); + } + } + + return gcTrends; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GlobalTraceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GlobalTraceEsUIDAO.java new file mode 100644 index 000000000..f5a8bb2a9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/GlobalTraceEsUIDAO.java @@ -0,0 +1,83 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.ArrayList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class GlobalTraceEsUIDAO extends EsDAO implements IGlobalTraceUIDAO { + + private final Logger logger = LoggerFactory.getLogger(GlobalTraceEsUIDAO.class); + + public GlobalTraceEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List getGlobalTraceId(String segmentId) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(GlobalTraceTable.TABLE); + searchRequestBuilder.setTypes(GlobalTraceTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setQuery(QueryBuilders.termQuery(GlobalTraceTable.COLUMN_SEGMENT_ID, segmentId)); + searchRequestBuilder.setSize(10); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List globalTraceIds = new ArrayList<>(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + for (SearchHit searchHit : searchHits) { + String globalTraceId = (String)searchHit.getSource().get(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID); + logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); + globalTraceIds.add(globalTraceId); + } + return globalTraceIds; + } + + @Override public List getSegmentIds(String globalTraceId) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(GlobalTraceTable.TABLE); + searchRequestBuilder.setTypes(GlobalTraceTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setQuery(QueryBuilders.termQuery(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, globalTraceId)); + searchRequestBuilder.setSize(10); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List segmentIds = new ArrayList<>(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + for (SearchHit searchHit : searchHits) { + String segmentId = (String)searchHit.getSource().get(GlobalTraceTable.COLUMN_SEGMENT_ID); + logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); + segmentIds.add(segmentId); + } + return segmentIds; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java new file mode 100644 index 000000000..d34f3a0e9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java @@ -0,0 +1,203 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; +import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.elasticsearch.action.get.GetRequestBuilder; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.AbstractQueryBuilder; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount; +import org.elasticsearch.search.sort.SortBuilders; +import org.elasticsearch.search.sort.SortMode; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceEsUIDAO.class); + + public InstanceEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public Long lastHeartBeatTime() { + long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; + fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); + RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gt(fiveMinuteBefore); + return heartBeatTime(rangeQueryBuilder); + } + + @Override public Long instanceLastHeartBeatTime(long applicationInstanceId) { + long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; + fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); + + BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); + boolQueryBuilder.must(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gt(fiveMinuteBefore)); + boolQueryBuilder.must(QueryBuilders.termQuery(InstanceTable.COLUMN_INSTANCE_ID, applicationInstanceId)); + return heartBeatTime(boolQueryBuilder); + } + + private Long heartBeatTime(AbstractQueryBuilder queryBuilder) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); + searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setQuery(queryBuilder); + searchRequestBuilder.setSize(1); + searchRequestBuilder.setFetchSource(InstanceTable.COLUMN_HEARTBEAT_TIME, null); + searchRequestBuilder.addSort(SortBuilders.fieldSort(InstanceTable.COLUMN_HEARTBEAT_TIME).sortMode(SortMode.MAX)); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + + Long heartBeatTime = 0L; + for (SearchHit searchHit : searchHits) { + heartBeatTime = (Long)searchHit.getSource().get(InstanceTable.COLUMN_HEARTBEAT_TIME); + logger.debug("heartBeatTime: {}", heartBeatTime); + heartBeatTime = heartBeatTime - 5; + } + return heartBeatTime; + } + + @Override public List getApplications(long startTime, long endTime, int... applicationIds) { + logger.debug("application list get, start time: {}, end time: {}", startTime, endTime); + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); + searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + boolQueryBuilder.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startTime)); + boolQueryBuilder.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); + if (applicationIds.length > 0) { + boolQueryBuilder.must().add(QueryBuilders.termsQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationIds)); + } + + searchRequestBuilder.setQuery(boolQueryBuilder); + searchRequestBuilder.setSize(0); + searchRequestBuilder.addAggregation(AggregationBuilders.terms(InstanceTable.COLUMN_APPLICATION_ID).field(InstanceTable.COLUMN_APPLICATION_ID).size(100) + .subAggregation(AggregationBuilders.count(InstanceTable.COLUMN_INSTANCE_ID).field(InstanceTable.COLUMN_INSTANCE_ID))); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + Terms genders = searchResponse.getAggregations().get(InstanceTable.COLUMN_APPLICATION_ID); + + List applications = new LinkedList<>(); + for (Terms.Bucket applicationsBucket : genders.getBuckets()) { + Integer applicationId = applicationsBucket.getKeyAsNumber().intValue(); + logger.debug("applicationId: {}", applicationId); + + ValueCount instanceCount = applicationsBucket.getAggregations().get(InstanceTable.COLUMN_INSTANCE_ID); + + Application application = new Application(); + application.setId(applicationId); + application.setNumOfServer((int)instanceCount.getValue()); + applications.add(application); + } + return applications; + } + + @Override public Instance getInstance(int instanceId) { + logger.debug("get instance info, instance id: {}", instanceId); + GetRequestBuilder requestBuilder = getClient().prepareGet(InstanceTable.TABLE, String.valueOf(instanceId)); + GetResponse getResponse = requestBuilder.get(); + if (getResponse.isExists()) { + Instance instance = new Instance(); + instance.setId(getResponse.getId()); + instance.setApplicationId(((Number)getResponse.getSource().get(InstanceTable.COLUMN_APPLICATION_ID)).intValue()); + instance.setAgentUUID((String)getResponse.getSource().get(InstanceTable.COLUMN_AGENT_UUID)); + instance.setRegisterTime(((Number)getResponse.getSource().get(InstanceTable.COLUMN_REGISTER_TIME)).longValue()); + instance.setHeartBeatTime(((Number)getResponse.getSource().get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue()); + instance.setOsInfo((String)getResponse.getSource().get(InstanceTable.COLUMN_OS_INFO)); + return instance; + } + return null; + } + + @Override public List searchServer(String keyword, long start, long end) { + logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); + searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setSize(1000); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end)); + if (StringUtils.isNotEmpty(keyword)) { + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_OS_INFO, keyword)); + } + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); + searchRequestBuilder.setQuery(boolQuery); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + + return buildAppServerInfo(searchHits); + } + + @Override public List getAllServer(int applicationId, long start, long end) { + logger.debug("get instances info, applicationId: {}, start: {}, end: {}", applicationId, start, end); + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); + searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setSize(1000); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end)); + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); + searchRequestBuilder.setQuery(boolQuery); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + + return buildAppServerInfo(searchHits); + } + + private List buildAppServerInfo(SearchHit[] searchHits) { + List appServerInfos = new LinkedList<>(); + for (SearchHit searchHit : searchHits) { + AppServerInfo appServerInfo = new AppServerInfo(); + appServerInfo.setId(((Number)searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID)).intValue()); + appServerInfo.setOsInfo((String)searchHit.getSource().get(InstanceTable.COLUMN_OS_INFO)); + appServerInfos.add(appServerInfo); + } + return appServerInfos; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java new file mode 100644 index 000000000..9417dd647 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java @@ -0,0 +1,93 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.get.MultiGetItemResponse; +import org.elasticsearch.action.get.MultiGetRequestBuilder; +import org.elasticsearch.action.get.MultiGetResponse; + +/** + * @author peng-yongsheng + */ +public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO { + + public InstanceMetricEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { + MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); + + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + prepareMultiGet.add(tableName, InstanceMetricTable.TABLE_TYPE, id); + }); + + List throughputTrend = new LinkedList<>(); + MultiGetResponse multiGetResponse = prepareMultiGet.get(); + + for (int i = 0; i < multiGetResponse.getResponses().length; i++) { + MultiGetItemResponse response = multiGetResponse.getResponses()[i]; + if (response.getResponse().isExists()) { + long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); + throughputTrend.add((int)(callTimes / durationPoints.get(i).getSecondsBetween())); + } else { + throughputTrend.add(0); + } + } + return throughputTrend; + } + + @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { + MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); + + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + prepareMultiGet.add(tableName, InstanceMetricTable.TABLE_TYPE, id); + }); + + List responseTimeTrends = new LinkedList<>(); + MultiGetResponse multiGetResponse = prepareMultiGet.get(); + for (MultiGetItemResponse response : multiGetResponse.getResponses()) { + if (response.getResponse().isExists()) { + long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); + long errorCallTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue(); + long durationSum = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue(); + long errorDurationSum = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue(); + responseTimeTrends.add((int)((durationSum - errorDurationSum) / (callTimes - errorCallTimes))); + } else { + responseTimeTrends.add(0); + } + } + return responseTimeTrends; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryMetricEsUIDAO.java new file mode 100644 index 000000000..66f2290d4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryMetricEsUIDAO.java @@ -0,0 +1,79 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.get.MultiGetItemResponse; +import org.elasticsearch.action.get.MultiGetRequestBuilder; +import org.elasticsearch.action.get.MultiGetResponse; + +/** + * @author peng-yongsheng + */ +public class MemoryMetricEsUIDAO extends EsDAO implements IMemoryMetricUIDAO { + + public MemoryMetricEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, true); + } + + @Override public Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, false); + } + + private Trend getMemoryTrend(int instanceId, Step step, List durationPoints, + boolean isHeap) { + String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE); + MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap); + prepareMultiGet.add(tableName, MemoryMetricTable.TABLE_TYPE, id); + }); + + Trend trend = new Trend(); + MultiGetResponse multiGetResponse = prepareMultiGet.get(); + for (MultiGetItemResponse response : multiGetResponse.getResponses()) { + if (response.getResponse().isExists()) { + long max = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_MAX)).longValue(); + long used = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_USED)).longValue(); + long times = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_TIMES)).longValue(); + trend.getMetrics().add((int)(used / times)); + trend.getMaxMetrics().add((int)(max / times)); + } else { + trend.getMetrics().add(0); + trend.getMaxMetrics().add(0); + } + } + + return trend; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryPoolMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryPoolMetricEsUIDAO.java new file mode 100644 index 000000000..2201b436f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/MemoryPoolMetricEsUIDAO.java @@ -0,0 +1,87 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; +import org.elasticsearch.action.get.GetResponse; +import org.elasticsearch.action.get.MultiGetItemResponse; +import org.elasticsearch.action.get.MultiGetRequestBuilder; +import org.elasticsearch.action.get.MultiGetResponse; + +/** + * @author peng-yongsheng + */ +public class MemoryPoolMetricEsUIDAO extends EsDAO implements IMemoryPoolMetricUIDAO { + + public MemoryPoolMetricEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public JsonObject getMetric(int instanceId, long timeBucket, int poolType) { + String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; + GetResponse getResponse = getClient().prepareGet(MemoryPoolMetricTable.TABLE, id).get(); + + JsonObject metric = new JsonObject(); + if (getResponse.isExists()) { + metric.addProperty("max", ((Number)getResponse.getSource().get(MemoryPoolMetricTable.COLUMN_MAX)).intValue()); + metric.addProperty("init", ((Number)getResponse.getSource().get(MemoryPoolMetricTable.COLUMN_INIT)).intValue()); + metric.addProperty("used", ((Number)getResponse.getSource().get(MemoryPoolMetricTable.COLUMN_USED)).intValue()); + } else { + metric.addProperty("max", 0); + metric.addProperty("init", 0); + metric.addProperty("used", 0); + } + return metric; + } + + @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, int poolType) { + MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + + long timeBucket = startTimeBucket; + do { +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); + String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; + prepareMultiGet.add(MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.TABLE_TYPE, id); + } + while (timeBucket <= endTimeBucket); + + JsonObject metric = new JsonObject(); + JsonArray usedMetric = new JsonArray(); + MultiGetResponse multiGetResponse = prepareMultiGet.get(); + for (MultiGetItemResponse response : multiGetResponse.getResponses()) { + if (response.getResponse().isExists()) { + metric.addProperty("max", ((Number)response.getResponse().getSource().get(MemoryPoolMetricTable.COLUMN_MAX)).longValue()); + metric.addProperty("init", ((Number)response.getResponse().getSource().get(MemoryPoolMetricTable.COLUMN_INIT)).longValue()); + usedMetric.add(((Number)response.getResponse().getSource().get(MemoryPoolMetricTable.COLUMN_USED)).longValue()); + } else { + metric.addProperty("max", 0); + metric.addProperty("init", 0); + usedMetric.add(0); + } + } + metric.add("used", usedMetric); + return metric; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/NetworkAddressEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/NetworkAddressEsUIDAO.java new file mode 100644 index 000000000..fa93aca55 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/NetworkAddressEsUIDAO.java @@ -0,0 +1,49 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.QueryBuilders; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressEsUIDAO extends EsDAO implements INetworkAddressUIDAO { + + public NetworkAddressEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public int getNumOfSpanLayer(int spanLayer) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(NetworkAddressTable.TABLE); + searchRequestBuilder.setTypes(NetworkAddressTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setQuery(QueryBuilders.termQuery(NetworkAddressTable.COLUMN_SPAN_LAYER, spanLayer)); + searchRequestBuilder.setSize(0); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + return (int)searchResponse.getHits().getTotalHits(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.java new file mode 100644 index 000000000..e33177881 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.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.apm.collector.storage.es.dao.ui; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.CollectionUtils; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.search.SearchHit; +import org.elasticsearch.search.sort.SortOrder; + +/** + * @author peng-yongsheng + */ +public class SegmentCostEsUIDAO extends EsDAO implements ISegmentCostUIDAO { + + public SegmentCostEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, + Error error, int applicationId, List segmentIds, int limit, int from, Sort sort) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(SegmentCostTable.TABLE); + searchRequestBuilder.setTypes(SegmentCostTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + searchRequestBuilder.setQuery(boolQueryBuilder); + List mustQueryList = boolQueryBuilder.must(); + + mustQueryList.add(QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + if (minCost != -1 || maxCost != -1) { + RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_COST); + if (minCost != -1) { + rangeQueryBuilder.gte(minCost); + } + if (maxCost != -1) { + rangeQueryBuilder.lte(maxCost); + } + boolQueryBuilder.must().add(rangeQueryBuilder); + } + if (StringUtils.isNotEmpty(operationName)) { + mustQueryList.add(QueryBuilders.matchQuery(SegmentCostTable.COLUMN_SERVICE_NAME, operationName)); + } + if (CollectionUtils.isNotEmpty(segmentIds)) { + boolQueryBuilder.must().add(QueryBuilders.termsQuery(SegmentCostTable.COLUMN_SEGMENT_ID, segmentIds.toArray(new String[0]))); + } + if (Error.True.equals(error)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, true)); + } else if (Error.False.equals(error)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, false)); + } + if (applicationId != 0) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_APPLICATION_ID, applicationId)); + } + + if (Sort.Cost.equals(sort)) { + searchRequestBuilder.addSort(SegmentCostTable.COLUMN_COST, SortOrder.DESC); + } else if (Sort.Time.equals(sort)) { + searchRequestBuilder.addSort(SegmentCostTable.COLUMN_START_TIME, SortOrder.DESC); + } + searchRequestBuilder.setSize(limit); + searchRequestBuilder.setFrom(from); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + JsonObject topSegPaging = new JsonObject(); + topSegPaging.addProperty("recordsTotal", searchResponse.getHits().totalHits); + + JsonArray topSegArray = new JsonArray(); + topSegPaging.add("data", topSegArray); + + int num = from; + for (SearchHit searchHit : searchResponse.getHits().getHits()) { + JsonObject topSegmentJson = new JsonObject(); + topSegmentJson.addProperty("num", num); + String segmentId = (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SEGMENT_ID); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_START_TIME)); + if (searchHit.getSource().containsKey(SegmentCostTable.COLUMN_END_TIME)) { + topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_END_TIME)); + } + + topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_APPLICATION_ID)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SERVICE_NAME)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_COST)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, (Boolean)searchHit.getSource().get(SegmentCostTable.COLUMN_IS_ERROR)); + + num++; + topSegArray.add(topSegmentJson); + } + + return topSegPaging; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentEsUIDAO.java new file mode 100644 index 000000000..1158ff759 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentEsUIDAO.java @@ -0,0 +1,59 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import com.google.protobuf.InvalidProtocolBufferException; +import java.util.Base64; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; +import org.apache.skywalking.apm.network.proto.TraceSegmentObject; +import org.elasticsearch.action.get.GetResponse; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class SegmentEsUIDAO extends EsDAO implements ISegmentUIDAO { + + private final Logger logger = LoggerFactory.getLogger(SegmentEsUIDAO.class); + + public SegmentEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public TraceSegmentObject load(String segmentId) { + GetResponse response = getClient().prepareGet(SegmentTable.TABLE, segmentId).get(); + Map source = response.getSource(); + String dataBinaryBase64 = (String)source.get(SegmentTable.COLUMN_DATA_BINARY); + if (StringUtils.isNotEmpty(dataBinaryBase64)) { + byte[] dataBinary = Base64.getDecoder().decode(dataBinaryBase64); + try { + return TraceSegmentObject.parseFrom(dataBinary); + } catch (InvalidProtocolBufferException e) { + logger.error(e.getMessage(), e); + } + } + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java new file mode 100644 index 000000000..67654d03d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.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.apm.collector.storage.es.dao.ui; + +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; + +/** + * @author peng-yongsheng + */ +public class ServiceNameServiceEsUIDAO extends EsDAO implements IServiceNameServiceUIDAO { + + public ServiceNameServiceEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public int getCount() { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceNameTable.TABLE); + searchRequestBuilder.setTypes(ServiceNameTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setSize(0); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + return (int)searchResponse.getHits().getTotalHits(); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java new file mode 100644 index 000000000..d78a55bbb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java @@ -0,0 +1,115 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import com.google.gson.JsonObject; +import java.util.LinkedHashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.metrics.sum.Sum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceEsUIDAO extends EsDAO implements IServiceReferenceUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceReferenceEsUIDAO.class); + + public ServiceReferenceEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override + public Map load(int entryServiceId, long startTime, long endTime) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceReferenceMetricTable.TABLE); + searchRequestBuilder.setTypes(ServiceReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + return load(searchRequestBuilder); + } + + private Map load(SearchRequestBuilder searchRequestBuilder) { + searchRequestBuilder.addAggregation(AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).size(100) + .subAggregation(AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).size(100) + .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)) + .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)) + .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)) + .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)))); + + Map serviceReferenceMap = new LinkedHashMap<>(); + + SearchResponse searchResponse = searchRequestBuilder.get(); + Terms frontServiceIdTerms = searchResponse.getAggregations().get(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); + for (Terms.Bucket frontServiceBucket : frontServiceIdTerms.getBuckets()) { + int frontServiceId = frontServiceBucket.getKeyAsNumber().intValue(); + if (frontServiceId != 0) { + parseSubAggregate(serviceReferenceMap, frontServiceBucket, frontServiceId); + } + } + + return serviceReferenceMap; + } + + private void parseSubAggregate(Map serviceReferenceMap, + Terms.Bucket frontServiceBucket, + int frontServiceId) { + Terms behindServiceIdTerms = frontServiceBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); + for (Terms.Bucket behindServiceIdBucket : behindServiceIdTerms.getBuckets()) { + int behindServiceId = behindServiceIdBucket.getKeyAsNumber().intValue(); + if (behindServiceId != 0) { + Sum calls = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum errorCalls = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + Sum durationSum = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + Sum errorDurationSum = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); + + JsonObject serviceReference = new JsonObject(); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID), frontServiceId); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID), behindServiceId); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS), (long)calls.getValue()); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS), (long)errorCalls.getValue()); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM), (long)durationSum.getValue()); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM), (long)errorDurationSum.getValue()); + + String id = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); + serviceReferenceMap.put(id, serviceReference); + } + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ApplicationEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ApplicationEsTableDefine.java index 7b9beef54..7d84a7869 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ApplicationEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ApplicationEsTableDefine.java @@ -38,6 +38,7 @@ public class ApplicationEsTableDefine extends ElasticSearchTableDefine { @Override public void initialize() { addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, ElasticSearchColumnDefine.Type.Keyword.name())); addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_LAYER, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, ElasticSearchColumnDefine.Type.Integer.name())); addColumn(new ElasticSearchColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, ElasticSearchColumnDefine.Type.Integer.name())); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index c7736d1c2..f70a8e8c2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -27,23 +27,10 @@ import org.apache.skywalking.apm.collector.core.module.ServiceNotProvidedExcepti import org.apache.skywalking.apm.collector.storage.StorageException; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; @@ -120,25 +107,27 @@ import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceDay import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceHourMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMinuteMetricPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.srmp.IServiceReferenceMonthMetricPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationComponentH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationMappingH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ApplicationReferenceMetricH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.CpuMetricH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.GCMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceMetricH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryMetricH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.MemoryPoolMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ServiceReferenceH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentDayH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentHourH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentMinuteH2PersistenceDAO; @@ -215,6 +204,21 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceD import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceHourMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceMinuteMetricH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.srmp.ServiceReferenceMonthMetricH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationComponentH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationMappingH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ApplicationReferenceMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.CpuMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.GCMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.GlobalTraceH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.InstanceH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.InstanceMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryPoolMetricH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.NetworkAddressH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentCostH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceNameServiceH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2UIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -364,6 +368,8 @@ public class StorageModuleH2Provider extends ModuleProvider { private void registerUiDAO() throws ServiceNotProvidedException { this.registerServiceImplementation(IInstanceUIDAO.class, new InstanceH2UIDAO(h2Client)); + this.registerServiceImplementation(INetworkAddressUIDAO.class, new NetworkAddressH2UIDAO(h2Client)); + this.registerServiceImplementation(IServiceNameServiceUIDAO.class, new ServiceNameServiceH2UIDAO(h2Client)); this.registerServiceImplementation(ICpuMetricUIDAO.class, new CpuMetricH2UIDAO(h2Client)); this.registerServiceImplementation(IGCMetricUIDAO.class, new GCMetricH2UIDAO(h2Client)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/NetworkAddressRegisterH2DAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/NetworkAddressRegisterH2DAO.java index 9ff6d0c8a..b0b632fac 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/NetworkAddressRegisterH2DAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/register/NetworkAddressRegisterH2DAO.java @@ -59,6 +59,7 @@ public class NetworkAddressRegisterH2DAO extends H2DAO implements INetworkAddres source.put(NetworkAddressTable.COLUMN_ID, networkAddress.getId()); source.put(NetworkAddressTable.COLUMN_NETWORK_ADDRESS, networkAddress.getNetworkAddress()); source.put(NetworkAddressTable.COLUMN_ADDRESS_ID, networkAddress.getAddressId()); + source.put(NetworkAddressTable.COLUMN_SPAN_LAYER, networkAddress.getSpanLayer()); String sql = SqlBuilder.buildBatchInsertSql(NetworkAddressTable.TABLE, source.keySet()); Object[] params = source.values().toArray(new Object[0]); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationComponentH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationComponentH2UIDAO.java new file mode 100644 index 000000000..d9cf10aef --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationComponentH2UIDAO.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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationComponentUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationComponentH2UIDAO.class); + private static final String AGGREGATE_COMPONENT_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100"; + + public ApplicationComponentH2UIDAO(H2Client client) { + super(client); + } + + @Override public List load(Step step, long startTime, long endTime) { + H2Client client = getClient(); + + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE); + + List applicationComponents = new LinkedList<>(); + String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_APPLICATION_ID, + tableName, ApplicationComponentTable.COLUMN_TIME_BUCKET); + + Object[] params = new Object[] {startTime, endTime}; + try (ResultSet rs = client.executeQuery(sql, params)) { + while (rs.next()) { + int applicationId = rs.getInt(ApplicationComponentTable.COLUMN_APPLICATION_ID); + int componentId = rs.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID); + + ApplicationComponent applicationComponent = new ApplicationComponent(); + applicationComponent.setComponentId(componentId); + applicationComponent.setApplicationId(applicationId); + applicationComponents.add(applicationComponent); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return applicationComponents; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationMappingH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationMappingH2UIDAO.java new file mode 100644 index 000000000..9669f5891 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationMappingH2UIDAO.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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMappingUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationMappingH2UIDAO.class); + private static final String APPLICATION_MAPPING_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100"; + + public ApplicationMappingH2UIDAO(H2Client client) { + super(client); + } + + @Override public List load(Step step, long startTime, long endTime) { + String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE); + + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(APPLICATION_MAPPING_SQL, ApplicationMappingTable.COLUMN_APPLICATION_ID, + ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, tableName, ApplicationMappingTable.COLUMN_TIME_BUCKET); + + List applicationMappings = new LinkedList<>(); + Object[] params = new Object[] {startTime, endTime}; + try (ResultSet rs = client.executeQuery(sql, params)) { + while (rs.next()) { + int applicationId = rs.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID); + int addressId = rs.getInt(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID); + + ApplicationMapping applicationMapping = new ApplicationMapping(); + applicationMapping.setApplicationId(applicationId); + applicationMapping.setMappingApplicationId(addressId); + applicationMappings.add(applicationMapping); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + logger.debug("node mapping data: {}", applicationMappings.toString()); + return applicationMappings; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationReferenceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationReferenceMetricH2UIDAO.java new file mode 100644 index 000000000..e9c8a707f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ApplicationReferenceMetricH2UIDAO.java @@ -0,0 +1,85 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import com.google.gson.JsonArray; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplicationReferenceMetricUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricH2UIDAO.class); + private static final String APPLICATION_REFERENCE_SQL = "select {8}, {9}, sum({0}) as {0}, sum({1}) as {1}, sum({2}) as {2}, " + + "sum({3}) as {3}, sum({4}) as {4}, sum({5}) as {5} from {6} where {7} >= ? and {7} <= ? group by {8}, {9} limit 100"; + + public ApplicationReferenceMetricH2UIDAO(H2Client client) { + super(client); + } + + @Override public List getFrontApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { + H2Client client = getClient(); + JsonArray applicationReferenceMetricArray = new JsonArray(); +// String sql = SqlBuilder.buildSql(APPLICATION_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE, +// ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE, +// ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY, +// ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, +// ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); +// +// Object[] params = new Object[] {startTime, endTime}; +// try (ResultSet rs = client.executeQuery(sql, params)) { +// while (rs.next()) { +// int frontApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); +// int behindApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); +// JsonObject nodeRefResSumObj = new JsonObject(); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S1_LTE)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S3_LTE)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_LTE)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_GT)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_ERROR)); +// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_SUMMARY)); +// nodeRefResSumArray.add(nodeRefResSumObj); +// } +// } catch (SQLException | H2ClientException e) { +// logger.error(e.getMessage(), e); +// } + return null; + } + + @Override public List getBehindApplications(Step step, int applicationId, long startTime, long endTime, + MetricSource metricSource) { + return null; + } + + @Override public List getApplications(Step step, long startTime, long endTime, MetricSource metricSource) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/CpuMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/CpuMetricH2UIDAO.java new file mode 100644 index 000000000..a044f4a0d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/CpuMetricH2UIDAO.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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class CpuMetricH2UIDAO extends H2DAO implements ICpuMetricUIDAO { + private final Logger logger = LoggerFactory.getLogger(CpuMetricH2UIDAO.class); + private static final String GET_CPU_METRIC_SQL = "select * from {0} where {1} = ?"; + + public CpuMetricH2UIDAO(H2Client client) { + super(client); + } + + @Override public List getCPUTrend(int instanceId, Step step, List durationPoints) { + H2Client client = getClient(); + String tableName = TimePyramidTableNameBuilder.build(step, CpuMetricTable.TABLE); + String sql = SqlBuilder.buildSql(GET_CPU_METRIC_SQL, tableName, CpuMetricTable.COLUMN_ID); + + List cpuTrends = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId; + + try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { + if (rs.next()) { + double cpuUsed = rs.getDouble(CpuMetricTable.COLUMN_USAGE_PERCENT); + long times = rs.getLong(CpuMetricTable.COLUMN_TIMES); + cpuTrends.add((int)((cpuUsed / times) * 100)); + } else { + cpuTrends.add(0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + + return cpuTrends; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java new file mode 100644 index 000000000..e15363a88 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GCMetricH2UIDAO.java @@ -0,0 +1,83 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.apache.skywalking.apm.network.proto.GCPhrase; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class GCMetricH2UIDAO extends H2DAO implements IGCMetricUIDAO { + + private final Logger logger = LoggerFactory.getLogger(GCMetricH2UIDAO.class); + private static final String GET_GC_METRIC_SQL = "select * from {0} where {1} = ?"; + + public GCMetricH2UIDAO(H2Client client) { + super(client); + } + + @Override public List getYoungGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE); + } + + @Override public List getOldGCTrend(int instanceId, Step step, List durationPoints) { + return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE); + } + + private List getGCTrend(int instanceId, Step step, List durationPoints, int gcPhrase) { + String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE); + + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_GC_METRIC_SQL, tableName, GCMetricTable.COLUMN_ID); + + List gcTrends = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase; + try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { + if (rs.next()) { + long count = rs.getLong(GCMetricTable.COLUMN_COUNT); + long times = rs.getLong(GCMetricTable.COLUMN_TIMES); + gcTrends.add((int)(count / times)); + } else { + gcTrends.add(0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + + return gcTrends; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GlobalTraceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GlobalTraceH2UIDAO.java new file mode 100644 index 000000000..c1cb1e56c --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/GlobalTraceH2UIDAO.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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class GlobalTraceH2UIDAO extends H2DAO implements IGlobalTraceUIDAO { + + private final Logger logger = LoggerFactory.getLogger(GlobalTraceH2UIDAO.class); + + private static final String GET_GLOBAL_TRACE_ID_SQL = "select {0} from {1} where {2} = ? limit 10"; + private static final String GET_SEGMENT_IDS_SQL = "select {0} from {1} where {2} = ? limit 10"; + + public GlobalTraceH2UIDAO(H2Client client) { + super(client); + } + + @Override public List getGlobalTraceId(String segmentId) { + List globalTraceIds = new ArrayList<>(); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_GLOBAL_TRACE_ID_SQL, GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, + GlobalTraceTable.TABLE, GlobalTraceTable.COLUMN_SEGMENT_ID); + Object[] params = new Object[] {segmentId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + while (rs.next()) { + String globalTraceId = rs.getString(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID); + logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); + globalTraceIds.add(globalTraceId); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return globalTraceIds; + } + + @Override public List getSegmentIds(String globalTraceId) { + List segmentIds = new ArrayList<>(); + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_SEGMENT_IDS_SQL, GlobalTraceTable.COLUMN_SEGMENT_ID, + GlobalTraceTable.TABLE, GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID); + Object[] params = new Object[] {globalTraceId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + while (rs.next()) { + String segmentId = rs.getString(GlobalTraceTable.COLUMN_SEGMENT_ID); + logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); + segmentIds.add(segmentId); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return segmentIds; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceH2UIDAO.java new file mode 100644 index 000000000..f80e8605d --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceH2UIDAO.java @@ -0,0 +1,166 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; +import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; +import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceH2UIDAO.class); + + public InstanceH2UIDAO(H2Client client) { + super(client); + } + + private static final String GET_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? limit 1"; + private static final String GET_INST_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? and {3} = ? limit 1"; + private static final String GET_INSTANCE_SQL = "select * from {0} where {1} = ?"; + private static final String GET_APPLICATIONS_SQL = "select {3}, count({0}) as cnt from {1} where {2} >= ? group by {3} limit 100"; + + @Override + public Long lastHeartBeatTime() { + H2Client client = getClient(); + long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; + fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); + String sql = SqlBuilder.buildSql(GET_LAST_HEARTBEAT_TIME_SQL, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME); + Object[] params = new Object[] {fiveMinuteBefore}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getLong(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0L; + } + + @Override + public Long instanceLastHeartBeatTime(long applicationInstanceId) { + H2Client client = getClient(); + long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; + fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); + String sql = SqlBuilder.buildSql(GET_INST_LAST_HEARTBEAT_TIME_SQL, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.TABLE, + InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_INSTANCE_ID); + Object[] params = new Object[] {fiveMinuteBefore, applicationInstanceId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + return rs.getLong(1); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0L; + } + + @Override + public List getApplications(long startTime, long endTime, int... applicationIds) { + H2Client client = getClient(); + List applications = new LinkedList<>(); + String sql = SqlBuilder.buildSql(GET_APPLICATIONS_SQL, InstanceTable.COLUMN_INSTANCE_ID, + InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_APPLICATION_ID); + Object[] params = new Object[] {startTime}; + try (ResultSet rs = client.executeQuery(sql, params)) { + while (rs.next()) { + Integer applicationId = rs.getInt(InstanceTable.COLUMN_APPLICATION_ID); + logger.debug("applicationId: {}", applicationId); + Application application = new Application(); + application.setId(applicationId); + application.setNumOfServer(rs.getInt("cnt")); + applications.add(application); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return applications; + } + + @Override + public Instance getInstance(int instanceId) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_INSTANCE_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID); + Object[] params = new Object[] {instanceId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + Instance instance = new Instance(); + instance.setId(rs.getString(InstanceTable.COLUMN_ID)); + instance.setApplicationId(rs.getInt(InstanceTable.COLUMN_APPLICATION_ID)); + instance.setAgentUUID(rs.getString(InstanceTable.COLUMN_AGENT_UUID)); + instance.setRegisterTime(rs.getLong(InstanceTable.COLUMN_REGISTER_TIME)); + instance.setHeartBeatTime(rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME)); + instance.setOsInfo(rs.getString(InstanceTable.COLUMN_OS_INFO)); + return instance; + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return null; + } + + @Override public List searchServer(String keyword, long start, long end) { + logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); + String dynamicSql = "select * from {0} where {1} like ? and {2} >= ? and {2} <= ? and {3} = ?"; + String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_OS_INFO, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {keyword, start, end, BooleanUtils.FALSE}; + return buildAppServerInfo(sql, params); + } + + @Override public List getAllServer(int applicationId, long start, long end) { + logger.debug("get instances info, applicationId: {}, start: {}, end: {}", applicationId, start, end); + String dynamicSql = "select * from {0} where {1} = ? and {2} >= ? and {2} <= ? and {3} = ?"; + String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); + Object[] params = new Object[] {applicationId, start, end, BooleanUtils.FALSE}; + return buildAppServerInfo(sql, params); + } + + private List buildAppServerInfo(String sql, Object[] params) { + H2Client client = getClient(); + + List appServerInfos = new LinkedList<>(); + try (ResultSet rs = client.executeQuery(sql, params)) { + while (rs.next()) { + AppServerInfo appServerInfo = new AppServerInfo(); + appServerInfo.setId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID)); + appServerInfo.setOsInfo(rs.getString(InstanceTable.COLUMN_OS_INFO)); + appServerInfos.add(appServerInfo); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return appServerInfos; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java new file mode 100644 index 000000000..cfce0db45 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java @@ -0,0 +1,100 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO { + + private final Logger logger = LoggerFactory.getLogger(InstanceMetricH2UIDAO.class); + private static final String GET_TPS_METRIC_SQL = "select * from {0} where {1} = ?"; + + public InstanceMetricH2UIDAO(H2Client client) { + super(client); + } + + @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { + H2Client client = getClient(); + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); + + String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID); + + List throughputTrend = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) { + if (rs.next()) { + long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); + throughputTrend.add((int)(callTimes / durationPoint.getSecondsBetween())); + } else { + throughputTrend.add(0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + + return throughputTrend; + } + + @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { + H2Client client = getClient(); + + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); + String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID); + + List responseTimeTrends = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) { + if (rs.next()) { + long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); + long errorCallTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + long durationSum = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + long errorDurationSum = rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM); + responseTimeTrends.add((int)((durationSum - errorDurationSum) / (callTimes - errorCallTimes))); + } else { + responseTimeTrends.add(0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + return responseTimeTrends; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryMetricH2UIDAO.java new file mode 100644 index 000000000..bc84318cf --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryMetricH2UIDAO.java @@ -0,0 +1,86 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author clevertension + */ +public class MemoryMetricH2UIDAO extends H2DAO implements IMemoryMetricUIDAO { + + private final Logger logger = LoggerFactory.getLogger(MemoryMetricH2UIDAO.class); + private static final String GET_MEMORY_METRIC_SQL = "select * from {0} where {1} =?"; + + public MemoryMetricH2UIDAO(H2Client client) { + super(client); + } + + @Override public Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, true); + } + + @Override public Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints) { + return getMemoryTrend(instanceId, step, durationPoints, false); + } + + private Trend getMemoryTrend(int instanceId, Step step, List durationPoints, + boolean isHeap) { + String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE); + + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_MEMORY_METRIC_SQL, tableName, MemoryMetricTable.COLUMN_ID); + + Trend trend = new Trend(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap); + try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { + if (rs.next()) { + long max = rs.getLong(MemoryMetricTable.COLUMN_MAX); + long used = rs.getLong(MemoryMetricTable.COLUMN_USED); + long times = rs.getLong(MemoryMetricTable.COLUMN_TIMES); + trend.getMetrics().add((int)(used / times)); + trend.getMaxMetrics().add((int)(max / times)); + } else { + trend.getMetrics().add(0); + trend.getMaxMetrics().add(0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + + return trend; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryPoolMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryPoolMetricH2UIDAO.java new file mode 100644 index 000000000..b60d49276 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/MemoryPoolMetricH2UIDAO.java @@ -0,0 +1,105 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author clevertension + */ +public class MemoryPoolMetricH2UIDAO extends H2DAO implements IMemoryPoolMetricUIDAO { + + private final Logger logger = LoggerFactory.getLogger(MemoryPoolMetricH2UIDAO.class); + private static final String GET_MEMORY_POOL_METRIC_SQL = "select * from {0} where {1} = ?"; + + public MemoryPoolMetricH2UIDAO(H2Client client) { + super(client); + } + + @Override public JsonObject getMetric(int instanceId, long timeBucket, int poolType) { + H2Client client = getClient(); + String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; + String sql = SqlBuilder.buildSql(GET_MEMORY_POOL_METRIC_SQL, MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.COLUMN_ID); + Object[] params = new Object[] {id}; + JsonObject metric = new JsonObject(); + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + metric.addProperty("max", rs.getInt(MemoryPoolMetricTable.COLUMN_MAX)); + metric.addProperty("init", rs.getInt(MemoryPoolMetricTable.COLUMN_INIT)); + metric.addProperty("used", rs.getInt(MemoryPoolMetricTable.COLUMN_USED)); + } else { + metric.addProperty("max", 0); + metric.addProperty("init", 0); + metric.addProperty("used", 0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return metric; + } + + @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, int poolType) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_MEMORY_POOL_METRIC_SQL, MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.COLUMN_ID); + List idList = new ArrayList<>(); + long timeBucket = startTimeBucket; + do { +// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); + String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; + idList.add(id); + } + while (timeBucket <= endTimeBucket); + + JsonObject metric = new JsonObject(); + JsonArray usedMetric = new JsonArray(); + + idList.forEach(id -> { + try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { + if (rs.next()) { + metric.addProperty("max", rs.getLong(MemoryPoolMetricTable.COLUMN_MAX)); + metric.addProperty("init", rs.getLong(MemoryPoolMetricTable.COLUMN_INIT)); + usedMetric.add(rs.getLong(MemoryPoolMetricTable.COLUMN_USED)); + } else { + metric.addProperty("max", 0); + metric.addProperty("init", 0); + usedMetric.add(0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + + metric.add("used", usedMetric); + return metric; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/NetworkAddressH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/NetworkAddressH2UIDAO.java new file mode 100644 index 000000000..54383f0fd --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/NetworkAddressH2UIDAO.java @@ -0,0 +1,57 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.NetworkAddressTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressH2UIDAO extends H2DAO implements INetworkAddressUIDAO { + + private final Logger logger = LoggerFactory.getLogger(NetworkAddressH2UIDAO.class); + + public NetworkAddressH2UIDAO(H2Client client) { + super(client); + } + + @Override public int getNumOfSpanLayer(int spanLayer) { + String dynamicSql = "select count({0}) as cnt from {1} where {2} = ?"; + String sql = SqlBuilder.buildSql(dynamicSql, NetworkAddressTable.COLUMN_NETWORK_ADDRESS, NetworkAddressTable.TABLE, NetworkAddressTable.COLUMN_SPAN_LAYER); + Object[] params = new Object[] {spanLayer}; + + try (ResultSet rs = getClient().executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt("cnt"); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java new file mode 100644 index 000000000..f3e0701e9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java @@ -0,0 +1,155 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import com.google.gson.JsonArray; +import com.google.gson.JsonObject; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.apache.skywalking.apm.collector.core.util.CollectionUtils; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.elasticsearch.search.sort.SortOrder; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class SegmentCostH2UIDAO extends H2DAO implements ISegmentCostUIDAO { + + private final Logger logger = LoggerFactory.getLogger(SegmentCostH2UIDAO.class); + private static final String GET_SEGMENT_COST_SQL = "select * from {0} where {1} >= ? and {1} <= ?"; + + public SegmentCostH2UIDAO(H2Client client) { + super(client); + } + + @Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, + Error error, int applicationId, List segmentIds, int limit, int from, Sort sort) { + H2Client client = getClient(); + String sql = GET_SEGMENT_COST_SQL; + List params = new ArrayList<>(); + List columns = new ArrayList<>(); + columns.add(SegmentCostTable.TABLE); + columns.add(SegmentCostTable.COLUMN_TIME_BUCKET); + params.add(startTime); + params.add(endTime); + int paramIndex = 1; + if (minCost != -1 || maxCost != -1) { + if (minCost != -1) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} >= ?"; + params.add(minCost); + columns.add(SegmentCostTable.COLUMN_COST); + } + if (maxCost != -1) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} <= ?"; + params.add(maxCost); + columns.add(SegmentCostTable.COLUMN_COST); + } + } + if (StringUtils.isNotEmpty(operationName)) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} = ?"; + params.add(operationName); + columns.add(SegmentCostTable.COLUMN_SERVICE_NAME); + } + if (CollectionUtils.isNotEmpty(segmentIds)) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} in ("; + columns.add(SegmentCostTable.COLUMN_SEGMENT_ID); + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < segmentIds.size(); i++) { + builder.append("?,"); + } + builder.delete(builder.length() - 1, builder.length()); + builder.append(")"); + sql = sql + builder; + for (String segmentId : segmentIds) { + params.add(segmentId); + } + } + if (Error.True.equals(error)) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} = ?"; + params.add(true); + columns.add(SegmentCostTable.COLUMN_IS_ERROR); + } else if (Error.False.equals(error)) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} = ?"; + params.add(false); + columns.add(SegmentCostTable.COLUMN_IS_ERROR); + } + if (applicationId != 0) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} = ?"; + params.add(applicationId); + columns.add(SegmentCostTable.COLUMN_APPLICATION_ID); + } + + if (Sort.Cost.equals(sort)) { + sql = sql + " order by " + SegmentCostTable.COLUMN_COST + " " + SortOrder.DESC; + } else if (Sort.Time.equals(sort)) { + sql = sql + " order by " + SegmentCostTable.COLUMN_START_TIME + " " + SortOrder.DESC; + } + + sql = sql + " limit " + from + "," + limit; + sql = SqlBuilder.buildSql(sql, columns); + Object[] p = params.toArray(new Object[0]); + + JsonObject topSegPaging = new JsonObject(); + + JsonArray topSegArray = new JsonArray(); + topSegPaging.add("data", topSegArray); + int cnt = 0; + int num = from; + try (ResultSet rs = client.executeQuery(sql, p)) { + while (rs.next()) { + JsonObject topSegmentJson = new JsonObject(); + topSegmentJson.addProperty("num", num); + String segmentId = rs.getString(SegmentCostTable.COLUMN_SEGMENT_ID); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, rs.getLong(SegmentCostTable.COLUMN_START_TIME)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, rs.getLong(SegmentCostTable.COLUMN_END_TIME)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, rs.getInt(SegmentCostTable.COLUMN_APPLICATION_ID)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, rs.getString(SegmentCostTable.COLUMN_SERVICE_NAME)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, rs.getLong(SegmentCostTable.COLUMN_COST)); + topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, rs.getBoolean(SegmentCostTable.COLUMN_IS_ERROR)); + + num++; + topSegArray.add(topSegmentJson); + cnt++; + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + topSegPaging.addProperty("recordsTotal", cnt); + return topSegPaging; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentH2UIDAO.java new file mode 100644 index 000000000..be52519bb --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentH2UIDAO.java @@ -0,0 +1,65 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import com.google.protobuf.InvalidProtocolBufferException; +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.network.proto.TraceSegmentObject; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class SegmentH2UIDAO extends H2DAO implements ISegmentUIDAO { + private final Logger logger = LoggerFactory.getLogger(SegmentH2UIDAO.class); + private static final String GET_SEGMENT_SQL = "select {0} from {1} where {2} = ?"; + + public SegmentH2UIDAO(H2Client client) { + super(client); + } + + @Override public TraceSegmentObject load(String segmentId) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_SEGMENT_SQL, SegmentTable.COLUMN_DATA_BINARY, + SegmentTable.TABLE, SegmentTable.COLUMN_ID); + Object[] params = new Object[] {segmentId}; + try (ResultSet rs = client.executeQuery(sql, params)) { + if (rs.next()) { + byte[] dataBinary = rs.getBytes(SegmentTable.COLUMN_DATA_BINARY); + try { + return TraceSegmentObject.parseFrom(dataBinary); + } catch (InvalidProtocolBufferException e) { + logger.error(e.getMessage(), e); + } + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java new file mode 100644 index 000000000..1c694a59e --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java @@ -0,0 +1,57 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceNameServiceH2UIDAO extends H2DAO implements IServiceNameServiceUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceNameServiceH2UIDAO.class); + + public ServiceNameServiceH2UIDAO(H2Client client) { + super(client); + } + + @Override public int getCount() { + String dynamicSql = "select count({0}) as cnt from {1}"; + String sql = SqlBuilder.buildSql(dynamicSql, ServiceNameTable.COLUMN_SERVICE_ID, ServiceNameTable.TABLE); + Object[] params = new Object[] {}; + + try (ResultSet rs = getClient().executeQuery(sql, params)) { + if (rs.next()) { + return rs.getInt("cnt"); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return 0; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java new file mode 100644 index 000000000..863191d27 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java @@ -0,0 +1,103 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import com.google.gson.JsonObject; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedHashMap; +import java.util.Map; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class ServiceReferenceH2UIDAO extends H2DAO implements IServiceReferenceUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceReferenceH2UIDAO.class); + + public ServiceReferenceH2UIDAO(H2Client client) { + super(client); + } + + private static final String GET_SRV_REF_LOAD1 = "select {3}, {4}, sum({5}) as {5}, sum({6}) as {6}, sum({7}) as {7}" + + ",sum({8}) as {8} from {0} where {1} >= ? and {1} <= ? and {2} = ? group by {3}, {4}"; + + @Override + public Map load(int entryServiceId, long startTime, long endTime) { + H2Client client = getClient(); + String sql = SqlBuilder.buildSql(GET_SRV_REF_LOAD1, ServiceReferenceMetricTable.TABLE, + ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, + ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, + ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, + ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); + Object[] params = new Object[] {startTime, endTime, entryServiceId}; + + return load(client, params, sql); + } + + private Map load(H2Client client, Object[] params, String sql) { + Map serviceReferenceMap = new LinkedHashMap<>(); + + try (ResultSet rs = client.executeQuery(sql, params)) { + while (rs.next()) { + int frontServiceId = rs.getInt(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); + parseSubAggregate(serviceReferenceMap, rs, frontServiceId); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return serviceReferenceMap; + } + + private void parseSubAggregate(Map serviceReferenceMap, ResultSet rs, + int frontServiceId) { + try { + int behindServiceId = rs.getInt(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); + if (behindServiceId != 0) { + long calls = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + long errorCalls = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + long durationSum = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + long errorDurationSum = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); + + JsonObject serviceReference = new JsonObject(); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID), frontServiceId); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID), behindServiceId); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS), calls); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS), errorCalls); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM), durationSum); + serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM), errorDurationSum); + + String id = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); + serviceReferenceMap.put(id, serviceReference); + } + } catch (SQLException e) { + logger.error(e.getMessage(), e); + } + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java index 62ef7fd27..c4bd87319 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/register/ApplicationH2TableDefine.java @@ -35,6 +35,7 @@ public class ApplicationH2TableDefine extends H2TableDefine { addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_CODE, H2ColumnDefine.Type.Varchar.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_LAYER, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_ADDRESS_ID, H2ColumnDefine.Type.Int.name())); addColumn(new H2ColumnDefine(ApplicationTable.COLUMN_IS_ADDRESS, H2ColumnDefine.Type.Int.name())); } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java index 539b3f1b9..9ac853c47 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java @@ -18,8 +18,10 @@ package org.apache.skywalking.apm.collector.ui.query; +import java.text.ParseException; import java.util.List; import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.ui.common.Duration; import org.apache.skywalking.apm.collector.storage.ui.common.Topology; import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend; @@ -28,21 +30,73 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBri import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.service.ApplicationService; +import org.apache.skywalking.apm.collector.ui.service.ClusterTopologyService; +import org.apache.skywalking.apm.collector.ui.service.NetworkAddressService; +import org.apache.skywalking.apm.collector.ui.service.ServiceNameService; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** * @author peng-yongsheng */ public class OverViewLayerQuery implements Query { + private final ModuleManager moduleManager; + private ClusterTopologyService clusterTopologyService; + private ApplicationService applicationService; + private NetworkAddressService networkAddressService; + private ServiceNameService serviceNameService; + public OverViewLayerQuery(ModuleManager moduleManager) { + this.moduleManager = moduleManager; } - public Topology getClusterTopology(Duration duration) { - return null; + private ClusterTopologyService getClusterTopologyService() { + if (ObjectUtils.isEmpty(clusterTopologyService)) { + this.clusterTopologyService = new ClusterTopologyService(moduleManager); + } + return clusterTopologyService; } - public ClusterBrief getClusterBrief(Duration duration) { - return null; + private ApplicationService getApplicationService() { + if (ObjectUtils.isEmpty(applicationService)) { + this.applicationService = new ApplicationService(moduleManager); + } + return applicationService; + } + + private NetworkAddressService getNetworkAddressService() { + if (ObjectUtils.isEmpty(networkAddressService)) { + this.networkAddressService = new NetworkAddressService(moduleManager); + } + return networkAddressService; + } + + private ServiceNameService getServiceNameService() { + if (ObjectUtils.isEmpty(serviceNameService)) { + this.serviceNameService = new ServiceNameService(moduleManager); + } + return serviceNameService; + } + + public Topology getClusterTopology(Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); + long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); + + return getClusterTopologyService().getClusterTopology(duration.getStep(), start, end); + } + + public ClusterBrief getClusterBrief(Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); + long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); + + ClusterBrief clusterBrief = new ClusterBrief(); + clusterBrief.setNumOfApplication(getApplicationService().getApplications(start, end).size()); + clusterBrief.setNumOfDatabase(getNetworkAddressService().getNumOfDatabase()); + clusterBrief.setNumOfCache(getNetworkAddressService().getNumOfCache()); + clusterBrief.setNumOfMQ(getNetworkAddressService().getNumOfMQ()); + clusterBrief.setNumOfService(getServiceNameService().getCount()); + return clusterBrief; } public AlarmTrend getAlarmTrend(Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java index 8008700e2..7f7ce816f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java @@ -23,7 +23,7 @@ import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.ui.application.Application; /** diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java index 821a435a4..fea4e0bed 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationTopologyService.java @@ -26,9 +26,9 @@ import java.util.Map; import java.util.Set; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.ui.common.Call; import org.apache.skywalking.apm.collector.storage.ui.common.Step; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java new file mode 100644 index 000000000..da98adbfe --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ClusterTopologyService.java @@ -0,0 +1,86 @@ +/* + * 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.apm.collector.ui.service; + +import java.text.ParseException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ClusterTopologyService { + + private final Logger logger = LoggerFactory.getLogger(ClusterTopologyService.class); + + private final IApplicationComponentUIDAO applicationComponentUIDAO; + private final IApplicationMappingUIDAO applicationMappingUIDAO; + private final IApplicationReferenceMetricUIDAO applicationReferenceMetricUIDAO; + private final ModuleManager moduleManager; + + public ClusterTopologyService(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + this.applicationComponentUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class); + this.applicationMappingUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationMappingUIDAO.class); + this.applicationReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMetricUIDAO.class); + } + + public Topology getClusterTopology(Step step, long startTime, long endTime) throws ParseException { + logger.debug("startTime: {}, endTime: {}", startTime, endTime); + List applicationComponents = applicationComponentUIDAO.load(step, startTime, endTime); + List applicationMappings = applicationMappingUIDAO.load(step, startTime, endTime); + + Map components = new HashMap<>(); + applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId()))); + + List callerCalls = applicationReferenceMetricUIDAO.getApplications(step, startTime, endTime, MetricSource.Caller); + callerCalls.forEach(callerCall -> callerCall.setCallType(components.get(callerCall.getTarget()))); + + List calleeCalls = applicationReferenceMetricUIDAO.getApplications(step, startTime, endTime, MetricSource.Callee); + + calleeCalls.forEach(calleeCall -> calleeCall.setCallType(components.get(calleeCall.getTarget()))); + + TopologyBuilder builder = new TopologyBuilder(moduleManager); + + long secondsBetween = DurationUtils.INSTANCE.secondsBetween(step, startTime, endTime); + Topology topology = builder.build(applicationComponents, applicationMappings, callerCalls, calleeCalls, secondsBetween); + + topology.getCalls().forEach(call -> { + long calls = call.getCalls(); + long responseTimes = call.getResponseTimes(); + call.setCallsPerSec(calls / secondsBetween); + call.setResponseTimePerSec(responseTimes / secondsBetween); + }); + return topology; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java index 718941342..5b1048b4c 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceHealthService.java @@ -24,9 +24,9 @@ import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java index 7d8c4dce5..61af75d2e 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/InstanceJVMService.java @@ -25,12 +25,12 @@ import org.apache.skywalking.apm.collector.core.UnexpectedException; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.network.proto.PoolType; import org.slf4j.Logger; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/NetworkAddressService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/NetworkAddressService.java new file mode 100644 index 000000000..ed7045365 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/NetworkAddressService.java @@ -0,0 +1,48 @@ +/* + * 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.apm.collector.ui.service; + +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; +import org.apache.skywalking.apm.network.proto.SpanLayer; + +/** + * @author peng-yongsheng + */ +public class NetworkAddressService { + + private final INetworkAddressUIDAO networkAddressUIDAO; + + public NetworkAddressService(ModuleManager moduleManager) { + this.networkAddressUIDAO = moduleManager.find(StorageModule.NAME).getService(INetworkAddressUIDAO.class); + } + + public int getNumOfDatabase() { + return networkAddressUIDAO.getNumOfSpanLayer(SpanLayer.Database_VALUE); + } + + public int getNumOfCache() { + return networkAddressUIDAO.getNumOfSpanLayer(SpanLayer.Cache_VALUE); + } + + public int getNumOfMQ() { + return networkAddressUIDAO.getNumOfSpanLayer(SpanLayer.MQ_VALUE); + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java index 7497b3de9..3d3b452f5 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java @@ -26,8 +26,8 @@ import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.CollectionUtils; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index aafc395b3..dc6b20559 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -28,11 +28,11 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ICpuMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java new file mode 100644 index 000000000..ebe66d0b2 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java @@ -0,0 +1,39 @@ +/* + * 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.apm.collector.ui.service; + +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; + +/** + * @author peng-yongsheng + */ +public class ServiceNameService { + + private final IServiceNameServiceUIDAO serviceNameServiceUIDAO; + + public ServiceNameService(ModuleManager moduleManager) { + this.serviceNameServiceUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameServiceUIDAO.class); + } + + public int getCount() { + return serviceNameServiceUIDAO.getCount(); + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java index 085120e61..64515d51a 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java @@ -30,7 +30,7 @@ import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; /** diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java index 57f118c8a..77bdefee2 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java @@ -25,7 +25,7 @@ import java.util.List; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TimeSynchronousService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TimeSynchronousService.java index 663ec3c75..d83abe06a 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TimeSynchronousService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TimeSynchronousService.java @@ -21,7 +21,7 @@ package org.apache.skywalking.apm.collector.ui.service; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java index fabdf601e..90bcd8344 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TopologyBuilder.java @@ -29,8 +29,8 @@ import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.BooleanUtils; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationMappingUIDAO; import org.apache.skywalking.apm.collector.storage.table.register.Application; import org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode; import org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java index 0c420e79a..55bb369ea 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java @@ -28,8 +28,8 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.CollectionUtils; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.util.StringUtils; From 7a175574d24a6defe5d83439eb19ad38a34ca0f9 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sat, 3 Feb 2018 14:18:10 +0800 Subject: [PATCH 23/36] Move ui dao to ui package. --- .../dao/IApplicationComponentUIDAO.java | 52 ----- .../storage/dao/IApplicationMappingUIDAO.java | 51 ----- .../dao/IApplicationReferenceMetricUIDAO.java | 36 ---- .../storage/dao/ICpuMetricUIDAO.java | 31 --- .../collector/storage/dao/IGCMetricUIDAO.java | 33 --- .../storage/dao/IGlobalTraceUIDAO.java | 31 --- .../storage/dao/IInstanceMetricUIDAO.java | 34 --- .../collector/storage/dao/IInstanceUIDAO.java | 42 ---- .../storage/dao/IMemoryMetricUIDAO.java | 60 ------ .../storage/dao/IMemoryPoolMetricUIDAO.java | 31 --- .../storage/dao/ISegmentCostUIDAO.java | 39 ---- .../collector/storage/dao/ISegmentUIDAO.java | 29 --- .../storage/dao/IServiceReferenceUIDAO.java | 30 --- .../es/dao/ApplicationComponentEsUIDAO.java | 86 -------- .../es/dao/ApplicationMappingEsUIDAO.java | 81 ------- .../ApplicationReferenceMetricEsUIDAO.java | 131 ------------ .../storage/es/dao/CpuMetricEsUIDAO.java | 66 ------ .../storage/es/dao/GCMetricEsUIDAO.java | 76 ------- .../storage/es/dao/GlobalTraceEsUIDAO.java | 83 ------- .../storage/es/dao/InstanceEsUIDAO.java | 202 ------------------ .../storage/es/dao/InstanceMetricEsUIDAO.java | 93 -------- .../storage/es/dao/MemoryMetricEsUIDAO.java | 79 ------- .../es/dao/MemoryPoolMetricEsUIDAO.java | 87 -------- .../storage/es/dao/SegmentCostEsUIDAO.java | 122 ----------- .../storage/es/dao/SegmentEsUIDAO.java | 59 ----- .../es/dao/ServiceReferenceEsUIDAO.java | 115 ---------- .../h2/dao/ApplicationComponentH2UIDAO.java | 73 ------- .../h2/dao/ApplicationMappingH2UIDAO.java | 73 ------- .../ApplicationReferenceMetricH2UIDAO.java | 81 ------- .../storage/h2/dao/CpuMetricH2UIDAO.java | 73 ------- .../storage/h2/dao/GCMetricH2UIDAO.java | 83 ------- .../storage/h2/dao/GlobalTraceH2UIDAO.java | 84 -------- .../storage/h2/dao/InstanceH2UIDAO.java | 166 -------------- .../storage/h2/dao/InstanceMetricH2UIDAO.java | 100 --------- .../storage/h2/dao/MemoryMetricH2UIDAO.java | 86 -------- .../h2/dao/MemoryPoolMetricH2UIDAO.java | 105 --------- .../storage/h2/dao/SegmentCostH2UIDAO.java | 155 -------------- .../storage/h2/dao/SegmentH2UIDAO.java | 65 ------ .../h2/dao/ServiceReferenceH2UIDAO.java | 103 --------- 39 files changed, 3026 deletions(-) delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentCostH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java deleted file mode 100644 index 903629e80..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationComponentUIDAO.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; - -/** - * @author peng-yongsheng - */ -public interface IApplicationComponentUIDAO extends DAO { - - List load(Step step, long startTime, long endTime); - - class ApplicationComponent { - private int componentId; - private int applicationId; - - public int getComponentId() { - return componentId; - } - - public void setComponentId(int componentId) { - this.componentId = componentId; - } - - public int getApplicationId() { - return applicationId; - } - - public void setApplicationId(int applicationId) { - this.applicationId = applicationId; - } - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java deleted file mode 100644 index 75e4898f6..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationMappingUIDAO.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; - -/** - * @author peng-yongsheng - */ -public interface IApplicationMappingUIDAO extends DAO { - List load(Step step, long startTime, long endTime); - - class ApplicationMapping { - private int applicationId; - private int mappingApplicationId; - - public int getApplicationId() { - return applicationId; - } - - public void setApplicationId(int applicationId) { - this.applicationId = applicationId; - } - - public int getMappingApplicationId() { - return mappingApplicationId; - } - - public void setMappingApplicationId(int mappingApplicationId) { - this.mappingApplicationId = mappingApplicationId; - } - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java deleted file mode 100644 index 505950b12..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IApplicationReferenceMetricUIDAO.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.table.MetricSource; -import org.apache.skywalking.apm.collector.storage.ui.common.Call; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; - -/** - * @author peng-yongsheng - */ -public interface IApplicationReferenceMetricUIDAO extends DAO { - List getFrontApplications(Step step, int applicationId, long startTime, long endTime, - MetricSource metricSource); - - List getBehindApplications(Step step, int applicationId, long startTime, long endTime, - MetricSource metricSource); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java deleted file mode 100644 index 592e58e14..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ICpuMetricUIDAO.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; - -/** - * @author peng-yongsheng - */ -public interface ICpuMetricUIDAO extends DAO { - List getCPUTrend(int instanceId, Step step, List durationPoints); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java deleted file mode 100644 index 66891bf96..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGCMetricUIDAO.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; - -/** - * @author peng-yongsheng - */ -public interface IGCMetricUIDAO extends DAO { - List getYoungGCTrend(int instanceId, Step step, List durationPoints); - - List getOldGCTrend(int instanceId, Step step, List durationPoints); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java deleted file mode 100644 index 731c8bbb6..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IGlobalTraceUIDAO.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; - -/** - * @author peng-yongsheng - */ -public interface IGlobalTraceUIDAO extends DAO { - List getGlobalTraceId(String segmentId); - - List getSegmentIds(String globalTraceId); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java deleted file mode 100644 index 5410d71fa..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceMetricUIDAO.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; - -/** - * @author peng-yongsheng - */ -public interface IInstanceMetricUIDAO extends DAO { - - List getServerTPSTrend(int instanceId, Step step, List durationPoints); - - List getResponseTimeTrend(int instanceId, Step step, List durationPoints); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java deleted file mode 100644 index 51177357f..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IInstanceUIDAO.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.table.register.Instance; -import org.apache.skywalking.apm.collector.storage.ui.application.Application; -import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; - -/** - * @author peng-yongsheng - */ -public interface IInstanceUIDAO extends DAO { - Long lastHeartBeatTime(); - - Long instanceLastHeartBeatTime(long applicationInstanceId); - - List getApplications(long startTime, long endTime, int... applicationIds); - - Instance getInstance(int instanceId); - - List searchServer(String keyword, long start, long end); - - List getAllServer(int applicationId, long start, long end); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java deleted file mode 100644 index 7ad16e5c5..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryMetricUIDAO.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; - -/** - * @author peng-yongsheng - */ -public interface IMemoryMetricUIDAO extends DAO { - Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints); - - Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints); - - class Trend { - private List metrics; - private List maxMetrics; - - public Trend() { - this.metrics = new LinkedList<>(); - this.maxMetrics = new LinkedList<>(); - } - - public List getMetrics() { - return metrics; - } - - public void setMetrics(List metrics) { - this.metrics = metrics; - } - - public List getMaxMetrics() { - return maxMetrics; - } - - public void setMaxMetrics(List maxMetrics) { - this.maxMetrics = maxMetrics; - } - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java deleted file mode 100644 index 2c09d124a..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IMemoryPoolMetricUIDAO.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import com.google.gson.JsonObject; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; - -/** - * @author peng-yongsheng - */ -public interface IMemoryPoolMetricUIDAO extends DAO { - JsonObject getMetric(int instanceId, long timeBucket, int poolType); - - JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, int poolType); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java deleted file mode 100644 index 101cf3715..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostUIDAO.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import com.google.gson.JsonObject; -import java.util.List; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; - -/** - * @author peng-yongsheng - */ -public interface ISegmentCostUIDAO extends DAO { - JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, - Error error, int applicationId, List segmentIds, int limit, int from, Sort sort); - - enum Sort { - Cost, Time - } - - enum Error { - All, True, False - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java deleted file mode 100644 index ba10c4ddb..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentUIDAO.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; -import org.apache.skywalking.apm.network.proto.TraceSegmentObject; - -/** - * @author peng-yongsheng - */ -public interface ISegmentUIDAO extends DAO { - TraceSegmentObject load(String segmentId); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java deleted file mode 100644 index 1ba320d82..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/IServiceReferenceUIDAO.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * 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.apm.collector.storage.dao; - -import com.google.gson.JsonObject; -import java.util.Map; -import org.apache.skywalking.apm.collector.storage.base.dao.DAO; - -/** - * @author peng-yongsheng - */ -public interface IServiceReferenceUIDAO extends DAO { - Map load(int entryServiceId, long startTime, long endTime); -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java deleted file mode 100644 index d3d8879f4..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationComponentEsUIDAO.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ApplicationComponentEsUIDAO extends EsDAO implements IApplicationComponentUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationComponentEsUIDAO.class); - - public ApplicationComponentEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public List load(Step step, long startTime, long endTime) { - logger.debug("application component load, start time: {}, end time: {}", startTime, endTime); - String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE); - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); - searchRequestBuilder.setTypes(ApplicationComponentTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationComponentTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - searchRequestBuilder.setSize(0); - - searchRequestBuilder.addAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_COMPONENT_ID).field(ApplicationComponentTable.COLUMN_COMPONENT_ID).size(100) - .subAggregation(AggregationBuilders.terms(ApplicationComponentTable.COLUMN_APPLICATION_ID).field(ApplicationComponentTable.COLUMN_APPLICATION_ID).size(100))); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - Terms componentIdTerms = searchResponse.getAggregations().get(ApplicationComponentTable.COLUMN_COMPONENT_ID); - - List applicationComponents = new LinkedList<>(); - for (Terms.Bucket componentIdBucket : componentIdTerms.getBuckets()) { - int componentId = componentIdBucket.getKeyAsNumber().intValue(); - buildApplicationComponents(componentIdBucket, componentId, applicationComponents); - } - - return applicationComponents; - } - - private void buildApplicationComponents(Terms.Bucket componentBucket, int componentId, - List applicationComponents) { - Terms peerIdTerms = componentBucket.getAggregations().get(ApplicationComponentTable.COLUMN_APPLICATION_ID); - for (Terms.Bucket peerIdBucket : peerIdTerms.getBuckets()) { - int applicationId = peerIdBucket.getKeyAsNumber().intValue(); - - ApplicationComponent applicationComponent = new ApplicationComponent(); - applicationComponent.setComponentId(componentId); - applicationComponent.setApplicationId(applicationId); - applicationComponents.add(applicationComponent); - } - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java deleted file mode 100644 index 6ffc1876d..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationMappingEsUIDAO.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ApplicationMappingEsUIDAO extends EsDAO implements IApplicationMappingUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationMappingEsUIDAO.class); - - public ApplicationMappingEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public List load(Step step, long startTime, long endTime) { - String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE); - - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); - searchRequestBuilder.setTypes(ApplicationMappingTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(QueryBuilders.rangeQuery(ApplicationMappingTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - searchRequestBuilder.setSize(0); - - searchRequestBuilder.addAggregation( - AggregationBuilders.terms(ApplicationMappingTable.COLUMN_APPLICATION_ID).field(ApplicationMappingTable.COLUMN_APPLICATION_ID).size(100) - .subAggregation(AggregationBuilders.terms(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID).field(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID).size(100))); - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - Terms applicationIdTerms = searchResponse.getAggregations().get(ApplicationMappingTable.COLUMN_APPLICATION_ID); - - List applicationMappings = new LinkedList<>(); - for (Terms.Bucket applicationIdBucket : applicationIdTerms.getBuckets()) { - int applicationId = applicationIdBucket.getKeyAsNumber().intValue(); - Terms addressIdTerms = applicationIdBucket.getAggregations().get(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID); - for (Terms.Bucket addressIdBucket : addressIdTerms.getBuckets()) { - int addressId = addressIdBucket.getKeyAsNumber().intValue(); - - ApplicationMapping applicationMapping = new ApplicationMapping(); - applicationMapping.setApplicationId(applicationId); - applicationMapping.setMappingApplicationId(addressId); - applicationMappings.add(applicationMapping); - } - } - logger.debug("application mapping data: {}", applicationMappings.toString()); - return applicationMappings; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java deleted file mode 100644 index 8a7ca9816..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ApplicationReferenceMetricEsUIDAO.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.MetricSource; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationReferenceMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Call; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; -import org.elasticsearch.search.aggregations.metrics.sum.Sum; - -/** - * @author peng-yongsheng - */ -public class ApplicationReferenceMetricEsUIDAO extends EsDAO implements IApplicationReferenceMetricUIDAO { - - public ApplicationReferenceMetricEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public List getFrontApplications(Step step, int applicationId, long startTime, long endTime, - MetricSource metricSource) { - String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE); - - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); - searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID, applicationId)); - boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); - - searchRequestBuilder.setQuery(boolQuery); - searchRequestBuilder.setSize(0); - - TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID).size(100); - aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); - aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); - - searchRequestBuilder.addAggregation(aggregationBuilder); - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - List nodes = new LinkedList<>(); - Terms frontApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); - for (Terms.Bucket frontApplicationIdBucket : frontApplicationIdTerms.getBuckets()) { - int frontApplicationId = frontApplicationIdBucket.getKeyAsNumber().intValue(); - Sum calls = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS); - Sum responseTimes = frontApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - - Call call = new Call(); - call.setSource(frontApplicationId); - call.setTarget(applicationId); - call.setCalls((int)calls.getValue()); - call.setResponseTimes((int)responseTimes.getValue()); - nodes.add(call); - } - - return nodes; - } - - @Override public List getBehindApplications(Step step, int applicationId, long startTime, long endTime, - MetricSource metricSource) { - String tableName = TimePyramidTableNameBuilder.build(step, ApplicationReferenceMetricTable.TABLE); - - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); - searchRequestBuilder.setTypes(ApplicationReferenceMetricTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, applicationId)); - boolQuery.must().add(QueryBuilders.termQuery(ApplicationReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); - - searchRequestBuilder.setQuery(boolQuery); - searchRequestBuilder.setSize(0); - - TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).field(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID).size(100); - aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); - aggregationBuilder.subAggregation(AggregationBuilders.sum(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); - - searchRequestBuilder.addAggregation(aggregationBuilder); - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - List nodes = new LinkedList<>(); - Terms behindApplicationIdTerms = searchResponse.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); - for (Terms.Bucket behindApplicationIdBucket : behindApplicationIdTerms.getBuckets()) { - int behindApplicationId = behindApplicationIdBucket.getKeyAsNumber().intValue(); - Sum calls = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_CALLS); - Sum responseTimes = behindApplicationIdBucket.getAggregations().get(ApplicationReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - - Call call = new Call(); - call.setTarget(behindApplicationId); - call.setSource(applicationId); - call.setCalls((int)calls.getValue()); - call.setResponseTimes((int)responseTimes.getValue()); - nodes.add(call); - } - - return nodes; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java deleted file mode 100644 index 21aef52d0..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/CpuMetricEsUIDAO.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.elasticsearch.action.get.MultiGetItemResponse; -import org.elasticsearch.action.get.MultiGetRequestBuilder; -import org.elasticsearch.action.get.MultiGetResponse; - -/** - * @author peng-yongsheng - */ -public class CpuMetricEsUIDAO extends EsDAO implements ICpuMetricUIDAO { - - public CpuMetricEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public List getCPUTrend(int instanceId, Step step, List durationPoints) { - MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); - String tableName = TimePyramidTableNameBuilder.build(step, CpuMetricTable.TABLE); - - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId; - prepareMultiGet.add(tableName, CpuMetricTable.TABLE_TYPE, id); - }); - - List cpuTrends = new LinkedList<>(); - MultiGetResponse multiGetResponse = prepareMultiGet.get(); - for (MultiGetItemResponse response : multiGetResponse.getResponses()) { - if (response.getResponse().isExists()) { - double cpuUsed = ((Number)response.getResponse().getSource().get(CpuMetricTable.COLUMN_USAGE_PERCENT)).doubleValue(); - long times = ((Number)response.getResponse().getSource().get(CpuMetricTable.COLUMN_TIMES)).longValue(); - cpuTrends.add((int)((cpuUsed / times) * 100)); - } else { - cpuTrends.add(0); - } - } - return cpuTrends; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java deleted file mode 100644 index d0f921e79..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GCMetricEsUIDAO.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.apache.skywalking.apm.network.proto.GCPhrase; -import org.elasticsearch.action.get.MultiGetItemResponse; -import org.elasticsearch.action.get.MultiGetRequestBuilder; -import org.elasticsearch.action.get.MultiGetResponse; - -/** - * @author peng-yongsheng - */ -public class GCMetricEsUIDAO extends EsDAO implements IGCMetricUIDAO { - - public GCMetricEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public List getYoungGCTrend(int instanceId, Step step, List durationPoints) { - return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE); - } - - @Override public List getOldGCTrend(int instanceId, Step step, List durationPoints) { - return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE); - } - - private List getGCTrend(int instanceId, Step step, List durationPoints, int gcPhrase) { - String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE); - - MultiGetRequestBuilder youngPrepareMultiGet = getClient().prepareMultiGet(); - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase; - youngPrepareMultiGet.add(tableName, GCMetricTable.TABLE_TYPE, id); - }); - - List gcTrends = new LinkedList<>(); - MultiGetResponse multiGetResponse = youngPrepareMultiGet.get(); - for (MultiGetItemResponse itemResponse : multiGetResponse.getResponses()) { - if (itemResponse.getResponse().isExists()) { - long count = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_COUNT)).longValue(); - long times = ((Number)itemResponse.getResponse().getSource().get(GCMetricTable.COLUMN_TIMES)).intValue(); - gcTrends.add((int)(count / times)); - } else { - gcTrends.add(0); - } - } - - return gcTrends; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java deleted file mode 100644 index fdf2cc661..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/GlobalTraceEsUIDAO.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.ArrayList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.SearchHit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class GlobalTraceEsUIDAO extends EsDAO implements IGlobalTraceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(GlobalTraceEsUIDAO.class); - - public GlobalTraceEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public List getGlobalTraceId(String segmentId) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(GlobalTraceTable.TABLE); - searchRequestBuilder.setTypes(GlobalTraceTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(QueryBuilders.termQuery(GlobalTraceTable.COLUMN_SEGMENT_ID, segmentId)); - searchRequestBuilder.setSize(10); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - List globalTraceIds = new ArrayList<>(); - SearchHit[] searchHits = searchResponse.getHits().getHits(); - for (SearchHit searchHit : searchHits) { - String globalTraceId = (String)searchHit.getSource().get(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID); - logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); - globalTraceIds.add(globalTraceId); - } - return globalTraceIds; - } - - @Override public List getSegmentIds(String globalTraceId) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(GlobalTraceTable.TABLE); - searchRequestBuilder.setTypes(GlobalTraceTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(QueryBuilders.termQuery(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, globalTraceId)); - searchRequestBuilder.setSize(10); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - List segmentIds = new ArrayList<>(); - SearchHit[] searchHits = searchResponse.getHits().getHits(); - for (SearchHit searchHit : searchHits) { - String segmentId = (String)searchHit.getSource().get(GlobalTraceTable.COLUMN_SEGMENT_ID); - logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); - segmentIds.add(segmentId); - } - return segmentIds; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java deleted file mode 100644 index 93291e09a..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceEsUIDAO.java +++ /dev/null @@ -1,202 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.BooleanUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.register.Instance; -import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; -import org.apache.skywalking.apm.collector.storage.ui.application.Application; -import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; -import org.elasticsearch.action.get.GetRequestBuilder; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.AbstractQueryBuilder; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.RangeQueryBuilder; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.metrics.valuecount.ValueCount; -import org.elasticsearch.search.sort.SortBuilders; -import org.elasticsearch.search.sort.SortMode; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(InstanceEsUIDAO.class); - - public InstanceEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public Long lastHeartBeatTime() { - long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; - fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); - RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gt(fiveMinuteBefore); - return heartBeatTime(rangeQueryBuilder); - } - - @Override public Long instanceLastHeartBeatTime(long applicationInstanceId) { - long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; - fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); - - BoolQueryBuilder boolQueryBuilder = new BoolQueryBuilder(); - boolQueryBuilder.must(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gt(fiveMinuteBefore)); - boolQueryBuilder.must(QueryBuilders.termQuery(InstanceTable.COLUMN_INSTANCE_ID, applicationInstanceId)); - return heartBeatTime(boolQueryBuilder); - } - - private Long heartBeatTime(AbstractQueryBuilder queryBuilder) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); - searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setQuery(queryBuilder); - searchRequestBuilder.setSize(1); - searchRequestBuilder.setFetchSource(InstanceTable.COLUMN_HEARTBEAT_TIME, null); - searchRequestBuilder.addSort(SortBuilders.fieldSort(InstanceTable.COLUMN_HEARTBEAT_TIME).sortMode(SortMode.MAX)); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - SearchHit[] searchHits = searchResponse.getHits().getHits(); - - Long heartBeatTime = 0L; - for (SearchHit searchHit : searchHits) { - heartBeatTime = (Long)searchHit.getSource().get(InstanceTable.COLUMN_HEARTBEAT_TIME); - logger.debug("heartBeatTime: {}", heartBeatTime); - heartBeatTime = heartBeatTime - 5; - } - return heartBeatTime; - } - - @Override public List getApplications(long startTime, long endTime, int... applicationIds) { - logger.debug("application list get, start time: {}, end time: {}", startTime, endTime); - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); - searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); - boolQueryBuilder.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(startTime)); - if (applicationIds.length > 0) { - boolQueryBuilder.must().add(QueryBuilders.termsQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationIds)); - } - - searchRequestBuilder.setQuery(boolQueryBuilder); - searchRequestBuilder.setSize(0); - searchRequestBuilder.addAggregation(AggregationBuilders.terms(InstanceTable.COLUMN_APPLICATION_ID).field(InstanceTable.COLUMN_APPLICATION_ID).size(100) - .subAggregation(AggregationBuilders.count(InstanceTable.COLUMN_INSTANCE_ID).field(InstanceTable.COLUMN_INSTANCE_ID))); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - Terms genders = searchResponse.getAggregations().get(InstanceTable.COLUMN_APPLICATION_ID); - - List applications = new LinkedList<>(); - for (Terms.Bucket applicationsBucket : genders.getBuckets()) { - Integer applicationId = applicationsBucket.getKeyAsNumber().intValue(); - logger.debug("applicationId: {}", applicationId); - - ValueCount instanceCount = applicationsBucket.getAggregations().get(InstanceTable.COLUMN_INSTANCE_ID); - - Application application = new Application(); - application.setId(applicationId); - application.setNumOfServer((int)instanceCount.getValue()); - applications.add(application); - } - return applications; - } - - @Override public Instance getInstance(int instanceId) { - logger.debug("get instance info, instance id: {}", instanceId); - GetRequestBuilder requestBuilder = getClient().prepareGet(InstanceTable.TABLE, String.valueOf(instanceId)); - GetResponse getResponse = requestBuilder.get(); - if (getResponse.isExists()) { - Instance instance = new Instance(); - instance.setId(getResponse.getId()); - instance.setApplicationId(((Number)getResponse.getSource().get(InstanceTable.COLUMN_APPLICATION_ID)).intValue()); - instance.setAgentUUID((String)getResponse.getSource().get(InstanceTable.COLUMN_AGENT_UUID)); - instance.setRegisterTime(((Number)getResponse.getSource().get(InstanceTable.COLUMN_REGISTER_TIME)).longValue()); - instance.setHeartBeatTime(((Number)getResponse.getSource().get(InstanceTable.COLUMN_HEARTBEAT_TIME)).longValue()); - instance.setOsInfo((String)getResponse.getSource().get(InstanceTable.COLUMN_OS_INFO)); - return instance; - } - return null; - } - - @Override public List searchServer(String keyword, long start, long end) { - logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); - searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setSize(1000); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end)); - if (StringUtils.isNotEmpty(keyword)) { - boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_OS_INFO, keyword)); - } - boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); - searchRequestBuilder.setQuery(boolQuery); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - SearchHit[] searchHits = searchResponse.getHits().getHits(); - - return buildAppServerInfo(searchHits); - } - - @Override public List getAllServer(int applicationId, long start, long end) { - logger.debug("get instances info, applicationId: {}, start: {}, end: {}", applicationId, start, end); - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(InstanceTable.TABLE); - searchRequestBuilder.setTypes(InstanceTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - searchRequestBuilder.setSize(1000); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end)); - boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_APPLICATION_ID, applicationId)); - boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); - searchRequestBuilder.setQuery(boolQuery); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - SearchHit[] searchHits = searchResponse.getHits().getHits(); - - return buildAppServerInfo(searchHits); - } - - private List buildAppServerInfo(SearchHit[] searchHits) { - List appServerInfos = new LinkedList<>(); - for (SearchHit searchHit : searchHits) { - AppServerInfo appServerInfo = new AppServerInfo(); - appServerInfo.setId(((Number)searchHit.getSource().get(InstanceTable.COLUMN_INSTANCE_ID)).intValue()); - appServerInfo.setOsInfo((String)searchHit.getSource().get(InstanceTable.COLUMN_OS_INFO)); - appServerInfos.add(appServerInfo); - } - return appServerInfos; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java deleted file mode 100644 index 89459ab5e..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/InstanceMetricEsUIDAO.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.MetricSource; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.elasticsearch.action.get.MultiGetItemResponse; -import org.elasticsearch.action.get.MultiGetRequestBuilder; -import org.elasticsearch.action.get.MultiGetResponse; - -/** - * @author peng-yongsheng - */ -public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO { - - public InstanceMetricEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { - MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); - String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); - prepareMultiGet.add(tableName, InstanceMetricTable.TABLE_TYPE, id); - }); - - List throughputTrend = new LinkedList<>(); - MultiGetResponse multiGetResponse = prepareMultiGet.get(); - - for (int i = 0; i < multiGetResponse.getResponses().length; i++) { - MultiGetItemResponse response = multiGetResponse.getResponses()[i]; - if (response.getResponse().isExists()) { - long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); - throughputTrend.add((int)(callTimes / durationPoints.get(i).getSecondsBetween())); - } else { - throughputTrend.add(0); - } - } - return throughputTrend; - } - - @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { - MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); - String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); - prepareMultiGet.add(tableName, InstanceMetricTable.TABLE_TYPE, id); - }); - - List responseTimeTrends = new LinkedList<>(); - MultiGetResponse multiGetResponse = prepareMultiGet.get(); - for (MultiGetItemResponse response : multiGetResponse.getResponses()) { - if (response.getResponse().isExists()) { - long callTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); - long errorCallTimes = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue(); - long durationSum = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue(); - long errorDurationSum = ((Number)response.getResponse().getSource().get(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM)).longValue(); - responseTimeTrends.add((int)((durationSum - errorDurationSum) / (callTimes - errorCallTimes))); - } else { - responseTimeTrends.add(0); - } - } - return responseTimeTrends; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java deleted file mode 100644 index 628332cbc..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryMetricEsUIDAO.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.BooleanUtils; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.elasticsearch.action.get.MultiGetItemResponse; -import org.elasticsearch.action.get.MultiGetRequestBuilder; -import org.elasticsearch.action.get.MultiGetResponse; - -/** - * @author peng-yongsheng - */ -public class MemoryMetricEsUIDAO extends EsDAO implements IMemoryMetricUIDAO { - - public MemoryMetricEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints) { - return getMemoryTrend(instanceId, step, durationPoints, true); - } - - @Override public Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints) { - return getMemoryTrend(instanceId, step, durationPoints, false); - } - - private Trend getMemoryTrend(int instanceId, Step step, List durationPoints, - boolean isHeap) { - String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE); - MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); - - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap); - prepareMultiGet.add(tableName, MemoryMetricTable.TABLE_TYPE, id); - }); - - Trend trend = new Trend(); - MultiGetResponse multiGetResponse = prepareMultiGet.get(); - for (MultiGetItemResponse response : multiGetResponse.getResponses()) { - if (response.getResponse().isExists()) { - long max = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_MAX)).longValue(); - long used = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_USED)).longValue(); - long times = ((Number)response.getResponse().getSource().get(MemoryMetricTable.COLUMN_TIMES)).longValue(); - trend.getMetrics().add((int)(used / times)); - trend.getMaxMetrics().add((int)(max / times)); - } else { - trend.getMetrics().add(0); - trend.getMaxMetrics().add(0); - } - } - - return trend; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java deleted file mode 100644 index 54a40c738..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/MemoryPoolMetricEsUIDAO.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; -import org.elasticsearch.action.get.GetResponse; -import org.elasticsearch.action.get.MultiGetItemResponse; -import org.elasticsearch.action.get.MultiGetRequestBuilder; -import org.elasticsearch.action.get.MultiGetResponse; - -/** - * @author peng-yongsheng - */ -public class MemoryPoolMetricEsUIDAO extends EsDAO implements IMemoryPoolMetricUIDAO { - - public MemoryPoolMetricEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public JsonObject getMetric(int instanceId, long timeBucket, int poolType) { - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; - GetResponse getResponse = getClient().prepareGet(MemoryPoolMetricTable.TABLE, id).get(); - - JsonObject metric = new JsonObject(); - if (getResponse.isExists()) { - metric.addProperty("max", ((Number)getResponse.getSource().get(MemoryPoolMetricTable.COLUMN_MAX)).intValue()); - metric.addProperty("init", ((Number)getResponse.getSource().get(MemoryPoolMetricTable.COLUMN_INIT)).intValue()); - metric.addProperty("used", ((Number)getResponse.getSource().get(MemoryPoolMetricTable.COLUMN_USED)).intValue()); - } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - metric.addProperty("used", 0); - } - return metric; - } - - @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, int poolType) { - MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); - - long timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; - prepareMultiGet.add(MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.TABLE_TYPE, id); - } - while (timeBucket <= endTimeBucket); - - JsonObject metric = new JsonObject(); - JsonArray usedMetric = new JsonArray(); - MultiGetResponse multiGetResponse = prepareMultiGet.get(); - for (MultiGetItemResponse response : multiGetResponse.getResponses()) { - if (response.getResponse().isExists()) { - metric.addProperty("max", ((Number)response.getResponse().getSource().get(MemoryPoolMetricTable.COLUMN_MAX)).longValue()); - metric.addProperty("init", ((Number)response.getResponse().getSource().get(MemoryPoolMetricTable.COLUMN_INIT)).longValue()); - usedMetric.add(((Number)response.getResponse().getSource().get(MemoryPoolMetricTable.COLUMN_USED)).longValue()); - } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - usedMetric.add(0); - } - } - metric.add("used", usedMetric); - return metric; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java deleted file mode 100644 index a99c8bbbb..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsUIDAO.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.CollectionUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.RangeQueryBuilder; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.sort.SortOrder; - -/** - * @author peng-yongsheng - */ -public class SegmentCostEsUIDAO extends EsDAO implements ISegmentCostUIDAO { - - public SegmentCostEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, - Error error, int applicationId, List segmentIds, int limit, int from, Sort sort) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(SegmentCostTable.TABLE); - searchRequestBuilder.setTypes(SegmentCostTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); - searchRequestBuilder.setQuery(boolQueryBuilder); - List mustQueryList = boolQueryBuilder.must(); - - mustQueryList.add(QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - if (minCost != -1 || maxCost != -1) { - RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_COST); - if (minCost != -1) { - rangeQueryBuilder.gte(minCost); - } - if (maxCost != -1) { - rangeQueryBuilder.lte(maxCost); - } - boolQueryBuilder.must().add(rangeQueryBuilder); - } - if (StringUtils.isNotEmpty(operationName)) { - mustQueryList.add(QueryBuilders.matchQuery(SegmentCostTable.COLUMN_SERVICE_NAME, operationName)); - } - if (CollectionUtils.isNotEmpty(segmentIds)) { - boolQueryBuilder.must().add(QueryBuilders.termsQuery(SegmentCostTable.COLUMN_SEGMENT_ID, segmentIds.toArray(new String[0]))); - } - if (Error.True.equals(error)) { - boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, true)); - } else if (Error.False.equals(error)) { - boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, false)); - } - if (applicationId != 0) { - boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_APPLICATION_ID, applicationId)); - } - - if (Sort.Cost.equals(sort)) { - searchRequestBuilder.addSort(SegmentCostTable.COLUMN_COST, SortOrder.DESC); - } else if (Sort.Time.equals(sort)) { - searchRequestBuilder.addSort(SegmentCostTable.COLUMN_START_TIME, SortOrder.DESC); - } - searchRequestBuilder.setSize(limit); - searchRequestBuilder.setFrom(from); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - JsonObject topSegPaging = new JsonObject(); - topSegPaging.addProperty("recordsTotal", searchResponse.getHits().totalHits); - - JsonArray topSegArray = new JsonArray(); - topSegPaging.add("data", topSegArray); - - int num = from; - for (SearchHit searchHit : searchResponse.getHits().getHits()) { - JsonObject topSegmentJson = new JsonObject(); - topSegmentJson.addProperty("num", num); - String segmentId = (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SEGMENT_ID); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_START_TIME)); - if (searchHit.getSource().containsKey(SegmentCostTable.COLUMN_END_TIME)) { - topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_END_TIME)); - } - - topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_APPLICATION_ID)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SERVICE_NAME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_COST)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, (Boolean)searchHit.getSource().get(SegmentCostTable.COLUMN_IS_ERROR)); - - num++; - topSegArray.add(topSegmentJson); - } - - return topSegPaging; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java deleted file mode 100644 index 22c20683f..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentEsUIDAO.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import com.google.protobuf.InvalidProtocolBufferException; -import java.util.Base64; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; -import org.apache.skywalking.apm.network.proto.TraceSegmentObject; -import org.elasticsearch.action.get.GetResponse; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class SegmentEsUIDAO extends EsDAO implements ISegmentUIDAO { - - private final Logger logger = LoggerFactory.getLogger(SegmentEsUIDAO.class); - - public SegmentEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public TraceSegmentObject load(String segmentId) { - GetResponse response = getClient().prepareGet(SegmentTable.TABLE, segmentId).get(); - Map source = response.getSource(); - String dataBinaryBase64 = (String)source.get(SegmentTable.COLUMN_DATA_BINARY); - if (StringUtils.isNotEmpty(dataBinaryBase64)) { - byte[] dataBinary = Base64.getDecoder().decode(dataBinaryBase64); - try { - return TraceSegmentObject.parseFrom(dataBinary); - } catch (InvalidProtocolBufferException e) { - logger.error(e.getMessage(), e); - } - } - return null; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java deleted file mode 100644 index ff24c32d3..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ServiceReferenceEsUIDAO.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao; - -import com.google.gson.JsonObject; -import java.util.LinkedHashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ServiceReferenceEsUIDAO extends EsDAO implements IServiceReferenceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceReferenceEsUIDAO.class); - - public ServiceReferenceEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override - public Map load(int entryServiceId, long startTime, long endTime) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceReferenceMetricTable.TABLE); - searchRequestBuilder.setTypes(ServiceReferenceMetricTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - - searchRequestBuilder.setQuery(boolQuery); - searchRequestBuilder.setSize(0); - - return load(searchRequestBuilder); - } - - private Map load(SearchRequestBuilder searchRequestBuilder) { - searchRequestBuilder.addAggregation(AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).size(100) - .subAggregation(AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).size(100) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)))); - - Map serviceReferenceMap = new LinkedHashMap<>(); - - SearchResponse searchResponse = searchRequestBuilder.get(); - Terms frontServiceIdTerms = searchResponse.getAggregations().get(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); - for (Terms.Bucket frontServiceBucket : frontServiceIdTerms.getBuckets()) { - int frontServiceId = frontServiceBucket.getKeyAsNumber().intValue(); - if (frontServiceId != 0) { - parseSubAggregate(serviceReferenceMap, frontServiceBucket, frontServiceId); - } - } - - return serviceReferenceMap; - } - - private void parseSubAggregate(Map serviceReferenceMap, - Terms.Bucket frontServiceBucket, - int frontServiceId) { - Terms behindServiceIdTerms = frontServiceBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); - for (Terms.Bucket behindServiceIdBucket : behindServiceIdTerms.getBuckets()) { - int behindServiceId = behindServiceIdBucket.getKeyAsNumber().intValue(); - if (behindServiceId != 0) { - Sum calls = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); - Sum errorCalls = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); - Sum durationSum = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - Sum errorDurationSum = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); - - JsonObject serviceReference = new JsonObject(); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID), frontServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID), behindServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS), (long)calls.getValue()); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS), (long)errorCalls.getValue()); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM), (long)durationSum.getValue()); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM), (long)errorDurationSum.getValue()); - - String id = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); - serviceReferenceMap.put(id, serviceReference); - } - } - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java deleted file mode 100644 index b783959a2..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationComponentH2UIDAO.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationComponentUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationComponentTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class ApplicationComponentH2UIDAO extends H2DAO implements IApplicationComponentUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationComponentH2UIDAO.class); - private static final String AGGREGATE_COMPONENT_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100"; - - public ApplicationComponentH2UIDAO(H2Client client) { - super(client); - } - - @Override public List load(Step step, long startTime, long endTime) { - H2Client client = getClient(); - - String tableName = TimePyramidTableNameBuilder.build(step, ApplicationComponentTable.TABLE); - - List applicationComponents = new LinkedList<>(); - String sql = SqlBuilder.buildSql(AGGREGATE_COMPONENT_SQL, ApplicationComponentTable.COLUMN_COMPONENT_ID, ApplicationComponentTable.COLUMN_APPLICATION_ID, - tableName, ApplicationComponentTable.COLUMN_TIME_BUCKET); - - Object[] params = new Object[] {startTime, endTime}; - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - int applicationId = rs.getInt(ApplicationComponentTable.COLUMN_APPLICATION_ID); - int componentId = rs.getInt(ApplicationComponentTable.COLUMN_COMPONENT_ID); - - ApplicationComponent applicationComponent = new ApplicationComponent(); - applicationComponent.setComponentId(componentId); - applicationComponent.setApplicationId(applicationId); - applicationComponents.add(applicationComponent); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return applicationComponents; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java deleted file mode 100644 index b060d887c..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationMappingH2UIDAO.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationMappingUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.application.ApplicationMappingTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class ApplicationMappingH2UIDAO extends H2DAO implements IApplicationMappingUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationMappingH2UIDAO.class); - private static final String APPLICATION_MAPPING_SQL = "select {0}, {1} from {2} where {3} >= ? and {3} <= ? group by {0}, {1} limit 100"; - - public ApplicationMappingH2UIDAO(H2Client client) { - super(client); - } - - @Override public List load(Step step, long startTime, long endTime) { - String tableName = TimePyramidTableNameBuilder.build(step, ApplicationMappingTable.TABLE); - - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(APPLICATION_MAPPING_SQL, ApplicationMappingTable.COLUMN_APPLICATION_ID, - ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID, tableName, ApplicationMappingTable.COLUMN_TIME_BUCKET); - - List applicationMappings = new LinkedList<>(); - Object[] params = new Object[] {startTime, endTime}; - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - int applicationId = rs.getInt(ApplicationMappingTable.COLUMN_APPLICATION_ID); - int addressId = rs.getInt(ApplicationMappingTable.COLUMN_MAPPING_APPLICATION_ID); - - ApplicationMapping applicationMapping = new ApplicationMapping(); - applicationMapping.setApplicationId(applicationId); - applicationMapping.setMappingApplicationId(addressId); - applicationMappings.add(applicationMapping); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - logger.debug("node mapping data: {}", applicationMappings.toString()); - return applicationMappings; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java deleted file mode 100644 index 36d9e6e0e..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ApplicationReferenceMetricH2UIDAO.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import com.google.gson.JsonArray; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.dao.IApplicationReferenceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.MetricSource; -import org.apache.skywalking.apm.collector.storage.ui.common.Call; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class ApplicationReferenceMetricH2UIDAO extends H2DAO implements IApplicationReferenceMetricUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ApplicationReferenceMetricH2UIDAO.class); - private static final String APPLICATION_REFERENCE_SQL = "select {8}, {9}, sum({0}) as {0}, sum({1}) as {1}, sum({2}) as {2}, " + - "sum({3}) as {3}, sum({4}) as {4}, sum({5}) as {5} from {6} where {7} >= ? and {7} <= ? group by {8}, {9} limit 100"; - - public ApplicationReferenceMetricH2UIDAO(H2Client client) { - super(client); - } - - @Override public List getFrontApplications(Step step, int applicationId, long startTime, long endTime, - MetricSource metricSource) { - H2Client client = getClient(); - JsonArray applicationReferenceMetricArray = new JsonArray(); -// String sql = SqlBuilder.buildSql(APPLICATION_REFERENCE_SQL, ApplicationReferenceMetricTable.COLUMN_S1_LTE, -// ApplicationReferenceMetricTable.COLUMN_S3_LTE, ApplicationReferenceMetricTable.COLUMN_S5_LTE, -// ApplicationReferenceMetricTable.COLUMN_S5_GT, ApplicationReferenceMetricTable.COLUMN_SUMMARY, -// ApplicationReferenceMetricTable.COLUMN_ERROR, ApplicationReferenceMetricTable.TABLE, ApplicationReferenceMetricTable.COLUMN_TIME_BUCKET, -// ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID, ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); -// -// Object[] params = new Object[] {startTime, endTime}; -// try (ResultSet rs = client.executeQuery(sql, params)) { -// while (rs.next()) { -// int frontApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID); -// int behindApplicationId = rs.getInt(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID); -// JsonObject nodeRefResSumObj = new JsonObject(); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_FRONT_APPLICATION_ID), frontApplicationId); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_BEHIND_APPLICATION_ID), behindApplicationId); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S1_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S1_LTE)); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S3_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S3_LTE)); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_LTE), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_LTE)); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_S5_GT), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_S5_GT)); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_ERROR), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_ERROR)); -// nodeRefResSumObj.addProperty(ColumnNameUtils.INSTANCE.rename(ApplicationReferenceMetricTable.COLUMN_SUMMARY), rs.getDouble(ApplicationReferenceMetricTable.COLUMN_SUMMARY)); -// nodeRefResSumArray.add(nodeRefResSumObj); -// } -// } catch (SQLException | H2ClientException e) { -// logger.error(e.getMessage(), e); -// } - return null; - } - - @Override public List getBehindApplications(Step step, int applicationId, long startTime, long endTime, - MetricSource metricSource) { - return null; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java deleted file mode 100644 index 0d4267925..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/CpuMetricH2UIDAO.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.ICpuMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.CpuMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class CpuMetricH2UIDAO extends H2DAO implements ICpuMetricUIDAO { - private final Logger logger = LoggerFactory.getLogger(CpuMetricH2UIDAO.class); - private static final String GET_CPU_METRIC_SQL = "select * from {0} where {1} = ?"; - - public CpuMetricH2UIDAO(H2Client client) { - super(client); - } - - @Override public List getCPUTrend(int instanceId, Step step, List durationPoints) { - H2Client client = getClient(); - String tableName = TimePyramidTableNameBuilder.build(step, CpuMetricTable.TABLE); - String sql = SqlBuilder.buildSql(GET_CPU_METRIC_SQL, tableName, CpuMetricTable.COLUMN_ID); - - List cpuTrends = new LinkedList<>(); - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId; - - try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { - if (rs.next()) { - double cpuUsed = rs.getDouble(CpuMetricTable.COLUMN_USAGE_PERCENT); - long times = rs.getLong(CpuMetricTable.COLUMN_TIMES); - cpuTrends.add((int)((cpuUsed / times) * 100)); - } else { - cpuTrends.add(0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - }); - - return cpuTrends; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java deleted file mode 100644 index b8e01eccb..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GCMetricH2UIDAO.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IGCMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.GCMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.apache.skywalking.apm.network.proto.GCPhrase; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class GCMetricH2UIDAO extends H2DAO implements IGCMetricUIDAO { - - private final Logger logger = LoggerFactory.getLogger(GCMetricH2UIDAO.class); - private static final String GET_GC_METRIC_SQL = "select * from {0} where {1} = ?"; - - public GCMetricH2UIDAO(H2Client client) { - super(client); - } - - @Override public List getYoungGCTrend(int instanceId, Step step, List durationPoints) { - return getGCTrend(instanceId, step, durationPoints, GCPhrase.NEW_VALUE); - } - - @Override public List getOldGCTrend(int instanceId, Step step, List durationPoints) { - return getGCTrend(instanceId, step, durationPoints, GCPhrase.OLD_VALUE); - } - - private List getGCTrend(int instanceId, Step step, List durationPoints, int gcPhrase) { - String tableName = TimePyramidTableNameBuilder.build(step, GCMetricTable.TABLE); - - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_GC_METRIC_SQL, tableName, GCMetricTable.COLUMN_ID); - - List gcTrends = new LinkedList<>(); - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + gcPhrase; - try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { - if (rs.next()) { - long count = rs.getLong(GCMetricTable.COLUMN_COUNT); - long times = rs.getLong(GCMetricTable.COLUMN_TIMES); - gcTrends.add((int)(count / times)); - } else { - gcTrends.add(0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - }); - - return gcTrends; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2UIDAO.java deleted file mode 100644 index 9a2eeee62..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/GlobalTraceH2UIDAO.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class GlobalTraceH2UIDAO extends H2DAO implements IGlobalTraceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(GlobalTraceH2UIDAO.class); - - private static final String GET_GLOBAL_TRACE_ID_SQL = "select {0} from {1} where {2} = ? limit 10"; - private static final String GET_SEGMENT_IDS_SQL = "select {0} from {1} where {2} = ? limit 10"; - - public GlobalTraceH2UIDAO(H2Client client) { - super(client); - } - - @Override public List getGlobalTraceId(String segmentId) { - List globalTraceIds = new ArrayList<>(); - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_GLOBAL_TRACE_ID_SQL, GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, - GlobalTraceTable.TABLE, GlobalTraceTable.COLUMN_SEGMENT_ID); - Object[] params = new Object[] {segmentId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - String globalTraceId = rs.getString(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID); - logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); - globalTraceIds.add(globalTraceId); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return globalTraceIds; - } - - @Override public List getSegmentIds(String globalTraceId) { - List segmentIds = new ArrayList<>(); - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_SEGMENT_IDS_SQL, GlobalTraceTable.COLUMN_SEGMENT_ID, - GlobalTraceTable.TABLE, GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID); - Object[] params = new Object[] {globalTraceId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - String segmentId = rs.getString(GlobalTraceTable.COLUMN_SEGMENT_ID); - logger.debug("segmentId: {}, global trace id: {}", segmentId, globalTraceId); - segmentIds.add(segmentId); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return segmentIds; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java deleted file mode 100644 index aeecc3989..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceH2UIDAO.java +++ /dev/null @@ -1,166 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.BooleanUtils; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.register.Instance; -import org.apache.skywalking.apm.collector.storage.table.register.InstanceTable; -import org.apache.skywalking.apm.collector.storage.ui.application.Application; -import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class InstanceH2UIDAO extends H2DAO implements IInstanceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(InstanceH2UIDAO.class); - - public InstanceH2UIDAO(H2Client client) { - super(client); - } - - private static final String GET_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? limit 1"; - private static final String GET_INST_LAST_HEARTBEAT_TIME_SQL = "select {0} from {1} where {2} > ? and {3} = ? limit 1"; - private static final String GET_INSTANCE_SQL = "select * from {0} where {1} = ?"; - private static final String GET_APPLICATIONS_SQL = "select {3}, count({0}) as cnt from {1} where {2} >= ? group by {3} limit 100"; - - @Override - public Long lastHeartBeatTime() { - H2Client client = getClient(); - long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; - fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); - String sql = SqlBuilder.buildSql(GET_LAST_HEARTBEAT_TIME_SQL, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME); - Object[] params = new Object[] {fiveMinuteBefore}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - return rs.getLong(1); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return 0L; - } - - @Override - public Long instanceLastHeartBeatTime(long applicationInstanceId) { - H2Client client = getClient(); - long fiveMinuteBefore = System.currentTimeMillis() - 5 * 60 * 1000; - fiveMinuteBefore = TimeBucketUtils.INSTANCE.getSecondTimeBucket(fiveMinuteBefore); - String sql = SqlBuilder.buildSql(GET_INST_LAST_HEARTBEAT_TIME_SQL, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.TABLE, - InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_INSTANCE_ID); - Object[] params = new Object[] {fiveMinuteBefore, applicationInstanceId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - return rs.getLong(1); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return 0L; - } - - @Override - public List getApplications(long startTime, long endTime, int... applicationIds) { - H2Client client = getClient(); - List applications = new LinkedList<>(); - String sql = SqlBuilder.buildSql(GET_APPLICATIONS_SQL, InstanceTable.COLUMN_INSTANCE_ID, - InstanceTable.TABLE, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_APPLICATION_ID); - Object[] params = new Object[] {startTime}; - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - Integer applicationId = rs.getInt(InstanceTable.COLUMN_APPLICATION_ID); - logger.debug("applicationId: {}", applicationId); - Application application = new Application(); - application.setId(applicationId); - application.setNumOfServer(rs.getInt("cnt")); - applications.add(application); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return applications; - } - - @Override - public Instance getInstance(int instanceId) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_INSTANCE_SQL, InstanceTable.TABLE, InstanceTable.COLUMN_INSTANCE_ID); - Object[] params = new Object[] {instanceId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - Instance instance = new Instance(); - instance.setId(rs.getString(InstanceTable.COLUMN_ID)); - instance.setApplicationId(rs.getInt(InstanceTable.COLUMN_APPLICATION_ID)); - instance.setAgentUUID(rs.getString(InstanceTable.COLUMN_AGENT_UUID)); - instance.setRegisterTime(rs.getLong(InstanceTable.COLUMN_REGISTER_TIME)); - instance.setHeartBeatTime(rs.getLong(InstanceTable.COLUMN_HEARTBEAT_TIME)); - instance.setOsInfo(rs.getString(InstanceTable.COLUMN_OS_INFO)); - return instance; - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return null; - } - - @Override public List searchServer(String keyword, long start, long end) { - logger.debug("get instances info, keyword: {}, start: {}, end: {}", keyword, start, end); - String dynamicSql = "select * from {0} where {1} like ? and {2} >= ? and {2} <= ? and {3} = ?"; - String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_OS_INFO, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); - Object[] params = new Object[] {keyword, start, end, BooleanUtils.FALSE}; - return buildAppServerInfo(sql, params); - } - - @Override public List getAllServer(int applicationId, long start, long end) { - logger.debug("get instances info, applicationId: {}, start: {}, end: {}", applicationId, start, end); - String dynamicSql = "select * from {0} where {1} = ? and {2} >= ? and {2} <= ? and {3} = ?"; - String sql = SqlBuilder.buildSql(dynamicSql, InstanceTable.TABLE, InstanceTable.COLUMN_APPLICATION_ID, InstanceTable.COLUMN_HEARTBEAT_TIME, InstanceTable.COLUMN_IS_ADDRESS); - Object[] params = new Object[] {applicationId, start, end, BooleanUtils.FALSE}; - return buildAppServerInfo(sql, params); - } - - private List buildAppServerInfo(String sql, Object[] params) { - H2Client client = getClient(); - - List appServerInfos = new LinkedList<>(); - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - AppServerInfo appServerInfo = new AppServerInfo(); - appServerInfo.setId(rs.getInt(InstanceTable.COLUMN_INSTANCE_ID)); - appServerInfo.setOsInfo(rs.getString(InstanceTable.COLUMN_OS_INFO)); - appServerInfos.add(appServerInfo); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return appServerInfos; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java deleted file mode 100644 index f1ea9d9c2..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/InstanceMetricH2UIDAO.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IInstanceMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.MetricSource; -import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO { - - private final Logger logger = LoggerFactory.getLogger(InstanceMetricH2UIDAO.class); - private static final String GET_TPS_METRIC_SQL = "select * from {0} where {1} = ?"; - - public InstanceMetricH2UIDAO(H2Client client) { - super(client); - } - - @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { - H2Client client = getClient(); - String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - - String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID); - - List throughputTrend = new LinkedList<>(); - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); - try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) { - if (rs.next()) { - long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - throughputTrend.add((int)(callTimes / durationPoint.getSecondsBetween())); - } else { - throughputTrend.add(0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - }); - - return throughputTrend; - } - - @Override public List getResponseTimeTrend(int instanceId, Step step, List durationPoints) { - H2Client client = getClient(); - - String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); - String sql = SqlBuilder.buildSql(GET_TPS_METRIC_SQL, tableName, InstanceMetricTable.COLUMN_ID); - - List responseTimeTrends = new LinkedList<>(); - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); - try (ResultSet rs = client.executeQuery(sql, new Object[] {id})) { - if (rs.next()) { - long callTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_CALLS); - long errorCallTimes = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); - long durationSum = rs.getLong(InstanceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - long errorDurationSum = rs.getLong(InstanceMetricTable.COLUMN_BUSINESS_TRANSACTION_ERROR_DURATION_SUM); - responseTimeTrends.add((int)((durationSum - errorDurationSum) / (callTimes - errorCallTimes))); - } else { - responseTimeTrends.add(0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - }); - return responseTimeTrends; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java deleted file mode 100644 index 1bfbcfd1d..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryMetricH2UIDAO.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.BooleanUtils; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryMetricTable; -import org.apache.skywalking.apm.collector.storage.ui.common.Step; -import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; -import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author clevertension - */ -public class MemoryMetricH2UIDAO extends H2DAO implements IMemoryMetricUIDAO { - - private final Logger logger = LoggerFactory.getLogger(MemoryMetricH2UIDAO.class); - private static final String GET_MEMORY_METRIC_SQL = "select * from {0} where {1} =?"; - - public MemoryMetricH2UIDAO(H2Client client) { - super(client); - } - - @Override public Trend getHeapMemoryTrend(int instanceId, Step step, List durationPoints) { - return getMemoryTrend(instanceId, step, durationPoints, true); - } - - @Override public Trend getNoHeapMemoryTrend(int instanceId, Step step, List durationPoints) { - return getMemoryTrend(instanceId, step, durationPoints, false); - } - - private Trend getMemoryTrend(int instanceId, Step step, List durationPoints, - boolean isHeap) { - String tableName = TimePyramidTableNameBuilder.build(step, MemoryMetricTable.TABLE); - - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_MEMORY_METRIC_SQL, tableName, MemoryMetricTable.COLUMN_ID); - - Trend trend = new Trend(); - durationPoints.forEach(durationPoint -> { - String id = durationPoint.getPoint() + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + BooleanUtils.booleanToValue(isHeap); - try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { - if (rs.next()) { - long max = rs.getLong(MemoryMetricTable.COLUMN_MAX); - long used = rs.getLong(MemoryMetricTable.COLUMN_USED); - long times = rs.getLong(MemoryMetricTable.COLUMN_TIMES); - trend.getMetrics().add((int)(used / times)); - trend.getMaxMetrics().add((int)(max / times)); - } else { - trend.getMetrics().add(0); - trend.getMaxMetrics().add(0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - }); - - return trend; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java deleted file mode 100644 index c7aa20427..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/MemoryPoolMetricH2UIDAO.java +++ /dev/null @@ -1,105 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IMemoryPoolMetricUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.jvm.MemoryPoolMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author clevertension - */ -public class MemoryPoolMetricH2UIDAO extends H2DAO implements IMemoryPoolMetricUIDAO { - - private final Logger logger = LoggerFactory.getLogger(MemoryPoolMetricH2UIDAO.class); - private static final String GET_MEMORY_POOL_METRIC_SQL = "select * from {0} where {1} = ?"; - - public MemoryPoolMetricH2UIDAO(H2Client client) { - super(client); - } - - @Override public JsonObject getMetric(int instanceId, long timeBucket, int poolType) { - H2Client client = getClient(); - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; - String sql = SqlBuilder.buildSql(GET_MEMORY_POOL_METRIC_SQL, MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.COLUMN_ID); - Object[] params = new Object[] {id}; - JsonObject metric = new JsonObject(); - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - metric.addProperty("max", rs.getInt(MemoryPoolMetricTable.COLUMN_MAX)); - metric.addProperty("init", rs.getInt(MemoryPoolMetricTable.COLUMN_INIT)); - metric.addProperty("used", rs.getInt(MemoryPoolMetricTable.COLUMN_USED)); - } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - metric.addProperty("used", 0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return metric; - } - - @Override public JsonObject getMetric(int instanceId, long startTimeBucket, long endTimeBucket, int poolType) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_MEMORY_POOL_METRIC_SQL, MemoryPoolMetricTable.TABLE, MemoryPoolMetricTable.COLUMN_ID); - List idList = new ArrayList<>(); - long timeBucket = startTimeBucket; - do { -// timeBucket = TimeBucketUtils.INSTANCE.addSecondForSecondTimeBucket(TimeBucketUtils.TimeBucketType.SECOND, timeBucket, 1); - String id = timeBucket + Const.ID_SPLIT + instanceId + Const.ID_SPLIT + poolType; - idList.add(id); - } - while (timeBucket <= endTimeBucket); - - JsonObject metric = new JsonObject(); - JsonArray usedMetric = new JsonArray(); - - idList.forEach(id -> { - try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { - if (rs.next()) { - metric.addProperty("max", rs.getLong(MemoryPoolMetricTable.COLUMN_MAX)); - metric.addProperty("init", rs.getLong(MemoryPoolMetricTable.COLUMN_INIT)); - usedMetric.add(rs.getLong(MemoryPoolMetricTable.COLUMN_USED)); - } else { - metric.addProperty("max", 0); - metric.addProperty("init", 0); - usedMetric.add(0); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - }); - - metric.add("used", usedMetric); - return metric; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentCostH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentCostH2UIDAO.java deleted file mode 100644 index 74baaa49c..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentCostH2UIDAO.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.apache.skywalking.apm.collector.core.util.CollectionUtils; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostUIDAO; -import org.elasticsearch.search.sort.SortOrder; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class SegmentCostH2UIDAO extends H2DAO implements ISegmentCostUIDAO { - - private final Logger logger = LoggerFactory.getLogger(SegmentCostH2UIDAO.class); - private static final String GET_SEGMENT_COST_SQL = "select * from {0} where {1} >= ? and {1} <= ?"; - - public SegmentCostH2UIDAO(H2Client client) { - super(client); - } - - @Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, - Error error, int applicationId, List segmentIds, int limit, int from, Sort sort) { - H2Client client = getClient(); - String sql = GET_SEGMENT_COST_SQL; - List params = new ArrayList<>(); - List columns = new ArrayList<>(); - columns.add(SegmentCostTable.TABLE); - columns.add(SegmentCostTable.COLUMN_TIME_BUCKET); - params.add(startTime); - params.add(endTime); - int paramIndex = 1; - if (minCost != -1 || maxCost != -1) { - if (minCost != -1) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} >= ?"; - params.add(minCost); - columns.add(SegmentCostTable.COLUMN_COST); - } - if (maxCost != -1) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} <= ?"; - params.add(maxCost); - columns.add(SegmentCostTable.COLUMN_COST); - } - } - if (StringUtils.isNotEmpty(operationName)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(operationName); - columns.add(SegmentCostTable.COLUMN_SERVICE_NAME); - } - if (CollectionUtils.isNotEmpty(segmentIds)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} in ("; - columns.add(SegmentCostTable.COLUMN_SEGMENT_ID); - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < segmentIds.size(); i++) { - builder.append("?,"); - } - builder.delete(builder.length() - 1, builder.length()); - builder.append(")"); - sql = sql + builder; - for (String segmentId : segmentIds) { - params.add(segmentId); - } - } - if (Error.True.equals(error)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(true); - columns.add(SegmentCostTable.COLUMN_IS_ERROR); - } else if (Error.False.equals(error)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(false); - columns.add(SegmentCostTable.COLUMN_IS_ERROR); - } - if (applicationId != 0) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(applicationId); - columns.add(SegmentCostTable.COLUMN_APPLICATION_ID); - } - - if (Sort.Cost.equals(sort)) { - sql = sql + " order by " + SegmentCostTable.COLUMN_COST + " " + SortOrder.DESC; - } else if (Sort.Time.equals(sort)) { - sql = sql + " order by " + SegmentCostTable.COLUMN_START_TIME + " " + SortOrder.DESC; - } - - sql = sql + " limit " + from + "," + limit; - sql = SqlBuilder.buildSql(sql, columns); - Object[] p = params.toArray(new Object[0]); - - JsonObject topSegPaging = new JsonObject(); - - JsonArray topSegArray = new JsonArray(); - topSegPaging.add("data", topSegArray); - int cnt = 0; - int num = from; - try (ResultSet rs = client.executeQuery(sql, p)) { - while (rs.next()) { - JsonObject topSegmentJson = new JsonObject(); - topSegmentJson.addProperty("num", num); - String segmentId = rs.getString(SegmentCostTable.COLUMN_SEGMENT_ID); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, rs.getLong(SegmentCostTable.COLUMN_START_TIME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, rs.getLong(SegmentCostTable.COLUMN_END_TIME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, rs.getInt(SegmentCostTable.COLUMN_APPLICATION_ID)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, rs.getString(SegmentCostTable.COLUMN_SERVICE_NAME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, rs.getLong(SegmentCostTable.COLUMN_COST)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, rs.getBoolean(SegmentCostTable.COLUMN_IS_ERROR)); - - num++; - topSegArray.add(topSegmentJson); - cnt++; - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - topSegPaging.addProperty("recordsTotal", cnt); - return topSegPaging; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentH2UIDAO.java deleted file mode 100644 index 7d5019bc0..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentH2UIDAO.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import com.google.protobuf.InvalidProtocolBufferException; -import java.sql.ResultSet; -import java.sql.SQLException; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentTable; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.network.proto.TraceSegmentObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class SegmentH2UIDAO extends H2DAO implements ISegmentUIDAO { - private final Logger logger = LoggerFactory.getLogger(SegmentH2UIDAO.class); - private static final String GET_SEGMENT_SQL = "select {0} from {1} where {2} = ?"; - - public SegmentH2UIDAO(H2Client client) { - super(client); - } - - @Override public TraceSegmentObject load(String segmentId) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_SEGMENT_SQL, SegmentTable.COLUMN_DATA_BINARY, - SegmentTable.TABLE, SegmentTable.COLUMN_ID); - Object[] params = new Object[] {segmentId}; - try (ResultSet rs = client.executeQuery(sql, params)) { - if (rs.next()) { - byte[] dataBinary = rs.getBytes(SegmentTable.COLUMN_DATA_BINARY); - try { - return TraceSegmentObject.parseFrom(dataBinary); - } catch (InvalidProtocolBufferException e) { - logger.error(e.getMessage(), e); - } - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return null; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java deleted file mode 100644 index c78ea2fee..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ServiceReferenceH2UIDAO.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao; - -import com.google.gson.JsonObject; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedHashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.IServiceReferenceUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class ServiceReferenceH2UIDAO extends H2DAO implements IServiceReferenceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceReferenceH2UIDAO.class); - - public ServiceReferenceH2UIDAO(H2Client client) { - super(client); - } - - private static final String GET_SRV_REF_LOAD1 = "select {3}, {4}, sum({5}) as {5}, sum({6}) as {6}, sum({7}) as {7}" + - ",sum({8}) as {8} from {0} where {1} >= ? and {1} <= ? and {2} = ? group by {3}, {4}"; - - @Override - public Map load(int entryServiceId, long startTime, long endTime) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_SRV_REF_LOAD1, ServiceReferenceMetricTable.TABLE, - ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, - ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, - ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, - ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); - Object[] params = new Object[] {startTime, endTime, entryServiceId}; - - return load(client, params, sql); - } - - private Map load(H2Client client, Object[] params, String sql) { - Map serviceReferenceMap = new LinkedHashMap<>(); - - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - int frontServiceId = rs.getInt(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); - parseSubAggregate(serviceReferenceMap, rs, frontServiceId); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return serviceReferenceMap; - } - - private void parseSubAggregate(Map serviceReferenceMap, ResultSet rs, - int frontServiceId) { - try { - int behindServiceId = rs.getInt(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); - if (behindServiceId != 0) { - long calls = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); - long errorCalls = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); - long durationSum = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - long errorDurationSum = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); - - JsonObject serviceReference = new JsonObject(); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID), frontServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID), behindServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS), calls); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS), errorCalls); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM), durationSum); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM), errorDurationSum); - - String id = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); - serviceReferenceMap.put(id, serviceReference); - } - } catch (SQLException e) { - logger.error(e.getMessage(), e); - } - } -} From 77f615a8ae6c5713be23b0dbcb1ccead9009563b Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sun, 4 Feb 2018 22:16:52 +0800 Subject: [PATCH 24/36] Provide the queryBasicTraces query. --- .../define/graph/MetricGraphIdDefine.java | 2 +- .../define/graph/MetricWorkerIdDefine.java | 2 +- .../AnalysisMetricModuleProvider.java | 10 +- ...stGraph.java => SegmentDurationGraph.java} | 10 +- ... => SegmentDurationPersistenceWorker.java} | 20 +-- ....java => SegmentDurationSpanListener.java} | 46 +++--- .../src/main/resources/application.yml | 22 +-- .../apm/collector/storage/StorageModule.java | 8 +- ...va => ISegmentDurationPersistenceDAO.java} | 4 +- ...tUIDAO.java => ISegmentDurationUIDAO.java} | 17 +- ...{SegmentCost.java => SegmentDuration.java} | 37 +++-- ...stTable.java => SegmentDurationTable.java} | 8 +- .../storage/ui/overview/ConjecturalApp.java | 16 ++ .../ui/overview/ConjecturalAppBrief.java | 8 + .../storage/ui/trace/BasicTrace.java | 42 ++++- .../storage/ui/trace/TraceBrief.java | 23 ++- .../storage/ui/trace/TraceQueryCondition.java | 63 ++++++- .../storage/es/DataTTLKeeperTimer.java | 14 +- .../storage/es/StorageModuleEsProvider.java | 12 +- ...a => SegmentDurationEsPersistenceDAO.java} | 42 ++--- .../storage/es/dao/ui/SegmentCostEsUIDAO.java | 122 -------------- .../es/dao/ui/SegmentDurationEsUIDAO.java | 100 +++++++++++ .../es/define/SegmentCostEsTableDefine.java | 49 ------ .../define/SegmentDurationEsTableDefine.java | 49 ++++++ .../resources/META-INF/defines/storage.define | 2 +- .../storage/h2/StorageModuleH2Provider.java | 12 +- ...a => SegmentDurationH2PersistenceDAO.java} | 38 ++--- .../storage/h2/dao/ui/SegmentCostH2UIDAO.java | 155 ------------------ .../h2/dao/ui/SegmentDurationH2UIDAO.java | 118 +++++++++++++ .../h2/define/SegmentCostH2TableDefine.java | 45 ----- .../define/SegmentDurationH2TableDefine.java | 46 ++++++ .../resources/META-INF/defines/storage.define | 2 +- .../ui/query/OverViewLayerQuery.java | 15 +- .../apm/collector/ui/query/TraceQuery.java | 37 ++++- .../collector/ui/service/AlarmService.java | 44 +++++ .../ui/service/SegmentTopService.java | 44 +---- .../main/resources/ui-graphql/trace.graphqls | 3 +- 37 files changed, 714 insertions(+), 573 deletions(-) rename apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/{SegmentCostGraph.java => SegmentDurationGraph.java} (83%) rename apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/{SegmentCostPersistenceWorker.java => SegmentDurationPersistenceWorker.java} (74%) rename apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/{SegmentCostSpanListener.java => SegmentDurationSpanListener.java} (70%) rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/{ISegmentCostPersistenceDAO.java => ISegmentDurationPersistenceDAO.java} (86%) rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/{ISegmentCostUIDAO.java => ISegmentDurationUIDAO.java} (70%) rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/{SegmentCost.java => SegmentDuration.java} (73%) rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/{SegmentCostTable.java => SegmentDurationTable.java} (85%) rename apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/{SegmentCostEsPersistenceDAO.java => SegmentDurationEsPersistenceDAO.java} (63%) delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentCostEsTableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentDurationEsTableDefine.java rename apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/{SegmentCostH2PersistenceDAO.java => SegmentDurationH2PersistenceDAO.java} (59%) delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentDurationH2UIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentDurationH2TableDefine.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/AlarmService.java diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java index d4b69bed7..e757f915f 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java @@ -33,7 +33,7 @@ public class MetricGraphIdDefine { public static final int APPLICATION_COMPONENT_GRAPH_ID = 406; public static final int APPLICATION_MAPPING_GRAPH_ID = 407; public static final int GLOBAL_TRACE_GRAPH_ID = 409; - public static final int SEGMENT_COST_GRAPH_ID = 410; + public static final int SEGMENT_DURATION_GRAPH_ID = 410; public static final int INSTANCE_MAPPING_GRAPH_ID = 411; public static final int INSTANCE_HEART_BEAT_PERSISTENCE_GRAPH_ID = 412; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java index a275a4417..cd9a6667b 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java @@ -113,7 +113,7 @@ public class MetricWorkerIdDefine { public static final int APPLICATION_COMPONENT_MONTH_TRANSFORM_NODE_ID = 4908; public static final int GLOBAL_TRACE_PERSISTENCE_WORKER_ID = 427; - public static final int SEGMENT_COST_PERSISTENCE_WORKER_ID = 428; + public static final int SEGMENT_DURATION_PERSISTENCE_WORKER_ID = 428; public static final int INSTANCE_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 429; public static final int APPLICATION_REFERENCE_GRAPH_BRIDGE_WORKER_ID = 430; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java index be6c3d3ee..bf0a4a6a9 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/AnalysisMetricModuleProvider.java @@ -35,8 +35,8 @@ import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.insta import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.mapping.InstanceMappingSpanListener; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.metric.InstanceMetricGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.instance.refmetric.InstanceReferenceMetricGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostGraph; -import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentCostSpanListener; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentDurationGraph; +import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.segment.SegmentDurationSpanListener; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.metric.ServiceMetricGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric.ServiceReferenceMetricGraph; import org.apache.skywalking.apm.collector.analysis.metric.provider.worker.service.refmetric.ServiceReferenceMetricSpanListener; @@ -93,7 +93,7 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { segmentParserListenerRegister.register(new ApplicationMappingSpanListener.Factory()); segmentParserListenerRegister.register(new InstanceMappingSpanListener.Factory()); segmentParserListenerRegister.register(new GlobalTraceSpanListener.Factory()); - segmentParserListenerRegister.register(new SegmentCostSpanListener.Factory()); + segmentParserListenerRegister.register(new SegmentDurationSpanListener.Factory()); } private void graphCreate(WorkerCreateListener workerCreateListener) { @@ -127,8 +127,8 @@ public class AnalysisMetricModuleProvider extends ModuleProvider { GlobalTraceGraph globalTraceGraph = new GlobalTraceGraph(getManager(), workerCreateListener); globalTraceGraph.create(); - SegmentCostGraph segmentCostGraph = new SegmentCostGraph(getManager(), workerCreateListener); - segmentCostGraph.create(); + SegmentDurationGraph segmentDurationGraph = new SegmentDurationGraph(getManager(), workerCreateListener); + segmentDurationGraph.create(); InstanceHeartBeatPersistenceGraph instanceHeartBeatPersistenceGraph = new InstanceHeartBeatPersistenceGraph(getManager(), workerCreateListener); instanceHeartBeatPersistenceGraph.create(); diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostGraph.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationGraph.java similarity index 83% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostGraph.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationGraph.java index badd115a0..af8fd2813 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostGraph.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationGraph.java @@ -22,23 +22,23 @@ import org.apache.skywalking.apm.collector.analysis.metric.define.graph.MetricGr import org.apache.skywalking.apm.collector.analysis.worker.model.base.WorkerCreateListener; import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration; /** * @author peng-yongsheng */ -public class SegmentCostGraph { +public class SegmentDurationGraph { private final ModuleManager moduleManager; private final WorkerCreateListener workerCreateListener; - public SegmentCostGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { + public SegmentDurationGraph(ModuleManager moduleManager, WorkerCreateListener workerCreateListener) { this.moduleManager = moduleManager; this.workerCreateListener = workerCreateListener; } public void create() { - GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class) - .addNode(new SegmentCostPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); + GraphManager.INSTANCE.createIfAbsent(MetricGraphIdDefine.SEGMENT_DURATION_GRAPH_ID, SegmentDuration.class) + .addNode(new SegmentDurationPersistenceWorker.Factory(moduleManager).create(workerCreateListener)); } } diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostPersistenceWorker.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationPersistenceWorker.java similarity index 74% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostPersistenceWorker.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationPersistenceWorker.java index aa6093627..17e9d7798 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostPersistenceWorker.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationPersistenceWorker.java @@ -24,20 +24,20 @@ import org.apache.skywalking.apm.collector.analysis.worker.model.impl.Persistenc import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration; /** * @author peng-yongsheng */ -public class SegmentCostPersistenceWorker extends PersistenceWorker { +public class SegmentDurationPersistenceWorker extends PersistenceWorker { - public SegmentCostPersistenceWorker(ModuleManager moduleManager) { + SegmentDurationPersistenceWorker(ModuleManager moduleManager) { super(moduleManager); } @Override public int id() { - return MetricWorkerIdDefine.SEGMENT_COST_PERSISTENCE_WORKER_ID; + return MetricWorkerIdDefine.SEGMENT_DURATION_PERSISTENCE_WORKER_ID; } @Override protected boolean needMergeDBData() { @@ -45,18 +45,18 @@ public class SegmentCostPersistenceWorker extends PersistenceWorker } @SuppressWarnings("unchecked") - @Override protected IPersistenceDAO persistenceDAO() { - return getModuleManager().find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class); + @Override protected IPersistenceDAO persistenceDAO() { + return getModuleManager().find(StorageModule.NAME).getService(ISegmentDurationPersistenceDAO.class); } - public static class Factory extends PersistenceWorkerProvider { + public static class Factory extends PersistenceWorkerProvider { public Factory(ModuleManager moduleManager) { super(moduleManager); } - @Override public SegmentCostPersistenceWorker workerInstance(ModuleManager moduleManager) { - return new SegmentCostPersistenceWorker(moduleManager); + @Override public SegmentDurationPersistenceWorker workerInstance(ModuleManager moduleManager) { + return new SegmentDurationPersistenceWorker(moduleManager); } @Override diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java similarity index 70% rename from apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostSpanListener.java rename to apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java index d12cfca97..e99126bc4 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentCostSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java @@ -35,46 +35,46 @@ import org.apache.skywalking.apm.collector.core.graph.GraphManager; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.BooleanUtils; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public class SegmentCostSpanListener implements EntrySpanListener, ExitSpanListener, LocalSpanListener, FirstSpanListener { +public class SegmentDurationSpanListener implements EntrySpanListener, ExitSpanListener, LocalSpanListener, FirstSpanListener { - private final Logger logger = LoggerFactory.getLogger(SegmentCostSpanListener.class); + private final Logger logger = LoggerFactory.getLogger(SegmentDurationSpanListener.class); - private final List segmentCosts; + private final List segmentDurations; private final ServiceNameCacheService serviceNameCacheService; private boolean isError = false; private long timeBucket; - public SegmentCostSpanListener(ModuleManager moduleManager) { - this.segmentCosts = new ArrayList<>(); + SegmentDurationSpanListener(ModuleManager moduleManager) { + this.segmentDurations = new ArrayList<>(); this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); } @Override public void parseFirst(SpanDecorator spanDecorator, int applicationId, int instanceId, String segmentId) { - timeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(spanDecorator.getStartTime()); + timeBucket = TimeBucketUtils.INSTANCE.getSecondTimeBucket(spanDecorator.getStartTime()); - SegmentCost segmentCost = new SegmentCost(); - segmentCost.setId(segmentId); - segmentCost.setSegmentId(segmentId); - segmentCost.setApplicationId(applicationId); - segmentCost.setCost(spanDecorator.getEndTime() - spanDecorator.getStartTime()); - segmentCost.setStartTime(spanDecorator.getStartTime()); - segmentCost.setEndTime(spanDecorator.getEndTime()); + SegmentDuration segmentDuration = new SegmentDuration(); + segmentDuration.setId(segmentId); + segmentDuration.setSegmentId(segmentId); + segmentDuration.setApplicationId(applicationId); + segmentDuration.setDuration(spanDecorator.getEndTime() - spanDecorator.getStartTime()); + segmentDuration.setStartTime(spanDecorator.getStartTime()); + segmentDuration.setEndTime(spanDecorator.getEndTime()); if (spanDecorator.getOperationNameId() == 0) { - segmentCost.setServiceName(spanDecorator.getOperationName()); + segmentDuration.setServiceName(spanDecorator.getOperationName()); } else { - segmentCost.setServiceName(serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(spanDecorator.getOperationNameId()))); + segmentDuration.setServiceName(serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(spanDecorator.getOperationNameId()))); } - segmentCosts.add(segmentCost); + segmentDurations.add(segmentDuration); isError = isError || spanDecorator.getIsError(); } @@ -96,18 +96,18 @@ public class SegmentCostSpanListener implements EntrySpanListener, ExitSpanListe } @Override public void build() { - Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SEGMENT_COST_GRAPH_ID, SegmentCost.class); + Graph graph = GraphManager.INSTANCE.findGraph(MetricGraphIdDefine.SEGMENT_DURATION_GRAPH_ID, SegmentDuration.class); logger.debug("segment cost listener build"); - for (SegmentCost segmentCost : segmentCosts) { - segmentCost.setIsError(BooleanUtils.booleanToValue(isError)); - segmentCost.setTimeBucket(timeBucket); - graph.start(segmentCost); + for (SegmentDuration segmentDuration : segmentDurations) { + segmentDuration.setIsError(BooleanUtils.booleanToValue(isError)); + segmentDuration.setTimeBucket(timeBucket); + graph.start(segmentDuration); } } public static class Factory implements SpanListenerFactory { @Override public SpanListener create(ModuleManager moduleManager) { - return new SegmentCostSpanListener(moduleManager); + return new SegmentDurationSpanListener(moduleManager); } } } diff --git a/apm-collector/apm-collector-boot/src/main/resources/application.yml b/apm-collector/apm-collector-boot/src/main/resources/application.yml index 6e8a91ddc..aa38e3799 100644 --- a/apm-collector/apm-collector-boot/src/main/resources/application.yml +++ b/apm-collector/apm-collector-boot/src/main/resources/application.yml @@ -34,18 +34,18 @@ ui: host: localhost port: 12800 context_path: / -#storage: -# elasticsearch: -# cluster_name: CollectorDBCluster -# cluster_transport_sniffer: true -# cluster_nodes: localhost:9300 -# index_shards_number: 2 -# index_replicas_number: 0 -# ttl: 7 storage: - h2: - url: jdbc:h2:tcp://localhost/~/test - user_name: sa + elasticsearch: + cluster_name: CollectorDBCluster + cluster_transport_sniffer: true + cluster_nodes: localhost:9300 + index_shards_number: 2 + index_replicas_number: 0 + ttl: 7 +#storage: +# h2: +# url: jdbc:h2:tcp://localhost/~/test +# user_name: sa configuration: default: application_apdex_threshold: 2000 diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java index c98f4c1e3..c024aafe8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java @@ -24,7 +24,7 @@ import org.apache.skywalking.apm.collector.core.module.Module; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; @@ -113,7 +113,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; @@ -197,7 +197,7 @@ public class StorageModule extends Module { classes.add(IInstanceMappingMonthPersistenceDAO.class); classes.add(IGlobalTracePersistenceDAO.class); - classes.add(ISegmentCostPersistenceDAO.class); + classes.add(ISegmentDurationPersistenceDAO.class); classes.add(ISegmentPersistenceDAO.class); classes.add(IInstanceHeartBeatPersistenceDAO.class); @@ -247,7 +247,7 @@ public class StorageModule extends Module { classes.add(IApplicationComponentUIDAO.class); classes.add(IApplicationMappingUIDAO.class); classes.add(IApplicationReferenceMetricUIDAO.class); - classes.add(ISegmentCostUIDAO.class); + classes.add(ISegmentDurationUIDAO.class); classes.add(ISegmentUIDAO.class); classes.add(IServiceReferenceUIDAO.class); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentDurationPersistenceDAO.java similarity index 86% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentDurationPersistenceDAO.java index f93b5c7f3..d9819e551 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentCostPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ISegmentDurationPersistenceDAO.java @@ -19,10 +19,10 @@ package org.apache.skywalking.apm.collector.storage.dao; import org.apache.skywalking.apm.collector.storage.base.dao.IPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration; /** * @author peng-yongsheng */ -public interface ISegmentCostPersistenceDAO extends IPersistenceDAO { +public interface ISegmentDurationPersistenceDAO extends IPersistenceDAO { } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentCostUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentDurationUIDAO.java similarity index 70% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentCostUIDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentDurationUIDAO.java index 7304fc768..a1660a417 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentCostUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/ISegmentDurationUIDAO.java @@ -18,22 +18,13 @@ package org.apache.skywalking.apm.collector.storage.dao.ui; -import com.google.gson.JsonObject; -import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief; /** * @author peng-yongsheng */ -public interface ISegmentCostUIDAO extends DAO { - JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, - Error error, int applicationId, List segmentIds, int limit, int from, Sort sort); - - enum Sort { - Cost, Time - } - - enum Error { - All, True, False - } +public interface ISegmentDurationUIDAO extends DAO { + TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName, + int applicationId, String traceId, int limit, int from); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCost.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentDuration.java similarity index 73% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCost.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentDuration.java index 475019bd0..9a0c94ff8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCost.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentDuration.java @@ -26,31 +26,32 @@ import org.apache.skywalking.apm.collector.core.data.operator.NonOperation; /** * @author peng-yongsheng */ -public class SegmentCost extends StreamData { +public class SegmentDuration extends StreamData { private static final Column[] STRING_COLUMNS = { - new Column(SegmentCostTable.COLUMN_ID, new NonOperation()), - new Column(SegmentCostTable.COLUMN_SEGMENT_ID, new CoverOperation()), - new Column(SegmentCostTable.COLUMN_SERVICE_NAME, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_ID, new NonOperation()), + new Column(SegmentDurationTable.COLUMN_SEGMENT_ID, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_SERVICE_NAME, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_TRACE_ID, new CoverOperation()), }; private static final Column[] LONG_COLUMNS = { - new Column(SegmentCostTable.COLUMN_COST, new CoverOperation()), - new Column(SegmentCostTable.COLUMN_START_TIME, new CoverOperation()), - new Column(SegmentCostTable.COLUMN_END_TIME, new CoverOperation()), - new Column(SegmentCostTable.COLUMN_TIME_BUCKET, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_DURATION, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_START_TIME, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_END_TIME, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_TIME_BUCKET, new CoverOperation()), }; private static final Column[] DOUBLE_COLUMNS = {}; private static final Column[] INTEGER_COLUMNS = { - new Column(SegmentCostTable.COLUMN_APPLICATION_ID, new CoverOperation()), - new Column(SegmentCostTable.COLUMN_IS_ERROR, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_APPLICATION_ID, new CoverOperation()), + new Column(SegmentDurationTable.COLUMN_IS_ERROR, new CoverOperation()), }; private static final Column[] BYTE_COLUMNS = {}; - public SegmentCost() { + public SegmentDuration() { super(STRING_COLUMNS, LONG_COLUMNS, DOUBLE_COLUMNS, INTEGER_COLUMNS, BYTE_COLUMNS); } @@ -86,12 +87,20 @@ public class SegmentCost extends StreamData { setDataString(2, serviceName); } - public Long getCost() { + public String getTraceId() { + return getDataString(3); + } + + public void setTraceId(String traceId) { + setDataString(3, traceId); + } + + public Long getDuration() { return getDataLong(0); } - public void setCost(Long cost) { - setDataLong(0, cost); + public void setDuration(Long duration) { + setDataLong(0, duration); } public Long getStartTime() { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCostTable.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentDurationTable.java similarity index 85% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCostTable.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentDurationTable.java index 4cf7abfaf..2784628ec 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentCostTable.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/table/segment/SegmentDurationTable.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.table.segment; import org.apache.skywalking.apm.collector.core.data.CommonTable; @@ -24,13 +23,14 @@ import org.apache.skywalking.apm.collector.core.data.CommonTable; /** * @author peng-yongsheng */ -public class SegmentCostTable extends CommonTable { - public static final String TABLE = "segment_cost"; +public class SegmentDurationTable extends CommonTable { + public static final String TABLE = "segment_duration"; public static final String COLUMN_SEGMENT_ID = "segment_id"; + public static final String COLUMN_TRACE_ID = "trace_id"; public static final String COLUMN_APPLICATION_ID = "application_id"; public static final String COLUMN_START_TIME = "start_time"; public static final String COLUMN_END_TIME = "end_time"; public static final String COLUMN_SERVICE_NAME = "service_name"; - public static final String COLUMN_COST = "cost"; + public static final String COLUMN_DURATION = "duration"; public static final String COLUMN_IS_ERROR = "is_error"; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java index a1acc0fe7..5085e8926 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalApp.java @@ -24,4 +24,20 @@ package org.apache.skywalking.apm.collector.storage.ui.overview; public class ConjecturalApp { private String name; private int num; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getNum() { + return num; + } + + public void setNum(int num) { + this.num = num; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java index d220623fa..0d561359b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/ConjecturalAppBrief.java @@ -25,4 +25,12 @@ import java.util.List; */ public class ConjecturalAppBrief { private List apps; + + public List getApps() { + return apps; + } + + public void setApps(List apps) { + this.apps = apps; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.java index f8829f128..127157bab 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/BasicTrace.java @@ -24,7 +24,47 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; public class BasicTrace { private String operationName; private int duration; - private String start; + private long start; private Boolean isError; private String traceId; + + public String getOperationName() { + return operationName; + } + + public void setOperationName(String operationName) { + this.operationName = operationName; + } + + public int getDuration() { + return duration; + } + + public void setDuration(int duration) { + this.duration = duration; + } + + public long getStart() { + return start; + } + + public void setStart(long start) { + this.start = start; + } + + public Boolean getError() { + return isError; + } + + public void setError(Boolean error) { + isError = error; + } + + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java index 1ec1987e3..df1963487 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceBrief.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; +import java.util.LinkedList; import java.util.List; /** @@ -25,5 +26,25 @@ import java.util.List; */ public class TraceBrief { private List traces; - private Integer total; + private int total; + + public TraceBrief() { + traces = new LinkedList<>(); + } + + public List getTraces() { + return traces; + } + + public void setTraces(List traces) { + this.traces = traces; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java index 62757804d..86bea1abe 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/TraceQueryCondition.java @@ -18,19 +18,74 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; -import java.util.List; import org.apache.skywalking.apm.collector.storage.ui.common.Duration; +import org.apache.skywalking.apm.collector.storage.ui.common.Pagination; /** * @author peng-yongsheng */ public class TraceQueryCondition { - private List applicationCodes; + private int applicationId; private String traceId; private String operationName; private Duration queryDuration; private int minTraceDuration; private int maxTraceDuration; - private Boolean topN; - private int needTotal; + private Pagination paging; + + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } + + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + public String getOperationName() { + return operationName; + } + + public void setOperationName(String operationName) { + this.operationName = operationName; + } + + public Duration getQueryDuration() { + return queryDuration; + } + + public void setQueryDuration(Duration queryDuration) { + this.queryDuration = queryDuration; + } + + public int getMinTraceDuration() { + return minTraceDuration; + } + + public void setMinTraceDuration(int minTraceDuration) { + this.minTraceDuration = minTraceDuration; + } + + public int getMaxTraceDuration() { + return maxTraceDuration; + } + + public void setMaxTraceDuration(int maxTraceDuration) { + this.maxTraceDuration = maxTraceDuration; + } + + public Pagination getPaging() { + return paging; + } + + public void setPaging(Pagination paging) { + this.paging = paging; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java index ca152a492..fde18dac3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/DataTTLKeeperTimer.java @@ -16,16 +16,16 @@ * */ - package org.apache.skywalking.apm.collector.storage.es; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.*; - import java.util.Calendar; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ampp.IApplicationMappingMinutePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.armp.IApplicationReferenceMinuteMetricPersistenceDAO; @@ -113,8 +113,8 @@ public class DataTTLKeeperTimer { IApplicationReferenceMinuteMetricPersistenceDAO applicationReferenceMetricPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationReferenceMinuteMetricPersistenceDAO.class); applicationReferenceMetricPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); - ISegmentCostPersistenceDAO segmentCostPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentCostPersistenceDAO.class); - segmentCostPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); + ISegmentDurationPersistenceDAO segmentDurationPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentDurationPersistenceDAO.class); + segmentDurationPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); ISegmentPersistenceDAO segmentPersistenceDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentPersistenceDAO.class); segmentPersistenceDAO.deleteHistory(startTimestamp, endTimestamp); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index 7a8ec4a9d..996b6cceb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -33,7 +33,7 @@ import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; @@ -122,7 +122,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; @@ -130,7 +130,7 @@ import org.apache.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller; import org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.InstanceHeartBeatEsPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.SegmentCostEsPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.SegmentDurationEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.SegmentEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentDayEsPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.dao.acp.ApplicationComponentHourEsPersistenceDAO; @@ -219,7 +219,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ui.InstanceMetricEsUID import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryPoolMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.NetworkAddressEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentCostEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentDurationEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceNameServiceEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsUIDAO; @@ -364,7 +364,7 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IApplicationReferenceDayMetricPersistenceDAO.class, new ApplicationReferenceDayMetricEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationReferenceMonthMetricPersistenceDAO.class, new ApplicationReferenceMonthMetricEsPersistenceDAO(elasticSearchClient)); - this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostEsPersistenceDAO(elasticSearchClient)); + this.registerServiceImplementation(ISegmentDurationPersistenceDAO.class, new SegmentDurationEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentEsPersistenceDAO(elasticSearchClient)); this.registerServiceImplementation(IServiceMinuteMetricPersistenceDAO.class, new ServiceMinuteMetricEsPersistenceDAO(elasticSearchClient)); @@ -405,7 +405,7 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricEsUIDAO(elasticSearchClient)); - this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostEsUIDAO(elasticSearchClient)); + this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceEsUIDAO(elasticSearchClient)); } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsPersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentDurationEsPersistenceDAO.java similarity index 63% rename from apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsPersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentDurationEsPersistenceDAO.java index 847e8b562..a1602b47b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentCostEsPersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/SegmentDurationEsPersistenceDAO.java @@ -22,10 +22,10 @@ import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable; import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.update.UpdateRequestBuilder; import org.elasticsearch.index.query.QueryBuilders; @@ -36,46 +36,46 @@ import org.slf4j.LoggerFactory; /** * @author peng-yongsheng */ -public class SegmentCostEsPersistenceDAO extends EsDAO implements ISegmentCostPersistenceDAO { +public class SegmentDurationEsPersistenceDAO extends EsDAO implements ISegmentDurationPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(SegmentCostEsPersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(SegmentDurationEsPersistenceDAO.class); - public SegmentCostEsPersistenceDAO(ElasticSearchClient client) { + public SegmentDurationEsPersistenceDAO(ElasticSearchClient client) { super(client); } - @Override public SegmentCost get(String id) { + @Override public SegmentDuration get(String id) { return null; } - @Override public UpdateRequestBuilder prepareBatchUpdate(SegmentCost data) { + @Override public UpdateRequestBuilder prepareBatchUpdate(SegmentDuration data) { return null; } - @Override public IndexRequestBuilder prepareBatchInsert(SegmentCost data) { + @Override public IndexRequestBuilder prepareBatchInsert(SegmentDuration data) { logger.debug("segment cost prepareBatchInsert, getId: {}", data.getId()); Map source = new HashMap<>(); - source.put(SegmentCostTable.COLUMN_SEGMENT_ID, data.getSegmentId()); - source.put(SegmentCostTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(SegmentCostTable.COLUMN_SERVICE_NAME, data.getServiceName()); - source.put(SegmentCostTable.COLUMN_COST, data.getCost()); - source.put(SegmentCostTable.COLUMN_START_TIME, data.getStartTime()); - source.put(SegmentCostTable.COLUMN_END_TIME, data.getEndTime()); - source.put(SegmentCostTable.COLUMN_IS_ERROR, data.getIsError()); - source.put(SegmentCostTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + source.put(SegmentDurationTable.COLUMN_SEGMENT_ID, data.getSegmentId()); + source.put(SegmentDurationTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(SegmentDurationTable.COLUMN_SERVICE_NAME, data.getServiceName()); + source.put(SegmentDurationTable.COLUMN_DURATION, data.getDuration()); + source.put(SegmentDurationTable.COLUMN_START_TIME, data.getStartTime()); + source.put(SegmentDurationTable.COLUMN_END_TIME, data.getEndTime()); + source.put(SegmentDurationTable.COLUMN_IS_ERROR, data.getIsError()); + source.put(SegmentDurationTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); logger.debug("segment cost source: {}", source.toString()); - return getClient().prepareIndex(SegmentCostTable.TABLE, data.getId()).setSource(source); + return getClient().prepareIndex(SegmentDurationTable.TABLE, data.getId()).setSource(source); } @Override public void deleteHistory(Long startTimestamp, Long endTimestamp) { long startTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(startTimestamp); long endTimeBucket = TimeBucketUtils.INSTANCE.getMinuteTimeBucket(endTimestamp); BulkByScrollResponse response = getClient().prepareDelete() - .filter(QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) - .source(SegmentCostTable.TABLE) + .filter(QueryBuilders.rangeQuery(SegmentDurationTable.COLUMN_TIME_BUCKET).gte(startTimeBucket).lte(endTimeBucket)) + .source(SegmentDurationTable.TABLE) .get(); long deleted = response.getDeleted(); - logger.info("Delete {} rows history from {} index.", deleted, SegmentCostTable.TABLE); + logger.info("Delete {} rows history from {} index.", deleted, SegmentDurationTable.TABLE); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.java deleted file mode 100644 index e33177881..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentCostEsUIDAO.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao.ui; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.util.List; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.CollectionUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.index.query.RangeQueryBuilder; -import org.elasticsearch.search.SearchHit; -import org.elasticsearch.search.sort.SortOrder; - -/** - * @author peng-yongsheng - */ -public class SegmentCostEsUIDAO extends EsDAO implements ISegmentCostUIDAO { - - public SegmentCostEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, - Error error, int applicationId, List segmentIds, int limit, int from, Sort sort) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(SegmentCostTable.TABLE); - searchRequestBuilder.setTypes(SegmentCostTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); - searchRequestBuilder.setQuery(boolQueryBuilder); - List mustQueryList = boolQueryBuilder.must(); - - mustQueryList.add(QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - if (minCost != -1 || maxCost != -1) { - RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentCostTable.COLUMN_COST); - if (minCost != -1) { - rangeQueryBuilder.gte(minCost); - } - if (maxCost != -1) { - rangeQueryBuilder.lte(maxCost); - } - boolQueryBuilder.must().add(rangeQueryBuilder); - } - if (StringUtils.isNotEmpty(operationName)) { - mustQueryList.add(QueryBuilders.matchQuery(SegmentCostTable.COLUMN_SERVICE_NAME, operationName)); - } - if (CollectionUtils.isNotEmpty(segmentIds)) { - boolQueryBuilder.must().add(QueryBuilders.termsQuery(SegmentCostTable.COLUMN_SEGMENT_ID, segmentIds.toArray(new String[0]))); - } - if (Error.True.equals(error)) { - boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, true)); - } else if (Error.False.equals(error)) { - boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_IS_ERROR, false)); - } - if (applicationId != 0) { - boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentCostTable.COLUMN_APPLICATION_ID, applicationId)); - } - - if (Sort.Cost.equals(sort)) { - searchRequestBuilder.addSort(SegmentCostTable.COLUMN_COST, SortOrder.DESC); - } else if (Sort.Time.equals(sort)) { - searchRequestBuilder.addSort(SegmentCostTable.COLUMN_START_TIME, SortOrder.DESC); - } - searchRequestBuilder.setSize(limit); - searchRequestBuilder.setFrom(from); - - SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); - - JsonObject topSegPaging = new JsonObject(); - topSegPaging.addProperty("recordsTotal", searchResponse.getHits().totalHits); - - JsonArray topSegArray = new JsonArray(); - topSegPaging.add("data", topSegArray); - - int num = from; - for (SearchHit searchHit : searchResponse.getHits().getHits()) { - JsonObject topSegmentJson = new JsonObject(); - topSegmentJson.addProperty("num", num); - String segmentId = (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SEGMENT_ID); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_START_TIME)); - if (searchHit.getSource().containsKey(SegmentCostTable.COLUMN_END_TIME)) { - topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_END_TIME)); - } - - topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_APPLICATION_ID)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, (String)searchHit.getSource().get(SegmentCostTable.COLUMN_SERVICE_NAME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, (Number)searchHit.getSource().get(SegmentCostTable.COLUMN_COST)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, (Boolean)searchHit.getSource().get(SegmentCostTable.COLUMN_IS_ERROR)); - - num++; - topSegArray.add(topSegmentJson); - } - - return topSegPaging; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java new file mode 100644 index 000000000..2ea1b4581 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/SegmentDurationEsUIDAO.java @@ -0,0 +1,100 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable; +import org.apache.skywalking.apm.collector.storage.ui.trace.BasicTrace; +import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.index.query.RangeQueryBuilder; +import org.elasticsearch.search.SearchHit; + +/** + * @author peng-yongsheng + */ +public class SegmentDurationEsUIDAO extends EsDAO implements ISegmentDurationUIDAO { + + public SegmentDurationEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override + public TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName, + int applicationId, String traceId, int limit, int from) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(SegmentDurationTable.TABLE); + searchRequestBuilder.setTypes(SegmentDurationTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery(); + searchRequestBuilder.setQuery(boolQueryBuilder); + List mustQueryList = boolQueryBuilder.must(); + + mustQueryList.add(QueryBuilders.rangeQuery(SegmentDurationTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + if (minDuration != 0 || maxDuration != 0) { + RangeQueryBuilder rangeQueryBuilder = QueryBuilders.rangeQuery(SegmentDurationTable.COLUMN_DURATION); + if (minDuration != 0) { + rangeQueryBuilder.gte(minDuration); + } + if (maxDuration != 0) { + rangeQueryBuilder.lte(maxDuration); + } + boolQueryBuilder.must().add(rangeQueryBuilder); + } + if (StringUtils.isNotEmpty(operationName)) { + mustQueryList.add(QueryBuilders.matchQuery(SegmentDurationTable.COLUMN_SERVICE_NAME, operationName)); + } + if (StringUtils.isNotEmpty(traceId)) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentDurationTable.COLUMN_SEGMENT_ID, traceId)); + } + if (applicationId != 0) { + boolQueryBuilder.must().add(QueryBuilders.termQuery(SegmentDurationTable.COLUMN_APPLICATION_ID, applicationId)); + } + + searchRequestBuilder.setSize(limit); + searchRequestBuilder.setFrom(from); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + TraceBrief traceBrief = new TraceBrief(); + traceBrief.setTotal((int)searchResponse.getHits().totalHits); + + for (SearchHit searchHit : searchResponse.getHits().getHits()) { + BasicTrace basicTrace = new BasicTrace(); + + basicTrace.setTraceId((String)searchHit.getSource().get(SegmentDurationTable.COLUMN_TRACE_ID)); + basicTrace.setStart(((Number)searchHit.getSource().get(SegmentDurationTable.COLUMN_START_TIME)).longValue()); + basicTrace.setOperationName((String)searchHit.getSource().get(SegmentDurationTable.COLUMN_SERVICE_NAME)); + basicTrace.setDuration(((Number)searchHit.getSource().get(SegmentDurationTable.COLUMN_DURATION)).intValue()); + basicTrace.setError(BooleanUtils.valueToBoolean(((Number)searchHit.getSource().get(SegmentDurationTable.COLUMN_IS_ERROR)).intValue())); + traceBrief.getTraces().add(basicTrace); + } + + return traceBrief; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentCostEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentCostEsTableDefine.java deleted file mode 100644 index 99003673b..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentCostEsTableDefine.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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.apm.collector.storage.es.define; - -import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; -import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; - -/** - * @author peng-yongsheng - */ -public class SegmentCostEsTableDefine extends ElasticSearchTableDefine { - - public SegmentCostEsTableDefine() { - super(SegmentCostTable.TABLE); - } - - @Override public int refreshInterval() { - return 5; - } - - @Override public void initialize() { - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_SEGMENT_ID, ElasticSearchColumnDefine.Type.Keyword.name())); - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_SERVICE_NAME, ElasticSearchColumnDefine.Type.Text.name())); - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_COST, ElasticSearchColumnDefine.Type.Long.name())); - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_START_TIME, ElasticSearchColumnDefine.Type.Long.name())); - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_END_TIME, ElasticSearchColumnDefine.Type.Long.name())); - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_IS_ERROR, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(SegmentCostTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentDurationEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentDurationEsTableDefine.java new file mode 100644 index 000000000..02d0a69d4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/SegmentDurationEsTableDefine.java @@ -0,0 +1,49 @@ +/* + * 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.apm.collector.storage.es.define; + +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchColumnDefine; +import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchTableDefine; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable; + +/** + * @author peng-yongsheng + */ +public class SegmentDurationEsTableDefine extends ElasticSearchTableDefine { + + public SegmentDurationEsTableDefine() { + super(SegmentDurationTable.TABLE); + } + + @Override public int refreshInterval() { + return 5; + } + + @Override public void initialize() { + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_SEGMENT_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_SERVICE_NAME, ElasticSearchColumnDefine.Type.Text.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_TRACE_ID, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_DURATION, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_START_TIME, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_END_TIME, ElasticSearchColumnDefine.Type.Long.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_IS_ERROR, ElasticSearchColumnDefine.Type.Integer.name())); + addColumn(new ElasticSearchColumnDefine(SegmentDurationTable.COLUMN_TIME_BUCKET, ElasticSearchColumnDefine.Type.Long.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define index d016737fb..725a4ceef 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/resources/META-INF/defines/storage.define @@ -50,7 +50,7 @@ org.apache.skywalking.apm.collector.storage.es.define.amp.ApplicationMonthMetric org.apache.skywalking.apm.collector.storage.es.define.GlobalTraceEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.SegmentEsTableDefine -org.apache.skywalking.apm.collector.storage.es.define.SegmentCostEsTableDefine +org.apache.skywalking.apm.collector.storage.es.define.SegmentDurationEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmEsTableDefine org.apache.skywalking.apm.collector.storage.es.define.alarm.ApplicationAlarmListEsTableDefine diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index f70a8e8c2..bc9278a0a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -29,7 +29,7 @@ import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.base.dao.IBatchDAO; import org.apache.skywalking.apm.collector.storage.dao.IGlobalTracePersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.IInstanceHeartBeatPersistenceDAO; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.ISegmentPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentDayPersistenceDAO; import org.apache.skywalking.apm.collector.storage.dao.acp.IApplicationComponentHourPersistenceDAO; @@ -118,7 +118,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; @@ -126,7 +126,7 @@ import org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller; import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.InstanceHeartBeatH2PersistenceDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentCostH2PersistenceDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentDurationH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.SegmentH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentDayH2PersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.acp.ApplicationComponentHourH2PersistenceDAO; @@ -215,7 +215,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ui.InstanceMetricH2UID import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryPoolMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.NetworkAddressH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentCostH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentDurationH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceNameServiceH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2UIDAO; @@ -316,7 +316,7 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IMemoryPoolMonthMetricPersistenceDAO.class, new MemoryPoolMonthMetricH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IGlobalTracePersistenceDAO.class, new GlobalTraceH2PersistenceDAO(h2Client)); - this.registerServiceImplementation(ISegmentCostPersistenceDAO.class, new SegmentCostH2PersistenceDAO(h2Client)); + this.registerServiceImplementation(ISegmentDurationPersistenceDAO.class, new SegmentDurationH2PersistenceDAO(h2Client)); this.registerServiceImplementation(ISegmentPersistenceDAO.class, new SegmentH2PersistenceDAO(h2Client)); this.registerServiceImplementation(IInstanceHeartBeatPersistenceDAO.class, new InstanceHeartBeatH2PersistenceDAO(h2Client)); @@ -381,7 +381,7 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IApplicationComponentUIDAO.class, new ApplicationComponentH2UIDAO(h2Client)); this.registerServiceImplementation(IApplicationMappingUIDAO.class, new ApplicationMappingH2UIDAO(h2Client)); this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricH2UIDAO(h2Client)); - this.registerServiceImplementation(ISegmentCostUIDAO.class, new SegmentCostH2UIDAO(h2Client)); + this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationH2UIDAO(h2Client)); this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentH2UIDAO(h2Client)); this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceH2UIDAO(h2Client)); } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentCostH2PersistenceDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentDurationH2PersistenceDAO.java similarity index 59% rename from apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentCostH2PersistenceDAO.java rename to apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentDurationH2PersistenceDAO.java index ced4126e0..30f70f50c 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentCostH2PersistenceDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/SegmentDurationH2PersistenceDAO.java @@ -23,51 +23,51 @@ import java.util.HashMap; import java.util.Map; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.ISegmentCostPersistenceDAO; +import org.apache.skywalking.apm.collector.storage.dao.ISegmentDurationPersistenceDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2SqlEntity; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCost; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDuration; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * @author peng-yongsheng, clevertension */ -public class SegmentCostH2PersistenceDAO extends H2DAO implements ISegmentCostPersistenceDAO { +public class SegmentDurationH2PersistenceDAO extends H2DAO implements ISegmentDurationPersistenceDAO { - private final Logger logger = LoggerFactory.getLogger(SegmentCostH2PersistenceDAO.class); + private final Logger logger = LoggerFactory.getLogger(SegmentDurationH2PersistenceDAO.class); - public SegmentCostH2PersistenceDAO(H2Client client) { + public SegmentDurationH2PersistenceDAO(H2Client client) { super(client); } - @Override public SegmentCost get(String id) { + @Override public SegmentDuration get(String id) { return null; } - @Override public H2SqlEntity prepareBatchInsert(SegmentCost data) { + @Override public H2SqlEntity prepareBatchInsert(SegmentDuration data) { logger.debug("segment cost prepareBatchInsert, getId: {}", data.getId()); H2SqlEntity entity = new H2SqlEntity(); Map source = new HashMap<>(); - source.put(SegmentCostTable.COLUMN_ID, data.getId()); - source.put(SegmentCostTable.COLUMN_SEGMENT_ID, data.getSegmentId()); - source.put(SegmentCostTable.COLUMN_APPLICATION_ID, data.getApplicationId()); - source.put(SegmentCostTable.COLUMN_SERVICE_NAME, data.getServiceName()); - source.put(SegmentCostTable.COLUMN_COST, data.getCost()); - source.put(SegmentCostTable.COLUMN_START_TIME, data.getStartTime()); - source.put(SegmentCostTable.COLUMN_END_TIME, data.getEndTime()); - source.put(SegmentCostTable.COLUMN_IS_ERROR, data.getIsError()); - source.put(SegmentCostTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); + source.put(SegmentDurationTable.COLUMN_ID, data.getId()); + source.put(SegmentDurationTable.COLUMN_SEGMENT_ID, data.getSegmentId()); + source.put(SegmentDurationTable.COLUMN_APPLICATION_ID, data.getApplicationId()); + source.put(SegmentDurationTable.COLUMN_SERVICE_NAME, data.getServiceName()); + source.put(SegmentDurationTable.COLUMN_DURATION, data.getDuration()); + source.put(SegmentDurationTable.COLUMN_START_TIME, data.getStartTime()); + source.put(SegmentDurationTable.COLUMN_END_TIME, data.getEndTime()); + source.put(SegmentDurationTable.COLUMN_IS_ERROR, data.getIsError()); + source.put(SegmentDurationTable.COLUMN_TIME_BUCKET, data.getTimeBucket()); logger.debug("segment cost source: {}", source.toString()); - String sql = SqlBuilder.buildBatchInsertSql(SegmentCostTable.TABLE, source.keySet()); + String sql = SqlBuilder.buildBatchInsertSql(SegmentDurationTable.TABLE, source.keySet()); entity.setSql(sql); entity.setParams(source.values().toArray(new Object[0])); return entity; } - @Override public H2SqlEntity prepareBatchUpdate(SegmentCost data) { + @Override public H2SqlEntity prepareBatchUpdate(SegmentDuration data) { return null; } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java deleted file mode 100644 index f3e0701e9..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentCostH2UIDAO.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao.ui; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.ArrayList; -import java.util.List; -import org.apache.skywalking.apm.collector.core.util.CollectionUtils; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; -import org.elasticsearch.search.sort.SortOrder; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.StringUtils; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class SegmentCostH2UIDAO extends H2DAO implements ISegmentCostUIDAO { - - private final Logger logger = LoggerFactory.getLogger(SegmentCostH2UIDAO.class); - private static final String GET_SEGMENT_COST_SQL = "select * from {0} where {1} >= ? and {1} <= ?"; - - public SegmentCostH2UIDAO(H2Client client) { - super(client); - } - - @Override public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, - Error error, int applicationId, List segmentIds, int limit, int from, Sort sort) { - H2Client client = getClient(); - String sql = GET_SEGMENT_COST_SQL; - List params = new ArrayList<>(); - List columns = new ArrayList<>(); - columns.add(SegmentCostTable.TABLE); - columns.add(SegmentCostTable.COLUMN_TIME_BUCKET); - params.add(startTime); - params.add(endTime); - int paramIndex = 1; - if (minCost != -1 || maxCost != -1) { - if (minCost != -1) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} >= ?"; - params.add(minCost); - columns.add(SegmentCostTable.COLUMN_COST); - } - if (maxCost != -1) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} <= ?"; - params.add(maxCost); - columns.add(SegmentCostTable.COLUMN_COST); - } - } - if (StringUtils.isNotEmpty(operationName)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(operationName); - columns.add(SegmentCostTable.COLUMN_SERVICE_NAME); - } - if (CollectionUtils.isNotEmpty(segmentIds)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} in ("; - columns.add(SegmentCostTable.COLUMN_SEGMENT_ID); - StringBuilder builder = new StringBuilder(); - for (int i = 0; i < segmentIds.size(); i++) { - builder.append("?,"); - } - builder.delete(builder.length() - 1, builder.length()); - builder.append(")"); - sql = sql + builder; - for (String segmentId : segmentIds) { - params.add(segmentId); - } - } - if (Error.True.equals(error)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(true); - columns.add(SegmentCostTable.COLUMN_IS_ERROR); - } else if (Error.False.equals(error)) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(false); - columns.add(SegmentCostTable.COLUMN_IS_ERROR); - } - if (applicationId != 0) { - paramIndex++; - sql = sql + " and {" + paramIndex + "} = ?"; - params.add(applicationId); - columns.add(SegmentCostTable.COLUMN_APPLICATION_ID); - } - - if (Sort.Cost.equals(sort)) { - sql = sql + " order by " + SegmentCostTable.COLUMN_COST + " " + SortOrder.DESC; - } else if (Sort.Time.equals(sort)) { - sql = sql + " order by " + SegmentCostTable.COLUMN_START_TIME + " " + SortOrder.DESC; - } - - sql = sql + " limit " + from + "," + limit; - sql = SqlBuilder.buildSql(sql, columns); - Object[] p = params.toArray(new Object[0]); - - JsonObject topSegPaging = new JsonObject(); - - JsonArray topSegArray = new JsonArray(); - topSegPaging.add("data", topSegArray); - int cnt = 0; - int num = from; - try (ResultSet rs = client.executeQuery(sql, p)) { - while (rs.next()) { - JsonObject topSegmentJson = new JsonObject(); - topSegmentJson.addProperty("num", num); - String segmentId = rs.getString(SegmentCostTable.COLUMN_SEGMENT_ID); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SEGMENT_ID, segmentId); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_START_TIME, rs.getLong(SegmentCostTable.COLUMN_START_TIME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_END_TIME, rs.getLong(SegmentCostTable.COLUMN_END_TIME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_APPLICATION_ID, rs.getInt(SegmentCostTable.COLUMN_APPLICATION_ID)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_SERVICE_NAME, rs.getString(SegmentCostTable.COLUMN_SERVICE_NAME)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_COST, rs.getLong(SegmentCostTable.COLUMN_COST)); - topSegmentJson.addProperty(SegmentCostTable.COLUMN_IS_ERROR, rs.getBoolean(SegmentCostTable.COLUMN_IS_ERROR)); - - num++; - topSegArray.add(topSegmentJson); - cnt++; - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - topSegPaging.addProperty("recordsTotal", cnt); - return topSegPaging; - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentDurationH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentDurationH2UIDAO.java new file mode 100644 index 000000000..a12771f73 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/SegmentDurationH2UIDAO.java @@ -0,0 +1,118 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.BooleanUtils; +import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable; +import org.apache.skywalking.apm.collector.storage.ui.trace.BasicTrace; +import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng, clevertension + */ +public class SegmentDurationH2UIDAO extends H2DAO implements ISegmentDurationUIDAO { + + private final Logger logger = LoggerFactory.getLogger(SegmentDurationH2UIDAO.class); + + public SegmentDurationH2UIDAO(H2Client client) { + super(client); + } + + @Override + public TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName, + int applicationId, String traceId, int limit, int from) { + H2Client client = getClient(); + String sql = "select * from {0} where {1} >= ? and {1} <= ?"; + List params = new ArrayList<>(); + List columns = new ArrayList<>(); + columns.add(SegmentDurationTable.TABLE); + columns.add(SegmentDurationTable.COLUMN_TIME_BUCKET); + params.add(startTime); + params.add(endTime); + int paramIndex = 1; + if (minDuration != -1 || maxDuration != -1) { + if (minDuration != -1) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} >= ?"; + params.add(minDuration); + columns.add(SegmentDurationTable.COLUMN_DURATION); + } + if (maxDuration != -1) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} <= ?"; + params.add(maxDuration); + columns.add(SegmentDurationTable.COLUMN_DURATION); + } + } + if (StringUtils.isNotEmpty(operationName)) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} = ?"; + params.add(operationName); + columns.add(SegmentDurationTable.COLUMN_SERVICE_NAME); + } + if (StringUtils.isNotEmpty(traceId)) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} = ?"; + params.add(traceId); + columns.add(SegmentDurationTable.COLUMN_TRACE_ID); + } + if (applicationId != 0) { + paramIndex++; + sql = sql + " and {" + paramIndex + "} = ?"; + params.add(applicationId); + columns.add(SegmentDurationTable.COLUMN_APPLICATION_ID); + } + + sql = sql + " limit " + from + "," + limit; + sql = SqlBuilder.buildSql(sql, columns); + Object[] p = params.toArray(new Object[0]); + + TraceBrief traceBrief = new TraceBrief(); + + int cnt = 0; + try (ResultSet rs = client.executeQuery(sql, p)) { + while (rs.next()) { + BasicTrace basicTrace = new BasicTrace(); + basicTrace.setDuration(rs.getInt(SegmentDurationTable.COLUMN_DURATION)); + basicTrace.setStart(rs.getLong(SegmentDurationTable.COLUMN_START_TIME)); + basicTrace.setTraceId(rs.getString(SegmentDurationTable.COLUMN_TRACE_ID)); + basicTrace.setOperationName(rs.getString(SegmentDurationTable.COLUMN_SERVICE_NAME)); + basicTrace.setError(BooleanUtils.valueToBoolean(rs.getInt(SegmentDurationTable.COLUMN_IS_ERROR))); + traceBrief.getTraces().add(basicTrace); + cnt++; + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + traceBrief.setTotal(cnt); + return traceBrief; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java deleted file mode 100644 index bc51a2d56..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentCostH2TableDefine.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * 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.apm.collector.storage.h2.define; - -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; -import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; - -/** - * @author peng-yongsheng - */ -public class SegmentCostH2TableDefine extends H2TableDefine { - - public SegmentCostH2TableDefine() { - super(SegmentCostTable.TABLE); - } - - @Override public void initialize() { - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_SEGMENT_ID, H2ColumnDefine.Type.Varchar.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_SERVICE_NAME, H2ColumnDefine.Type.Varchar.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_COST, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_START_TIME, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_END_TIME, H2ColumnDefine.Type.Bigint.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_IS_ERROR, H2ColumnDefine.Type.Int.name())); - addColumn(new H2ColumnDefine(SegmentCostTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentDurationH2TableDefine.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentDurationH2TableDefine.java new file mode 100644 index 000000000..1cf32d312 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/define/SegmentDurationH2TableDefine.java @@ -0,0 +1,46 @@ +/* + * 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.apm.collector.storage.h2.define; + +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2ColumnDefine; +import org.apache.skywalking.apm.collector.storage.h2.base.define.H2TableDefine; +import org.apache.skywalking.apm.collector.storage.table.segment.SegmentDurationTable; + +/** + * @author peng-yongsheng + */ +public class SegmentDurationH2TableDefine extends H2TableDefine { + + public SegmentDurationH2TableDefine() { + super(SegmentDurationTable.TABLE); + } + + @Override public void initialize() { + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_SEGMENT_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_APPLICATION_ID, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_SERVICE_NAME, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_TRACE_ID, H2ColumnDefine.Type.Varchar.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_DURATION, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_START_TIME, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_END_TIME, H2ColumnDefine.Type.Bigint.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_IS_ERROR, H2ColumnDefine.Type.Int.name())); + addColumn(new H2ColumnDefine(SegmentDurationTable.COLUMN_TIME_BUCKET, H2ColumnDefine.Type.Bigint.name())); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define index 476ac990e..b3403d961 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define @@ -43,7 +43,7 @@ org.apache.skywalking.apm.collector.storage.h2.define.instmapping.InstanceMappin org.apache.skywalking.apm.collector.storage.h2.define.instmapping.InstanceMappingMonthH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.GlobalTraceH2TableDefine -org.apache.skywalking.apm.collector.storage.h2.define.SegmentCostH2TableDefine +org.apache.skywalking.apm.collector.storage.h2.define.SegmentDurationH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.SegmentH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.amp.ApplicationMinuteMetricH2TableDefine diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java index 9ac853c47..6d1fa55a9 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java @@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBri import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.service.AlarmService; import org.apache.skywalking.apm.collector.ui.service.ApplicationService; import org.apache.skywalking.apm.collector.ui.service.ClusterTopologyService; import org.apache.skywalking.apm.collector.ui.service.NetworkAddressService; @@ -46,6 +47,7 @@ public class OverViewLayerQuery implements Query { private ApplicationService applicationService; private NetworkAddressService networkAddressService; private ServiceNameService serviceNameService; + private AlarmService alarmService; public OverViewLayerQuery(ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -79,6 +81,13 @@ public class OverViewLayerQuery implements Query { return serviceNameService; } + private AlarmService getAlarmService() { + if (ObjectUtils.isEmpty(alarmService)) { + this.alarmService = new AlarmService(moduleManager); + } + return alarmService; + } + public Topology getClusterTopology(Duration duration) throws ParseException { long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); @@ -99,8 +108,10 @@ public class OverViewLayerQuery implements Query { return clusterBrief; } - public AlarmTrend getAlarmTrend(Duration duration) { - return null; + public AlarmTrend getAlarmTrend(Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); + long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); + return getAlarmService().getApplicationAlarmTrend(duration.getStep(), start, end); } public ConjecturalAppBrief getConjecturalApps(Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java index 32eaa7291..e77a8e59f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java @@ -18,17 +18,48 @@ package org.apache.skywalking.apm.collector.ui.query; -import org.apache.skywalking.apm.collector.ui.graphql.Query; +import java.text.ParseException; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.ui.trace.Trace; import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief; import org.apache.skywalking.apm.collector.storage.ui.trace.TraceQueryCondition; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.service.SegmentTopService; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** * @author peng-yongsheng */ public class TraceQuery implements Query { - public TraceBrief queryBasicTraces(TraceQueryCondition condition) { - return null; + + private final ModuleManager moduleManager; + private SegmentTopService segmentTopService; + + public TraceQuery(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + private SegmentTopService getSegmentTopService() { + if (ObjectUtils.isEmpty(segmentTopService)) { + this.segmentTopService = new SegmentTopService(moduleManager); + } + return segmentTopService; + } + + public TraceBrief queryBasicTraces(TraceQueryCondition condition) throws ParseException { + long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getStart()); + long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getEnd()); + + long minDuration = condition.getMinTraceDuration(); + long maxDuration = condition.getMaxTraceDuration(); + String operationName = condition.getOperationName(); + String traceId = condition.getTraceId(); + int applicationId = condition.getApplicationId(); + int limit = condition.getPaging().getPageSize(); + int from = condition.getPaging().getPageSize() * condition.getPaging().getPageNum(); + + return segmentTopService.loadTop(start, end, minDuration, maxDuration, operationName, traceId, applicationId, limit, from); } public Trace queryTrace(String id) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/AlarmService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/AlarmService.java new file mode 100644 index 000000000..e364088f8 --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/AlarmService.java @@ -0,0 +1,44 @@ +/* + * 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.apm.collector.ui.service; + +import java.text.ParseException; +import java.util.List; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; + +/** + * @author peng-yongsheng + */ +public class AlarmService { + + public AlarmService(ModuleManager moduleManager) { + + } + + public AlarmTrend getApplicationAlarmTrend(Step step, long start, long end) throws ParseException { + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + + AlarmTrend alarmTrend = new AlarmTrend(); + return alarmTrend; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java index 3d3b452f5..10173b3e6 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SegmentTopService.java @@ -16,22 +16,12 @@ * */ - package org.apache.skywalking.apm.collector.ui.service; -import com.google.gson.JsonArray; -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import java.util.LinkedList; -import java.util.List; import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.CollectionUtils; -import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentCostUIDAO; -import org.apache.skywalking.apm.collector.storage.table.segment.SegmentCostTable; -import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.table.global.GlobalTraceTable; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,34 +32,16 @@ public class SegmentTopService { private final Logger logger = LoggerFactory.getLogger(SegmentTopService.class); - private final IGlobalTraceUIDAO globalTraceDAO; - private final ISegmentCostUIDAO segmentCostDAO; + private final ISegmentDurationUIDAO segmentDurationUIDAO; public SegmentTopService(ModuleManager moduleManager) { - this.globalTraceDAO = moduleManager.find(StorageModule.NAME).getService(IGlobalTraceUIDAO.class); - this.segmentCostDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentCostUIDAO.class); + this.segmentDurationUIDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentDurationUIDAO.class); } - public JsonObject loadTop(long startTime, long endTime, long minCost, long maxCost, String operationName, - String globalTraceId, ISegmentCostUIDAO.Error error, int applicationId, int limit, int from, - ISegmentCostUIDAO.Sort sort) { - logger.debug("startTime: {}, endTime: {}, minCost: {}, maxCost: {}, operationName: {}, globalTraceId: {}, error: {}, applicationId: {}, limit: {}, from: {}", startTime, endTime, minCost, maxCost, operationName, globalTraceId, error, applicationId, limit, from); + public TraceBrief loadTop(long startTime, long endTime, long minDuration, long maxDuration, String operationName, + String traceId, int applicationId, int limit, int from) { + logger.debug("startTime: {}, endTime: {}, minDuration: {}, maxDuration: {}, operationName: {}, traceId: {}, applicationId: {}, limit: {}, from: {}", startTime, endTime, minDuration, maxDuration, operationName, traceId, applicationId, limit, from); - List segmentIds = new LinkedList<>(); - if (StringUtils.isNotEmpty(globalTraceId)) { - segmentIds = globalTraceDAO.getSegmentIds(globalTraceId); - } - - JsonObject loadTopJsonObj = segmentCostDAO.loadTop(startTime, endTime, minCost, maxCost, operationName, error, applicationId, segmentIds, limit, from, sort); - JsonArray loadTopJsonArray = loadTopJsonObj.get("data").getAsJsonArray(); - for (JsonElement loadTopElement : loadTopJsonArray) { - JsonObject jsonObject = loadTopElement.getAsJsonObject(); - String segmentId = jsonObject.get(SegmentCostTable.COLUMN_SEGMENT_ID).getAsString(); - List globalTraces = globalTraceDAO.getGlobalTraceId(segmentId); - if (CollectionUtils.isNotEmpty(globalTraces)) { - jsonObject.addProperty(GlobalTraceTable.COLUMN_GLOBAL_TRACE_ID, globalTraces.get(0)); - } - } - return loadTopJsonObj; + return segmentDurationUIDAO.loadTop(startTime, endTime, minDuration, maxDuration, operationName, applicationId, traceId, limit, from); } } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls index 0e5340899..9188cfedb 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/trace.graphqls @@ -15,7 +15,8 @@ type BasicTrace { # Represent the conditions used for query TraceBrief input TraceQueryCondition { - applicationCodes: [String!] + # The value of 0 means all application. + applicationId: Int traceId: String operationName: String # The time range of traces started From 1d625d2ad5116874d1ec7c5d3bb08afc6d3a4fce Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Sun, 4 Feb 2018 23:57:40 +0800 Subject: [PATCH 25/36] Provide the queryTrace query. --- .../test/resources/json/dubbox-provider.json | 2 +- .../collector/storage/ui/trace/KeyValue.java | 16 ++ .../collector/storage/ui/trace/LogEntity.java | 23 +- .../apm/collector/storage/ui/trace/Ref.java | 34 ++- .../apm/collector/storage/ui/trace/Span.java | 170 ++++++++++- .../apm/collector/storage/ui/trace/Trace.java | 14 + .../ui/jetty/handler/GraphQLHandler.java | 11 +- .../apm/collector/ui/query/TraceQuery.java | 15 +- .../ui/service/TraceStackService.java | 272 ++++++++---------- 9 files changed, 397 insertions(+), 160 deletions(-) diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json index 01c6e76ad..174112074 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json @@ -24,7 +24,7 @@ { "pts": [230150, 185809, 24040000], //上级的segment_id 一个应用中的一个实例在链路中产生的编号 "pii": 2, //上级的实例编号 - "psp": 0, //上级的埋点编号span_id + "psp": 1, //上级的埋点编号span_id "psi": 0, //上级的服务编号(org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()注册后的ID) "psn": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", //上级的服务名 "ni": 0, //上级调用时使用的地址注册后的ID diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java index 03e1d6857..deac45f07 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/KeyValue.java @@ -24,4 +24,20 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; public class KeyValue { private String key; private String value; + + public String getKey() { + return key; + } + + public void setKey(String key) { + this.key = key; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java index 61855c8ea..a7988702e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/LogEntity.java @@ -18,12 +18,33 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; +import java.util.LinkedList; import java.util.List; /** * @author peng-yongsheng */ public class LogEntity { - private String time; + private long time; private List data; + + public LogEntity() { + this.data = new LinkedList<>(); + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public List getData() { + return data; + } + + public void setData(List data) { + this.data = data; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java index a013e0c1a..7f189e765 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Ref.java @@ -23,7 +23,39 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; */ public class Ref { private String traceId; - private Integer parentSegmentId; + private String parentSegmentId; private Integer parentSpanId; private RefType type; + + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + public String getParentSegmentId() { + return parentSegmentId; + } + + public void setParentSegmentId(String parentSegmentId) { + this.parentSegmentId = parentSegmentId; + } + + public Integer getParentSpanId() { + return parentSpanId; + } + + public void setParentSpanId(Integer parentSpanId) { + this.parentSpanId = parentSpanId; + } + + public RefType getType() { + return type; + } + + public void setType(RefType type) { + this.type = type; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java index 1df21844c..9d56c39ce 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Span.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; +import java.util.LinkedList; import java.util.List; /** @@ -26,12 +27,12 @@ import java.util.List; public class Span { private String traceId; private String segmentId; - private Integer spanId; - private Integer parentSpanId; + private int spanId; + private int parentSpanId; private List refs; private String applicationCode; - private Long startTime; - private Long endTime; + private long startTime; + private long endTime; private String operationName; private String type; private String peer; @@ -40,4 +41,165 @@ public class Span { private String layer; private List tags; private List logs; + private boolean isRoot; + private String segmentSpanId; + private String segmentParentSpanId; + + public Span() { + this.refs = new LinkedList<>(); + this.tags = new LinkedList<>(); + this.logs = new LinkedList<>(); + } + + public String getTraceId() { + return traceId; + } + + public void setTraceId(String traceId) { + this.traceId = traceId; + } + + public String getSegmentId() { + return segmentId; + } + + public void setSegmentId(String segmentId) { + this.segmentId = segmentId; + } + + public int getSpanId() { + return spanId; + } + + public void setSpanId(int spanId) { + this.spanId = spanId; + } + + public int getParentSpanId() { + return parentSpanId; + } + + public void setParentSpanId(int parentSpanId) { + this.parentSpanId = parentSpanId; + } + + public List getRefs() { + return refs; + } + + public void setRefs(List refs) { + this.refs = refs; + } + + public String getApplicationCode() { + return applicationCode; + } + + public void setApplicationCode(String applicationCode) { + this.applicationCode = applicationCode; + } + + public long getStartTime() { + return startTime; + } + + public void setStartTime(long startTime) { + this.startTime = startTime; + } + + public long getEndTime() { + return endTime; + } + + public void setEndTime(long endTime) { + this.endTime = endTime; + } + + public String getOperationName() { + return operationName; + } + + public void setOperationName(String operationName) { + this.operationName = operationName; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getPeer() { + return peer; + } + + public void setPeer(String peer) { + this.peer = peer; + } + + public String getComponent() { + return component; + } + + public void setComponent(String component) { + this.component = component; + } + + public Boolean getError() { + return isError; + } + + public void setError(Boolean error) { + isError = error; + } + + public String getLayer() { + return layer; + } + + public void setLayer(String layer) { + this.layer = layer; + } + + public List getTags() { + return tags; + } + + public void setTags(List tags) { + this.tags = tags; + } + + public List getLogs() { + return logs; + } + + public void setLogs(List logs) { + this.logs = logs; + } + + public boolean isRoot() { + return isRoot; + } + + public void setRoot(boolean root) { + isRoot = root; + } + + public String getSegmentParentSpanId() { + return segmentParentSpanId; + } + + public void setSegmentParentSpanId(String segmentParentSpanId) { + this.segmentParentSpanId = segmentParentSpanId; + } + + public String getSegmentSpanId() { + return segmentSpanId; + } + + public void setSegmentSpanId(String segmentSpanId) { + this.segmentSpanId = segmentSpanId; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java index a9f03964f..a3524aa44 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/trace/Trace.java @@ -18,11 +18,25 @@ package org.apache.skywalking.apm.collector.storage.ui.trace; +import java.util.LinkedList; import java.util.List; /** * @author peng-yongsheng */ public class Trace { + private List spans; + + public Trace() { + this.spans = new LinkedList<>(); + } + + public List getSpans() { + return spans; + } + + public void setSpans(List spans) { + this.spans = spans; + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index c66a5052c..7c30f793d 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -23,6 +23,7 @@ import com.google.gson.Gson; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; +import com.google.gson.reflect.TypeToken; import graphql.ExecutionInput; import graphql.ExecutionResult; import graphql.GraphQL; @@ -31,6 +32,7 @@ import graphql.schema.GraphQLSchema; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; +import java.lang.reflect.Type; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; @@ -64,6 +66,7 @@ public class GraphQLHandler extends JettyHandler { private final Gson gson = new Gson(); private final GraphQL graphQL; private static final String QUERY = "query"; + private static final String VARIABLES = "variables"; private static final String DATA = "data"; private static final String ERRORS = "errors"; private static final String MESSAGE = "message"; @@ -79,7 +82,7 @@ public class GraphQLHandler extends JettyHandler { .file("ui-graphql/service-layer.graphqls") .file("ui-graphql/trace.graphqls") .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery(moduleManager)) - .resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(moduleManager), new ServiceQuery(), new TraceQuery()) + .resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(moduleManager), new ServiceQuery(), new TraceQuery(moduleManager)) .resolvers(new ConfigQuery(), new ConfigMutation()) .dictionary(ConjecturalNode.class, VisualUserNode.class, ApplicationNode.class) .build() @@ -105,7 +108,11 @@ public class GraphQLHandler extends JettyHandler { } JsonObject requestJson = gson.fromJson(request, JsonObject.class); - return execute(requestJson.get(QUERY).getAsString(), gson.fromJson(requestJson.get("variables"), Map.class)); + + Type mapType = new TypeToken>() { + }.getType(); + + return execute(requestJson.get(QUERY).getAsString(), gson.fromJson(requestJson.get(VARIABLES), mapType)); } private JsonObject execute(String request, Map variables) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java index e77a8e59f..336824467 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/TraceQuery.java @@ -26,6 +26,7 @@ import org.apache.skywalking.apm.collector.storage.ui.trace.TraceBrief; import org.apache.skywalking.apm.collector.storage.ui.trace.TraceQueryCondition; import org.apache.skywalking.apm.collector.ui.graphql.Query; import org.apache.skywalking.apm.collector.ui.service.SegmentTopService; +import org.apache.skywalking.apm.collector.ui.service.TraceStackService; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** @@ -35,6 +36,7 @@ public class TraceQuery implements Query { private final ModuleManager moduleManager; private SegmentTopService segmentTopService; + private TraceStackService traceStackService; public TraceQuery(ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -47,6 +49,13 @@ public class TraceQuery implements Query { return segmentTopService; } + private TraceStackService getTraceStackService() { + if (ObjectUtils.isEmpty(traceStackService)) { + this.traceStackService = new TraceStackService(moduleManager); + } + return traceStackService; + } + public TraceBrief queryBasicTraces(TraceQueryCondition condition) throws ParseException { long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getStart()); long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(condition.getQueryDuration().getStep(), condition.getQueryDuration().getEnd()); @@ -59,10 +68,10 @@ public class TraceQuery implements Query { int limit = condition.getPaging().getPageSize(); int from = condition.getPaging().getPageSize() * condition.getPaging().getPageNum(); - return segmentTopService.loadTop(start, end, minDuration, maxDuration, operationName, traceId, applicationId, limit, from); + return getSegmentTopService().loadTop(start, end, minDuration, maxDuration, operationName, traceId, applicationId, limit, from); } - public Trace queryTrace(String id) { - return null; + public Trace queryTrace(String traceId) { + return getTraceStackService().load(traceId); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java index 55bb369ea..989d4318f 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java @@ -16,26 +16,33 @@ * */ - package org.apache.skywalking.apm.collector.ui.service; -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; import java.util.ArrayList; +import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; +import org.apache.skywalking.apm.collector.cache.service.NetworkAddressCacheService; +import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.CollectionUtils; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; -import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; -import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; -import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.trace.KeyValue; +import org.apache.skywalking.apm.collector.storage.ui.trace.LogEntity; +import org.apache.skywalking.apm.collector.storage.ui.trace.Ref; +import org.apache.skywalking.apm.collector.storage.ui.trace.RefType; +import org.apache.skywalking.apm.collector.storage.ui.trace.Span; +import org.apache.skywalking.apm.collector.storage.ui.trace.Trace; import org.apache.skywalking.apm.network.proto.SpanObject; import org.apache.skywalking.apm.network.proto.TraceSegmentObject; +import org.apache.skywalking.apm.network.proto.UniqueId; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; /** * @author peng-yongsheng @@ -46,60 +53,45 @@ public class TraceStackService { private final ISegmentUIDAO segmentDAO; private final ApplicationCacheService applicationCacheService; private final ServiceNameCacheService serviceNameCacheService; + private final NetworkAddressCacheService networkAddressCacheService; public TraceStackService(ModuleManager moduleManager) { this.globalTraceDAO = moduleManager.find(StorageModule.NAME).getService(IGlobalTraceUIDAO.class); this.segmentDAO = moduleManager.find(StorageModule.NAME).getService(ISegmentUIDAO.class); this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); + this.networkAddressCacheService = moduleManager.find(CacheModule.NAME).getService(NetworkAddressCacheService.class); } - public JsonArray load(String globalTraceId) { - List spans = new ArrayList<>(); - List segmentIds = globalTraceDAO.getSegmentIds(globalTraceId); + public Trace load(String traceId) { + Trace trace = new Trace(); + List segmentIds = globalTraceDAO.getSegmentIds(traceId); if (CollectionUtils.isNotEmpty(segmentIds)) { for (String segmentId : segmentIds) { TraceSegmentObject segment = segmentDAO.load(segmentId); if (ObjectUtils.isNotEmpty(segment)) { - spans.addAll(buildSpanList(segmentId, segment)); + trace.getSpans().addAll(buildSpanList(traceId, segmentId, segment.getApplicationId(), segment.getSpansList())); } } } - List sortedSpans = new ArrayList<>(); - if (CollectionUtils.isNotEmpty(spans)) { - List rootSpans = findRoot(spans); + List sortedSpans = new LinkedList<>(); + if (CollectionUtils.isNotEmpty(trace.getSpans())) { + List rootSpans = findRoot(trace.getSpans()); if (CollectionUtils.isNotEmpty(rootSpans)) { rootSpans.forEach(span -> { List childrenSpan = new ArrayList<>(); childrenSpan.add(span); - findChildren(spans, span, childrenSpan); + findChildren(trace.getSpans(), span, childrenSpan); sortedSpans.addAll(childrenSpan); }); } } - minStartTime(sortedSpans); +// minStartTime(sortedSpans); - return toJsonArray(sortedSpans); - } - - private JsonArray toJsonArray(List sortedSpans) { - JsonArray traceStackArray = new JsonArray(); - sortedSpans.forEach(span -> { - JsonObject spanJson = new JsonObject(); - spanJson.addProperty("spanId", span.getSpanId()); - spanJson.addProperty("parentSpanId", span.getParentSpanId()); - spanJson.addProperty("segmentSpanId", span.getSegmentSpanId()); - spanJson.addProperty("segmentParentSpanId", span.getSegmentParentSpanId()); - spanJson.addProperty("startTime", span.getStartTime()); - spanJson.addProperty("operationName", span.getOperationName()); - spanJson.addProperty("applicationCode", span.getApplicationCode()); - spanJson.addProperty("cost", span.getCost()); - spanJson.addProperty("isRoot", span.isRoot()); - traceStackArray.add(spanJson); - }); - return traceStackArray; + trace.setSpans(sortedSpans); + return trace; } private void minStartTime(List spans) { @@ -115,56 +107,108 @@ public class TraceStackService { } } - private List buildSpanList(String segmentId, TraceSegmentObject segment) { + private List buildSpanList(String traceId, String segmentId, int applicationId, + List spanObjects) { List spans = new ArrayList<>(); - if (segment.getSpansCount() > 0) { - for (SpanObject spanObject : segment.getSpansList()) { - int spanId = spanObject.getSpanId(); - int parentSpanId = spanObject.getParentSpanId(); - String segmentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(spanId); - String segmentParentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(parentSpanId); - long startTime = spanObject.getStartTime(); - String operationName = spanObject.getOperationName(); - if (spanObject.getOperationNameId() != 0) { - String serviceName = serviceNameCacheService.get(spanObject.getOperationNameId()); - if (StringUtils.isNotEmpty(serviceName)) { - operationName = serviceName.split(Const.ID_SPLIT)[1]; + spanObjects.forEach(spanObject -> { + Span span = new Span(); + span.setTraceId(traceId); + span.setSegmentId(segmentId); + span.setSpanId(spanObject.getSpanId()); + span.setParentSpanId(spanObject.getParentSpanId()); + span.setStartTime(spanObject.getStartTime()); + span.setEndTime(spanObject.getEndTime()); + span.setError(spanObject.getIsError()); + span.setLayer(spanObject.getSpanLayer().name()); + span.setType(spanObject.getSpanType().name()); + + String segmentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(spanObject.getSpanId()); + span.setSegmentSpanId(segmentSpanId); + + String segmentParentSpanId = segmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(spanObject.getParentSpanId()); + span.setSegmentParentSpanId(segmentParentSpanId); + + if (spanObject.getPeerId() == 0) { + span.setPeer(spanObject.getPeer()); + } else { + span.setPeer(networkAddressCacheService.getAddress(spanObject.getPeerId())); + } + + String operationName = spanObject.getOperationName(); + if (spanObject.getOperationNameId() != 0) { + String serviceName = serviceNameCacheService.get(spanObject.getOperationNameId()); + if (StringUtils.isNotEmpty(serviceName)) { + operationName = serviceName.split(Const.ID_SPLIT)[1]; + } else { + operationName = Const.EMPTY_STRING; + } + } + span.setOperationName(operationName); + + String applicationCode = applicationCacheService.getApplicationById(applicationId).getApplicationCode(); + span.setApplicationCode(applicationCode); + + if (spanObject.getComponentId() == 0) { + span.setComponent(spanObject.getComponent()); + } else { + span.setComponent(ComponentsDefine.getInstance().getComponentName(spanObject.getComponentId())); + } + + spanObject.getRefsList().forEach(reference -> { + Ref ref = new Ref(); + ref.setTraceId(traceId); + + switch (reference.getRefType()) { + case CrossThread: + ref.setType(RefType.CROSS_THREAD); + break; + case CrossProcess: + ref.setType(RefType.CROSS_PROCESS); + break; + } + ref.setParentSpanId(reference.getParentSpanId()); + + UniqueId uniqueId = reference.getParentTraceSegmentId(); + StringBuilder segmentIdBuilder = new StringBuilder(); + for (int i = 0; i < uniqueId.getIdPartsList().size(); i++) { + if (i == 0) { + segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().get(i))); } else { - operationName = Const.EMPTY_STRING; + segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().get(i))); } } - String applicationCode = applicationCacheService.getApplicationById(segment.getApplicationId()).getApplicationCode(); + ref.setParentSegmentId(segmentIdBuilder.toString()); - long cost = spanObject.getEndTime() - spanObject.getStartTime(); - if (cost == 0) { - cost = 1; - } + span.setSegmentParentSpanId(ref.getParentSegmentId() + Const.SEGMENT_SPAN_SPLIT + String.valueOf(ref.getParentSpanId())); + + span.getRefs().add(ref); + }); + + spanObject.getTagsList().forEach(tag -> { + KeyValue keyValue = new KeyValue(); + keyValue.setKey(tag.getKey()); + keyValue.setValue(tag.getValue()); + span.getTags().add(keyValue); + }); + + spanObject.getLogsList().forEach(log -> { + LogEntity logEntity = new LogEntity(); + logEntity.setTime(log.getTime()); + + log.getDataList().forEach(data -> { + KeyValue keyValue = new KeyValue(); + keyValue.setKey(data.getKey()); + keyValue.setValue(data.getValue()); + logEntity.getData().add(keyValue); + }); + + span.getLogs().add(logEntity); + }); + + spans.add(span); + }); -// if (parentSpanId == -1 && segment.getRefsCount() > 0) { -// for (TraceSegmentReference reference : segment.getRefsList()) { -// parentSpanId = reference.getParentSpanId(); -// UniqueId uniqueId = reference.getParentTraceSegmentId(); -// -// StringBuilder segmentIdBuilder = new StringBuilder(); -// for (int i = 0; i < uniqueId.getIdPartsList().size(); i++) { -// if (i == 0) { -// segmentIdBuilder.append(String.valueOf(uniqueId.getIdPartsList().getApplicationIdByCode(i))); -// } else { -// segmentIdBuilder.append(".").append(String.valueOf(uniqueId.getIdPartsList().getApplicationIdByCode(i))); -// } -// } -// -// String parentSegmentId = segmentIdBuilder.toString(); -// segmentParentSpanId = parentSegmentId + Const.SEGMENT_SPAN_SPLIT + String.valueOf(parentSpanId); -// -// spans.add(new Span(spanId, parentSpanId, segmentSpanId, segmentParentSpanId, startTime, operationName, applicationCode, cost)); -// } -// } else { -// spans.add(new Span(spanId, parentSpanId, segmentSpanId, segmentParentSpanId, startTime, operationName, applicationCode, cost)); -// } - } - } return spans; } @@ -174,8 +218,8 @@ public class TraceStackService { String segmentParentSpanId = span.getSegmentParentSpanId(); boolean hasParent = false; - for (Span span1 : spans) { - if (segmentParentSpanId.equals(span1.getSegmentSpanId())) { + for (Span subSpan : spans) { + if (segmentParentSpanId.equals(subSpan.getSegmentSpanId())) { hasParent = true; } } @@ -196,72 +240,4 @@ public class TraceStackService { } }); } - - class Span { - private int spanId; - private int parentSpanId; - private String segmentSpanId; - private String segmentParentSpanId; - private long startTime; - private String operationName; - private String applicationCode; - private long cost; - private boolean isRoot = false; - - Span(int spanId, int parentSpanId, String segmentSpanId, String segmentParentSpanId, long startTime, - String operationName, String applicationCode, long cost) { - this.spanId = spanId; - this.parentSpanId = parentSpanId; - this.segmentSpanId = segmentSpanId; - this.segmentParentSpanId = segmentParentSpanId; - this.startTime = startTime; - this.operationName = operationName; - this.applicationCode = applicationCode; - this.cost = cost; - } - - int getSpanId() { - return spanId; - } - - int getParentSpanId() { - return parentSpanId; - } - - String getSegmentSpanId() { - return segmentSpanId; - } - - String getSegmentParentSpanId() { - return segmentParentSpanId; - } - - long getStartTime() { - return startTime; - } - - String getOperationName() { - return operationName; - } - - String getApplicationCode() { - return applicationCode; - } - - long getCost() { - return cost; - } - - public boolean isRoot() { - return isRoot; - } - - public void setRoot(boolean root) { - isRoot = root; - } - - public void setStartTime(long startTime) { - this.startTime = startTime; - } - } } From b513024a85aeceaf2604235c3b673ba0905517f3 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Mon, 5 Feb 2018 10:26:54 +0800 Subject: [PATCH 26/36] Provide the searchService query. --- .../dao/ui/IServiceNameServiceUIDAO.java | 4 ++ .../storage/ui/service/ServiceInfo.java | 18 ++++++++- .../storage/ui/service/ServiceNode.java | 39 +++++++++++++++++-- .../es/dao/ui/ServiceNameServiceEsUIDAO.java | 26 +++++++++++++ .../register/ServiceNameEsTableDefine.java | 2 +- .../h2/dao/ui/ServiceNameServiceH2UIDAO.java | 22 +++++++++++ .../ui/jetty/handler/GraphQLHandler.java | 5 ++- .../apm/collector/ui/query/ServiceQuery.java | 27 +++++++++++-- .../ui/service/ServiceNameService.java | 6 +++ .../ui-graphql/service-layer.graphqls | 7 +++- 10 files changed, 143 insertions(+), 13 deletions(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java index 8f39dda9a..0d8fe4859 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceNameServiceUIDAO.java @@ -18,11 +18,15 @@ package org.apache.skywalking.apm.collector.storage.dao.ui; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; /** * @author peng-yongsheng */ public interface IServiceNameServiceUIDAO extends DAO { int getCount(); + + List searchService(String keyword, int topN); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java index f33fbd469..808fe25f3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceInfo.java @@ -24,6 +24,20 @@ package org.apache.skywalking.apm.collector.storage.ui.service; public class ServiceInfo { private int id; private String name; - private int avgResponseTime; - private int tps; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java index 5d2b0cc95..4a15a5e5a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java @@ -24,7 +24,40 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Node; * @author peng-yongsheng */ public class ServiceNode extends Node { - private Float sla; - private Long calls; - private Integer numOfServiceAlarm; + private float sla; + private long calls; + private int numOfServiceAlarm; + private int applicationId; + + public float getSla() { + return sla; + } + + public void setSla(float sla) { + this.sla = sla; + } + + public long getCalls() { + return calls; + } + + public void setCalls(long calls) { + this.calls = calls; + } + + public int getNumOfServiceAlarm() { + return numOfServiceAlarm; + } + + public void setNumOfServiceAlarm(int numOfServiceAlarm) { + this.numOfServiceAlarm = numOfServiceAlarm; + } + + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java index 67654d03d..f050e0a16 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceNameServiceEsUIDAO.java @@ -18,13 +18,18 @@ package org.apache.skywalking.apm.collector.storage.es.dao.ui; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.elasticsearch.action.search.SearchRequestBuilder; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.SearchHit; /** * @author peng-yongsheng @@ -44,4 +49,25 @@ public class ServiceNameServiceEsUIDAO extends EsDAO implements IServiceNameServ SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); return (int)searchResponse.getHits().getTotalHits(); } + + @Override public List searchService(String keyword, int topN) { + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceNameTable.TABLE); + searchRequestBuilder.setTypes(ServiceNameTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + searchRequestBuilder.setSize(topN); + + searchRequestBuilder.setQuery(QueryBuilders.matchQuery(ServiceNameTable.COLUMN_SERVICE_NAME, keyword)); + + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + SearchHit[] searchHits = searchResponse.getHits().getHits(); + + List serviceInfos = new LinkedList<>(); + for (SearchHit searchHit : searchHits) { + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.setId(((Number)searchHit.getSource().get(ServiceNameTable.COLUMN_SERVICE_ID)).intValue()); + serviceInfo.setName((String)searchHit.getSource().get(ServiceNameTable.COLUMN_SERVICE_NAME)); + serviceInfos.add(serviceInfo); + } + return serviceInfos; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ServiceNameEsTableDefine.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ServiceNameEsTableDefine.java index f15707bec..2a5dc39c0 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ServiceNameEsTableDefine.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/define/register/ServiceNameEsTableDefine.java @@ -37,7 +37,7 @@ public class ServiceNameEsTableDefine extends ElasticSearchTableDefine { @Override public void initialize() { addColumn(new ElasticSearchColumnDefine(ServiceNameTable.COLUMN_APPLICATION_ID, ElasticSearchColumnDefine.Type.Integer.name())); - addColumn(new ElasticSearchColumnDefine(ServiceNameTable.COLUMN_SERVICE_NAME, ElasticSearchColumnDefine.Type.Keyword.name())); + addColumn(new ElasticSearchColumnDefine(ServiceNameTable.COLUMN_SERVICE_NAME, ElasticSearchColumnDefine.Type.Text.name())); addColumn(new ElasticSearchColumnDefine(ServiceNameTable.COLUMN_SERVICE_ID, ElasticSearchColumnDefine.Type.Integer.name())); } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java index 1c694a59e..29470eefb 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceNameServiceH2UIDAO.java @@ -20,12 +20,15 @@ package org.apache.skywalking.apm.collector.storage.h2.dao.ui; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,4 +57,23 @@ public class ServiceNameServiceH2UIDAO extends H2DAO implements IServiceNameServ } return 0; } + + @Override public List searchService(String keyword, int topN) { + String dynamicSql = "select {0},{1} from {2} where {3} like ? limit ?"; + String sql = SqlBuilder.buildSql(dynamicSql, ServiceNameTable.COLUMN_SERVICE_ID, ServiceNameTable.COLUMN_SERVICE_NAME, ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_NAME); + Object[] params = new Object[] {keyword, topN}; + + List serviceInfos = new LinkedList<>(); + try (ResultSet rs = getClient().executeQuery(sql, params)) { + while (rs.next()) { + ServiceInfo serviceInfo = new ServiceInfo(); + serviceInfo.setId(rs.getInt(ServiceNameTable.COLUMN_SERVICE_ID)); + serviceInfo.setName(rs.getString(ServiceNameTable.COLUMN_SERVICE_NAME)); + serviceInfos.add(serviceInfo); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + return serviceInfos; + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index 7c30f793d..81cedadbf 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -43,6 +43,7 @@ import org.apache.skywalking.apm.collector.server.jetty.JettyHandler; import org.apache.skywalking.apm.collector.storage.ui.application.ApplicationNode; import org.apache.skywalking.apm.collector.storage.ui.application.ConjecturalNode; import org.apache.skywalking.apm.collector.storage.ui.common.VisualUserNode; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceNode; import org.apache.skywalking.apm.collector.ui.graphql.VersionMutation; import org.apache.skywalking.apm.collector.ui.graphql.VersionQuery; import org.apache.skywalking.apm.collector.ui.mutation.ConfigMutation; @@ -82,9 +83,9 @@ public class GraphQLHandler extends JettyHandler { .file("ui-graphql/service-layer.graphqls") .file("ui-graphql/trace.graphqls") .resolvers(new VersionQuery(), new VersionMutation(), new AlarmQuery(), new ApplicationQuery(moduleManager)) - .resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(moduleManager), new ServiceQuery(), new TraceQuery(moduleManager)) + .resolvers(new OverViewLayerQuery(moduleManager), new ServerQuery(moduleManager), new ServiceQuery(moduleManager), new TraceQuery(moduleManager)) .resolvers(new ConfigQuery(), new ConfigMutation()) - .dictionary(ConjecturalNode.class, VisualUserNode.class, ApplicationNode.class) + .dictionary(ConjecturalNode.class, VisualUserNode.class, ApplicationNode.class, ServiceNode.class) .build() .makeExecutableSchema(); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java index ef11c1066..600f36e50 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java @@ -18,21 +18,40 @@ package org.apache.skywalking.apm.collector.ui.query; +import java.text.ParseException; import java.util.List; -import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.ui.common.Duration; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.SLATrend; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; import org.apache.skywalking.apm.collector.storage.ui.common.Topology; -import org.apache.skywalking.apm.collector.storage.ui.service.ServiceNode; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; +import org.apache.skywalking.apm.collector.ui.graphql.Query; +import org.apache.skywalking.apm.collector.ui.service.ServiceNameService; /** * @author peng-yongsheng */ public class ServiceQuery implements Query { - public List searchService(String keyword, Duration duration, Integer topN) { - return null; + + private final ModuleManager moduleManager; + private ServiceNameService serviceNameService; + + public ServiceQuery(ModuleManager moduleManager) { + this.moduleManager = moduleManager; + } + + private ServiceNameService getServiceNameService() { + if (ObjectUtils.isEmpty(serviceNameService)) { + this.serviceNameService = new ServiceNameService(moduleManager); + } + return serviceNameService; + } + + public List searchService(String keyword, int topN) throws ParseException { + return getServiceNameService().searchService(keyword, topN); } public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java index ebe66d0b2..673461352 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java @@ -18,9 +18,11 @@ package org.apache.skywalking.apm.collector.ui.service; +import java.util.List; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; /** * @author peng-yongsheng @@ -36,4 +38,8 @@ public class ServiceNameService { public int getCount() { return serviceNameServiceUIDAO.getCount(); } + + public List searchService(String keyword, int topN) { + return serviceNameServiceUIDAO.searchService(keyword, topN); + } } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls index a5b44557a..2c14b8be2 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls @@ -15,6 +15,11 @@ type ServiceNode implements Node { type ServiceInfo { id: ID! name: String +} + +type ServiceMetric { + id: ID! + name: String # The unit is millisecond. avgResponseTime: Int! tps: Int! @@ -27,7 +32,7 @@ type TraceItem { } extend type Query { - searchService(keyword: String!, duration: Duration!, topN: Int!): [ServiceNode!]! + searchService(keyword: String!, topN: Int!): [ServiceInfo!]! getServiceResponseTimeTrend(serviceId: ID!, duration: Duration!): ResponseTimeTrend getServiceTPSTrend(serviceId: ID!, duration: Duration!): ThroughputTrend getServiceSLATrend(serviceId: ID!, duration: Duration!): SLATrend From cccba2ec8f09f6beef39fc4641aaaaff71d08020 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Mon, 5 Feb 2018 16:04:56 +0800 Subject: [PATCH 27/36] Provide the getServiceResponseTimeTrend query. --- .../apm/collector/storage/StorageModule.java | 2 + .../storage/dao/ui/IServiceMetricUIDAO.java | 31 ++++++++ .../es/StorageModuleEsNamingListener.java | 3 +- .../storage/es/StorageModuleEsProvider.java | 5 +- .../es/dao/ui/ServiceMetricEsUIDAO.java | 69 ++++++++++++++++ .../storage/h2/StorageModuleH2Provider.java | 3 + .../h2/dao/ui/ServiceMetricH2UIDAO.java | 78 +++++++++++++++++++ .../apm/collector/ui/query/ServiceQuery.java | 7 +- .../ui/service/ServiceNameService.java | 16 ++++ 9 files changed, 209 insertions(+), 5 deletions(-) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java index c024aafe8..c3e35cb82 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java @@ -115,6 +115,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; @@ -236,6 +237,7 @@ public class StorageModule extends Module { classes.add(IInstanceUIDAO.class); classes.add(INetworkAddressUIDAO.class); classes.add(IServiceNameServiceUIDAO.class); + classes.add(IServiceMetricUIDAO.class); classes.add(ICpuMetricUIDAO.class); classes.add(IGCMetricUIDAO.class); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java new file mode 100644 index 000000000..926d18dca --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java @@ -0,0 +1,31 @@ +/* + * 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.apm.collector.storage.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; + +/** + * @author peng-yongsheng + */ +public interface IServiceMetricUIDAO extends DAO { + List load(int serviceId, Step step, List durationPoints); +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsNamingListener.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsNamingListener.java index ab0f7f6fe..a4e689c4e 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsNamingListener.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsNamingListener.java @@ -16,7 +16,6 @@ * */ - package org.apache.skywalking.apm.collector.storage.es; import org.apache.skywalking.apm.collector.cluster.ClusterModuleListener; @@ -27,7 +26,7 @@ import org.apache.skywalking.apm.collector.storage.StorageModule; */ public class StorageModuleEsNamingListener extends ClusterModuleListener { - public static final String PATH = "/" + StorageModule.NAME + "/" + StorageModuleEsProvider.NAME; + private static final String PATH = "/" + StorageModule.NAME + "/" + StorageModuleEsProvider.NAME; @Override public String path() { return PATH; diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index 996b6cceb..9d450dbe6 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -124,6 +124,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO; @@ -221,6 +222,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ui.MemoryPoolMetricEsU import org.apache.skywalking.apm.collector.storage.es.dao.ui.NetworkAddressEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentDurationEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceNameServiceEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsUIDAO; import org.slf4j.Logger; @@ -233,7 +235,7 @@ public class StorageModuleEsProvider extends ModuleProvider { private final Logger logger = LoggerFactory.getLogger(StorageModuleEsProvider.class); - public static final String NAME = "elasticsearch"; + static final String NAME = "elasticsearch"; private static final String CLUSTER_NAME = "cluster_name"; private static final String CLUSTER_TRANSPORT_SNIFFER = "cluster_transport_sniffer"; private static final String CLUSTER_NODES = "cluster_nodes"; @@ -394,6 +396,7 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IInstanceUIDAO.class, new InstanceEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(INetworkAddressUIDAO.class, new NetworkAddressEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(IServiceNameServiceUIDAO.class, new ServiceNameServiceEsUIDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceMetricUIDAO.class, new ServiceMetricEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(ICpuMetricUIDAO.class, new CpuMetricEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(IGCMetricUIDAO.class, new GCMetricEsUIDAO(elasticSearchClient)); diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java new file mode 100644 index 000000000..f6eea47af --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.get.MultiGetItemResponse; +import org.elasticsearch.action.get.MultiGetRequestBuilder; +import org.elasticsearch.action.get.MultiGetResponse; + +/** + * @author peng-yongsheng + */ +public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO { + + public ServiceMetricEsUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List load(int serviceId, Step step, List durationPoints) { + MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); + + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + prepareMultiGet.add(tableName, ServiceMetricTable.TABLE_TYPE, id); + }); + + List trends = new LinkedList<>(); + MultiGetResponse multiGetResponse = prepareMultiGet.get(); + for (MultiGetItemResponse response : multiGetResponse.getResponses()) { + if (response.getResponse().isExists()) { + long calls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); + long errorCalls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue(); + long durationSum = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)).longValue(); + long errorDurationSum = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)).longValue(); + trends.add((int)((durationSum - errorDurationSum) / (calls - errorCalls))); + } else { + trends.add(0); + } + } + return trends; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index bc9278a0a..a29cdcb13 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -120,6 +120,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryPoolMetricUIDAO import org.apache.skywalking.apm.collector.storage.dao.ui.INetworkAddressUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO; @@ -217,6 +218,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ui.MemoryPoolMetricH2U import org.apache.skywalking.apm.collector.storage.h2.dao.ui.NetworkAddressH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentDurationH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceNameServiceH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2UIDAO; import org.slf4j.Logger; @@ -370,6 +372,7 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IInstanceUIDAO.class, new InstanceH2UIDAO(h2Client)); this.registerServiceImplementation(INetworkAddressUIDAO.class, new NetworkAddressH2UIDAO(h2Client)); this.registerServiceImplementation(IServiceNameServiceUIDAO.class, new ServiceNameServiceH2UIDAO(h2Client)); + this.registerServiceImplementation(IServiceMetricUIDAO.class, new ServiceMetricH2UIDAO(h2Client)); this.registerServiceImplementation(ICpuMetricUIDAO.class, new CpuMetricH2UIDAO(h2Client)); this.registerServiceImplementation(IGCMetricUIDAO.class, new GCMetricH2UIDAO(h2Client)); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java new file mode 100644 index 000000000..7ff3bc0e8 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java @@ -0,0 +1,78 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO { + + private final Logger logger = LoggerFactory.getLogger(ServiceMetricH2UIDAO.class); + + public ServiceMetricH2UIDAO(H2Client client) { + super(client); + } + + @Override public List load(int serviceId, Step step, List durationPoints) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); + + H2Client client = getClient(); + String dynamicSql = "select * from {0} where {1} = ?"; + String sql = SqlBuilder.buildSql(dynamicSql, tableName, ServiceMetricTable.COLUMN_ID); + + List trends = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + + try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { + if (rs.next()) { + long calls = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_CALLS); + long errorCalls = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + long durationSum = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + long errorDurationSum = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); + trends.add((int)((durationSum - errorDurationSum) / (calls - errorCalls))); + } else { + trends.add(0); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + + return trends; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java index 600f36e50..bea694460 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java @@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Topology; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.apache.skywalking.apm.collector.ui.graphql.Query; import org.apache.skywalking.apm.collector.ui.service.ServiceNameService; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** * @author peng-yongsheng @@ -54,8 +55,10 @@ public class ServiceQuery implements Query { return getServiceNameService().searchService(keyword, topN); } - public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Duration duration) { - return null; + public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServiceNameService().getServiceResponseTimeTrend(serviceId, duration.getStep(), start, end); } public ThroughputTrend getServiceTPSTrend(int serviceId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java index 673461352..d25eedd8e 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java @@ -18,11 +18,17 @@ package org.apache.skywalking.apm.collector.ui.service; +import java.text.ParseException; import java.util.List; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; +import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; +import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** * @author peng-yongsheng @@ -30,9 +36,11 @@ import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; public class ServiceNameService { private final IServiceNameServiceUIDAO serviceNameServiceUIDAO; + private final IServiceMetricUIDAO serviceMetricUIDAO; public ServiceNameService(ModuleManager moduleManager) { this.serviceNameServiceUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameServiceUIDAO.class); + this.serviceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceMetricUIDAO.class); } public int getCount() { @@ -42,4 +50,12 @@ public class ServiceNameService { public List searchService(String keyword, int topN) { return serviceNameServiceUIDAO.searchService(keyword, topN); } + + public ResponseTimeTrend getServiceResponseTimeTrend(int serviceId, Step step, long start, + long end) throws ParseException { + ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend(); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + responseTimeTrend.setTrendList(serviceMetricUIDAO.load(serviceId, step, durationPoints)); + return responseTimeTrend; + } } From 2c6b03bfbb04d945abb327b35041dea6de7570d2 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Mon, 5 Feb 2018 19:21:39 +0800 Subject: [PATCH 28/36] Provide the getServiceSLATrend query. --- .../storage/dao/ui/IServiceMetricUIDAO.java | 4 ++- .../collector/storage/ui/common/SLATrend.java | 8 +++++ .../es/dao/ui/ServiceMetricEsUIDAO.java | 26 +++++++++++++++- .../h2/dao/ui/ServiceMetricH2UIDAO.java | 30 ++++++++++++++++++- .../apm/collector/ui/query/ServiceQuery.java | 6 ++-- .../ui/service/ServiceNameService.java | 10 ++++++- 6 files changed, 78 insertions(+), 6 deletions(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java index 926d18dca..265d66cbf 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java @@ -27,5 +27,7 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; * @author peng-yongsheng */ public interface IServiceMetricUIDAO extends DAO { - List load(int serviceId, Step step, List durationPoints); + List getServiceResponseTimeTrend(int serviceId, Step step, List durationPoints); + + List getServiceSLATrend(int serviceId, Step step, List durationPoints); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java index a6204646b..ed75ddac8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/SLATrend.java @@ -25,4 +25,12 @@ import java.util.List; */ public class SLATrend { private List trendList; + + public List getTrendList() { + return trendList; + } + + public void setTrendList(List trendList) { + this.trendList = trendList; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java index f6eea47af..812ba2506 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java @@ -42,7 +42,8 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO { super(client); } - @Override public List load(int serviceId, Step step, List durationPoints) { + @Override + public List getServiceResponseTimeTrend(int serviceId, Step step, List durationPoints) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); @@ -66,4 +67,27 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO { } return trends; } + + @Override public List getServiceSLATrend(int serviceId, Step step, List durationPoints) { + MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); + String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); + + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + prepareMultiGet.add(tableName, ServiceMetricTable.TABLE_TYPE, id); + }); + + List trends = new LinkedList<>(); + MultiGetResponse multiGetResponse = prepareMultiGet.get(); + for (MultiGetItemResponse response : multiGetResponse.getResponses()) { + if (response.getResponse().isExists()) { + long calls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)).longValue(); + long errorCalls = ((Number)response.getResponse().getSource().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)).longValue(); + trends.add((int)(((calls - errorCalls) / calls)) * 10000); + } else { + trends.add(10000); + } + } + return trends; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java index 7ff3bc0e8..1fb3c4634 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java @@ -47,7 +47,8 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO { super(client); } - @Override public List load(int serviceId, Step step, List durationPoints) { + @Override + public List getServiceResponseTimeTrend(int serviceId, Step step, List durationPoints) { String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); H2Client client = getClient(); @@ -75,4 +76,31 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO { return trends; } + + @Override public List getServiceSLATrend(int serviceId, Step step, List durationPoints) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); + + H2Client client = getClient(); + String dynamicSql = "select * from {0} where {1} = ?"; + String sql = SqlBuilder.buildSql(dynamicSql, tableName, ServiceMetricTable.COLUMN_ID); + + List trends = new LinkedList<>(); + durationPoints.forEach(durationPoint -> { + String id = durationPoint.getPoint() + Const.ID_SPLIT + serviceId + Const.ID_SPLIT + MetricSource.Callee.getValue(); + + try (ResultSet rs = client.executeQuery(sql, new String[] {id})) { + if (rs.next()) { + long calls = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_CALLS); + long errorCalls = rs.getLong(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + trends.add((int)(((calls - errorCalls) / calls)) * 10000); + } else { + trends.add(10000); + } + } catch (SQLException | H2ClientException e) { + logger.error(e.getMessage(), e); + } + }); + + return trends; + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java index bea694460..4f6c0aed4 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java @@ -65,8 +65,10 @@ public class ServiceQuery implements Query { return null; } - public SLATrend getServiceSLATrend(int serviceId, Duration duration) { - return null; + public SLATrend getServiceSLATrend(int serviceId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServiceNameService().getServiceSLATrend(serviceId, duration.getStep(), start, end); } public Topology getServiceTopology(int serviceId, Duration duration) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java index d25eedd8e..a4de32ea7 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java @@ -25,6 +25,7 @@ import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; +import org.apache.skywalking.apm.collector.storage.ui.common.SLATrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; @@ -55,7 +56,14 @@ public class ServiceNameService { long end) throws ParseException { ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend(); List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); - responseTimeTrend.setTrendList(serviceMetricUIDAO.load(serviceId, step, durationPoints)); + responseTimeTrend.setTrendList(serviceMetricUIDAO.getServiceResponseTimeTrend(serviceId, step, durationPoints)); return responseTimeTrend; } + + public SLATrend getServiceSLATrend(int serviceId, Step step, long start, long end) throws ParseException { + SLATrend slaTrend = new SLATrend(); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + slaTrend.setTrendList(serviceMetricUIDAO.getServiceSLATrend(serviceId, step, durationPoints)); + return slaTrend; + } } From 62477a53188a441e5fabc3dbb157647c2cfe4386 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 7 Feb 2018 18:10:17 +0800 Subject: [PATCH 29/36] Provide the getServiceTopology query. --- .../test/resources/json/dubbox-provider.json | 2 +- .../define/graph/MetricGraphIdDefine.java | 1 + .../define/graph/MetricWorkerIdDefine.java | 64 +++--- .../segment/SegmentDurationSpanListener.java | 2 +- .../service/ServiceNameCacheService.java | 6 +- .../service/ServiceNameCacheGuavaService.java | 37 +--- .../apm/collector/storage/StorageModule.java | 4 +- .../dao/cache/IServiceNameCacheDAO.java | 3 +- .../storage/dao/ui/IServiceMetricUIDAO.java | 6 + ...java => IServiceReferenceMetricUIDAO.java} | 21 +- .../collector/storage/ui/common/Topology.java | 6 + .../storage/ui/service/ServiceNode.java | 6 +- ...kywalking.apm.collector.core.module.Module | 3 +- .../storage/es/StorageModuleEsProvider.java | 6 +- .../es/dao/cache/ServiceNameEsCacheDAO.java | 15 +- .../es/dao/ui/ServiceMetricEsUIDAO.java | 53 +++++ .../dao/ui/ServiceReferenceEsMetricUIDAO.java | 200 ++++++++++++++++++ .../es/dao/ui/ServiceReferenceEsUIDAO.java | 115 ---------- .../storage/h2/StorageModuleH2Provider.java | 6 +- .../h2/dao/cache/ServiceNameH2CacheDAO.java | 17 +- .../h2/dao/ui/ServiceMetricH2UIDAO.java | 8 + .../dao/ui/ServiceReferenceH2MetricUIDAO.java | 57 +++++ .../h2/dao/ui/ServiceReferenceH2UIDAO.java | 103 --------- .../resources/META-INF/defines/storage.define | 2 + .../apm/collector/ui/query/ServiceQuery.java | 15 +- .../ui/service/ServiceTopologyService.java | 93 ++++++++ .../ui/service/ServiceTreeService.java | 123 ----------- .../apm/collector/ui/service/SpanService.java | 13 +- .../ui/service/TraceStackService.java | 8 +- .../ui-graphql/service-layer.graphqls | 5 +- 30 files changed, 552 insertions(+), 448 deletions(-) rename apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/{IServiceReferenceUIDAO.java => IServiceReferenceMetricUIDAO.java} (53%) create mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsMetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2MetricUIDAO.java delete mode 100644 apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java create mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java delete mode 100644 apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java diff --git a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json index 174112074..856cfc03c 100644 --- a/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json +++ b/apm-collector/apm-collector-agent/agent-jetty/agent-jetty-provider/src/test/resources/json/dubbox-provider.json @@ -26,7 +26,7 @@ "pii": 2, //上级的实例编号 "psp": 1, //上级的埋点编号span_id "psi": 0, //上级的服务编号(org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()注册后的ID) - "psn": "org.skywaking.apm.testcase.dubbo.services.GreetService.doBusiness()", //上级的服务名 + "psn": "/dubbox-case/case/dubbox-rest", //上级的服务名 "ni": 0, //上级调用时使用的地址注册后的ID "nn": "172.25.0.4:20880", //上级的地址 "eii": 2, //入口的实例编号 diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java index e757f915f..de3545e30 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricGraphIdDefine.java @@ -32,6 +32,7 @@ public class MetricGraphIdDefine { public static final int APPLICATION_COMPONENT_GRAPH_ID = 406; public static final int APPLICATION_MAPPING_GRAPH_ID = 407; + public static final int SERVICE_MAPPING_GRAPH_ID = 408; public static final int GLOBAL_TRACE_GRAPH_ID = 409; public static final int SEGMENT_DURATION_GRAPH_ID = 410; public static final int INSTANCE_MAPPING_GRAPH_ID = 411; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java index cd9a6667b..80e6d31c5 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-define/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/define/graph/MetricWorkerIdDefine.java @@ -22,35 +22,45 @@ package org.apache.skywalking.apm.collector.analysis.metric.define.graph; * @author peng-yongsheng */ public class MetricWorkerIdDefine { - public static final int SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4100; - public static final int SERVICE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4101; - public static final int SERVICE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4102; - public static final int SERVICE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4103; - public static final int SERVICE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4104; - public static final int SERVICE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4105; - public static final int SERVICE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4106; - public static final int SERVICE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4107; - public static final int SERVICE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4108; + public static final int SERVICE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4010; + public static final int SERVICE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4011; + public static final int SERVICE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4012; + public static final int SERVICE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4013; + public static final int SERVICE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4014; + public static final int SERVICE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4015; + public static final int SERVICE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4016; + public static final int SERVICE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4017; + public static final int SERVICE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4018; - public static final int INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4200; - public static final int INSTANCE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4201; - public static final int INSTANCE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4202; - public static final int INSTANCE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4203; - public static final int INSTANCE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4204; - public static final int INSTANCE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4205; - public static final int INSTANCE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4206; - public static final int INSTANCE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4207; - public static final int INSTANCE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4208; + public static final int INSTANCE_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4020; + public static final int INSTANCE_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4021; + public static final int INSTANCE_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4022; + public static final int INSTANCE_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4023; + public static final int INSTANCE_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4024; + public static final int INSTANCE_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4025; + public static final int INSTANCE_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4026; + public static final int INSTANCE_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4027; + public static final int INSTANCE_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4028; - public static final int APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4300; - public static final int APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4301; - public static final int APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4302; - public static final int APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4303; - public static final int APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4304; - public static final int APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4305; - public static final int APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4306; - public static final int APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4307; - public static final int APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4308; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4030; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_REMOTE_WORKER_ID = 4031; + public static final int APPLICATION_REFERENCE_MINUTE_METRIC_PERSISTENCE_WORKER_ID = 4032; + public static final int APPLICATION_REFERENCE_HOUR_METRIC_PERSISTENCE_WORKER_ID = 4033; + public static final int APPLICATION_REFERENCE_HOUR_METRIC_TRANSFORM_NODE_ID = 4034; + public static final int APPLICATION_REFERENCE_DAY_METRIC_PERSISTENCE_WORKER_ID = 4035; + public static final int APPLICATION_REFERENCE_DAY_METRIC_TRANSFORM_NODE_ID = 4036; + public static final int APPLICATION_REFERENCE_MONTH_METRIC_PERSISTENCE_WORKER_ID = 4037; + public static final int APPLICATION_REFERENCE_MONTH_METRIC_TRANSFORM_NODE_ID = 4038; + + public static final int SERVICE_MAPPING_MINUTE_AGGREGATION_WORKER_ID = 4040; + public static final int SERVICE_MAPPING_MINUTE_REMOTE_WORKER_ID = 4041; + public static final int SERVICE_MAPPING_MINUTE_PERSISTENCE_WORKER_ID = 4042; + public static final int SERVICE_MAPPING_HOUR_PERSISTENCE_WORKER_ID = 4043; + public static final int SERVICE_MAPPING_HOUR_TRANSFORM_NODE_ID = 4044; + public static final int SERVICE_MAPPING_DAY_PERSISTENCE_WORKER_ID = 4045; + public static final int SERVICE_MAPPING_DAY_TRANSFORM_NODE_ID = 4046; + public static final int SERVICE_MAPPING_MONTH_PERSISTENCE_WORKER_ID = 4047; + public static final int SERVICE_MAPPING_MONTH_TRANSFORM_NODE_ID = 4048; public static final int SERVICE_MINUTE_METRIC_AGGREGATION_WORKER_ID = 4400; public static final int SERVICE_MINUTE_METRIC_REMOTE_WORKER_ID = 4401; diff --git a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java index e99126bc4..89e13eed4 100644 --- a/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java +++ b/apm-collector/apm-collector-analysis/analysis-metric/metric-provider/src/main/java/org/apache/skywalking/apm/collector/analysis/metric/provider/worker/segment/SegmentDurationSpanListener.java @@ -71,7 +71,7 @@ public class SegmentDurationSpanListener implements EntrySpanListener, ExitSpanL if (spanDecorator.getOperationNameId() == 0) { segmentDuration.setServiceName(spanDecorator.getOperationName()); } else { - segmentDuration.setServiceName(serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(spanDecorator.getOperationNameId()))); + segmentDuration.setServiceName(serviceNameCacheService.get(spanDecorator.getOperationNameId()).getServiceName()); } segmentDurations.add(segmentDuration); diff --git a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ServiceNameCacheService.java b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ServiceNameCacheService.java index 0517e4d20..298a5a659 100644 --- a/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ServiceNameCacheService.java +++ b/apm-collector/apm-collector-cache/collector-cache-define/src/main/java/org/apache/skywalking/apm/collector/cache/service/ServiceNameCacheService.java @@ -16,16 +16,14 @@ * */ - package org.apache.skywalking.apm.collector.cache.service; import org.apache.skywalking.apm.collector.core.module.Service; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; /** * @author peng-yongsheng */ public interface ServiceNameCacheService extends Service { - String get(int serviceId); - - String getSplitServiceName(String serviceName); + ServiceName get(int serviceId); } diff --git a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java index 5aa3fd80e..528dbd6f0 100644 --- a/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java +++ b/apm-collector/apm-collector-cache/collector-cache-guava-provider/src/main/java/org/apache/skywalking/apm/collector/cache/guava/service/ServiceNameCacheGuavaService.java @@ -16,18 +16,16 @@ * */ - package org.apache.skywalking.apm.collector.cache.guava.service; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; -import org.apache.skywalking.apm.collector.core.util.StringUtils; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.ObjectUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -38,7 +36,7 @@ public class ServiceNameCacheGuavaService implements ServiceNameCacheService { private final Logger logger = LoggerFactory.getLogger(ServiceNameCacheGuavaService.class); - private final Cache serviceNameCache = CacheBuilder.newBuilder().maximumSize(10000).build(); + private final Cache serviceCache = CacheBuilder.newBuilder().maximumSize(10000).build(); private final ModuleManager moduleManager; private IServiceNameCacheDAO serviceNameCacheDAO; @@ -54,34 +52,21 @@ public class ServiceNameCacheGuavaService implements ServiceNameCacheService { return this.serviceNameCacheDAO; } - public String get(int serviceId) { - String serviceName = Const.EMPTY_STRING; + public ServiceName get(int serviceId) { + ServiceName serviceName = null; try { - serviceName = serviceNameCache.get(serviceId, () -> getServiceNameCacheDAO().getServiceName(serviceId)); + serviceName = serviceCache.get(serviceId, () -> getServiceNameCacheDAO().get(serviceId)); } catch (Throwable e) { logger.error(e.getMessage(), e); } - if (StringUtils.isEmpty(serviceName)) { - serviceName = getServiceNameCacheDAO().getServiceName(serviceId); - if (StringUtils.isNotEmpty(serviceName)) { - serviceNameCache.put(serviceId, serviceName); + if (ObjectUtils.isEmpty(serviceName)) { + serviceName = getServiceNameCacheDAO().get(serviceId); + if (ObjectUtils.isNotEmpty(serviceName)) { + serviceCache.put(serviceId, serviceName); } } return serviceName; } - - public String getSplitServiceName(String serviceName) { - if (StringUtils.isNotEmpty(serviceName)) { - String[] serviceNames = serviceName.split(Const.ID_SPLIT, 2); - if (serviceNames.length == 2) { - return serviceNames[1]; - } else { - return Const.EMPTY_STRING; - } - } else { - return Const.EMPTY_STRING; - } - } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java index c3e35cb82..b2230b947 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/StorageModule.java @@ -117,7 +117,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO; /** * @author peng-yongsheng @@ -251,7 +251,7 @@ public class StorageModule extends Module { classes.add(IApplicationReferenceMetricUIDAO.class); classes.add(ISegmentDurationUIDAO.class); classes.add(ISegmentUIDAO.class); - classes.add(IServiceReferenceUIDAO.class); + classes.add(IServiceReferenceMetricUIDAO.class); } private void addAlarmDAO(List classes) { diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java index 9e9ba334b..d9b34d828 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/cache/IServiceNameCacheDAO.java @@ -19,12 +19,13 @@ package org.apache.skywalking.apm.collector.storage.dao.cache; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; /** * @author peng-yongsheng */ public interface IServiceNameCacheDAO extends DAO { - String getServiceName(int serviceId); + ServiceName get(int serviceId); int getServiceId(int applicationId, String serviceName); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java index 265d66cbf..4303aa797 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java @@ -18,8 +18,11 @@ package org.apache.skywalking.apm.collector.storage.dao.ui; +import java.util.Collection; import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Node; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; @@ -30,4 +33,7 @@ public interface IServiceMetricUIDAO extends DAO { List getServiceResponseTimeTrend(int serviceId, Step step, List durationPoints); List getServiceSLATrend(int serviceId, Step step, List durationPoints); + + List getServicesMetric(Step step, long startTime, long endTime, + MetricSource metricSource, Collection serviceIds); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceMetricUIDAO.java similarity index 53% rename from apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.java rename to apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceMetricUIDAO.java index 3aec0ce57..8aba521d2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceReferenceMetricUIDAO.java @@ -18,13 +18,26 @@ package org.apache.skywalking.apm.collector.storage.dao.ui; -import com.google.gson.JsonObject; -import java.util.Map; +import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; /** * @author peng-yongsheng */ -public interface IServiceReferenceUIDAO extends DAO { - Map load(int entryServiceId, long startTime, long endTime); +public interface IServiceReferenceMetricUIDAO extends DAO { + + List getFrontServices(Step step, long startTime, long endTime, + MetricSource metricSource, int behindServiceId); + + List getBehindServices(Step step, long startTime, long endTime, + MetricSource metricSource, int frontServiceId); + + List getFrontServices(Step step, long startTime, long endTime, + MetricSource metricSource, List behindServiceIds); + + List getBehindServices(Step step, long startTime, long endTime, + MetricSource metricSource, List frontServiceIds); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java index 2f9340f91..a019a97b7 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/Topology.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.collector.storage.ui.common; +import java.util.LinkedList; import java.util.List; /** @@ -28,6 +29,11 @@ public class Topology { private List nodes; private List calls; + public Topology() { + this.nodes = new LinkedList<>(); + this.calls = new LinkedList<>(); + } + public List getNodes() { return nodes; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java index 4a15a5e5a..b935f9250 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceNode.java @@ -24,16 +24,16 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Node; * @author peng-yongsheng */ public class ServiceNode extends Node { - private float sla; + private int sla; private long calls; private int numOfServiceAlarm; private int applicationId; - public float getSla() { + public int getSla() { return sla; } - public void setSla(float sla) { + public void setSla(int sla) { this.sla = sla; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.Module b/apm-collector/apm-collector-storage/collector-storage-define/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.Module index b1217c903..e872625d2 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.Module +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/resources/META-INF/services/org.apache.skywalking.apm.collector.core.module.Module @@ -16,5 +16,4 @@ # # - -org.apache.skywalking.apm.collector.storage.StorageModule +org.apache.skywalking.apm.collector.storage.StorageModule \ No newline at end of file diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java index 9d450dbe6..943af2af3 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/StorageModuleEsProvider.java @@ -126,7 +126,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.BatchEsDAO; import org.apache.skywalking.apm.collector.storage.es.base.define.ElasticSearchStorageInstaller; import org.apache.skywalking.apm.collector.storage.es.dao.GlobalTraceEsPersistenceDAO; @@ -224,7 +224,7 @@ import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentDurationEsUI import org.apache.skywalking.apm.collector.storage.es.dao.ui.SegmentEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceMetricEsUIDAO; import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceNameServiceEsUIDAO; -import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsUIDAO; +import org.apache.skywalking.apm.collector.storage.es.dao.ui.ServiceReferenceEsMetricUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -410,7 +410,7 @@ public class StorageModuleEsProvider extends ModuleProvider { this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationEsUIDAO(elasticSearchClient)); this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentEsUIDAO(elasticSearchClient)); - this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceEsUIDAO(elasticSearchClient)); + this.registerServiceImplementation(IServiceReferenceMetricUIDAO.class, new ServiceReferenceEsMetricUIDAO(elasticSearchClient)); } private void registerAlarmDAO() throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java index 5a4fb8aef..1d157667b 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/cache/ServiceNameEsCacheDAO.java @@ -19,9 +19,9 @@ package org.apache.skywalking.apm.collector.storage.es.dao.cache; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; import org.elasticsearch.action.get.GetRequestBuilder; import org.elasticsearch.action.get.GetResponse; @@ -41,16 +41,19 @@ public class ServiceNameEsCacheDAO extends EsDAO implements IServiceNameCacheDAO super(client); } - @Override public String getServiceName(int serviceId) { + @Override public ServiceName get(int serviceId) { GetRequestBuilder getRequestBuilder = getClient().prepareGet(ServiceNameTable.TABLE, String.valueOf(serviceId)); GetResponse getResponse = getRequestBuilder.get(); + if (getResponse.isExists()) { - String serviceName = (String)getResponse.getSource().get(ServiceNameTable.COLUMN_SERVICE_NAME); - int applicationId = ((Number)getResponse.getSource().get(ServiceNameTable.COLUMN_APPLICATION_ID)).intValue(); - return applicationId + Const.ID_SPLIT + serviceName; + ServiceName serviceName = new ServiceName(); + serviceName.setApplicationId(((Number)getResponse.getSource().get(ServiceNameTable.COLUMN_APPLICATION_ID)).intValue()); + serviceName.setServiceId(serviceId); + serviceName.setServiceName((String)getResponse.getSource().get(ServiceNameTable.COLUMN_SERVICE_NAME)); + return serviceName; } - return Const.EMPTY_STRING; + return null; } @Override public int getServiceId(int applicationId, String serviceName) { diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java index 812ba2506..43ed65f74 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java @@ -18,6 +18,7 @@ package org.apache.skywalking.apm.collector.storage.es.dao.ui; +import java.util.Collection; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; @@ -26,12 +27,23 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Node; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceNode; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; +import org.elasticsearch.search.aggregations.metrics.sum.Sum; /** * @author peng-yongsheng @@ -90,4 +102,45 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO { } return trends; } + + @Override + public List getServicesMetric(Step step, long startTime, long endTime, MetricSource metricSource, + Collection serviceIds) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ServiceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termsQuery(ServiceMetricTable.COLUMN_SERVICE_ID, serviceIds)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ServiceMetricTable.COLUMN_SERVICE_ID).field(ServiceMetricTable.COLUMN_SERVICE_ID).size(100); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List nodes = new LinkedList<>(); + Terms serviceIdTerms = searchResponse.getAggregations().get(ServiceMetricTable.COLUMN_SERVICE_ID); + serviceIdTerms.getBuckets().forEach(serviceIdBucket -> { + int serviceId = serviceIdBucket.getKeyAsNumber().intValue(); + + Sum callsSum = serviceIdBucket.getAggregations().get(ServiceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum errorCallsSum = serviceIdBucket.getAggregations().get(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + + ServiceNode serviceNode = new ServiceNode(); + serviceNode.setId(serviceId); + serviceNode.setCalls((long)callsSum.getValue()); + serviceNode.setSla((int)(((callsSum.getValue() - errorCallsSum.getValue()) / callsSum.getValue()) * 10000)); + nodes.add(serviceNode); + }); + return nodes; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsMetricUIDAO.java new file mode 100644 index 000000000..879952282 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsMetricUIDAO.java @@ -0,0 +1,200 @@ +/* + * 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.apm.collector.storage.es.dao.ui; + +import java.util.LinkedList; +import java.util.List; +import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; +import org.elasticsearch.search.aggregations.metrics.sum.Sum; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceEsMetricUIDAO extends EsDAO implements IServiceReferenceMetricUIDAO { + + public ServiceReferenceEsMetricUIDAO(ElasticSearchClient client) { + super(client); + } + + @Override public List getFrontServices(Step step, long startTime, long endTime, MetricSource metricSource, + int behindServiceId) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ServiceReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, behindServiceId)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).size(100); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List calls = new LinkedList<>(); + Terms frontServiceIdTerms = searchResponse.getAggregations().get(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); + buildNodeByBehindServiceId(calls, frontServiceIdTerms, behindServiceId); + + return calls; + } + + @Override public List getBehindServices(Step step, long startTime, long endTime, MetricSource metricSource, + int frontServiceId) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ServiceReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, frontServiceId)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).size(100); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List calls = new LinkedList<>(); + Terms behindServiceIdTerms = searchResponse.getAggregations().get(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); + buildNodeByFrontServiceId(calls, behindServiceIdTerms, frontServiceId); + + return calls; + } + + @Override public List getFrontServices(Step step, long startTime, long endTime, MetricSource metricSource, + List behindServiceIds) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ServiceReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termsQuery(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, behindServiceIds)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + return executeAggregation(searchRequestBuilder); + } + + @Override public List getBehindServices(Step step, long startTime, long endTime, MetricSource metricSource, + List frontServiceIds) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceReferenceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ServiceReferenceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); + boolQuery.must().add(QueryBuilders.termsQuery(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, frontServiceIds)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceReferenceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + return executeAggregation(searchRequestBuilder); + } + + private List executeAggregation(SearchRequestBuilder searchRequestBuilder) { + TermsAggregationBuilder frontAggregationBuilder = AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).size(100); + TermsAggregationBuilder behindAggregationBuilder = AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).size(100); + behindAggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); + behindAggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + frontAggregationBuilder.subAggregation(behindAggregationBuilder); + + searchRequestBuilder.addAggregation(frontAggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List nodes = new LinkedList<>(); + Terms frontServiceIdTerms = searchResponse.getAggregations().get(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); + frontServiceIdTerms.getBuckets().forEach(frontServiceIdBucket -> { + int frontServiceId = frontServiceIdBucket.getKeyAsNumber().intValue(); + + Terms behindServiceIdTerms = frontServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); + buildNodeByFrontServiceId(nodes, behindServiceIdTerms, frontServiceId); + }); + + return nodes; + } + + private void buildNodeByFrontServiceId(List calls, Terms behindServiceIdTerms, int frontServiceId) { + behindServiceIdTerms.getBuckets().forEach(behindServiceIdBucket -> { + int behindServiceId = behindServiceIdBucket.getKeyAsNumber().intValue(); + + Sum callsSum = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum responseTimes = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + + Call call = new Call(); + call.setSource(frontServiceId); + call.setTarget(behindServiceId); + call.setCalls((int)callsSum.getValue()); + call.setResponseTimes((int)responseTimes.getValue()); + calls.add(call); + }); + } + + private void buildNodeByBehindServiceId(List calls, Terms frontServiceIdTerms, int behindServiceId) { + frontServiceIdTerms.getBuckets().forEach(frontServiceIdBucket -> { + int frontServiceId = frontServiceIdBucket.getKeyAsNumber().intValue(); + Sum callsSum = frontServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); + Sum responseTimes = frontServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + + Call call = new Call(); + call.setTarget(behindServiceId); + call.setSource(frontServiceId); + call.setCalls((int)callsSum.getValue()); + call.setResponseTimes((int)responseTimes.getValue()); + calls.add(call); + }); + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java deleted file mode 100644 index d78a55bbb..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceReferenceEsUIDAO.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * 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.apm.collector.storage.es.dao.ui; - -import com.google.gson.JsonObject; -import java.util.LinkedHashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; -import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; -import org.elasticsearch.action.search.SearchRequestBuilder; -import org.elasticsearch.action.search.SearchResponse; -import org.elasticsearch.action.search.SearchType; -import org.elasticsearch.index.query.BoolQueryBuilder; -import org.elasticsearch.index.query.QueryBuilders; -import org.elasticsearch.search.aggregations.AggregationBuilders; -import org.elasticsearch.search.aggregations.bucket.terms.Terms; -import org.elasticsearch.search.aggregations.metrics.sum.Sum; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng - */ -public class ServiceReferenceEsUIDAO extends EsDAO implements IServiceReferenceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceReferenceEsUIDAO.class); - - public ServiceReferenceEsUIDAO(ElasticSearchClient client) { - super(client); - } - - @Override - public Map load(int entryServiceId, long startTime, long endTime) { - SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(ServiceReferenceMetricTable.TABLE); - searchRequestBuilder.setTypes(ServiceReferenceMetricTable.TABLE_TYPE); - searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); - - BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); - boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - boolQuery.must().add(QueryBuilders.rangeQuery(ServiceReferenceMetricTable.COLUMN_TIME_BUCKET).gte(startTime).lte(endTime)); - - searchRequestBuilder.setQuery(boolQuery); - searchRequestBuilder.setSize(0); - - return load(searchRequestBuilder); - } - - private Map load(SearchRequestBuilder searchRequestBuilder) { - searchRequestBuilder.addAggregation(AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID).size(100) - .subAggregation(AggregationBuilders.terms(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).field(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID).size(100) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)) - .subAggregation(AggregationBuilders.sum(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM).field(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)))); - - Map serviceReferenceMap = new LinkedHashMap<>(); - - SearchResponse searchResponse = searchRequestBuilder.get(); - Terms frontServiceIdTerms = searchResponse.getAggregations().get(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); - for (Terms.Bucket frontServiceBucket : frontServiceIdTerms.getBuckets()) { - int frontServiceId = frontServiceBucket.getKeyAsNumber().intValue(); - if (frontServiceId != 0) { - parseSubAggregate(serviceReferenceMap, frontServiceBucket, frontServiceId); - } - } - - return serviceReferenceMap; - } - - private void parseSubAggregate(Map serviceReferenceMap, - Terms.Bucket frontServiceBucket, - int frontServiceId) { - Terms behindServiceIdTerms = frontServiceBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); - for (Terms.Bucket behindServiceIdBucket : behindServiceIdTerms.getBuckets()) { - int behindServiceId = behindServiceIdBucket.getKeyAsNumber().intValue(); - if (behindServiceId != 0) { - Sum calls = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); - Sum errorCalls = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); - Sum durationSum = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - Sum errorDurationSum = behindServiceIdBucket.getAggregations().get(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); - - JsonObject serviceReference = new JsonObject(); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID), frontServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID), behindServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS), (long)calls.getValue()); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS), (long)errorCalls.getValue()); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM), (long)durationSum.getValue()); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM), (long)errorDurationSum.getValue()); - - String id = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); - serviceReferenceMap.put(id, serviceReference); - } - } - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java index a29cdcb13..ba2512525 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/StorageModuleH2Provider.java @@ -122,7 +122,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentDurationUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; -import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.BatchH2DAO; import org.apache.skywalking.apm.collector.storage.h2.base.define.H2StorageInstaller; import org.apache.skywalking.apm.collector.storage.h2.dao.GlobalTraceH2PersistenceDAO; @@ -220,7 +220,7 @@ import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentDurationH2UI import org.apache.skywalking.apm.collector.storage.h2.dao.ui.SegmentH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceMetricH2UIDAO; import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceNameServiceH2UIDAO; -import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2UIDAO; +import org.apache.skywalking.apm.collector.storage.h2.dao.ui.ServiceReferenceH2MetricUIDAO; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -386,7 +386,7 @@ public class StorageModuleH2Provider extends ModuleProvider { this.registerServiceImplementation(IApplicationReferenceMetricUIDAO.class, new ApplicationReferenceMetricH2UIDAO(h2Client)); this.registerServiceImplementation(ISegmentDurationUIDAO.class, new SegmentDurationH2UIDAO(h2Client)); this.registerServiceImplementation(ISegmentUIDAO.class, new SegmentH2UIDAO(h2Client)); - this.registerServiceImplementation(IServiceReferenceUIDAO.class, new ServiceReferenceH2UIDAO(h2Client)); + this.registerServiceImplementation(IServiceReferenceMetricUIDAO.class, new ServiceReferenceH2MetricUIDAO(h2Client)); } private void registerAlarmDAO() throws ServiceNotProvidedException { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java index dd5de4ab7..88c085382 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/cache/ServiceNameH2CacheDAO.java @@ -16,17 +16,16 @@ * */ - package org.apache.skywalking.apm.collector.storage.h2.dao.cache; import java.sql.ResultSet; import java.sql.SQLException; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.client.h2.H2Client; import org.apache.skywalking.apm.collector.client.h2.H2ClientException; +import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; import org.apache.skywalking.apm.collector.storage.dao.cache.IServiceNameCacheDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.apache.skywalking.apm.collector.storage.table.register.ServiceNameTable; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -45,21 +44,23 @@ public class ServiceNameH2CacheDAO extends H2DAO implements IServiceNameCacheDAO super(client); } - @Override public String getServiceName(int serviceId) { + @Override public ServiceName get(int serviceId) { H2Client client = getClient(); String sql = SqlBuilder.buildSql(GET_SERVICE_NAME_SQL, ServiceNameTable.COLUMN_APPLICATION_ID, ServiceNameTable.COLUMN_SERVICE_NAME, ServiceNameTable.TABLE, ServiceNameTable.COLUMN_SERVICE_ID); Object[] params = new Object[] {serviceId}; try (ResultSet rs = client.executeQuery(sql, params)) { if (rs.next()) { - String serviceName = rs.getString(ServiceNameTable.COLUMN_SERVICE_NAME); - int applicationId = rs.getInt(ServiceNameTable.COLUMN_APPLICATION_ID); - return applicationId + Const.ID_SPLIT + serviceName; + ServiceName serviceName = new ServiceName(); + serviceName.setServiceId(serviceId); + serviceName.setApplicationId(rs.getInt(ServiceNameTable.COLUMN_APPLICATION_ID)); + serviceName.setServiceName(rs.getString(ServiceNameTable.COLUMN_SERVICE_NAME)); + return serviceName; } } catch (SQLException | H2ClientException e) { logger.error(e.getMessage(), e); } - return Const.EMPTY_STRING; + return null; } @Override public int getServiceId(int applicationId, String serviceName) { diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java index 1fb3c4634..2b5628a10 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java @@ -20,6 +20,7 @@ package org.apache.skywalking.apm.collector.storage.h2.dao.ui; import java.sql.ResultSet; import java.sql.SQLException; +import java.util.Collection; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.client.h2.H2Client; @@ -30,6 +31,7 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; +import org.apache.skywalking.apm.collector.storage.ui.common.Node; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; @@ -103,4 +105,10 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO { return trends; } + + @Override + public List getServicesMetric(Step step, long startTime, long endTime, MetricSource metricSource, + Collection serviceIds) { + return null; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2MetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2MetricUIDAO.java new file mode 100644 index 000000000..c5f27f97f --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2MetricUIDAO.java @@ -0,0 +1,57 @@ +/* + * 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.apm.collector.storage.h2.dao.ui; + +import java.util.List; +import org.apache.skywalking.apm.collector.client.h2.H2Client; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; + +/** + * @author peng-yongsheng + */ +public class ServiceReferenceH2MetricUIDAO extends H2DAO implements IServiceReferenceMetricUIDAO { + + public ServiceReferenceH2MetricUIDAO(H2Client client) { + super(client); + } + + @Override public List getFrontServices(Step step, long startTime, long endTime, MetricSource metricSource, + int behindServiceId) { + return null; + } + + @Override public List getBehindServices(Step step, long startTime, long endTime, MetricSource metricSource, + int frontServiceId) { + return null; + } + + @Override public List getFrontServices(Step step, long startTime, long endTime, MetricSource metricSource, + List behindServiceIds) { + return null; + } + + @Override public List getBehindServices(Step step, long startTime, long endTime, MetricSource metricSource, + List frontServiceIds) { + return null; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java deleted file mode 100644 index 863191d27..000000000 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceReferenceH2UIDAO.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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.apm.collector.storage.h2.dao.ui; - -import com.google.gson.JsonObject; -import java.sql.ResultSet; -import java.sql.SQLException; -import java.util.LinkedHashMap; -import java.util.Map; -import org.apache.skywalking.apm.collector.client.h2.H2Client; -import org.apache.skywalking.apm.collector.client.h2.H2ClientException; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.base.sql.SqlBuilder; -import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; -import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author peng-yongsheng, clevertension - */ -public class ServiceReferenceH2UIDAO extends H2DAO implements IServiceReferenceUIDAO { - - private final Logger logger = LoggerFactory.getLogger(ServiceReferenceH2UIDAO.class); - - public ServiceReferenceH2UIDAO(H2Client client) { - super(client); - } - - private static final String GET_SRV_REF_LOAD1 = "select {3}, {4}, sum({5}) as {5}, sum({6}) as {6}, sum({7}) as {7}" + - ",sum({8}) as {8} from {0} where {1} >= ? and {1} <= ? and {2} = ? group by {3}, {4}"; - - @Override - public Map load(int entryServiceId, long startTime, long endTime) { - H2Client client = getClient(); - String sql = SqlBuilder.buildSql(GET_SRV_REF_LOAD1, ServiceReferenceMetricTable.TABLE, - ServiceReferenceMetricTable.COLUMN_TIME_BUCKET, - ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID, ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID, - ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, - ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); - Object[] params = new Object[] {startTime, endTime, entryServiceId}; - - return load(client, params, sql); - } - - private Map load(H2Client client, Object[] params, String sql) { - Map serviceReferenceMap = new LinkedHashMap<>(); - - try (ResultSet rs = client.executeQuery(sql, params)) { - while (rs.next()) { - int frontServiceId = rs.getInt(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID); - parseSubAggregate(serviceReferenceMap, rs, frontServiceId); - } - } catch (SQLException | H2ClientException e) { - logger.error(e.getMessage(), e); - } - return serviceReferenceMap; - } - - private void parseSubAggregate(Map serviceReferenceMap, ResultSet rs, - int frontServiceId) { - try { - int behindServiceId = rs.getInt(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID); - if (behindServiceId != 0) { - long calls = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS); - long errorCalls = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); - long durationSum = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); - long errorDurationSum = rs.getLong(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); - - JsonObject serviceReference = new JsonObject(); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID), frontServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID), behindServiceId); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS), calls); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS), errorCalls); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM), durationSum); - serviceReference.addProperty(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM), errorDurationSum); - - String id = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); - serviceReferenceMap.put(id, serviceReference); - } - } catch (SQLException e) { - logger.error(e.getMessage(), e); - } - } -} diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define index b3403d961..fdb2fd844 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/resources/META-INF/defines/storage.define @@ -80,10 +80,12 @@ org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmH2Ta org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationAlarmListH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationReferenceAlarmH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.ApplicationReferenceAlarmListH2TableDefine + org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceAlarmH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceAlarmListH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceReferenceAlarmH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.InstanceReferenceAlarmListH2TableDefine + org.apache.skywalking.apm.collector.storage.h2.define.alarm.ServiceAlarmH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.ServiceAlarmListH2TableDefine org.apache.skywalking.apm.collector.storage.h2.define.alarm.ServiceReferenceAlarmH2TableDefine diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java index 4f6c0aed4..d4051b035 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ServiceQuery.java @@ -30,6 +30,7 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Topology; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; import org.apache.skywalking.apm.collector.ui.graphql.Query; import org.apache.skywalking.apm.collector.ui.service.ServiceNameService; +import org.apache.skywalking.apm.collector.ui.service.ServiceTopologyService; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; /** @@ -39,6 +40,7 @@ public class ServiceQuery implements Query { private final ModuleManager moduleManager; private ServiceNameService serviceNameService; + private ServiceTopologyService serviceTopologyService; public ServiceQuery(ModuleManager moduleManager) { this.moduleManager = moduleManager; @@ -51,6 +53,13 @@ public class ServiceQuery implements Query { return serviceNameService; } + private ServiceTopologyService getServiceTopologyService() { + if (ObjectUtils.isEmpty(serviceTopologyService)) { + this.serviceTopologyService = new ServiceTopologyService(moduleManager); + } + return serviceTopologyService; + } + public List searchService(String keyword, int topN) throws ParseException { return getServiceNameService().searchService(keyword, topN); } @@ -71,7 +80,9 @@ public class ServiceQuery implements Query { return getServiceNameService().getServiceSLATrend(serviceId, duration.getStep(), start, end); } - public Topology getServiceTopology(int serviceId, Duration duration) { - return null; + public Topology getServiceTopology(int serviceId, Duration duration) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServiceTopologyService().getServiceTopology(duration.getStep(), serviceId, start, end); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java new file mode 100644 index 000000000..5ce4340be --- /dev/null +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTopologyService.java @@ -0,0 +1,93 @@ +/* + * 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.apm.collector.ui.service; + +import java.text.ParseException; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; +import org.apache.skywalking.apm.collector.core.util.Const; +import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ui.IApplicationComponentUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; +import org.apache.skywalking.apm.collector.storage.ui.common.Call; +import org.apache.skywalking.apm.collector.storage.ui.common.Node; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author peng-yongsheng + */ +public class ServiceTopologyService { + + private final Logger logger = LoggerFactory.getLogger(ServiceTopologyService.class); + + private final IApplicationComponentUIDAO applicationComponentUIDAO; + private final IServiceMetricUIDAO serviceMetricUIDAO; + private final IServiceReferenceMetricUIDAO serviceReferenceMetricUIDAO; + private final ServiceNameCacheService serviceNameCacheService; + + public ServiceTopologyService(ModuleManager moduleManager) { + this.serviceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceMetricUIDAO.class); + this.serviceReferenceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceReferenceMetricUIDAO.class); + this.applicationComponentUIDAO = moduleManager.find(StorageModule.NAME).getService(IApplicationComponentUIDAO.class); + this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); + } + + public Topology getServiceTopology(Step step, int serviceId, long start, long end) throws ParseException { + logger.debug("start: {}, end: {}", start, end); + List applicationComponents = applicationComponentUIDAO.load(step, start, end); + + Map components = new HashMap<>(); + applicationComponents.forEach(component -> components.put(component.getApplicationId(), ComponentsDefine.getInstance().getComponentName(component.getComponentId()))); + + List calleeCalls = serviceReferenceMetricUIDAO.getFrontServices(step, start, end, MetricSource.Callee, serviceId); + calleeCalls.addAll(serviceReferenceMetricUIDAO.getBehindServices(step, start, end, MetricSource.Caller, serviceId)); + + Set nodeIds = new HashSet<>(); + calleeCalls.forEach(call -> { + call.setCallType(Const.EMPTY_STRING); + nodeIds.add(call.getSource()); + nodeIds.add(call.getTarget()); + }); + + List serviceNodes = serviceMetricUIDAO.getServicesMetric(step, start, end, MetricSource.Callee, nodeIds); + + serviceNodes.forEach(serviceNode -> { + ServiceName serviceName = serviceNameCacheService.get(serviceNode.getId()); + serviceNode.setName(serviceName.getServiceName()); + }); + + Topology topology = new Topology(); + topology.setCalls(calleeCalls); + topology.setNodes(serviceNodes); + return topology; + } +} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java deleted file mode 100644 index 64515d51a..000000000 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceTreeService.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * 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.apm.collector.ui.service; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import java.util.Iterator; -import java.util.Map; -import org.apache.skywalking.apm.collector.cache.CacheModule; -import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; -import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.ColumnNameUtils; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.ObjectUtils; -import org.apache.skywalking.apm.collector.storage.StorageModule; -import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceReferenceUIDAO; -import org.apache.skywalking.apm.collector.storage.table.service.ServiceReferenceMetricTable; - -/** - * @author peng-yongsheng - */ -public class ServiceTreeService { - - private final IServiceReferenceUIDAO serviceReferenceDAO; - private final ApplicationCacheService applicationCacheService; - private final ServiceNameCacheService serviceNameCacheService; - - public ServiceTreeService(ModuleManager moduleManager) { - this.serviceReferenceDAO = moduleManager.find(StorageModule.NAME).getService(IServiceReferenceUIDAO.class); - this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); - this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); - } - - public JsonArray loadServiceTree(int entryServiceId, long startTime, long endTime) { - Map serviceReferenceMap = serviceReferenceDAO.load(entryServiceId, startTime, endTime); - serviceReferenceMap.values().forEach(serviceReference -> { - int frontServiceId = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)).getAsInt(); - int behindServiceId = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)).getAsInt(); - String frontServiceName = serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(frontServiceId)); - String behindServiceName = serviceNameCacheService.getSplitServiceName(serviceNameCacheService.get(behindServiceId)); - serviceReference.addProperty("frontServiceName", frontServiceName); - serviceReference.addProperty("behindServiceName", behindServiceName); - }); - return buildTreeData(serviceReferenceMap); - } - - private JsonArray buildTreeData(Map serviceReferenceMap) { - JsonArray serviceReferenceArray = new JsonArray(); - JsonObject rootServiceReference = findRoot(serviceReferenceMap); - if (ObjectUtils.isNotEmpty(rootServiceReference)) { - serviceReferenceArray.add(rootServiceReference); - String id = rootServiceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + rootServiceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); - serviceReferenceMap.remove(id); - - int rootServiceId = rootServiceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)).getAsInt(); - sortAsTree(rootServiceId, serviceReferenceArray, serviceReferenceMap); - } - - return serviceReferenceArray; - } - - private JsonObject findRoot(Map serviceReferenceMap) { - for (JsonObject serviceReference : serviceReferenceMap.values()) { - int frontServiceId = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)).getAsInt(); - if (frontServiceId == 1) { - return serviceReference; - } - } - return null; - } - - private void sortAsTree(int serviceId, JsonArray serviceReferenceArray, - Map serviceReferenceMap) { - Iterator iterator = serviceReferenceMap.values().iterator(); - while (iterator.hasNext()) { - JsonObject serviceReference = iterator.next(); - int frontServiceId = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)).getAsInt(); - if (serviceId == frontServiceId) { - serviceReferenceArray.add(serviceReference); - - int behindServiceId = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)).getAsInt(); - sortAsTree(behindServiceId, serviceReferenceArray, serviceReferenceMap); - } - } - } - - private void merge(Map serviceReferenceMap, JsonObject serviceReference) { - String id = serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_FRONT_SERVICE_ID)) + Const.ID_SPLIT + serviceReference.get(ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_BEHIND_SERVICE_ID)); - - if (serviceReferenceMap.containsKey(id)) { - JsonObject reference = serviceReferenceMap.get(id); - add(reference, serviceReference, ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_CALLS)); - add(reference, serviceReference, ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)); - add(reference, serviceReference, ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); - add(reference, serviceReference, ColumnNameUtils.INSTANCE.rename(ServiceReferenceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)); - } else { - serviceReferenceMap.put(id, serviceReference); - } - } - - private void add(JsonObject oldReference, JsonObject newReference, String key) { - long oldValue = oldReference.get(key).getAsLong(); - long newValue = newReference.get(key).getAsLong(); - oldReference.addProperty(key, oldValue + newValue); - } -} diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java index 77bdefee2..c149778fe 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/SpanService.java @@ -16,25 +16,24 @@ * */ - package org.apache.skywalking.apm.collector.ui.service; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import java.util.List; import org.apache.skywalking.apm.collector.cache.CacheModule; -import org.apache.skywalking.apm.collector.core.module.ModuleManager; -import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; -import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; +import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; +import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.apache.skywalking.apm.network.proto.KeyWithStringValue; import org.apache.skywalking.apm.network.proto.LogMessage; import org.apache.skywalking.apm.network.proto.SpanObject; import org.apache.skywalking.apm.network.proto.TraceSegmentObject; +import org.apache.skywalking.apm.network.trace.component.ComponentsDefine; /** * @author peng-yongsheng @@ -60,9 +59,9 @@ public class SpanService { if (spanId == spanObject.getSpanId()) { String operationName = spanObject.getOperationName(); if (spanObject.getOperationNameId() != 0) { - String serviceName = serviceNameCacheService.get(spanObject.getOperationNameId()); + ServiceName serviceName = serviceNameCacheService.get(spanObject.getOperationNameId()); if (StringUtils.isNotEmpty(serviceName)) { - operationName = serviceName.split(Const.ID_SPLIT)[1]; + operationName = serviceName.getServiceName(); } } spanJson.addProperty("operationName", operationName); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java index 989d4318f..9d65686f2 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/TraceStackService.java @@ -29,10 +29,10 @@ import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.CollectionUtils; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.ObjectUtils; -import org.apache.skywalking.apm.collector.core.util.StringUtils; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.ui.IGlobalTraceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.ISegmentUIDAO; +import org.apache.skywalking.apm.collector.storage.table.register.ServiceName; import org.apache.skywalking.apm.collector.storage.ui.trace.KeyValue; import org.apache.skywalking.apm.collector.storage.ui.trace.LogEntity; import org.apache.skywalking.apm.collector.storage.ui.trace.Ref; @@ -137,9 +137,9 @@ public class TraceStackService { String operationName = spanObject.getOperationName(); if (spanObject.getOperationNameId() != 0) { - String serviceName = serviceNameCacheService.get(spanObject.getOperationNameId()); - if (StringUtils.isNotEmpty(serviceName)) { - operationName = serviceName.split(Const.ID_SPLIT)[1]; + ServiceName serviceName = serviceNameCacheService.get(spanObject.getOperationNameId()); + if (ObjectUtils.isNotEmpty(serviceName)) { + operationName = serviceName.getServiceName(); } else { operationName = Const.EMPTY_STRING; } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls index 2c14b8be2..cf4b73ee8 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/service-layer.graphqls @@ -3,9 +3,8 @@ type ServiceNode implements Node { name: String! type: String # Success rate of all incoming requests. - # Max value is 100. - # 2 Digits after floating point. - sla: Float! + # Max value is 10000. + sla: Int! # The number of incoming calls calls: Long! # The number of services alerting From a81719786e5fcd58095fd3995c959760dfee5dbf Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Thu, 8 Feb 2018 18:16:58 +0800 Subject: [PATCH 30/36] Provide the getSlowService query. --- .../storage/dao/ui/IServiceMetricUIDAO.java | 4 ++ .../apm/collector/storage/ui/alarm/Alarm.java | 10 +-- .../collector/storage/ui/alarm/AlarmItem.java | 2 +- .../storage/ui/service/ServiceMetric.java | 61 +++++++++++++++++++ .../es/dao/ui/ServiceMetricEsUIDAO.java | 60 ++++++++++++++++++ .../h2/dao/ui/ServiceMetricH2UIDAO.java | 9 ++- .../apm/collector/ui/query/AlarmQuery.java | 4 +- .../collector/ui/query/ApplicationQuery.java | 9 ++- .../ui/service/ApplicationService.java | 21 +++++++ .../ui-graphql/application-layer.graphqls | 2 +- 10 files changed, 168 insertions(+), 14 deletions(-) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceMetric.java diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java index 4303aa797..0ca4c752a 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IServiceMetricUIDAO.java @@ -24,6 +24,7 @@ import org.apache.skywalking.apm.collector.storage.base.dao.DAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.ui.common.Node; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; /** @@ -36,4 +37,7 @@ public interface IServiceMetricUIDAO extends DAO { List getServicesMetric(Step step, long startTime, long endTime, MetricSource metricSource, Collection serviceIds); + + List getSlowService(int applicationId, Step step, long start, long end, + Integer top, MetricSource metricSource); } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java index 62c3dc102..001024a27 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/Alarm.java @@ -25,7 +25,7 @@ import java.util.List; */ public class Alarm { private List items; - private Integer count; + private int total; public List getItems() { return items; @@ -35,11 +35,11 @@ public class Alarm { this.items = items; } - public Integer getCount() { - return count; + public int getTotal() { + return total; } - public void setCount(Integer count) { - this.count = count; + public void setTotal(int total) { + this.total = total; } } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java index 1523ec931..1e47c71da 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java @@ -25,6 +25,6 @@ public class AlarmItem { private String title; private String content; private String startTime; - private AlarmType alertType; + private AlarmType alarmType; private CauseType causeType; } diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceMetric.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceMetric.java new file mode 100644 index 000000000..7db67f8b4 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/service/ServiceMetric.java @@ -0,0 +1,61 @@ +/* + * 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.apm.collector.storage.ui.service; + +/** + * @author peng-yongsheng + */ +public class ServiceMetric { + private int id; + private String name; + private int avgResponseTime; + private int tps; + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getAvgResponseTime() { + return avgResponseTime; + } + + public void setAvgResponseTime(int avgResponseTime) { + this.avgResponseTime = avgResponseTime; + } + + public int getTps() { + return tps; + } + + public void setTps(int tps) { + this.tps = tps; + } +} diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java index 43ed65f74..cd8cb02f6 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java @@ -19,8 +19,10 @@ package org.apache.skywalking.apm.collector.storage.es.dao.ui; import java.util.Collection; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; @@ -29,6 +31,7 @@ import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; import org.apache.skywalking.apm.collector.storage.ui.common.Node; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceNode; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; @@ -40,16 +43,21 @@ import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; import org.elasticsearch.search.aggregations.AggregationBuilders; import org.elasticsearch.search.aggregations.bucket.terms.Terms; import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; import org.elasticsearch.search.aggregations.metrics.sum.Sum; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders; /** * @author peng-yongsheng */ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO { + private static final String AVG_DURATION = "avg_duration"; + public ServiceMetricEsUIDAO(ElasticSearchClient client) { super(client); } @@ -143,4 +151,56 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO { }); return nodes; } + + @Override public List getSlowService(int applicationId, Step step, long start, long end, Integer top, + MetricSource metricSource) { + String tableName = TimePyramidTableNameBuilder.build(step, ServiceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(ServiceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(ServiceMetricTable.COLUMN_TIME_BUCKET).gte(start).lte(end)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceMetricTable.COLUMN_APPLICATION_ID, applicationId)); + boolQuery.must().add(QueryBuilders.termQuery(ServiceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ServiceMetricTable.COLUMN_SERVICE_ID).field(ServiceMetricTable.COLUMN_SERVICE_ID).size(100); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM).field(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM)); + + Map bucketsPathsMap = new HashMap<>(); + bucketsPathsMap.put(ServiceMetricTable.COLUMN_TRANSACTION_CALLS, ServiceMetricTable.COLUMN_TRANSACTION_CALLS); + bucketsPathsMap.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + bucketsPathsMap.put(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM, ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM); + bucketsPathsMap.put(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM, ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM); + + String idOrCode = "(params." + ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM + " - params." + ServiceMetricTable.COLUMN_TRANSACTION_ERROR_DURATION_SUM + ")" + + " / " + + "(params." + ServiceMetricTable.COLUMN_TRANSACTION_CALLS + " - params." + ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS + ")"; + Script script = new Script(idOrCode); + aggregationBuilder.subAggregation(PipelineAggregatorBuilders.bucketScript(AVG_DURATION, bucketsPathsMap, script)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List serviceMetrics = new LinkedList<>(); + Terms serviceIdTerms = searchResponse.getAggregations().get(ServiceMetricTable.COLUMN_SERVICE_ID); + serviceIdTerms.getBuckets().forEach(serviceIdTerm -> { + int serviceId = serviceIdTerm.getKeyAsNumber().intValue(); + + ServiceMetric serviceMetric = new ServiceMetric(); + InternalSimpleValue simpleValue = serviceIdTerm.getAggregations().get(AVG_DURATION); + + serviceMetric.setId(serviceId); + serviceMetric.setAvgResponseTime((int)simpleValue.getValue()); + serviceMetrics.add(serviceMetric); + }); + return serviceMetrics; + } } diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java index 2b5628a10..0bab7e5b8 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/ServiceMetricH2UIDAO.java @@ -33,6 +33,7 @@ import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.service.ServiceMetricTable; import org.apache.skywalking.apm.collector.storage.ui.common.Node; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; @@ -106,9 +107,13 @@ public class ServiceMetricH2UIDAO extends H2DAO implements IServiceMetricUIDAO { return trends; } - @Override - public List getServicesMetric(Step step, long startTime, long endTime, MetricSource metricSource, + @Override public List getServicesMetric(Step step, long startTime, long endTime, MetricSource metricSource, Collection serviceIds) { return null; } + + @Override public List getSlowService(int applicationId, Step step, long start, long end, Integer top, + MetricSource metricSource) { + return null; + } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java index 820b41a19..61b1d2990 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java @@ -29,9 +29,9 @@ import org.apache.skywalking.apm.collector.storage.ui.common.Pagination; */ public class AlarmQuery implements Query { - public Alarm loadAlertList(String keyword, AlarmType alarmType, Duration duration, Pagination pagination) { + public Alarm loadAlarmList(String keyword, AlarmType alarmType, Duration duration, Pagination paging) { Alarm alarm = new Alarm(); - alarm.setCount(0); + alarm.setTotal(0); return alarm; } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java index 7a97ee968..121cdce78 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/ApplicationQuery.java @@ -26,7 +26,7 @@ import org.apache.skywalking.apm.collector.storage.ui.application.Application; import org.apache.skywalking.apm.collector.storage.ui.common.Duration; import org.apache.skywalking.apm.collector.storage.ui.common.Topology; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; -import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; import org.apache.skywalking.apm.collector.ui.graphql.Query; import org.apache.skywalking.apm.collector.ui.service.ApplicationService; import org.apache.skywalking.apm.collector.ui.service.ApplicationTopologyService; @@ -73,8 +73,11 @@ public class ApplicationQuery implements Query { return getApplicationTopologyService().getApplicationTopology(duration.getStep(), applicationId, start, end); } - public List getSlowService(int applicationId, Duration duration, Integer top) { - return null; + public List getSlowService(int applicationId, Duration duration, Integer top) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + + return getApplicationService().getSlowService(applicationId, duration.getStep(), start, end, top); } public List getServerThroughput(int applicationId, Duration duration, Integer top) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java index 7f7ce816f..42c094fe8 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ApplicationService.java @@ -18,13 +18,19 @@ package org.apache.skywalking.apm.collector.ui.service; +import java.text.ParseException; import java.util.List; import org.apache.skywalking.apm.collector.cache.CacheModule; import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; +import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; +import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.ui.application.Application; +import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; /** * @author peng-yongsheng @@ -32,11 +38,15 @@ import org.apache.skywalking.apm.collector.storage.ui.application.Application; public class ApplicationService { private final IInstanceUIDAO instanceDAO; + private final IServiceMetricUIDAO serviceMetricUIDAO; private final ApplicationCacheService applicationCacheService; + private final ServiceNameCacheService serviceNameCacheService; public ApplicationService(ModuleManager moduleManager) { this.instanceDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); + this.serviceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceMetricUIDAO.class); this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); + this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); } public List getApplications(long startTime, long endTime, int... applicationIds) { @@ -48,4 +58,15 @@ public class ApplicationService { }); return applications; } + + public List getSlowService(int applicationId, Step step, long start, long end, + Integer top) throws ParseException { + List slowServices = serviceMetricUIDAO.getSlowService(applicationId, step, start, end, top, MetricSource.Callee); + slowServices.forEach(slowService -> { + slowService.setName(serviceNameCacheService.get(slowService.getId()).getServiceName()); + //TODO + slowService.setTps(1); + }); + return slowServices; + } } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls index bb99a4910..67f435073 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/application-layer.graphqls @@ -43,6 +43,6 @@ type Application { extend type Query { getAllApplication(duration: Duration!): [Application!]! getApplicationTopology(applicationId: ID!, duration: Duration!): Topology - getSlowService(applicationId: ID!, duration: Duration!, top: Int!): [ServiceInfo!]! + getSlowService(applicationId: ID!, duration: Duration!, top: Int!): [ServiceMetric!]! getServerThroughput(applicationId: ID!, duration: Duration!, top: Int!): [AppServerInfo!]! } From 425324ee46332c4f1981b77e61494cb228715115 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Thu, 8 Feb 2018 19:02:53 +0800 Subject: [PATCH 31/36] Provide the overview/getTopNSlowService query. --- .../storage/es/dao/ui/ServiceMetricEsUIDAO.java | 6 ++++-- .../collector/ui/query/OverViewLayerQuery.java | 8 +++++--- .../ui/service/ServiceNameService.java | 17 +++++++++++++++++ .../ui-graphql/overview-layer.graphqls | 2 +- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java index cd8cb02f6..e8f6fd81d 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/ServiceMetricEsUIDAO.java @@ -162,13 +162,15 @@ public class ServiceMetricEsUIDAO extends EsDAO implements IServiceMetricUIDAO { BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); boolQuery.must().add(QueryBuilders.rangeQuery(ServiceMetricTable.COLUMN_TIME_BUCKET).gte(start).lte(end)); - boolQuery.must().add(QueryBuilders.termQuery(ServiceMetricTable.COLUMN_APPLICATION_ID, applicationId)); + if (applicationId != 0) { + boolQuery.must().add(QueryBuilders.termQuery(ServiceMetricTable.COLUMN_APPLICATION_ID, applicationId)); + } boolQuery.must().add(QueryBuilders.termQuery(ServiceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); searchRequestBuilder.setQuery(boolQuery); searchRequestBuilder.setSize(0); - TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ServiceMetricTable.COLUMN_SERVICE_ID).field(ServiceMetricTable.COLUMN_SERVICE_ID).size(100); + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(ServiceMetricTable.COLUMN_SERVICE_ID).field(ServiceMetricTable.COLUMN_SERVICE_ID).size(top); aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_CALLS).field(ServiceMetricTable.COLUMN_TRANSACTION_CALLS)); aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(ServiceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)); aggregationBuilder.subAggregation(AggregationBuilders.sum(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM).field(ServiceMetricTable.COLUMN_TRANSACTION_DURATION_SUM)); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java index 6d1fa55a9..afbec260d 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java @@ -28,7 +28,7 @@ import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend; import org.apache.skywalking.apm.collector.storage.ui.overview.ClusterBrief; import org.apache.skywalking.apm.collector.storage.ui.overview.ConjecturalAppBrief; import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; -import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; import org.apache.skywalking.apm.collector.ui.graphql.Query; import org.apache.skywalking.apm.collector.ui.service.AlarmService; import org.apache.skywalking.apm.collector.ui.service.ApplicationService; @@ -118,8 +118,10 @@ public class OverViewLayerQuery implements Query { return null; } - public List getTopNSlowService(Duration duration, int topN) { - return null; + public List getTopNSlowService(Duration duration, int topN) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServiceNameService().getSlowService(duration.getStep(), start, end, topN); } public List getTopNServerThroughput(Duration duration, int topN) { diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java index a4de32ea7..2342deb3b 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServiceNameService.java @@ -20,14 +20,18 @@ package org.apache.skywalking.apm.collector.ui.service; import java.text.ParseException; import java.util.List; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ServiceNameCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.storage.StorageModule; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IServiceNameServiceUIDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.SLATrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.service.ServiceInfo; +import org.apache.skywalking.apm.collector.storage.ui.service.ServiceMetric; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; @@ -38,10 +42,12 @@ public class ServiceNameService { private final IServiceNameServiceUIDAO serviceNameServiceUIDAO; private final IServiceMetricUIDAO serviceMetricUIDAO; + private final ServiceNameCacheService serviceNameCacheService; public ServiceNameService(ModuleManager moduleManager) { this.serviceNameServiceUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceNameServiceUIDAO.class); this.serviceMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IServiceMetricUIDAO.class); + this.serviceNameCacheService = moduleManager.find(CacheModule.NAME).getService(ServiceNameCacheService.class); } public int getCount() { @@ -66,4 +72,15 @@ public class ServiceNameService { slaTrend.setTrendList(serviceMetricUIDAO.getServiceSLATrend(serviceId, step, durationPoints)); return slaTrend; } + + public List getSlowService(Step step, long start, long end, + Integer top) throws ParseException { + List slowServices = serviceMetricUIDAO.getSlowService(0, step, start, end, top, MetricSource.Callee); + slowServices.forEach(slowService -> { + slowService.setName(serviceNameCacheService.get(slowService.getId()).getServiceName()); + //TODO + slowService.setTps(1); + }); + return slowServices; + } } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index 04b1033a6..50e1ff26c 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -32,6 +32,6 @@ extend type Query { getClusterBrief(duration: Duration!): ClusterBrief getAlarmTrend(duration: Duration!): AlarmTrend getConjecturalApps(duration: Duration!): ConjecturalAppBrief - getTopNSlowService(duration: Duration!, topN: Int!): [ServiceInfo!]! + getTopNSlowService(duration: Duration!, topN: Int!): [ServiceMetric!]! getTopNServerThroughput(duration: Duration!, topN: Int!): [AppServerInfo!]! } From 59c512fb2b36fcf7b9ed29de903570ac92773a98 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 9 Feb 2018 10:20:31 +0800 Subject: [PATCH 32/36] CI fail fixed. --- .../apm/collector/ui/jetty/handler/GraphQLHandler.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java index 81cedadbf..c845edd65 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/jetty/handler/GraphQLHandler.java @@ -110,8 +110,7 @@ public class GraphQLHandler extends JettyHandler { JsonObject requestJson = gson.fromJson(request, JsonObject.class); - Type mapType = new TypeToken>() { - }.getType(); + Type mapType = new TypeToken>() { }.getType(); return execute(requestJson.get(QUERY).getAsString(), gson.fromJson(requestJson.get(VARIABLES), mapType)); } From 87d246d75637a8bdcc055a1f2fad937b80f5778f Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 9 Feb 2018 10:40:06 +0800 Subject: [PATCH 33/36] Fixed the bug: service/searchService #104 --- .../apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java index d34f3a0e9..e60da8b00 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceEsUIDAO.java @@ -160,7 +160,7 @@ public class InstanceEsUIDAO extends EsDAO implements IInstanceUIDAO { BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); boolQuery.must().add(QueryBuilders.rangeQuery(InstanceTable.COLUMN_HEARTBEAT_TIME).gte(start).lte(end)); if (StringUtils.isNotEmpty(keyword)) { - boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_OS_INFO, keyword)); + boolQuery.must().add(QueryBuilders.queryStringQuery(keyword)); } boolQuery.must().add(QueryBuilders.termQuery(InstanceTable.COLUMN_IS_ADDRESS, BooleanUtils.FALSE)); searchRequestBuilder.setQuery(boolQuery); From 1bc0d84532363ca12190aba4ef3b21ee5d61a68f Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 9 Feb 2018 14:12:04 +0800 Subject: [PATCH 34/36] Provide the getTopNServerThroughput query. --- .../storage/dao/ui/IInstanceMetricUIDAO.java | 6 ++ .../storage/ui/server/AppServerInfo.java | 18 +++++ .../es/dao/ui/InstanceMetricEsUIDAO.java | 66 +++++++++++++++++++ .../h2/dao/ui/InstanceMetricH2UIDAO.java | 6 ++ .../ui/query/OverViewLayerQuery.java | 19 +++++- .../collector/ui/service/ServerService.java | 24 +++++++ .../ui-graphql/overview-layer.graphqls | 2 +- .../ui-graphql/server-layer.graphqls | 2 + 8 files changed, 140 insertions(+), 3 deletions(-) diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java index a62c07116..0e605ae67 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/dao/ui/IInstanceMetricUIDAO.java @@ -20,7 +20,9 @@ package org.apache.skywalking.apm.collector.storage.dao.ui; import java.util.List; import org.apache.skywalking.apm.collector.storage.base.dao.DAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; /** @@ -28,6 +30,10 @@ import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; */ public interface IInstanceMetricUIDAO extends DAO { + List getTopNServerThroughput(int applicationId, Step step, long start, long end, long secondBetween, + int topN, + MetricSource metricSource); + List getServerTPSTrend(int instanceId, Step step, List durationPoints); List getResponseTimeTrend(int instanceId, Step step, List durationPoints); diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java index 9989ecbbc..c1ee6f307 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/server/AppServerInfo.java @@ -25,6 +25,8 @@ import java.util.List; */ public class AppServerInfo { private int id; + private int applicationId; + private String applicationCode; private String osInfo; private String name; private int tps; @@ -40,6 +42,22 @@ public class AppServerInfo { this.id = id; } + public int getApplicationId() { + return applicationId; + } + + public void setApplicationId(int applicationId) { + this.applicationId = applicationId; + } + + public String getApplicationCode() { + return applicationCode; + } + + public void setApplicationCode(String applicationCode) { + this.applicationCode = applicationCode; + } + public String getOsInfo() { return osInfo; } diff --git a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java index 9417dd647..fc32f5b24 100644 --- a/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-es-provider/src/main/java/org/apache/skywalking/apm/collector/storage/es/dao/ui/InstanceMetricEsUIDAO.java @@ -18,8 +18,10 @@ package org.apache.skywalking.apm.collector.storage.es.dao.ui; +import java.util.HashMap; import java.util.LinkedList; import java.util.List; +import java.util.Map; import org.apache.skywalking.apm.collector.client.elasticsearch.ElasticSearchClient; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; @@ -27,21 +29,85 @@ import org.apache.skywalking.apm.collector.storage.es.base.dao.EsDAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.elasticsearch.action.get.MultiGetItemResponse; import org.elasticsearch.action.get.MultiGetRequestBuilder; import org.elasticsearch.action.get.MultiGetResponse; +import org.elasticsearch.action.search.SearchRequestBuilder; +import org.elasticsearch.action.search.SearchResponse; +import org.elasticsearch.action.search.SearchType; +import org.elasticsearch.index.query.BoolQueryBuilder; +import org.elasticsearch.index.query.QueryBuilders; +import org.elasticsearch.script.Script; +import org.elasticsearch.search.aggregations.AggregationBuilders; +import org.elasticsearch.search.aggregations.bucket.terms.Terms; +import org.elasticsearch.search.aggregations.bucket.terms.TermsAggregationBuilder; +import org.elasticsearch.search.aggregations.pipeline.InternalSimpleValue; +import org.elasticsearch.search.aggregations.pipeline.PipelineAggregatorBuilders; /** * @author peng-yongsheng */ public class InstanceMetricEsUIDAO extends EsDAO implements IInstanceMetricUIDAO { + private static final String AVG_TPS = "avg_tps"; + public InstanceMetricEsUIDAO(ElasticSearchClient client) { super(client); } + @Override public List getTopNServerThroughput(int applicationId, Step step, long start, long end, + long secondBetween, int topN, MetricSource metricSource) { + String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); + + SearchRequestBuilder searchRequestBuilder = getClient().prepareSearch(tableName); + searchRequestBuilder.setTypes(InstanceMetricTable.TABLE_TYPE); + searchRequestBuilder.setSearchType(SearchType.DFS_QUERY_THEN_FETCH); + + BoolQueryBuilder boolQuery = QueryBuilders.boolQuery(); + boolQuery.must().add(QueryBuilders.rangeQuery(InstanceMetricTable.COLUMN_TIME_BUCKET).gte(start).lte(end)); + if (applicationId != 0) { + boolQuery.must().add(QueryBuilders.termQuery(InstanceMetricTable.COLUMN_APPLICATION_ID, applicationId)); + } + boolQuery.must().add(QueryBuilders.termQuery(InstanceMetricTable.COLUMN_SOURCE_VALUE, metricSource.getValue())); + + searchRequestBuilder.setQuery(boolQuery); + searchRequestBuilder.setSize(0); + + TermsAggregationBuilder aggregationBuilder = AggregationBuilders.terms(InstanceMetricTable.COLUMN_INSTANCE_ID).field(InstanceMetricTable.COLUMN_INSTANCE_ID).size(topN); + aggregationBuilder.subAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_CALLS).field(InstanceMetricTable.COLUMN_TRANSACTION_CALLS)); + aggregationBuilder.subAggregation(AggregationBuilders.sum(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS).field(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS)); + + Map bucketsPathsMap = new HashMap<>(); + bucketsPathsMap.put(InstanceMetricTable.COLUMN_TRANSACTION_CALLS, InstanceMetricTable.COLUMN_TRANSACTION_CALLS); + bucketsPathsMap.put(InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS, InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS); + + String idOrCode = "(params." + InstanceMetricTable.COLUMN_TRANSACTION_CALLS + " - params." + InstanceMetricTable.COLUMN_TRANSACTION_ERROR_CALLS + ")" + + " / " + + "( " + secondBetween + " )"; + Script script = new Script(idOrCode); + aggregationBuilder.subAggregation(PipelineAggregatorBuilders.bucketScript(AVG_TPS, bucketsPathsMap, script)); + + searchRequestBuilder.addAggregation(aggregationBuilder); + SearchResponse searchResponse = searchRequestBuilder.execute().actionGet(); + + List appServerInfos = new LinkedList<>(); + Terms serviceIdTerms = searchResponse.getAggregations().get(InstanceMetricTable.COLUMN_INSTANCE_ID); + serviceIdTerms.getBuckets().forEach(serviceIdTerm -> { + int instanceId = serviceIdTerm.getKeyAsNumber().intValue(); + + AppServerInfo appServerInfo = new AppServerInfo(); + InternalSimpleValue simpleValue = serviceIdTerm.getAggregations().get(AVG_TPS); + + appServerInfo.setId(instanceId); + appServerInfo.setTps((int)simpleValue.getValue()); + appServerInfos.add(appServerInfo); + }); + return appServerInfos; + } + @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { MultiGetRequestBuilder prepareMultiGet = getClient().prepareMultiGet(); String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); diff --git a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java index cfce0db45..fdc746e82 100644 --- a/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java +++ b/apm-collector/apm-collector-storage/collector-storage-h2-provider/src/main/java/org/apache/skywalking/apm/collector/storage/h2/dao/ui/InstanceMetricH2UIDAO.java @@ -31,6 +31,7 @@ import org.apache.skywalking.apm.collector.storage.h2.base.dao.H2DAO; import org.apache.skywalking.apm.collector.storage.table.MetricSource; import org.apache.skywalking.apm.collector.storage.table.instance.InstanceMetricTable; import org.apache.skywalking.apm.collector.storage.ui.common.Step; +import org.apache.skywalking.apm.collector.storage.ui.server.AppServerInfo; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.apache.skywalking.apm.collector.storage.utils.TimePyramidTableNameBuilder; import org.slf4j.Logger; @@ -48,6 +49,11 @@ public class InstanceMetricH2UIDAO extends H2DAO implements IInstanceMetricUIDAO super(client); } + @Override public List getTopNServerThroughput(int applicationId, Step step, long start, long end, + long secondBetween, int topN, MetricSource metricSource) { + return null; + } + @Override public List getServerTPSTrend(int instanceId, Step step, List durationPoints) { H2Client client = getClient(); String tableName = TimePyramidTableNameBuilder.build(step, InstanceMetricTable.TABLE); diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java index afbec260d..e424512dd 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/OverViewLayerQuery.java @@ -34,6 +34,7 @@ import org.apache.skywalking.apm.collector.ui.service.AlarmService; import org.apache.skywalking.apm.collector.ui.service.ApplicationService; import org.apache.skywalking.apm.collector.ui.service.ClusterTopologyService; import org.apache.skywalking.apm.collector.ui.service.NetworkAddressService; +import org.apache.skywalking.apm.collector.ui.service.ServerService; import org.apache.skywalking.apm.collector.ui.service.ServiceNameService; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; @@ -47,6 +48,7 @@ public class OverViewLayerQuery implements Query { private ApplicationService applicationService; private NetworkAddressService networkAddressService; private ServiceNameService serviceNameService; + private ServerService serverService; private AlarmService alarmService; public OverViewLayerQuery(ModuleManager moduleManager) { @@ -88,6 +90,13 @@ public class OverViewLayerQuery implements Query { return alarmService; } + private ServerService getServerService() { + if (ObjectUtils.isEmpty(serverService)) { + this.serverService = new ServerService(moduleManager); + } + return serverService; + } + public Topology getClusterTopology(Duration duration) throws ParseException { long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); @@ -111,6 +120,7 @@ public class OverViewLayerQuery implements Query { public AlarmTrend getAlarmTrend(Duration duration) throws ParseException { long start = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getStart()); long end = DurationUtils.INSTANCE.durationToSecondTimeBucket(duration.getStep(), duration.getEnd()); + return getAlarmService().getApplicationAlarmTrend(duration.getStep(), start, end); } @@ -121,10 +131,15 @@ public class OverViewLayerQuery implements Query { public List getTopNSlowService(Duration duration, int topN) throws ParseException { long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServiceNameService().getSlowService(duration.getStep(), start, end, topN); } - public List getTopNServerThroughput(Duration duration, int topN) { - return null; + public List getTopNServerThroughput(int applicationId, Duration duration, + int topN) throws ParseException { + long start = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long end = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + + return getServerService().getTopNServerThroughput(applicationId, duration.getStep(), start, end, topN); } } diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java index dc6b20559..12a27420d 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/service/ServerService.java @@ -24,6 +24,9 @@ import com.google.gson.JsonObject; import java.text.ParseException; import java.util.LinkedList; import java.util.List; +import org.apache.skywalking.apm.collector.cache.CacheModule; +import org.apache.skywalking.apm.collector.cache.service.ApplicationCacheService; +import org.apache.skywalking.apm.collector.cache.service.InstanceCacheService; import org.apache.skywalking.apm.collector.core.module.ModuleManager; import org.apache.skywalking.apm.collector.core.util.Const; import org.apache.skywalking.apm.collector.core.util.StringUtils; @@ -33,6 +36,8 @@ import org.apache.skywalking.apm.collector.storage.dao.ui.IGCMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceMetricUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IInstanceUIDAO; import org.apache.skywalking.apm.collector.storage.dao.ui.IMemoryMetricUIDAO; +import org.apache.skywalking.apm.collector.storage.table.MetricSource; +import org.apache.skywalking.apm.collector.storage.table.register.Instance; import org.apache.skywalking.apm.collector.storage.ui.common.ResponseTimeTrend; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.ui.common.ThroughputTrend; @@ -54,6 +59,8 @@ public class ServerService { private final ICpuMetricUIDAO cpuMetricUIDAO; private final IGCMetricUIDAO gcMetricUIDAO; private final IMemoryMetricUIDAO memoryMetricUIDAO; + private final InstanceCacheService instanceCacheService; + private final ApplicationCacheService applicationCacheService; public ServerService(ModuleManager moduleManager) { this.instanceUIDAO = moduleManager.find(StorageModule.NAME).getService(IInstanceUIDAO.class); @@ -61,6 +68,20 @@ public class ServerService { this.cpuMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(ICpuMetricUIDAO.class); this.gcMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IGCMetricUIDAO.class); this.memoryMetricUIDAO = moduleManager.find(StorageModule.NAME).getService(IMemoryMetricUIDAO.class); + this.instanceCacheService = moduleManager.find(CacheModule.NAME).getService(InstanceCacheService.class); + this.applicationCacheService = moduleManager.find(CacheModule.NAME).getService(ApplicationCacheService.class); + } + + public List getTopNServerThroughput(int applicationId, Step step, long start, long end, int topN) { + //TODO + List appServerInfos = instanceMetricUIDAO.getTopNServerThroughput(applicationId, step, start, end, 1000, topN, MetricSource.Callee); + appServerInfos.forEach(appServerInfo -> { + Instance instance = instanceUIDAO.getInstance(appServerInfo.getId()); + appServerInfo.setOsInfo(instance.getOsInfo()); + }); + buildAppServerInfo(appServerInfos); + + return appServerInfos; } public List searchServer(String keyword, long start, long end) { @@ -132,6 +153,9 @@ public class ServerService { private void buildAppServerInfo(List serverInfos) { serverInfos.forEach(serverInfo -> { + int applicationId = instanceCacheService.getApplicationId(serverInfo.getId()); + serverInfo.setApplicationId(applicationId); + serverInfo.setApplicationCode(applicationCacheService.getApplicationById(applicationId).getApplicationCode()); if (StringUtils.isNotEmpty(serverInfo.getOsInfo())) { JsonObject osInfoJson = gson.fromJson(serverInfo.getOsInfo(), JsonObject.class); if (osInfoJson.has("osName")) { diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls index 50e1ff26c..8aae1e2e4 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/overview-layer.graphqls @@ -33,5 +33,5 @@ extend type Query { getAlarmTrend(duration: Duration!): AlarmTrend getConjecturalApps(duration: Duration!): ConjecturalAppBrief getTopNSlowService(duration: Duration!, topN: Int!): [ServiceMetric!]! - getTopNServerThroughput(duration: Duration!, topN: Int!): [AppServerInfo!]! + getTopNServerThroughput(applicationId: Int, duration: Duration!, topN: Int!): [AppServerInfo!]! } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls index fdf1d1bcd..b43e21225 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/server-layer.graphqls @@ -6,6 +6,8 @@ type AppServerInfo { id: ID! name: String! + applicationId: Int! + applicationName: String tps: Int! host: String pid: Int From af6d91dfbaff7f83db2abaa2bef461b345d35c81 Mon Sep 17 00:00:00 2001 From: hanahmily Date: Fri, 9 Feb 2018 14:18:26 +0800 Subject: [PATCH 35/36] Refactor alarm schema --- .../skywalking/apm/collector/storage/ui/alarm/AlarmItem.java | 1 + .../apache/skywalking/apm/collector/ui/query/AlarmQuery.java | 3 +++ .../src/main/resources/ui-graphql/alarm.graphqls | 1 + 3 files changed, 5 insertions(+) diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java index 1e47c71da..bdd9f6ff9 100644 --- a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/alarm/AlarmItem.java @@ -22,6 +22,7 @@ package org.apache.skywalking.apm.collector.storage.ui.alarm; * @author peng-yongsheng */ public class AlarmItem { + private String id; private String title; private String content; private String startTime; diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java index 61b1d2990..3b377d213 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/query/AlarmQuery.java @@ -24,6 +24,8 @@ import org.apache.skywalking.apm.collector.storage.ui.alarm.AlarmType; import org.apache.skywalking.apm.collector.storage.ui.common.Duration; import org.apache.skywalking.apm.collector.storage.ui.common.Pagination; +import java.util.Collections; + /** * @author peng-yongsheng */ @@ -32,6 +34,7 @@ public class AlarmQuery implements Query { public Alarm loadAlarmList(String keyword, AlarmType alarmType, Duration duration, Pagination paging) { Alarm alarm = new Alarm(); alarm.setTotal(0); + alarm.setItems(Collections.emptyList()); return alarm; } } diff --git a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls index ae1461b47..de8070040 100644 --- a/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls +++ b/apm-protocol/apm-ui-protocol/src/main/resources/ui-graphql/alarm.graphqls @@ -4,6 +4,7 @@ type Alarm { } type AlarmItem { + id: ID! # Typical include: Application Code + cause type. This is a short description. title: String! # Include all related info to trigger this alarm. From e6f0c3ee75a3c0933f041c38a50d6bf3a9d36f01 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Fri, 9 Feb 2018 16:09:43 +0800 Subject: [PATCH 36/36] Fixed CI fail. --- .../apm/collector/ui/utils/DurationUtils.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java index ffeb3322c..e7ac4c8cf 100644 --- a/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java +++ b/apm-collector/apm-collector-ui/collector-ui-jetty-provider/src/main/java/org/apache/skywalking/apm/collector/ui/utils/DurationUtils.java @@ -19,12 +19,12 @@ package org.apache.skywalking.apm.collector.ui.utils; import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Date; import java.util.LinkedList; import java.util.List; import org.apache.skywalking.apm.collector.core.UnexpectedException; import org.apache.skywalking.apm.collector.core.util.Const; -import org.apache.skywalking.apm.collector.core.util.TimeBucketUtils; import org.apache.skywalking.apm.collector.storage.ui.common.Step; import org.apache.skywalking.apm.collector.storage.utils.DurationPoint; import org.joda.time.DateTime; @@ -69,24 +69,24 @@ public enum DurationUtils { Date endDate = null; switch (step) { case MONTH: - startDate = TimeBucketUtils.MONTH_DATE_FORMAT.parse(String.valueOf(start)); - endDate = TimeBucketUtils.MONTH_DATE_FORMAT.parse(String.valueOf(end)); + startDate = new SimpleDateFormat("yyyyMM").parse(String.valueOf(start)); + endDate = new SimpleDateFormat("yyyyMM").parse(String.valueOf(end)); break; case DAY: - startDate = TimeBucketUtils.DAY_DATE_FORMAT.parse(String.valueOf(start)); - endDate = TimeBucketUtils.DAY_DATE_FORMAT.parse(String.valueOf(end)); + startDate = new SimpleDateFormat("yyyyMMdd").parse(String.valueOf(start)); + endDate = new SimpleDateFormat("yyyyMMdd").parse(String.valueOf(end)); break; case HOUR: - startDate = TimeBucketUtils.HOUR_DATE_FORMAT.parse(String.valueOf(start)); - endDate = TimeBucketUtils.HOUR_DATE_FORMAT.parse(String.valueOf(end)); + startDate = new SimpleDateFormat("yyyyMMddHH").parse(String.valueOf(start)); + endDate = new SimpleDateFormat("yyyyMMddHH").parse(String.valueOf(end)); break; case MINUTE: - startDate = TimeBucketUtils.MINUTE_DATE_FORMAT.parse(String.valueOf(start)); - endDate = TimeBucketUtils.MINUTE_DATE_FORMAT.parse(String.valueOf(end)); + startDate = new SimpleDateFormat("yyyyMMddHHmm").parse(String.valueOf(start)); + endDate = new SimpleDateFormat("yyyyMMddHHmm").parse(String.valueOf(end)); break; case SECOND: - startDate = TimeBucketUtils.SECOND_DATE_FORMAT.parse(String.valueOf(start)); - endDate = TimeBucketUtils.SECOND_DATE_FORMAT.parse(String.valueOf(end)); + startDate = new SimpleDateFormat("yyyyMMddHHmmss").parse(String.valueOf(start)); + endDate = new SimpleDateFormat("yyyyMMddHHmmss").parse(String.valueOf(end)); break; } @@ -115,23 +115,23 @@ public enum DurationUtils { switch (step) { case MONTH: - Date date = TimeBucketUtils.MONTH_DATE_FORMAT.parse(String.valueOf(time)); + Date date = new SimpleDateFormat("yyyyMM").parse(String.valueOf(time)); dateTime = new DateTime(date); break; case DAY: - date = TimeBucketUtils.DAY_DATE_FORMAT.parse(String.valueOf(time)); + date = new SimpleDateFormat("yyyyMMdd").parse(String.valueOf(time)); dateTime = new DateTime(date); break; case HOUR: - date = TimeBucketUtils.HOUR_DATE_FORMAT.parse(String.valueOf(time)); + date = new SimpleDateFormat("yyyyMMddHH").parse(String.valueOf(time)); dateTime = new DateTime(date); break; case MINUTE: - date = TimeBucketUtils.MINUTE_DATE_FORMAT.parse(String.valueOf(time)); + date = new SimpleDateFormat("yyyyMMddHHmm").parse(String.valueOf(time)); dateTime = new DateTime(date); break; case SECOND: - date = TimeBucketUtils.SECOND_DATE_FORMAT.parse(String.valueOf(time)); + date = new SimpleDateFormat("yyyyMMddHHmmss").parse(String.valueOf(time)); dateTime = new DateTime(date); break; } @@ -150,27 +150,27 @@ public enum DurationUtils { switch (step) { case MONTH: dateTime = dateTime.plusMonths(1); - String timeBucket = TimeBucketUtils.MONTH_DATE_FORMAT.format(dateTime.toDate()); + String timeBucket = new SimpleDateFormat("yyyyMM").format(dateTime.toDate()); durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case DAY: dateTime = dateTime.plusDays(1); - timeBucket = TimeBucketUtils.DAY_DATE_FORMAT.format(dateTime.toDate()); + timeBucket = new SimpleDateFormat("yyyyMMdd").format(dateTime.toDate()); durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case HOUR: dateTime = dateTime.plusHours(1); - timeBucket = TimeBucketUtils.HOUR_DATE_FORMAT.format(dateTime.toDate()); + timeBucket = new SimpleDateFormat("yyyyMMddHH").format(dateTime.toDate()); durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case MINUTE: dateTime = dateTime.plusMinutes(1); - timeBucket = TimeBucketUtils.MINUTE_DATE_FORMAT.format(dateTime.toDate()); + timeBucket = new SimpleDateFormat("yyyyMMddHHmm").format(dateTime.toDate()); durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; case SECOND: dateTime = dateTime.plusSeconds(1); - timeBucket = TimeBucketUtils.SECOND_DATE_FORMAT.format(dateTime.toDate()); + timeBucket = new SimpleDateFormat("yyyyMMddHHmmss").format(dateTime.toDate()); durations.add(new DurationPoint(Long.valueOf(timeBucket), secondsBetween(step, dateTime))); break; }