use of com.yahoo.vespa.config.server.ServerCache in project vespa by vespa-engine.
the class ServerCacheLoader method loadConfigDefinitions.
/**
* Reads config definitions from zookeeper, parses them and puts both ConfigDefinition instances
* and payload (raw config definition) into cache.
*
* @return the populated cache.
*/
public ServerCache loadConfigDefinitions() {
ServerCache cache = new ServerCache();
try {
log.log(LogLevel.DEBUG, "Getting config definitions");
loadGlobalConfigDefinitions(cache);
loadConfigDefinitionsFromPath(cache, path.append(ConfigCurator.USER_DEFCONFIGS_ZK_SUBPATH).getAbsolute());
log.log(LogLevel.DEBUG, "Done getting config definitions");
} catch (Exception e) {
throw new IllegalStateException("Could not load config definitions for " + path, e);
}
return cache;
}
use of com.yahoo.vespa.config.server.ServerCache in project vespa by vespa-engine.
the class ActivatedModelsBuilder method buildModelVersion.
@Override
protected Application buildModelVersion(ModelFactory modelFactory, ApplicationPackage applicationPackage, ApplicationId applicationId, com.yahoo.component.Version wantedNodeVespaVersion, // Ignored since we have this in the app package for activated models
Optional<AllocatedHosts> ignored, Instant now) {
log.log(LogLevel.DEBUG, String.format("Loading model version %s for session %s application %s", modelFactory.getVersion(), appGeneration, applicationId));
ServerCache cache = zkClient.loadServerCache();
ModelContext modelContext = new ModelContextImpl(applicationPackage, Optional.empty(), permanentApplicationPackage.get().applicationPackage(), logger, configDefinitionRepo, getForVersionOrLatest(applicationPackage.getFileRegistryMap(), modelFactory.getVersion()).orElse(new MockFileRegistry()), createStaticProvisioner(applicationPackage.getAllocatedHosts()), createModelContextProperties(applicationId), Optional.empty(), new com.yahoo.component.Version(modelFactory.getVersion().toString()), wantedNodeVespaVersion);
MetricUpdater applicationMetricUpdater = metrics.getOrCreateMetricUpdater(Metrics.createDimensions(applicationId));
return new Application(modelFactory.createModel(modelContext), cache, appGeneration, modelFactory.getVersion(), applicationMetricUpdater, applicationId);
}
use of com.yahoo.vespa.config.server.ServerCache in project vespa by vespa-engine.
the class ApplicationTest method testThatApplicationIsInitialized.
@Test
public void testThatApplicationIsInitialized() throws IOException, SAXException {
ApplicationId appId = ApplicationId.from(TenantName.defaultName(), ApplicationName.from("foobar"), InstanceName.defaultName());
ServerCache cache = new ServerCache();
Version vespaVersion = Version.fromIntValues(1, 2, 3);
Application app = new Application(new ModelStub(), cache, 1337, vespaVersion, MetricUpdater.createTestUpdater(), appId);
assertThat(app.getApplicationGeneration(), is(1337l));
assertNotNull(app.getModel());
assertThat(app.getCache(), is(cache));
assertThat(app.getId().application().value(), is("foobar"));
assertThat(app.getVespaVersion(), is(vespaVersion));
assertThat(app.toString(), is("application 'foobar', generation 1337, vespa version 1.2.3"));
}
use of com.yahoo.vespa.config.server.ServerCache in project vespa by vespa-engine.
the class ApplicationTest method setupHandler.
@Before
public void setupHandler() throws IOException, SAXException {
File testApp = new File("src/test/apps/app");
ServerCache cache = createCacheAndAddContent();
VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(testApp));
final ApplicationId applicationId = new ApplicationId.Builder().tenant("foo").applicationName("foo").build();
handler = new Application(model, cache, 1, Version.fromIntValues(1, 2, 3), new MetricUpdater(Metrics.createTestMetrics(), Metrics.createDimensions(applicationId)), applicationId);
}
use of com.yahoo.vespa.config.server.ServerCache in project vespa by vespa-engine.
the class TenantRequestHandlerTest method testListConfigs.
@Test
public void testListConfigs() throws IOException, SAXException {
assertdefaultAppNotFound();
/*assertTrue(server.allConfigIds(ApplicationId.defaultId()).isEmpty());
assertTrue(server.allConfigsProduced(ApplicationId.defaultId()).isEmpty());
assertTrue(server.listConfigs(ApplicationId.defaultId(), false).isEmpty());
assertTrue(server.listConfigs(ApplicationId.defaultId(), true).isEmpty());*/
VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(new File("src/test/apps/app")));
server.reloadConfig(ApplicationSet.fromSingle(new Application(model, new ServerCache(), 1, vespaVersion, MetricUpdater.createTestUpdater(), ApplicationId.defaultId())));
Set<ConfigKey<?>> configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), false);
assertTrue(configNames.contains(new ConfigKey<>("sentinel", "hosts", "cloud.config")));
// for (ConfigKey<?> ck : configNames) {
// assertTrue(!"".equals(ck.getConfigId()));
// }
configNames = server.listConfigs(ApplicationId.defaultId(), Optional.of(vespaVersion), true);
System.out.println(configNames);
assertTrue(configNames.contains(new ConfigKey<>("feeder", "jdisc", "vespaclient.config")));
assertTrue(configNames.contains(new ConfigKey<>("documentmanager", "jdisc", "document.config")));
assertTrue(configNames.contains(new ConfigKey<>("documentmanager", "", "document.config")));
assertTrue(configNames.contains(new ConfigKey<>("documenttypes", "", "document")));
assertTrue(configNames.contains(new ConfigKey<>("documentmanager", "jdisc", "document.config")));
assertTrue(configNames.contains(new ConfigKey<>("health-monitor", "jdisc", "container.jdisc.config")));
assertTrue(configNames.contains(new ConfigKey<>("specific", "jdisc", "project")));
}
Aggregations