@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 final Optional<ConfigDefinition> getConfigDefinition(ConfigDefinitionKey defKey) { if (existingConfigDefs == null) { existingConfigDefs = new LinkedHashMap<>(); if (configDefinitionRepo.isPresent()) { existingConfigDefs.putAll(createLazyMapping(configDefinitionRepo.get())); } existingConfigDefs.putAll(applicationPackage.getAllExistingConfigDefs()); } if ( ! existingConfigDefs.containsKey(defKey)) return Optional.empty(); if (defArchive.get(defKey) != null) return Optional.of(defArchive.get(defKey)); ConfigDefinition def = existingConfigDefs.get(defKey).parse(); defArchive.put(defKey, def); return Optional.of(def); }
@Override public void validate(VespaModel model, DeployState deployState) { ApplicationPackage app = deployState.getApplicationPackage(); for (ComponentInfo info : app.getComponentsInfo(deployState.getVespaVersion())) { try { this.jarFile = new JarFile(app.getFileReference(Path.fromString(info.getPathRelativeToAppDir()))); } catch (ZipException e) { throw new IllegalArgumentException("Error opening jar file '" + info.getPathRelativeToAppDir() + "'. Please check that this is a valid jar file"); } catch (IOException e) { e.printStackTrace(); } try { validateAll(deployState.getDeployLogger()); } catch (IOException e) { e.printStackTrace(); } } }
public MockRoot(String rootConfigId, DeployState deployState) { super(rootConfigId); hostSystem = new HostSystem(this, "hostsystem", deployState.getProvisioner(), deployState.getDeployLogger()); this.deployState = deployState; fileDistributor = new FileDistributor(deployState.getFileRegistry(), null); }
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); } }
public DeployLogger deployLogger() { return deployState.getDeployLogger(); }
private VespaModel(ConfigModelRegistry configModelRegistry, DeployState deployState, boolean complete, FileDistributor fileDistributor) throws IOException, SAXException { super("vespamodel"); this.validationOverrides = deployState.validationOverrides(); configModelRegistry = new VespaConfigModelRegistry(configModelRegistry); VespaModelBuilder builder = new VespaDomBuilder(); this.applicationPackage = deployState.getApplicationPackage(); root = builder.getRoot(VespaModel.ROOT_CONFIGID, deployState, this); createGlobalRankProfiles(deployState.getDeployLogger(), deployState.getImportedModels(), deployState.rankProfileRegistry(), deployState.getQueryProfiles()); this.rankProfileList = new RankProfileList(null, // null search -> global rankingConstants, AttributeFields.empty, deployState.rankProfileRegistry(), deployState.getQueryProfiles().getRegistry(), deployState.getImportedModels());
if (deployState.getProperties().isFirstTimeDeployment()) { validateFirstTimeDeployment(model, deployState); } else { Optional<Model> currentActiveModel = deployState.getPreviousModel(); if (currentActiveModel.isPresent() && (currentActiveModel.get() instanceof VespaModel)) result = validateChanges((VespaModel) currentActiveModel.get(), model, deployState.validationOverrides(), deployState.getDeployLogger(), deployState.now());
private void deriveSingleSearchDefinition(com.yahoo.searchdefinition.Search localSearch, DeployState deployState) { if (!localSearch.getName().equals(docTypeName)) { throw new IllegalStateException("Mismatch between document type name (" + docTypeName + ") and name of search definition (" + localSearch.getName() + ")"); } this.sdConfig = new DerivedConfiguration(localSearch, deployState.getDeployLogger(), deployState.rankProfileRegistry(), deployState.getQueryProfiles().getRegistry(), deployState.getImportedModels()); } @Override
/** 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()); }
@Override protected ConnectorFactory doBuild(DeployState deployState, AbstractConfigProducer ancestor, Element serverSpec) { String name = XmlHelper.getIdString(serverSpec); int port = HttpBuilder.readPort(serverSpec, deployState.isHosted(), deployState.getDeployLogger()); SimpleComponent sslProviderComponent = getSslConfigComponents(name, serverSpec); return new ConnectorFactory(name, port, sslProviderComponent); }
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); }); }
/** 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); } }
public ModelContext.Properties properties() { return deployState.getProperties(); }
ModelElement documentsElement = contentElement.getChild("documents"); Map<String, NewDocumentType> documentDefinitions = new SearchDefinitionBuilder().build(deployState.getDocumentModel().getDocumentManager(), documentsElement); deployState.zone(), deployState.isHosted()); c.clusterControllerConfig = new ClusterControllerConfig.Builder(getClusterName(contentElement), contentElement).build(deployState, c, contentElement.getXml()); c.search = new ContentSearchCluster.Builder(documentDefinitions, globallyDistributedDocuments).build(deployState, c, contentElement.getXml());
private void addAndSendApplicationBundles(DeployState deployState) { for (ComponentInfo component : deployState.getApplicationPackage().getComponentsInfo(deployState.getVespaVersion())) { FileReference reference = FileSender.sendFileToServices(component.getPathRelativeToAppDir(), containers); applicationBundles.add(reference); } }
/** Initialize part 1.: Reads the config models used in the application package. */ public void readConfigModels(DeployState deployState, VespaModel vespaModel, VespaModelBuilder builder, ApplicationConfigProducerRoot root, ConfigModelRegistry configModelRegistry) throws IOException, SAXException { Element userServicesElement = getServicesFromApp(deployState.getApplicationPackage()); readConfigModels(root, userServicesElement, deployState, vespaModel, configModelRegistry); builder.postProc(deployState.getDeployLogger(), root, this); }
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); }
private ContainerSearch buildSearch(DeployState deployState, ContainerCluster containerCluster, Element producerSpec) { SearchChains searchChains = new DomSearchChainsBuilder(null, false).build(deployState, containerCluster, producerSpec); ContainerSearch containerSearch = new ContainerSearch(containerCluster, searchChains, new ContainerSearch.Options()); applyApplicationPackageDirectoryConfigs(deployState.getApplicationPackage(), containerSearch); containerSearch.setQueryProfiles(deployState.getQueryProfiles()); containerSearch.setSemanticRules(deployState.getSemanticRules()); return containerSearch; }
private void addSearchDefinitions(DeployState deployState, List<ModelElement> searchDefs, AbstractSearchCluster sc) { for (ModelElement e : searchDefs) { SearchDefinitionXMLHandler searchDefinitionXMLHandler = new SearchDefinitionXMLHandler(e); SearchDefinition searchDefinition = searchDefinitionXMLHandler.getResponsibleSearchDefinition(deployState.getSearchDefinitions()); if (searchDefinition == null) throw new RuntimeException("Search definition parsing error or file does not exist: '" + searchDefinitionXMLHandler.getName() + "'"); // TODO: remove explicit building of user configs when the complete content model is built using builders. sc.getLocalSDS().add(new AbstractSearchCluster.SearchDefinitionSpec(searchDefinition, UserConfigBuilder.build(e.getXml(), deployState, deployState.getDeployLogger()))); //need to get the document names from this sdfile sc.addDocumentNames(searchDefinition); } }