use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class StorageNodeTest method getConfig.
private StorDevicesConfig getConfig(boolean useVdsEngine) {
String vdsConfig = useVdsEngine ? " <engine>" + " <vds/>" + " </engine>" : "";
String servicesXml = "<?xml version='1.0' encoding='utf-8' ?>" + "<services version='1.0'>" + " <admin version='2.0'>" + " <adminserver hostalias='node0'/>" + " </admin>" + " <content version='1.0' id='zoo'>" + " <redundancy>1</redundancy>" + " <nodes count='1' />" + " <documents>" + " <document type='type1' mode='streaming' />" + " </documents>" + vdsConfig + " </content>" + "</services>";
List<String> searchDefinitions = ApplicationPackageUtils.generateSearchDefinition("type1");
VespaModelCreatorWithMockPkg modelCreator = new VespaModelCreatorWithMockPkg(null, servicesXml, searchDefinitions);
ApplicationPackage appPkg = modelCreator.appPkg;
boolean failOnOutOfCapacity = true;
InMemoryProvisioner provisioner = new InMemoryProvisioner(failOnOutOfCapacity, "host1.yahoo.com", "host2.yahoo.com");
DeployProperties.Builder builder = new DeployProperties.Builder();
DeployProperties properties = builder.hostedVespa(true).build();
DeployState deployState = new DeployState.Builder().applicationPackage(appPkg).modelHostProvisioner(provisioner).properties(properties).build(true);
VespaModel model = modelCreator.create(true, deployState);
return model.getConfig(StorDevicesConfig.class, "zoo/storage/0");
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class ApplicationPreprocessor method run.
public void run() throws IOException, TransformerException, ParserConfigurationException, SAXException {
DeployLogger logger = new BaseDeployLogger();
FilesApplicationPackage.Builder applicationPackageBuilder = new FilesApplicationPackage.Builder(applicationDir);
outputDir.ifPresent(applicationPackageBuilder::preprocessedDir);
ApplicationPackage preprocessed = applicationPackageBuilder.build().preprocess(new Zone(environment.orElse(Environment.defaultEnvironment()), region.orElse(RegionName.defaultName())), logger);
preprocessed.validateXML();
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class FilesApplicationPackageTest method testPreprocessing.
@Test
public void testPreprocessing() throws IOException, TransformerException, ParserConfigurationException, SAXException {
File appDir = temporaryFolder.newFolder();
IOUtils.copyDirectory(new File("src/test/resources/multienvapp"), appDir);
assertTrue(new File(appDir, "services.xml").exists());
assertTrue(new File(appDir, "hosts.xml").exists());
FilesApplicationPackage app = FilesApplicationPackage.fromFile(appDir);
ApplicationPackage processed = app.preprocess(new Zone(Environment.dev, RegionName.defaultName()), new BaseDeployLogger());
assertTrue(new File(appDir, ".preprocessed").exists());
String expectedServices = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><services xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\" version=\"1.0\">\n" + " <admin version=\"2.0\">\n" + " <adminserver hostalias=\"node0\"/>\n" + " </admin>\n" + " <content id=\"foo\" version=\"1.0\">\n" + " <redundancy>1</redundancy>\n" + " <documents>\n" + " <document mode=\"index\" type=\"music.sd\"/>\n" + " </documents>\n" + " <nodes>\n" + " <node distribution-key=\"0\" hostalias=\"node0\"/>\n" + " </nodes>\n" + " </content>\n" + " <jdisc id=\"stateless\" version=\"1.0\">\n" + " <search/>\n" + " <component bundle=\"foobundle\" class=\"MyFoo\" id=\"foo\"/>\n" + " <component bundle=\"foobundle\" class=\"TestBar\" id=\"bar\"/>\n" + " <nodes>\n" + " <node hostalias=\"node0\" baseport=\"5000\"/>\n" + " </nodes>\n" + " </jdisc>\n" + "</services>";
TestBase.assertDocument(expectedServices, processed.getServices());
String expectedHosts = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><hosts xmlns:deploy=\"vespa\" xmlns:preprocess=\"properties\">\n" + " <host name=\"bar.yahoo.com\">\n" + " <alias>node1</alias>\n" + " </host>\n" + "</hosts>";
TestBase.assertDocument(expectedHosts, processed.getHosts());
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class RankingConstantsValidator method validate.
@Override
public void validate(VespaModel model, DeployState deployState) {
ApplicationPackage applicationPackage = deployState.getApplicationPackage();
ExceptionMessageCollector exceptionMessageCollector = new ExceptionMessageCollector("Invalid constant tensor file(s):");
for (SearchDefinition sd : deployState.getSearchDefinitions()) {
for (RankingConstant rc : sd.getSearch().getRankingConstants().values()) {
try {
validateRankingConstant(rc, applicationPackage);
} catch (InvalidConstantTensor | FileNotFoundException ex) {
exceptionMessageCollector.add(ex, rc.getName(), rc.getFileName());
}
}
}
if (exceptionMessageCollector.exceptionsOccurred) {
throw new TensorValidationFailed(exceptionMessageCollector.combinedMessage);
}
}
use of com.yahoo.config.application.api.ApplicationPackage in project vespa by vespa-engine.
the class ConfigModelContextTest method testConfigModelContext.
@Test
public void testConfigModelContext() {
AbstractConfigProducer root = new MockRoot();
String id = "foobar";
ApplicationPackage pkg = new MockApplicationPackage.Builder().withServices("<services version=\"1.0\"><admin version=\"2.0\" /></services>").build();
DeployState deployState = DeployState.createTestState(pkg);
DeployLogger logger = deployState.getDeployLogger();
ConfigModelContext ctx = ConfigModelContext.create(deployState, null, root, id);
assertThat(ctx.getApplicationPackage(), is(pkg));
assertThat(ctx.getProducerId(), is(id));
assertThat(ctx.getParentProducer(), is(root));
assertThat(ctx.getDeployLogger(), is(logger));
ctx = ConfigModelContext.create(null, root, id);
assertThat(ctx.getProducerId(), is(id));
assertThat(ctx.getParentProducer(), is(root));
AbstractConfigProducer newRoot = new MockRoot("bar");
ctx = ctx.withParent(newRoot);
assertThat(ctx.getProducerId(), is(id));
assertThat(ctx.getParentProducer(), is(not(root)));
assertThat(ctx.getParentProducer(), is(newRoot));
}
Aggregations