⚗️ Build client once
This commit is contained in:
parent
d8dcb462da
commit
98668642f7
@ -26,25 +26,10 @@ public class NodeResource
|
|||||||
{
|
{
|
||||||
@GET
|
@GET
|
||||||
@Produces(MediaType.APPLICATION_JSON)
|
@Produces(MediaType.APPLICATION_JSON)
|
||||||
public List<NodeStats> getMonitoring() throws IOException, InterruptedException
|
public List<NodeStats> getMonitoring()
|
||||||
{
|
{
|
||||||
List<NodeStats> result = new ArrayList<>();
|
List<NodeStats> result = new ArrayList<>();
|
||||||
|
|
||||||
List<String> stats = getTopNodes();
|
|
||||||
for(String nodeName : stats)
|
|
||||||
{
|
|
||||||
String[] parts = nodeName.split("\\s+");
|
|
||||||
if(parts.length == 5)
|
|
||||||
{
|
|
||||||
String name = parts[0];
|
|
||||||
Node node = ClientProvider.getClient().nodes().withName(name).get();
|
|
||||||
Integer absoluteCpu = extractInteger(parts[1]);
|
|
||||||
Integer relativeCpu = extractInteger(parts[2]);
|
|
||||||
Integer absoluteMemory = extractMemory(parts[3]);
|
|
||||||
Integer relativeMemory = extractInteger(parts[4]);
|
|
||||||
result.add(new NodeStats(node, absoluteCpu, relativeCpu, Integer.parseInt(node.getStatus().getAllocatable().get("cpu").getAmount()) * 1000, absoluteMemory, relativeMemory, extractMemory(node.getStatus().getAllocatable().get("memory").getAmount())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package dev.dinauer.utils;
|
package dev.dinauer.utils;
|
||||||
|
|
||||||
import io.fabric8.kubernetes.client.Config;
|
import io.fabric8.kubernetes.client.Config;
|
||||||
|
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
|
||||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||||
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
|
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
|
||||||
import io.vertx.mutiny.core.Vertx;
|
import io.vertx.mutiny.core.Vertx;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user