use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.
the class Preparer method moveToActiveGroup.
/**
* Move nodes from unwanted groups to wanted groups to avoid lingering groups consisting of retired nodes
*/
private void moveToActiveGroup(List<Node> surplusNodes, int wantedGroups, Optional<ClusterSpec.Group> targetGroup) {
for (ListIterator<Node> i = surplusNodes.listIterator(); i.hasNext(); ) {
Node node = i.next();
ClusterMembership membership = node.allocation().get().membership();
ClusterSpec cluster = membership.cluster();
if (cluster.group().get().index() >= wantedGroups) {
ClusterSpec.Group newGroup = targetGroup.orElse(ClusterSpec.Group.from(0));
ClusterMembership newGroupMembership = membership.with(cluster.with(Optional.of(newGroup)));
i.set(node.with(node.allocation().get().with(newGroupMembership)));
}
}
}
use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.
the class ContainerModelBuilder method createNodesFromNodeCount.
private List<Container> createNodesFromNodeCount(ContainerCluster cluster, Element nodesElement, ConfigModelContext context) {
NodesSpecification nodesSpecification = NodesSpecification.from(new ModelElement(nodesElement), context.getDeployState().getWantedNodeVespaVersion());
Map<HostResource, ClusterMembership> hosts = nodesSpecification.provision(cluster.getRoot().getHostSystem(), ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), log);
return createNodesFromHosts(hosts, cluster);
}
use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.
the class ContainerModelBuilder method createNodesFromNodeType.
private List<Container> createNodesFromNodeType(ContainerCluster cluster, Element nodesElement, ConfigModelContext context) {
NodeType type = NodeType.valueOf(nodesElement.getAttribute("type"));
ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), context.getDeployState().getWantedNodeVespaVersion(), false);
Map<HostResource, ClusterMembership> hosts = cluster.getRoot().getHostSystem().allocateHosts(clusterSpec, Capacity.fromRequiredNodeType(type), 1, log);
return createNodesFromHosts(hosts, cluster);
}
use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.
the class ContainerModelBuilder method createNodesFromContentServiceReference.
private List<Container> createNodesFromContentServiceReference(ContainerCluster cluster, Element nodesElement, ConfigModelContext context) {
// Resolve references to content clusters at the XML level because content clusters must be built after container clusters
String referenceId = nodesElement.getAttribute("of");
Element services = servicesRootOf(nodesElement).orElseThrow(() -> clusterReferenceNotFoundException(cluster, referenceId));
Element referencedService = findChildById(services, referenceId).orElseThrow(() -> clusterReferenceNotFoundException(cluster, referenceId));
if (!referencedService.getTagName().equals("content"))
throw new IllegalArgumentException(cluster + " references service '" + referenceId + "', " + "but that is not a content service");
Element referencedNodesElement = XML.getChild(referencedService, "nodes");
if (referencedNodesElement == null)
throw new IllegalArgumentException(cluster + " references service '" + referenceId + "' to supply nodes, " + "but that service has no <nodes> element");
cluster.setHostClusterId(referenceId);
Map<HostResource, ClusterMembership> hosts = StorageGroup.provisionHosts(NodesSpecification.from(new ModelElement(referencedNodesElement), context.getDeployState().getWantedNodeVespaVersion()), referenceId, cluster.getRoot().getHostSystem(), context.getDeployLogger());
return createNodesFromHosts(hosts, cluster);
}
use of com.yahoo.config.provision.ClusterMembership in project vespa by vespa-engine.
the class DynamicDockerProvisioningTest method addAndAssignNode.
private Node addAndAssignNode(ApplicationId id, String hostname, String parentHostname, Flavor flavor, int index, ProvisioningTester tester) {
Node node1a = Node.create("open1", Collections.singleton("127.0.0.100"), new HashSet<>(), hostname, Optional.of(parentHostname), flavor, NodeType.tenant);
ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.content, ClusterSpec.Id.from("myContent"), Version.fromString("6.100"), false).with(Optional.of(ClusterSpec.Group.from(0)));
ClusterMembership clusterMembership1 = ClusterMembership.from(clusterSpec, index);
Node node1aAllocation = node1a.allocate(id, clusterMembership1, Instant.now());
tester.nodeRepository().addNodes(Collections.singletonList(node1aAllocation));
NestedTransaction transaction = new NestedTransaction().add(new CuratorTransaction(tester.getCurator()));
tester.nodeRepository().activate(Collections.singletonList(node1aAllocation), transaction);
transaction.commit();
return node1aAllocation;
}
Aggregations