Search in sources :

Example 1 with NodeRepositoryNode

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;
}
Also used : NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ClusterSpec(com.yahoo.config.provision.ClusterSpec) IOException(java.io.IOException) HashMap(java.util.HashMap) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Level(java.util.logging.Level) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) List(java.util.List) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId) Duration(java.time.Duration) Map(java.util.Map) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) Deployment(com.yahoo.vespa.hosted.controller.application.Deployment) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) Application(com.yahoo.vespa.hosted.controller.Application) Controller(com.yahoo.vespa.hosted.controller.Controller) HashMap(java.util.HashMap) NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode) ClusterSpec(com.yahoo.config.provision.ClusterSpec) ClusterInfo(com.yahoo.vespa.hosted.controller.application.ClusterInfo) ApplicationList(com.yahoo.vespa.hosted.controller.application.ApplicationList) List(java.util.List) NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) DeploymentId(com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId) ZoneId(com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)

Example 2 with NodeRepositoryNode

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;
}
Also used : NodeMembership(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeMembership) NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode)

Example 3 with NodeRepositoryNode

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;
}
Also used : NodeMembership(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeMembership) NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode)

Example 4 with NodeRepositoryNode

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));
}
Also used : NodeList(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList) NodeRepositoryNode(com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode)

Aggregations

NodeRepositoryNode (com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeRepositoryNode)4 NodeList (com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeList)2 NodeMembership (com.yahoo.vespa.hosted.controller.api.integration.noderepository.NodeMembership)2 ClusterSpec (com.yahoo.config.provision.ClusterSpec)1 Application (com.yahoo.vespa.hosted.controller.Application)1 Controller (com.yahoo.vespa.hosted.controller.Controller)1 DeploymentId (com.yahoo.vespa.hosted.controller.api.identifiers.DeploymentId)1 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)1 ApplicationList (com.yahoo.vespa.hosted.controller.application.ApplicationList)1 ClusterInfo (com.yahoo.vespa.hosted.controller.application.ClusterInfo)1 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)1 IOException (java.io.IOException)1 Duration (java.time.Duration)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Map (java.util.Map)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Collectors (java.util.stream.Collectors)1