use of com.yahoo.vespa.model.container.ContainerModel in project vespa by vespa-engine.
the class DomAdminV4Builder method pickContainerHostsForSlobrok.
/**
* Returns a list of container hosts to use for an auxiliary cluster.
* The list returns the same nodes on each invocation given the same available nodes.
*
* @param count the desired number of nodes. More nodes may be returned to ensure a smooth transition
* on topology changes, and less nodes may be returned if fewer are available
* @param minHostsPerContainerCluster the desired number of hosts per cluster
*/
private List<HostResource> pickContainerHostsForSlobrok(int count, int minHostsPerContainerCluster) {
Collection<ContainerModel> containerModelsWithSlobrok = containerModels.stream().filter(this::shouldHaveSlobrok).collect(Collectors.toList());
int hostsPerCluster = (int) Math.max(minHostsPerContainerCluster, Math.ceil((double) count / containerModelsWithSlobrok.size()));
// Pick from all container clusters to make sure we don't lose all nodes at once if some clusters are removed.
// This will overshoot the desired size (due to ceil and picking at least one node per cluster).
List<HostResource> picked = new ArrayList<>();
for (ContainerModel containerModel : containerModelsWithSlobrok) picked.addAll(pickContainerHostsFrom(containerModel, hostsPerCluster));
return picked;
}
use of com.yahoo.vespa.model.container.ContainerModel in project vespa by vespa-engine.
the class Content method createTlds.
public void createTlds(ConfigModelRepo modelRepo) {
IndexedSearchCluster indexedCluster = cluster.getSearch().getIndexed();
if (indexedCluster == null)
return;
SimpleConfigProducer tldParent = new SimpleConfigProducer(indexedCluster, "tlds");
for (ConfigModel model : modelRepo.asMap().values()) {
if (!(model instanceof ContainerModel))
continue;
ContainerCluster containerCluster = ((ContainerModel) model).getCluster();
// this is not a qrs cluster
if (containerCluster.getSearch() == null)
continue;
log.log(LogLevel.DEBUG, "Adding tlds for indexed cluster " + indexedCluster.getClusterName() + ", container cluster " + containerCluster.getName());
indexedCluster.addTldsWithSameIdsAsContainers(tldParent, containerCluster);
}
indexedCluster.setupDispatchGroups();
}
use of com.yahoo.vespa.model.container.ContainerModel in project vespa by vespa-engine.
the class ContainerModelBuilderTestBase method createModel.
public static void createModel(MockRoot root, DeployState deployState, Element... containerElems) throws SAXException, IOException {
for (Element containerElem : containerElems) {
ContainerModel model = new ContainerModelBuilder(false, ContainerModelBuilder.Networking.enable).build(deployState, null, root, containerElem);
ContainerCluster cluster = model.getCluster();
generateDefaultSearchChains(cluster);
}
root.freezeModelTopology();
}
use of com.yahoo.vespa.model.container.ContainerModel in project vespa by vespa-engine.
the class StandaloneDocprocContainerTest method setupCluster.
public ContainerCluster setupCluster(boolean standalone) {
ContainerModelBuilder builder = new ContainerModelBuilder(standalone, Networking.disable);
ContainerModel model = builder.build(DeployState.createTestState(), null, root, servicesXml());
if (!standalone)
model.getCluster().getDocproc().getChains().addServersAndClientsForChains();
root.freezeModelTopology();
return model.getCluster();
}
use of com.yahoo.vespa.model.container.ContainerModel in project vespa by vespa-engine.
the class DeploymentFileValidator method validate.
@Override
public void validate(VespaModel model, DeployState deployState) {
Optional<Reader> deployment = deployState.getApplicationPackage().getDeployment();
if (deployment.isPresent()) {
Reader deploymentReader = deployment.get();
DeploymentSpec deploymentSpec = DeploymentSpec.fromXml(deploymentReader);
final Optional<String> globalServiceId = deploymentSpec.globalServiceId();
if (globalServiceId.isPresent()) {
Set<ContainerCluster> containerClusters = model.getRoot().configModelRepo().getModels(ContainerModel.class).stream().map(ContainerModel::getCluster).filter(cc -> cc.getName().equals(globalServiceId.get())).collect(Collectors.toSet());
if (containerClusters.size() != 1) {
throw new IllegalArgumentException("global-service-id '" + globalServiceId.get() + "' specified in deployment.xml does not match any container cluster id");
}
}
}
}
Aggregations