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);
}
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);
}
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;
}
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;
}
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);
}
}
Aggregations