From 1e57d48d940631c1d0658f44eaec90a268da1f23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=99=9F=20Wu=20Sheng?= Date: Mon, 23 Apr 2018 09:31:39 +0800 Subject: [PATCH] GraphQL for Thermodynamic in overview page. (#1068) * Provide graphQL for Thermodynamic in overview page. * Finish the Thermodynamic. * `nodes` should not be null. * Add initialized java bean for graphql protocol. * Add license head. * Fixed bean definition fault. --- .../storage/ui/common/ValueType.java | 28 ++++++++++ .../storage/ui/overview/Thermodynamic.java | 51 +++++++++++++++++++ .../ui/query/OverViewLayerQuery.java | 17 +++++-- .../main/resources/ui-graphql/common.graphqls | 6 +++ .../ui-graphql/overview-layer.graphqls | 17 +++++++ 5 files changed, 115 insertions(+), 4 deletions(-) create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ValueType.java create mode 100644 apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/Thermodynamic.java diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ValueType.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ValueType.java new file mode 100644 index 000000000..a07ed6766 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/common/ValueType.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; + +/** + * @author peng-yongsheng + */ +public enum ValueType { + ALL, + RIGHT, + WRONG +} diff --git a/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/Thermodynamic.java b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/Thermodynamic.java new file mode 100644 index 000000000..55ee86ae9 --- /dev/null +++ b/apm-collector/apm-collector-storage/collector-storage-define/src/main/java/org/apache/skywalking/apm/collector/storage/ui/overview/Thermodynamic.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.ui.overview; + +import java.util.LinkedList; +import java.util.List; + +/** + * @author peng-yongsheng + */ +public class Thermodynamic { + + private List> nodes; + private int responseTimeStep; + + public Thermodynamic() { + this.nodes = new LinkedList<>(); + } + + public List> getNodes() { + return nodes; + } + + public void setNodes(List> nodes) { + this.nodes = nodes; + } + + public int getResponseTimeStep() { + return responseTimeStep; + } + + public void setResponseTimeStep(int responseTimeStep) { + this.responseTimeStep = responseTimeStep; + } +} 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 e87e65467..72e09a1c7 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,21 +18,26 @@ 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.storage.ui.common.Duration; import org.apache.skywalking.apm.collector.storage.ui.common.Topology; +import org.apache.skywalking.apm.collector.storage.ui.common.ValueType; import org.apache.skywalking.apm.collector.storage.ui.overview.AlarmTrend; import org.apache.skywalking.apm.collector.storage.ui.overview.ApplicationTPS; 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.overview.Thermodynamic; 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.*; +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.ServiceNameService; import org.apache.skywalking.apm.collector.ui.utils.DurationUtils; -import java.text.ParseException; -import java.util.List; - import static java.util.Objects.isNull; /** @@ -143,4 +148,8 @@ public class OverViewLayerQuery implements Query { return getApplicationService().getTopNApplicationThroughput(duration.getStep(), startTimeBucket, endTimeBucket, topN); } + + public Thermodynamic getThermodynamic(Duration duration, ValueType type) throws ParseException { + return new Thermodynamic(); + } } 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 d6b9d326b..82eca5e12 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 @@ -124,3 +124,9 @@ type Call { # Unit: millisecond avgResponseTime: Long! } + +enum ValueType { + ALL, + RIGHT, + WRONG +} 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 c467e5e25..87261b9bb 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 @@ -49,6 +49,22 @@ type ApplicationTPS { callsPerSec: Int! } +type Thermodynamic { + # Each element in nodes represents a point in Thermodynamic Diagram + # And the element includes three values: + # 1) Time Bucket based on query duration + # 2) Response time index. + # Response time = [responseTimeStep * index, responseTimeStep * (index+1)) + # The last element: [Response Time * index, MAX) + # 3) The number of calls in this response time duration. + # + # Example: + # [ [0, 0, 10], [0, 1, 43], ...] + # These ^^^ two represent the left bottom element, and another element above it. + nodes: [[Long]!]! + responseTimeStep: Int! +} + extend type Query { getClusterTopology(duration: Duration!): Topology getClusterBrief(duration: Duration!): ClusterBrief @@ -56,4 +72,5 @@ extend type Query { getConjecturalApps(duration: Duration!): ConjecturalAppBrief getTopNSlowService(duration: Duration!, topN: Int!): [ServiceMetric!]! getTopNApplicationThroughput(duration: Duration!, topN: Int!): [ApplicationTPS!]! + getThermodynamic(duration: Duration!, type: ValueType!): Thermodynamic! }