use of com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList 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.NodeList 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));
}
use of com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList in project vespa by vespa-engine.
the class ClusterInfoMaintainer method maintain.
@Override
protected void maintain() {
for (Application application : ApplicationList.from(controller().applications().asList()).notPullRequest().asList()) {
for (Deployment deployment : application.deployments().values()) {
DeploymentId deploymentId = new DeploymentId(application.id(), deployment.zone());
try {
NodeList nodes = controller.nodeRepositoryClient().listNodes(deploymentId.zoneId(), deploymentId.applicationId().tenant().value(), deploymentId.applicationId().application().value(), deploymentId.applicationId().instance().value());
Map<ClusterSpec.Id, ClusterInfo> clusterInfo = getClusterInfo(nodes, deployment.zone());
controller().applications().lockIfPresent(application.id(), lockedApplication -> controller.applications().store(lockedApplication.withClusterInfo(deployment.zone(), clusterInfo)));
} catch (IOException | IllegalArgumentException e) {
log.log(Level.WARNING, "Failing getting cluster info of for " + deploymentId, e);
}
}
}
}
Aggregations