Search in sources :

Example 1 with ServerCache

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;
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache)

Example 2 with ServerCache

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);
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) ModelContext(com.yahoo.config.model.api.ModelContext) MetricUpdater(com.yahoo.vespa.config.server.monitoring.MetricUpdater) ModelContextImpl(com.yahoo.vespa.config.server.deploy.ModelContextImpl) MockFileRegistry(com.yahoo.config.model.application.provider.MockFileRegistry) Application(com.yahoo.vespa.config.server.application.Application)

Example 3 with ServerCache

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"));
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) Version(com.yahoo.config.provision.Version) ApplicationId(com.yahoo.config.provision.ApplicationId) ModelStub(com.yahoo.vespa.config.server.ModelStub) Test(org.junit.Test)

Example 4 with ServerCache

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);
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) MetricUpdater(com.yahoo.vespa.config.server.monitoring.MetricUpdater) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationId(com.yahoo.config.provision.ApplicationId) File(java.io.File) Before(org.junit.Before)

Example 5 with ServerCache

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")));
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) ConfigKey(com.yahoo.vespa.config.ConfigKey) VespaModel(com.yahoo.vespa.model.VespaModel) File(java.io.File) Application(com.yahoo.vespa.config.server.application.Application) Test(org.junit.Test)

Aggregations

ServerCache (com.yahoo.vespa.config.server.ServerCache)9 Application (com.yahoo.vespa.config.server.application.Application)4 VespaModel (com.yahoo.vespa.model.VespaModel)4 Test (org.junit.Test)3 ApplicationId (com.yahoo.config.provision.ApplicationId)2 MetricUpdater (com.yahoo.vespa.config.server.monitoring.MetricUpdater)2 File (java.io.File)2 Before (org.junit.Before)2 Model (com.yahoo.config.model.api.Model)1 ModelContext (com.yahoo.config.model.api.ModelContext)1 MockFileRegistry (com.yahoo.config.model.application.provider.MockFileRegistry)1 Version (com.yahoo.config.provision.Version)1 ConfigDefinitionKey (com.yahoo.vespa.config.ConfigDefinitionKey)1 ConfigKey (com.yahoo.vespa.config.ConfigKey)1 ModelStub (com.yahoo.vespa.config.server.ModelStub)1 ApplicationSet (com.yahoo.vespa.config.server.application.ApplicationSet)1 ModelContextImpl (com.yahoo.vespa.config.server.deploy.ModelContextImpl)1