From 45a718de467e15f8f90bd9b6eddeb8982811e155 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 28 Feb 2018 21:11:59 +0800 Subject: [PATCH 1/2] 1. Change the parameter name: Start -> startTimeBucket End -> endTimeBucket --- .../skywalking/apm/collector/ui/query/ServerQuery.java | 6 +++--- .../apm/collector/ui/service/ServerService.java | 6 +++--- .../apm/collector/ui/utils/DurationUtils.java | 10 +++++----- 3 files changed, 11 insertions(+), 11 deletions(-) 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 b269703ad..5651a8d8d 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 @@ -65,9 +65,9 @@ public class ServerQuery implements Query { } 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); + long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getServerResponseTimeTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket); } public ThroughputTrend getServerTPSTrend(int serverId, Duration duration) throws ParseException { 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 41620c751..10f02715f 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 @@ -92,10 +92,10 @@ public class ServerService { return serverInfos; } - public ResponseTimeTrend getServerResponseTimeTrend(int instanceId, Step step, long start, - long end) throws ParseException { + public ResponseTimeTrend getServerResponseTimeTrend(int instanceId, Step step, long startTimeBucket, + long endTimeBucket) throws ParseException { ResponseTimeTrend responseTimeTrend = new ResponseTimeTrend(); - List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket); List trends = instanceMetricUIDAO.getResponseTimeTrend(instanceId, step, durationPoints); responseTimeTrend.setTrendList(trends); return responseTimeTrend; 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 d88a23657..52e5976dd 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 @@ -139,11 +139,11 @@ public enum DurationUtils { return dateTime; } - public List getDurationPoints(Step step, long start, long end) throws ParseException { - DateTime dateTime = parseToDateTime(step, start); + public List getDurationPoints(Step step, long startTimeBucket, long endTimeBucket) throws ParseException { + DateTime dateTime = parseToDateTime(step, startTimeBucket); List durations = new LinkedList<>(); - durations.add(new DurationPoint(start, secondsBetween(step, dateTime))); + durations.add(new DurationPoint(startTimeBucket, secondsBetween(step, dateTime))); int i = 0; do { @@ -176,10 +176,10 @@ public enum DurationUtils { } i++; if (i > 500) { - throw new UnexpectedException("Duration data error, step: " + step.name() + ", start: " + start + ", end: " + end); + throw new UnexpectedException("Duration data error, step: " + step.name() + ", start: " + startTimeBucket + ", end: " + endTimeBucket); } } - while (end != durations.get(durations.size() - 1).getPoint()); + while (endTimeBucket != durations.get(durations.size() - 1).getPoint()); return durations; } From 48981e87f2af9502d7b1a470d3d16201e689ea52 Mon Sep 17 00:00:00 2001 From: peng-yongsheng <8082209@qq.com> Date: Wed, 28 Feb 2018 21:29:01 +0800 Subject: [PATCH 2/2] 1. Change the parameter name: Start -> startTimeBucket End -> endTimeBucket --- .../apm/collector/ui/query/ServerQuery.java | 24 +++++++++---------- .../collector/ui/service/ServerService.java | 19 ++++++++------- 2 files changed, 23 insertions(+), 20 deletions(-) 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 5651a8d8d..cae9a389f 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 @@ -71,26 +71,26 @@ public class ServerQuery implements Query { } 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); + long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getServerTPSTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket); } 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); + long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getCPUTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket); } 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); + long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getGCTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket); } 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); + long startTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getStart()); + long endTimeBucket = DurationUtils.INSTANCE.exchangeToTimeBucket(duration.getEnd()); + return getServerService().getMemoryTrend(serverId, duration.getStep(), startTimeBucket, endTimeBucket); } } 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 10f02715f..f3e7d85cf 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 @@ -117,25 +117,28 @@ public class ServerService { return serverThroughput; } - public ThroughputTrend getServerTPSTrend(int instanceId, Step step, long start, long end) throws ParseException { + public ThroughputTrend getServerTPSTrend(int instanceId, Step step, long startTimeBucket, + long endTimeBucket) throws ParseException { ThroughputTrend throughputTrend = new ThroughputTrend(); - List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket); List trends = instanceMetricUIDAO.getServerTPSTrend(instanceId, step, durationPoints); throughputTrend.setTrendList(trends); return throughputTrend; } - public CPUTrend getCPUTrend(int instanceId, Step step, long start, long end) throws ParseException { + public CPUTrend getCPUTrend(int instanceId, Step step, long startTimeBucket, + long endTimeBucket) throws ParseException { CPUTrend cpuTrend = new CPUTrend(); - List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket); List trends = cpuMetricUIDAO.getCPUTrend(instanceId, step, durationPoints); cpuTrend.setCost(trends); return cpuTrend; } - public GCTrend getGCTrend(int instanceId, Step step, long start, long end) throws ParseException { + public GCTrend getGCTrend(int instanceId, Step step, long startTimeBucket, + long endTimeBucket) throws ParseException { GCTrend gcTrend = new GCTrend(); - List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket); List youngGCTrend = gcMetricUIDAO.getYoungGCTrend(instanceId, step, durationPoints); gcTrend.setYoungGC(youngGCTrend); List oldGCTrend = gcMetricUIDAO.getOldGCTrend(instanceId, step, durationPoints); @@ -143,9 +146,9 @@ public class ServerService { return gcTrend; } - public MemoryTrend getMemoryTrend(int instanceId, Step step, long start, long end) throws ParseException { + public MemoryTrend getMemoryTrend(int instanceId, Step step, long startTimeBucket, long endTimeBucket) throws ParseException { MemoryTrend memoryTrend = new MemoryTrend(); - List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, start, end); + List durationPoints = DurationUtils.INSTANCE.getDurationPoints(step, startTimeBucket, endTimeBucket); IMemoryMetricUIDAO.Trend heapMemoryTrend = memoryMetricUIDAO.getHeapMemoryTrend(instanceId, step, durationPoints); memoryTrend.setHeap(heapMemoryTrend.getMetrics()); memoryTrend.setMaxHeap(heapMemoryTrend.getMaxMetrics());