Search in sources :

Example 1 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class ComponentRegistry method getComponent.

/**
 * Returns a component. If the id does not specify an (exact) version, the newest (matching) version is returned.
 * For example, if version 3.1 is specified and we have 3.1.0, 3.1.1 and 3.1.3 registered, 3.1.3 is returned.
 *
 * @param id the id of the component to return. May not include a version, or include
 *        an underspecified version, in which case the highest (matching) version which
 *        does not contain a qualifier is returned
 * @return the search chain or null if no component of this name (and matching version, if specified) is registered
 */
public COMPONENT getComponent(ComponentSpecification id) {
    Map<String, Map<Version, COMPONENT>> componentVersionsByName = componentsByNameByNamespace.get(id.getNamespace());
    // No matching namespace
    if (componentVersionsByName == null)
        return null;
    Map<Version, COMPONENT> versions = componentVersionsByName.get(id.getName());
    // No versions of this component
    if (versions == null)
        return null;
    Version version = findBestMatch(id.getVersionSpecification(), versions.keySet());
    return versions.get(version);
}
Also used : Version(com.yahoo.component.Version) ImmutableMap(com.google.common.collect.ImmutableMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 2 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class DomAdminV4Builder method doBuildAdmin.

@Override
protected void doBuildAdmin(Admin admin, Element w3cAdminElement) {
    ModelElement adminElement = new ModelElement(w3cAdminElement);
    admin.addConfigservers(getConfigServersFromSpec(admin));
    Version version = context.getDeployState().getWantedNodeVespaVersion();
    // Note: These two elements only exists in admin version 4.0
    // This build handles admin version 3.0 by ignoring its content (as the content is not useful)
    Optional<NodesSpecification> requestedSlobroks = NodesSpecification.optionalDedicatedFromParent(adminElement.getChild("slobroks"), version);
    Optional<NodesSpecification> requestedLogservers = NodesSpecification.optionalDedicatedFromParent(adminElement.getChild("logservers"), version);
    assignSlobroks(requestedSlobroks.orElse(NodesSpecification.nonDedicated(3, version)), admin);
    assignLogserver(requestedLogservers.orElse(NodesSpecification.nonDedicated(1, version)), admin);
    addLogForwarders(adminElement.getChild("logforwarding"), admin);
}
Also used : Version(com.yahoo.component.Version)

Example 3 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class ApplicationDeployTest method createAppPkg.

public FilesApplicationPackage createAppPkg(String appPkg, boolean validateXml) throws IOException {
    final FilesApplicationPackage filesApplicationPackage = FilesApplicationPackage.fromFile(new File(appPkg));
    if (validateXml) {
        ApplicationPackageXmlFilesValidator validator = ApplicationPackageXmlFilesValidator.create(new File(appPkg), new Version(6));
        validator.checkApplication();
        validator.checkIncludedDirs(filesApplicationPackage);
    }
    return filesApplicationPackage;
}
Also used : Version(com.yahoo.component.Version) JarFile(java.util.jar.JarFile) File(java.io.File)

Example 4 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class ClusterControllerTestCase method createVespaModel.

private VespaModel createVespaModel(String servicesXml) throws IOException, SAXException {
    VespaModel model = new VespaModel(new MockApplicationPackage.Builder().withServices(servicesXml).withSearchDefinitions(sds).build());
    SimpleApplicationValidator.checkServices(new StringReader(servicesXml), new Version(6));
    return model;
}
Also used : Version(com.yahoo.component.Version) VespaModel(com.yahoo.vespa.model.VespaModel) StringReader(java.io.StringReader)

Example 5 with Version

use of com.yahoo.component.Version in project vespa by vespa-engine.

the class VespaModelCreatorWithMockPkg method create.

public VespaModel create(boolean validate, DeployState deployState, ConfigModelRegistry configModelRegistry) {
    try {
        this.deployState = deployState;
        VespaModel model = new VespaModel(configModelRegistry, deployState);
        Version vespaVersion = new Version(6);
        if (validate) {
            SchemaValidators validators = new SchemaValidators(vespaVersion);
            try {
                if (appPkg.getHosts() != null) {
                    validators.hostsXmlValidator().validate(appPkg.getHosts());
                }
                if (appPkg.getDeployment().isPresent()) {
                    validators.deploymentXmlValidator().validate(appPkg.getDeployment().get());
                }
                validators.servicesXmlValidator().validate(appPkg.getServices());
            } catch (Exception e) {
                System.err.println(e.getClass());
                throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
            }
            // Validate, but without checking configSources or routing (routing
            // is constructed in a special way and cannot always be validated in
            // this step for unit tests)
            configChangeActions = Validation.validate(model, false, false, deployState);
        }
        return model;
    } catch (Exception e) {
        e.printStackTrace();
        throw e instanceof RuntimeException ? (RuntimeException) e : new RuntimeException(e);
    }
}
Also used : Version(com.yahoo.component.Version) SchemaValidators(com.yahoo.config.model.application.provider.SchemaValidators) VespaModel(com.yahoo.vespa.model.VespaModel)

Aggregations

Version (com.yahoo.component.Version)83 Test (org.junit.Test)46 Application (com.yahoo.vespa.hosted.controller.Application)32 JobType.systemTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.systemTest)30 ApplicationPackage (com.yahoo.vespa.hosted.controller.application.ApplicationPackage)25 JobType.stagingTest (com.yahoo.vespa.hosted.controller.application.DeploymentJobs.JobType.stagingTest)25 DeploymentTester (com.yahoo.vespa.hosted.controller.deployment.DeploymentTester)24 VespaVersion (com.yahoo.vespa.hosted.controller.versions.VespaVersion)22 ApplicationPackageBuilder (com.yahoo.vespa.hosted.controller.deployment.ApplicationPackageBuilder)17 ApplicationVersion (com.yahoo.vespa.hosted.controller.application.ApplicationVersion)15 ApplicationId (com.yahoo.config.provision.ApplicationId)11 Collections (java.util.Collections)11 List (java.util.List)11 Deployment (com.yahoo.vespa.hosted.controller.application.Deployment)10 Optional (java.util.Optional)10 Slime (com.yahoo.slime.Slime)9 Map (java.util.Map)9 ControllerTester (com.yahoo.vespa.hosted.controller.ControllerTester)7 ZoneId (com.yahoo.vespa.hosted.controller.api.integration.zone.ZoneId)7 URI (java.net.URI)7