From 3aa44039205faf75c1ef4f65f3713b22737722fc Mon Sep 17 00:00:00 2001 From: catdrink <2738035238@qq.com> Date: Sun, 8 Dec 2024 00:55:58 +0800 Subject: [PATCH] spotless check --- .../controller/MonitoringController.java | 4 +- .../manager/server/proxy/BigtopProxy.java | 4 +- .../manager/server/proxy/PrometheusProxy.java | 127 ++++++++++-------- .../service/impl/MonitoringServiceImpl.java | 3 +- .../manager/server/utils/ProxyUtils.java | 53 ++++---- 5 files changed, 106 insertions(+), 85 deletions(-) diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/MonitoringController.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/MonitoringController.java index 7bd40fea..6e6f1d07 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/MonitoringController.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/controller/MonitoringController.java @@ -51,11 +51,13 @@ public ResponseEntity agentHostsHealthyStatus() { public ResponseEntity queryAgentsInfo() { return ResponseEntity.success(monitoringService.queryAgentsInfo()); } + @Operation(summary = "dynamicAgentInfo", description = "agent info query") @GetMapping("dynamicAgentInfo") - public ResponseEntity queryAgentsInfo(@RequestParam(value = "pace", defaultValue = "1") String pace){ + public ResponseEntity queryAgentsInfo(@RequestParam(value = "pace", defaultValue = "1") String pace) { return ResponseEntity.success(monitoringService.queryAgentsInfo(pace)); } + @Operation(summary = "cluster info", description = "cluster info") @GetMapping("clusterInfo") public ResponseEntity queryCluster( diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/BigtopProxy.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/BigtopProxy.java index 5d26abfc..81e90aad 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/BigtopProxy.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/BigtopProxy.java @@ -18,7 +18,6 @@ */ package org.apache.bigtop.manager.server.proxy; -import com.fasterxml.jackson.databind.node.ObjectNode; import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; @@ -29,6 +28,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; import reactor.core.publisher.Mono; import java.util.ArrayList; @@ -75,7 +75,7 @@ public JsonNode queryClusterAgentsList(String clusterId) { agents.forEach(agent -> hosts.add(agent.get("ipv4").asText())); } ObjectNode clusterAgents = objectMapper.createObjectNode(); - clusterAgents.put("agentsNum",hosts.size()); + clusterAgents.put("agentsNum", hosts.size()); clusterAgents.set("agents", objectMapper.valueToTree(hosts)); return clusterAgents; } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/PrometheusProxy.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/PrometheusProxy.java index cf724b06..d39d8aac 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/PrometheusProxy.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/proxy/PrometheusProxy.java @@ -19,6 +19,7 @@ package org.apache.bigtop.manager.server.proxy; import org.apache.bigtop.manager.server.utils.ProxyUtils; + import org.springframework.beans.factory.annotation.Value; import org.springframework.http.MediaType; import org.springframework.stereotype.Component; @@ -32,7 +33,6 @@ import reactor.core.publisher.Mono; import jakarta.annotation.Resource; - import java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; @@ -78,8 +78,7 @@ public JsonNode query(String params) { .post() .uri(uriBuilder -> uriBuilder.path("/api/v1/query").build()) .contentType(MediaType.APPLICATION_FORM_URLENCODED) - .body(BodyInserters.fromFormData("query", params) - .with("timeout", "10")) + .body(BodyInserters.fromFormData("query", params).with("timeout", "10")) .retrieve() .bodyToMono(JsonNode.class); JsonNode result = body.block(); @@ -100,9 +99,9 @@ public JsonNode queryRange(String query, long start, long end, String step) { .contentType(MediaType.APPLICATION_FORM_URLENCODED) .body(BodyInserters.fromFormData("query", query) .with("timeout", "10") - .with("start",String.valueOf(start)) - .with("end",String.valueOf(end)) - .with("step",step)) + .with("start", String.valueOf(start)) + .with("end", String.valueOf(end)) + .with("step", step)) .retrieve() .bodyToMono(JsonNode.class); JsonNode result = body.block(); @@ -159,7 +158,7 @@ private JsonNode queryAgents() { iPv4addrArray.add(value); } ObjectNode node = objectMapper.createObjectNode(); - node.put("agentsNum",iPv4addrArray.size()); + node.put("agentsNum", iPv4addrArray.size()); node.set("iPv4addr", iPv4addrArray); return node; // iPv4 } @@ -199,7 +198,7 @@ public JsonNode queryAgentsInfo() { /** * query agents dynamic info */ - public JsonNode queryAgentsInfo(String pace){ + public JsonNode queryAgentsInfo(String pace) { JsonNode agents = queryAgents(); JsonNode agentsIpv4 = agents.get("iPv4addr"); ObjectMapper mapper = new ObjectMapper(); @@ -225,8 +224,8 @@ public JsonNode queryAgentsInfo(String pace){ // dynamic JsonNode agentCpuInterval = retrieveAgentCpu(agentIpv4.asText(), pace); - JsonNode agentMemInterval = retrieveAgentMemory(agentIpv4.asText(),pace); - JsonNode agentDiskIOInterval = queryAgentDiskIO(agentIpv4.asText(),pace); + JsonNode agentMemInterval = retrieveAgentMemory(agentIpv4.asText(), pace); + JsonNode agentDiskIOInterval = queryAgentDiskIO(agentIpv4.asText(), pace); for (int i = 0; i < 6; i++) { // CPU System.out.println(agentCpuInterval); @@ -245,21 +244,32 @@ public JsonNode queryAgentsInfo(String pace){ } // cur ag.put("cpu_usage_cur", agentCpu.get(CPU_USAGE).asDouble()); - ag.put("memory_usage_cur", (double)(agentMem.get(MEM_TOTAL).asLong() - agentMem.get(MEM_IDLE).asLong()) / agentMem.get(MEM_TOTAL).asLong()); - ag.put("disk_usage_cur",(double) (agentDisk.get(DISK_TOTAL).asLong() - agentDisk.get(DISK_IDLE).asLong()) / agentDisk.get(DISK_TOTAL).asLong()); - ag.put("file_descriptor_usage",(double)agentCpu.get(FILE_OPEN_DESCRIPTOR).asLong() / agentCpu.get(FILE_TOTAL_DESCRIPTOR).asLong()); - ag.put("disk_read",agentDiskIO.get(DISK_READ).asLong()); - ag.put("disk_read",agentDiskIO.get(DISK_WRITE).asLong()); + ag.put( + "memory_usage_cur", + (double) (agentMem.get(MEM_TOTAL).asLong() + - agentMem.get(MEM_IDLE).asLong()) + / agentMem.get(MEM_TOTAL).asLong()); + ag.put( + "disk_usage_cur", + (double) (agentDisk.get(DISK_TOTAL).asLong() + - agentDisk.get(DISK_IDLE).asLong()) + / agentDisk.get(DISK_TOTAL).asLong()); + ag.put( + "file_descriptor_usage", + (double) agentCpu.get(FILE_OPEN_DESCRIPTOR).asLong() + / agentCpu.get(FILE_TOTAL_DESCRIPTOR).asLong()); + ag.put("disk_read", agentDiskIO.get(DISK_READ).asLong()); + ag.put("disk_read", agentDiskIO.get(DISK_WRITE).asLong()); // cpu - ag.set("cpu_usage",ProxyUtils.array2node(agentsCpuUsage)); - ag.set("system_load1",ProxyUtils.array2node(agentsCpuLoad1)); - ag.set("system_load2",ProxyUtils.array2node(agentsCpuLoad2)); - ag.set("system_load3",ProxyUtils.array2node(agentsCpuLoad3)); + ag.set("cpu_usage", ProxyUtils.array2node(agentsCpuUsage)); + ag.set("system_load1", ProxyUtils.array2node(agentsCpuLoad1)); + ag.set("system_load2", ProxyUtils.array2node(agentsCpuLoad2)); + ag.set("system_load3", ProxyUtils.array2node(agentsCpuLoad3)); // mem - ag.set("memory_usage",ProxyUtils.array2node(agentMemIdle,agentMemTotal)); + ag.set("memory_usage", ProxyUtils.array2node(agentMemIdle, agentMemTotal)); // disk io - ag.set("disk_read",ProxyUtils.array2node(agentDiskRead)); - ag.set("disk_write",ProxyUtils.array2node(agentDiskWrite)); + ag.set("disk_read", ProxyUtils.array2node(agentDiskRead)); + ag.set("disk_write", ProxyUtils.array2node(agentDiskWrite)); agentsInfo.add(ag); } @@ -270,7 +280,8 @@ public JsonNode queryAgentsInfo(String pace){ */ public JsonNode queryClusterInfo(String clusterId, String pace) { JsonNode agents = bigtopProxy.queryClusterAgentsList(clusterId).get("agents"); // cluster's agents - int agentsNum = bigtopProxy.queryClusterAgentsList(clusterId).get("agentsNum").asInt(); // agentsNum + int agentsNum = + bigtopProxy.queryClusterAgentsList(clusterId).get("agentsNum").asInt(); // agentsNum ObjectMapper mapper = new ObjectMapper(); int total_physical_cores = 0; long totalMemSpace = 0L; @@ -300,15 +311,19 @@ public JsonNode queryClusterInfo(String clusterId, String pace) { // avg time JsonNode agentCpuStep = retrieveAgentCpu(agentIpv4.asText(), pace); - JsonNode agentMemStep = retrieveAgentMemory(agents.asText(),pace); + JsonNode agentMemStep = retrieveAgentMemory(agents.asText(), pace); int agent_physical_cores = agentCpuStep.get(PHYSICAL_CORES).asInt(); total_physical_cores += agent_physical_cores; for (int i = 0; i < 6; i++) { // CPU - agentsCpuUsage[agentIndex][i] = ProxyUtils.getDoubleSafely(agentCpuStep, CPU_USAGE, i) * agent_physical_cores; - agentsCpuLoad1[agentIndex][i] = ProxyUtils.getDoubleSafely(agentCpuStep, CPU_LOAD_AVG_MIN_1, i) * agent_physical_cores; - agentsCpuLoad2[agentIndex][i] = ProxyUtils.getDoubleSafely(agentCpuStep, CPU_LOAD_AVG_MIN_5, i) * agent_physical_cores; - agentsCpuLoad3[agentIndex][i] = ProxyUtils.getDoubleSafely(agentCpuStep, CPU_LOAD_AVG_MIN_15, i) * agent_physical_cores; + agentsCpuUsage[agentIndex][i] = + ProxyUtils.getDoubleSafely(agentCpuStep, CPU_USAGE, i) * agent_physical_cores; + agentsCpuLoad1[agentIndex][i] = + ProxyUtils.getDoubleSafely(agentCpuStep, CPU_LOAD_AVG_MIN_1, i) * agent_physical_cores; + agentsCpuLoad2[agentIndex][i] = + ProxyUtils.getDoubleSafely(agentCpuStep, CPU_LOAD_AVG_MIN_5, i) * agent_physical_cores; + agentsCpuLoad3[agentIndex][i] = + ProxyUtils.getDoubleSafely(agentCpuStep, CPU_LOAD_AVG_MIN_15, i) * agent_physical_cores; // MEM agentMemIdle[agentIndex][i] = ProxyUtils.getLongSafely(agentMemStep, MEM_IDLE, i); @@ -321,21 +336,20 @@ public JsonNode queryClusterInfo(String clusterId, String pace) { clusterInfo.put("total_disk", totalDiskSpace); // cur - clusterInfo.put("cpu_usage_cur", instantCpuUsage / total_physical_cores); - clusterInfo.put("memory_usage_cur", (double) (totalMemSpace - totalMemIdle)/ totalMemSpace); + clusterInfo.put("cpu_usage_cur", instantCpuUsage / total_physical_cores); + clusterInfo.put("memory_usage_cur", (double) (totalMemSpace - totalMemIdle) / totalMemSpace); // cpu - clusterInfo.set("cpu_usage",ProxyUtils.array2node(agentsCpuUsage,total_physical_cores,agentsNum)); - clusterInfo.set("system_load1",ProxyUtils.array2node(agentsCpuLoad1,total_physical_cores,agentsNum)); - clusterInfo.set("system_load2",ProxyUtils.array2node(agentsCpuLoad2,total_physical_cores,agentsNum)); - clusterInfo.set("system_load3",ProxyUtils.array2node(agentsCpuLoad3,total_physical_cores,agentsNum)); + clusterInfo.set("cpu_usage", ProxyUtils.array2node(agentsCpuUsage, total_physical_cores, agentsNum)); + clusterInfo.set("system_load1", ProxyUtils.array2node(agentsCpuLoad1, total_physical_cores, agentsNum)); + clusterInfo.set("system_load2", ProxyUtils.array2node(agentsCpuLoad2, total_physical_cores, agentsNum)); + clusterInfo.set("system_load3", ProxyUtils.array2node(agentsCpuLoad3, total_physical_cores, agentsNum)); // mem - clusterInfo.set("memory_usage",ProxyUtils.array2node(agentMemIdle,agentMemTotal,agentsNum)); + clusterInfo.set("memory_usage", ProxyUtils.array2node(agentMemIdle, agentMemTotal, agentsNum)); return clusterInfo; } - /** * retrieve cpu */ @@ -354,8 +368,7 @@ public JsonNode retrieveAgentCpu(String iPv4addr) { agentInfo.put("iPv4addr", agentCpuMetric.get("iPv4addr").asText()); agentInfo.put("os", agentCpuMetric.get("os").asText()); agentInfo.put("architecture", agentCpuMetric.get("arch").asText()); - agentInfo.put( - PHYSICAL_CORES, agentCpuMetric.get(PHYSICAL_CORES).asText()); + agentInfo.put(PHYSICAL_CORES, agentCpuMetric.get(PHYSICAL_CORES).asText()); agentInfo.put( FILE_OPEN_DESCRIPTOR, agentCpuMetric.get(FILE_OPEN_DESCRIPTOR).asLong()); @@ -378,10 +391,13 @@ public JsonNode retrieveAgentCpu(String iPv4addr) { * retrieve cpu internal */ public JsonNode retrieveAgentCpu(String iPv4addr, String pace) { - String params = String.format("agent_host_monitoring_cpu{iPv4addr=\"%s\"}",iPv4addr); + String params = String.format("agent_host_monitoring_cpu{iPv4addr=\"%s\"}", iPv4addr); ArrayList timeStampsList = ProxyUtils.getTimeStampsList(Integer.parseInt(pace)); JsonNode result = queryRange( - params, timeStampsList.get(timeStampsList.size() - 1), timeStampsList.get(0), ProxyUtils.Number2Param(Integer.parseInt(pace))); // end start + params, + timeStampsList.get(timeStampsList.size() - 1), + timeStampsList.get(0), + ProxyUtils.Number2Param(Integer.parseInt(pace))); // end start ObjectMapper objectMapper = new ObjectMapper(); if (result != null) { JsonNode agentCpu = result.get("data").get("result"); @@ -395,8 +411,7 @@ public JsonNode retrieveAgentCpu(String iPv4addr, String pace) { agentCpuInfo.put("os", agentCpuMetrics.get("os").asText()); agentCpuInfo.put("architecture", agentCpuMetrics.get("arch").asText()); agentCpuInfo.put( - PHYSICAL_CORES, - agentCpuMetrics.get(PHYSICAL_CORES).asInt()); + PHYSICAL_CORES, agentCpuMetrics.get(PHYSICAL_CORES).asInt()); agentCpuInfo.put( FILE_OPEN_DESCRIPTOR, agentCpuMetrics.get(FILE_OPEN_DESCRIPTOR).asLong()); @@ -419,7 +434,6 @@ public JsonNode retrieveAgentCpu(String iPv4addr, String pace) { return objectMapper.createObjectNode(); } - /** * retrieve memory */ @@ -452,7 +466,10 @@ public JsonNode retrieveAgentMemory(String iPv4addr, String pace) { String params = String.format("agent_host_monitoring_mem{iPv4addr=\"%s\"}", iPv4addr); ArrayList timeStampsList = ProxyUtils.getTimeStampsList(Integer.parseInt(pace)); // sum 8 and between 7 JsonNode result = queryRange( - params, timeStampsList.get(timeStampsList.size() - 1), timeStampsList.get(0), ProxyUtils.Number2Param(Integer.parseInt(pace))); // end start + params, + timeStampsList.get(timeStampsList.size() - 1), + timeStampsList.get(0), + ProxyUtils.Number2Param(Integer.parseInt(pace))); // end start ObjectMapper objectMapper = new ObjectMapper(); if (result != null) { JsonNode agentMem = result.get("data").get("result"); @@ -495,7 +512,7 @@ public JsonNode queryAgentDisk(String iPv4addr) { agentDiskInfo.put("iPv4addr", agentDisksMetric.get("iPv4addr").asText()); // value - Long diskTotalSpace = 0L,diskFreeSpace = 0L; + Long diskTotalSpace = 0L, diskFreeSpace = 0L; for (JsonNode agent : agentDisksResult) { if (Objects.equals(agent.get("metric").get("diskUsage").asText(), DISK_IDLE)) { diskFreeSpace += agent.get("value").get(1).asLong(); @@ -538,8 +555,8 @@ public JsonNode queryAgentDiskIO(String iPv4addr) { diskRead += disk.get("value").get(1).asLong(); } } - agentDiskIOInfo.put(DISK_WRITE,diskWrite); - agentDiskIOInfo.put(DISK_READ,diskRead); + agentDiskIOInfo.put(DISK_WRITE, diskWrite); + agentDiskIOInfo.put(DISK_READ, diskRead); return agentDiskIOInfo; } } @@ -548,11 +565,14 @@ public JsonNode queryAgentDiskIO(String iPv4addr) { /** * retrieve diskIO internal */ - public JsonNode queryAgentDiskIO(String iPv4addr,String step) { + public JsonNode queryAgentDiskIO(String iPv4addr, String step) { String params = String.format("agent_host_monitoring_diskIO{iPv4addr=\"%s\"}", iPv4addr); ArrayList timeStampsList = ProxyUtils.getTimeStampsList(Integer.parseInt(step)); JsonNode result = queryRange( - params, timeStampsList.get(timeStampsList.size() - 1), timeStampsList.get(0), ProxyUtils.Number2Param(Integer.parseInt(step))); + params, + timeStampsList.get(timeStampsList.size() - 1), + timeStampsList.get(0), + ProxyUtils.Number2Param(Integer.parseInt(step))); ObjectMapper objectMapper = new ObjectMapper(); if (result != null) { JsonNode agentDisksResult = result.get("data").get("result"); @@ -569,19 +589,18 @@ public JsonNode queryAgentDiskIO(String iPv4addr,String step) { long[] diskRead = new long[6]; for (JsonNode disk : agentDisksResult) { if (Objects.equals(disk.get("metric").get("diskIO").asText(), DISK_WRITE)) { - for (int i = 0 ; i<6;i++) + for (int i = 0; i < 6; i++) diskWrite[i] += disk.get("values").get(i).get(1).asLong(); } else { - for (int i = 0 ; i<6;i++) + for (int i = 0; i < 6; i++) diskRead[i] += disk.get("values").get(i).get(1).asLong(); } } - agentDiskIOInfo.set(DISK_WRITE,ProxyUtils.array2node(diskWrite)); - agentDiskIOInfo.set(DISK_READ,ProxyUtils.array2node(diskRead)); + agentDiskIOInfo.set(DISK_WRITE, ProxyUtils.array2node(diskWrite)); + agentDiskIOInfo.set(DISK_READ, ProxyUtils.array2node(diskRead)); return agentDiskIOInfo; } } return objectMapper.createObjectNode(); } - } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/MonitoringServiceImpl.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/MonitoringServiceImpl.java index 5796c97c..794cc8b6 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/MonitoringServiceImpl.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/service/impl/MonitoringServiceImpl.java @@ -44,8 +44,9 @@ public JsonNode queryAgentsHealthyStatus() { public JsonNode queryAgentsInfo() { return prometheusProxy.queryAgentsInfo(); } + @Override - public JsonNode queryAgentsInfo(String pace){ + public JsonNode queryAgentsInfo(String pace) { return prometheusProxy.queryAgentsInfo(pace); } diff --git a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/ProxyUtils.java b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/ProxyUtils.java index 6cd9b4f4..1a8201b9 100644 --- a/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/ProxyUtils.java +++ b/bigtop-manager-server/src/main/java/org/apache/bigtop/manager/server/utils/ProxyUtils.java @@ -19,50 +19,49 @@ public static double getDoubleSafely(JsonNode parentNode, String key, int index) return listNode.get(index).asDouble(); return 0.0; } + public static Long getLongSafely(JsonNode parentNode, String key, int index) { JsonNode listNode = parentNode.get(key); if (listNode != null && listNode.isArray() && index < listNode.size()) return listNode.get(index).asLong(); return 0L; } - public static JsonNode array2node(double[][] array,int num,int cores){ + + public static JsonNode array2node(double[][] array, int num, int cores) { ObjectMapper mapper = new ObjectMapper(); double[] cache = new double[6]; - for(int i = 0; i< num;i++) - for(int j = 0;j<6;j++) - cache[j] += array[i][j]; + for (int i = 0; i < num; i++) for (int j = 0; j < 6; j++) cache[j] += array[i][j]; ArrayNode node = mapper.createArrayNode(); // 数据排序为日期小在前,日期大在后 - for(int j = 0;j<6;j++) - node.add(cache[j] / cores); + for (int j = 0; j < 6; j++) node.add(cache[j] / cores); return node; } - public static JsonNode array2node(double[] array){ + + public static JsonNode array2node(double[] array) { ArrayNode node = new ObjectMapper().createArrayNode(); - for(int j = 0;j<6;j++) - node.add(array[j]); + for (int j = 0; j < 6; j++) node.add(array[j]); return node; } - public static JsonNode array2node(long[] array){ + + public static JsonNode array2node(long[] array) { ArrayNode node = new ObjectMapper().createArrayNode(); - for(int j = 0;j<6;j++) - node.add(array[j]); + for (int j = 0; j < 6; j++) node.add(array[j]); return node; } - public static JsonNode array2node(long[] array1,long[] array2){ + + public static JsonNode array2node(long[] array1, long[] array2) { ArrayNode node = new ObjectMapper().createArrayNode(); - for(int j = 0;j<6;j++) - if(array2[j] <= 0) - node.add(0.0); - else - node.add((double) ( array2[j] - array1[j]) / array2[j]); + for (int j = 0; j < 6; j++) + if (array2[j] <= 0) node.add(0.0); + else node.add((double) (array2[j] - array1[j]) / array2[j]); return node; } - public static JsonNode array2node(long[][] array1,long[][] array2,int num){ + + public static JsonNode array2node(long[][] array1, long[][] array2, int num) { ObjectMapper mapper = new ObjectMapper(); long[] cache1 = new long[6]; long[] cache2 = new long[6]; - for(int i = 0; i< num;i++) { + for (int i = 0; i < num; i++) { for (int j = 0; j < 6; j++) { cache1[j] += array1[i][j]; cache2[j] += array2[i][j]; @@ -70,13 +69,12 @@ public static JsonNode array2node(long[][] array1,long[][] array2,int num){ } ArrayNode node = mapper.createArrayNode(); // The data is sorted with earlier dates coming first and later dates following. - for(int j = 0;j < 6;j++) - if(cache2[j] <= 0) - node.add(0.0); - else - node.add((double) (cache2[j] - cache1[j]) / cache2[j]); + for (int j = 0; j < 6; j++) + if (cache2[j] <= 0) node.add(0.0); + else node.add((double) (cache2[j] - cache1[j]) / cache2[j]); return node; } + public static ArrayList getTimeStampsList(int step) { // format String currentTimeStr = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")); @@ -96,7 +94,8 @@ public static ArrayList getTimeStampsList(int step) { } return timestamps; } - public static String Number2Param(int step){ - return String.format("%sm",step); + + public static String Number2Param(int step) { + return String.format("%sm", step); } }