Skip to content

Commit

Permalink
fix method params error and api
Browse files Browse the repository at this point in the history
  • Loading branch information
Cat-Drink committed Dec 27, 2024
1 parent d157933 commit 7bf2bad
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ public class MetricsController {
private MetricsService metricsService;

@Operation(summary = "hosts healthy", description = "hosts healthy check")
@GetMapping("hosts/healthy")
@GetMapping("hostshealthy")
public ResponseEntity<JsonNode> agentHostsHealthyStatus() {
return ResponseEntity.success(metricsService.queryAgentsHealthyStatus());
}

@Operation(summary = "host info", description = "host info query")
@GetMapping("hosts/{id}")
public ResponseEntity<JsonNode> queryAgentInfo(
@RequestParam(value = "interval", defaultValue = "1") String interval, @PathVariable String id) {
@RequestParam(value = "interval", defaultValue = "1m") String interval, @PathVariable String id) {
return ResponseEntity.success(metricsService.queryAgentsInfo(Long.valueOf(id), interval));
}

@Operation(summary = "cluster info", description = "cluster info query")
@GetMapping("clusters/{id}")
public ResponseEntity<JsonNode> queryCluster(
@RequestParam(value = "interval", defaultValue = "1") String interval, @PathVariable String id) {
@RequestParam(value = "interval", defaultValue = "1m") String interval, @PathVariable String id) {
return ResponseEntity.success(metricsService.queryClustersInfo(Long.valueOf(id), interval));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,8 @@ public JsonNode queryClustersInfo(Long clusterId, String interval) {
hostQuery.setClusterId(clusterId);
PageVO<HostVO> hostPage = hostService.list(hostQuery); // query host list
List<HostVO> hostList = hostPage.getContent();
ObjectMapper objectMapper = new ObjectMapper();
int agentsNum = Math.toIntExact(hostPage.getTotal()); // change to agentsNum
ObjectMapper objectMapper = new ObjectMapper();
if (agentsNum > 0) {
int totalPhysicalCores = 0;
long totalMemSpace = 0L, totalMemIdle = 0L;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static Long getLongSafely(JsonNode parentNode, String key, int index) {
return 0L;
}

public static JsonNode array2node(double[][] array, int num, int cores) {
public static JsonNode array2node(double[][] array, int cores, int num) {
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];
Expand Down

0 comments on commit 7bf2bad

Please sign in to comment.