public ModelContext.Properties properties() { return deployState.getProperties(); }
public IndexedSearchCluster(AbstractConfigProducer parent, String clusterName, int index, DeployState deployState) { super(parent, clusterName, index); unionCfg = new UnionConfiguration(this, documentDbs); dispatchParent = new SimpleConfigProducer(this, "dispatchers"); rootDispatch = new DispatchGroup(this); useFdispatchByDefault = deployState.getProperties().useFdispatchByDefault(); useAdaptiveDispatch = deployState.getProperties().useAdaptiveDispatch(); }
/** * Returns the id of the deployed application, or the default value if not explicitly set (self-hosted). */ private static ApplicationName getDeployedApplicationId(DeployState deployState, AbstractConfigProducer ancestor) { return getContainerCluster(ancestor) .map(cluster -> deployState.getProperties().applicationId().application()) .orElse(ApplicationId.defaultId().application()); }
/** Returns a requirement from <code>count</code> dedicated nodes in one group */ public static NodesSpecification dedicated(int count, ConfigModelContext context) { return new NodesSpecification(true, count, 1, context.getDeployState().getWantedNodeVespaVersion(), false, ! context.getDeployState().getProperties().isBootstrap(), false, Optional.empty(), Optional.empty()); }
/** Returns a requirement from <code>count</code> nondedicated nodes in one group */ public static NodesSpecification nonDedicated(int count, ConfigModelContext context) { return new NodesSpecification(false, count, 1, context.getDeployState().getWantedNodeVespaVersion(), false, ! context.getDeployState().getProperties().isBootstrap(), false, Optional.empty(), Optional.empty()); }
private boolean shouldHaveSlobrok(ContainerModel containerModel) { // Avoid Slobroks on node-admin container cluster, as node-admin is migrating // TODO: Remove this hack once node-admin has migrated out the zone app ApplicationId applicationId = context.getDeployState().getProperties().applicationId(); if (!applicationId.equals(ZONE_APPLICATION_ID)) { return true; } // aka clustername, aka application-model's ClusterId String clustername = containerModel.getCluster().getName(); return !Objects.equals(clustername, "node-admin"); }
private void addAthensCopperArgos(ContainerCluster cluster, ConfigModelContext context) { app.getDeployment().map(DeploymentSpec::fromXml) .ifPresent(deploymentSpec -> { addIdentityProvider(cluster, context.getDeployState().getProperties().configServerSpecs(), context.getDeployState().getProperties().loadBalancerName(), context.getDeployState().getProperties().ztsUrl(), context.getDeployState().getProperties().athenzDnsSuffix(), context.getDeployState().zone(), deploymentSpec); addRotationProperties(cluster, context.getDeployState().zone(), context.getDeployState().getRotations(), deploymentSpec); }); }
/** * Returns a requirement for undedicated or dedicated nodes taken from the <code>nodes</code> element * contained in the given parent element, or empty if the parent element is null, or the nodes elements * is not present. */ public static Optional<NodesSpecification> optionalDedicatedFromParent(ModelElement parentElement, ConfigModelContext context) { if (parentElement == null) return Optional.empty(); ModelElement nodesElement = parentElement.getChild("nodes"); if (nodesElement == null) return Optional.empty(); return Optional.of(new NodesSpecification(nodesElement.getBooleanAttribute("dedicated", false), ! context.getDeployState().getProperties().isBootstrap(), context.getDeployState().getWantedNodeVespaVersion(), nodesElement)); }
/** Creates a single host when there is no nodes tag */ private HostResource allocateSingleNodeHost(ContainerCluster cluster, DeployLogger logger, Element containerElement, ConfigModelContext context) { DeployState deployState = context.getDeployState(); HostSystem hostSystem = cluster.getHostSystem(); if (deployState.isHosted()) { Optional<HostResource> singleContentHost = getHostResourceFromContentClusters(cluster, containerElement, context); if (singleContentHost.isPresent()) { // there is a content cluster; put the container on its first node return singleContentHost.get(); } else { // request 1 node ClusterSpec clusterSpec = ClusterSpec.request(ClusterSpec.Type.container, ClusterSpec.Id.from(cluster.getName()), deployState.getWantedNodeVespaVersion(), false, Collections.emptySet()); Capacity capacity = Capacity.fromNodeCount(1, Optional.empty(), false, ! deployState.getProperties().isBootstrap()); return hostSystem.allocateHosts(clusterSpec, capacity, 1, logger).keySet().iterator().next(); } } else { return hostSystem.getHost(Container.SINGLENODE_CONTAINER_SERVICESPEC); } }
/** * Returns a requirement for dedicated nodes taken from the given <code>nodes</code> element */ public static NodesSpecification from(ModelElement nodesElement, ConfigModelContext context) { return new NodesSpecification(true, ! context.getDeployState().getProperties().isBootstrap(), context.getDeployState().getWantedNodeVespaVersion(), nodesElement); }
private NodesSpecification createNodesSpecificationForLogserver() { // TODO: Enable for main system as well DeployState deployState = context.getDeployState(); if (deployState.getProperties().useDedicatedNodeForLogserver() && context.getApplicationType() == ConfigModelContext.ApplicationType.DEFAULT && deployState.isHosted()) return NodesSpecification.dedicated(1, context); else return NodesSpecification.nonDedicated(1, context); }
@Override protected ApplicationConfigProducerRoot doBuild(DeployState deployState, AbstractConfigProducer parent, Element producerSpec) { ApplicationConfigProducerRoot root = new ApplicationConfigProducerRoot(parent, name, deployState.getDocumentModel(), deployState.getVespaVersion(), deployState.getProperties().applicationId()); root.setHostSystem(new HostSystem(root, "hosts", deployState.getProvisioner(), deployState.getDeployLogger())); new Client(root); return root; } }
@Override public void doBuild(AdminModel model, Element adminElement, ConfigModelContext modelContext) { AbstractConfigProducer parent = modelContext.getParentProducer(); ModelContext.Properties properties = modelContext.getDeployState().getProperties(); DomAdminV4Builder domBuilder = new DomAdminV4Builder(modelContext, properties.multitenant(), properties.configServerSpecs(), model.getContainerModels()); model.admin = domBuilder.build(modelContext.getDeployState(), parent, adminElement); // TODO: Is required since other models depend on admin. if (parent instanceof ApplicationConfigProducerRoot) { ((ApplicationConfigProducerRoot)parent).setupAdmin(model.admin); } } }
private void addCommonServices(HostResource host, DeployState deployState) { addConfigSentinel(deployState.getDeployLogger(), host, deployState.getProperties().applicationId(), deployState.zone()); addLogd(deployState.getDeployLogger(), host); addConfigProxy(deployState.getDeployLogger(), host); addFileDistribution(host); if (logForwarderConfig != null) { addLogForwarder(deployState.getDeployLogger(), host); } }
@Override public void doBuild(AdminModel model, Element adminElement, ConfigModelContext modelContext) { AbstractConfigProducer parent = modelContext.getParentProducer(); ModelContext.Properties properties = modelContext.getDeployState().getProperties(); DomAdminV2Builder domBuilder = new DomAdminV2Builder(modelContext.getApplicationType(), modelContext.getDeployState().getFileRegistry(), properties.multitenant(), properties.configServerSpecs()); model.admin = domBuilder.build(modelContext.getDeployState(), parent, adminElement); // TODO: Is required since other models depend on admin. if (parent instanceof ApplicationConfigProducerRoot) { ((ApplicationConfigProducerRoot)parent).setupAdmin(model.admin); } } }
if (deployState.getProperties().isFirstTimeDeployment()) { validateFirstTimeDeployment(model, deployState); } else {
static Pair<VespaModel, Container> createContainerModel(Path applicationPath, FileRegistry fileRegistry, File preprocessedApplicationDir, Networking networkingOption, ConfigModelRepo configModelRepo) throws Exception { DeployLogger logger = new BaseDeployLogger(); FilesApplicationPackage rawApplicationPackage = new FilesApplicationPackage.Builder(applicationPath.toFile()) .includeSourceFiles(true).preprocessedDir(preprocessedApplicationDir).build(); ApplicationPackage applicationPackage = rawApplicationPackage.preprocess(getZone(), logger); validateApplication(applicationPackage); DeployState deployState = createDeployState(applicationPackage, fileRegistry, logger); VespaModel root = VespaModel.createIncomplete(deployState); ApplicationConfigProducerRoot vespaRoot = new ApplicationConfigProducerRoot(root, "vespa", deployState.getDocumentModel(), deployState.getVespaVersion(), deployState.getProperties().applicationId()); Element spec = containerRootElement(applicationPackage); ContainerModel containerModel = newContainerModelBuilder(networkingOption).build(deployState, root, configModelRepo, vespaRoot, spec); containerModel.getCluster().prepare(deployState); initializeContainerModel(containerModel, configModelRepo); Container container = first(containerModel.getCluster().getContainers()); // TODO: Separate out model finalization from the VespaModel constructor, // such that the above and below code to finalize the container can be // replaced by root.finalize(); initializeContainer(deployState.getDeployLogger(), container, spec); root.freezeModelTopology(); return new Pair<>(root, container); }