use of com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode in project vespa by vespa-engine.
the class ClusterInfoMaintainer method getClusterInfo.
private Map<ClusterSpec.Id, ClusterInfo> getClusterInfo(NodeList nodes, ZoneId zone) {
Map<ClusterSpec.Id, ClusterInfo> infoMap = new HashMap<>();
// Group nodes by clusterid
Map<String, List<NodeRepositoryNode>> clusters = nodes.nodes().stream().filter(node -> node.getMembership() != null).collect(Collectors.groupingBy(ClusterInfoMaintainer::clusterid));
// For each cluster - get info
for (String id : clusters.keySet()) {
List<NodeRepositoryNode> clusterNodes = clusters.get(id);
// Assume they are all equal and use first node as a representative for the cluster
NodeRepositoryNode node = clusterNodes.get(0);
// Extract flavor info
double cpu = 0;
double mem = 0;
double disk = 0;
// TODO: This code was never run. Reenable when flavours are available from a FlavorRegistry or something, or remove.
/*if (zone.nodeFlavors().isPresent()) {
Optional<Flavor> flavorOptional = zone.nodeFlavors().get().getFlavor(node.flavor);
if ((flavorOptional.isPresent())) {
Flavor flavor = flavorOptional.get();
cpu = flavor.getMinCpuCores();
mem = flavor.getMinMainMemoryAvailableGb();
disk = flavor.getMinMainMemoryAvailableGb();
}
}*/
// Add to map
List<String> hostnames = clusterNodes.stream().map(NodeRepositoryNode::getHostname).collect(Collectors.toList());
ClusterInfo inf = new ClusterInfo(node.getFlavor(), node.getCost(), cpu, mem, disk, ClusterSpec.Type.from(node.getMembership().clustertype), hostnames);
infoMap.put(new ClusterSpec.Id(id), inf);
}
return infoMap;
}
use of com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode in project vespa by vespa-engine.
the class NodeRepositoryClientMock method createNodeB.
private static NodeRepositoryNode createNodeB() {
NodeRepositoryNode node = new NodeRepositoryNode();
node.setHostname("hostB");
node.setCost(20);
node.setFlavor("C-2C/24/500");
NodeMembership membership = new NodeMembership();
membership.clusterid = "clusterB";
membership.clustertype = "content";
node.setMembership(membership);
return node;
}
use of com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode in project vespa by vespa-engine.
the class NodeRepositoryClientMock method createNodeA.
private static NodeRepositoryNode createNodeA() {
NodeRepositoryNode node = new NodeRepositoryNode();
node.setHostname("hostA");
node.setCost(10);
node.setFlavor("C-2B/24/500");
NodeMembership membership = new NodeMembership();
membership.clusterid = "clusterA";
membership.clustertype = "container";
node.setMembership(membership);
return node;
}
use of com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode in project vespa by vespa-engine.
the class NodeRepositoryClientMock method listNodes.
@Override
public NodeList listNodes(ZoneId zone, String tenant, String applicationId, String instance) throws IOException {
NodeRepositoryNode nodeA = createNodeA();
NodeRepositoryNode nodeB = createNodeB();
return new NodeList(Arrays.asList(nodeA, nodeB));
}
Aggregations