Search in sources :

Example 1 with ApplicationSet

use of com.yahoo.vespa.config.server.application.ApplicationSet in project vespa by vespa-engine.

the class ApplicationRepository method prepare.

public PrepareResult prepare(Tenant tenant, long sessionId, PrepareParams prepareParams, Instant now) {
    validateThatLocalSessionIsNotActive(tenant, sessionId);
    LocalSession session = getLocalSession(tenant, sessionId);
    ApplicationId applicationId = prepareParams.getApplicationId();
    Optional<ApplicationSet> currentActiveApplicationSet = getCurrentActiveApplicationSet(tenant, applicationId);
    Slime deployLog = createDeployLog();
    DeployLogger logger = new DeployHandlerLogger(deployLog.get().setArray("log"), prepareParams.isVerbose(), applicationId);
    ConfigChangeActions actions = session.prepare(logger, prepareParams, currentActiveApplicationSet, tenant.getPath(), now);
    logConfigChangeActions(actions, logger);
    log.log(LogLevel.INFO, Tenants.logPre(applicationId) + "Session " + sessionId + " prepared successfully. ");
    return new PrepareResult(sessionId, actions, deployLog);
}
Also used : PrepareResult(com.yahoo.vespa.config.server.http.v2.PrepareResult) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) ConfigChangeActions(com.yahoo.vespa.config.server.configchange.ConfigChangeActions) DeployHandlerLogger(com.yahoo.vespa.config.server.deploy.DeployHandlerLogger) DeployLogger(com.yahoo.config.application.api.DeployLogger) SilentDeployLogger(com.yahoo.vespa.config.server.session.SilentDeployLogger) ApplicationId(com.yahoo.config.provision.ApplicationId) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet) Slime(com.yahoo.slime.Slime)

Example 2 with ApplicationSet

use of com.yahoo.vespa.config.server.application.ApplicationSet in project vespa by vespa-engine.

the class ApplicationRepository method getCurrentActiveApplicationSet.

private Optional<ApplicationSet> getCurrentActiveApplicationSet(Tenant tenant, ApplicationId appId) {
    Optional<ApplicationSet> currentActiveApplicationSet = Optional.empty();
    TenantApplications applicationRepo = tenant.getApplicationRepo();
    try {
        long currentActiveSessionId = applicationRepo.getSessionIdForApplication(appId);
        RemoteSession currentActiveSession = getRemoteSession(tenant, currentActiveSessionId);
        if (currentActiveSession != null) {
            currentActiveApplicationSet = Optional.ofNullable(currentActiveSession.ensureApplicationLoaded());
        }
    } catch (IllegalArgumentException e) {
    // Do nothing if we have no currently active session
    }
    return currentActiveApplicationSet;
}
Also used : RemoteSession(com.yahoo.vespa.config.server.session.RemoteSession) TenantApplications(com.yahoo.vespa.config.server.application.TenantApplications) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet)

Example 3 with ApplicationSet

use of com.yahoo.vespa.config.server.application.ApplicationSet in project vespa by vespa-engine.

the class RpcServerTest method testEnabled.

private void testEnabled() throws IOException, SAXException {
    generationCounter.increment();
    Application app = new Application(new VespaModel(MockApplicationPackage.createEmpty()), new ServerCache(), 2l, Version.fromIntValues(1, 2, 3), MetricUpdater.createTestUpdater(), ApplicationId.defaultId());
    ApplicationSet appSet = ApplicationSet.fromSingle(app);
    rpcServer.configActivated(TenantName.defaultName(), appSet);
    ConfigKey<?> key = new ConfigKey<>(LbServicesConfig.class, "*");
    JRTClientConfigRequest clientReq = JRTClientConfigRequestV3.createFromRaw(new RawConfig(key, LbServicesConfig.CONFIG_DEF_MD5), 120_000, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty());
    assertTrue(clientReq.validateParameters());
    performRequest(clientReq.getRequest());
    assertFalse(clientReq.validateResponse());
    assertThat(clientReq.errorCode(), is(ErrorCode.APPLICATION_NOT_LOADED));
    rpcServer.onTenantsLoaded();
    clientReq = JRTClientConfigRequestV3.createFromRaw(new RawConfig(key, LbServicesConfig.CONFIG_DEF_MD5), 120_000, Trace.createDummy(), CompressionType.UNCOMPRESSED, Optional.empty());
    assertTrue(clientReq.validateParameters());
    performRequest(clientReq.getRequest());
    boolean validResponse = clientReq.validateResponse();
    assertTrue(clientReq.errorMessage(), validResponse);
    assertThat(clientReq.errorCode(), is(0));
}
Also used : ServerCache(com.yahoo.vespa.config.server.ServerCache) VespaModel(com.yahoo.vespa.model.VespaModel) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet) Application(com.yahoo.vespa.config.server.application.Application)

Example 4 with ApplicationSet

use of com.yahoo.vespa.config.server.application.ApplicationSet in project vespa by vespa-engine.

the class RemoteSession method makeActive.

public void makeActive(ReloadHandler reloadHandler) {
    Curator.CompletionWaiter waiter = zooKeeperClient.getActiveWaiter();
    log.log(LogLevel.DEBUG, logPre() + "Getting session from repo: " + getSessionId());
    ApplicationSet app = ensureApplicationLoaded();
    log.log(LogLevel.DEBUG, logPre() + "Reloading config for " + app);
    reloadHandler.reloadConfig(app);
    log.log(LogLevel.DEBUG, logPre() + "Notifying " + waiter);
    notifyCompletion(waiter);
    log.log(LogLevel.DEBUG, logPre() + "Session activated: " + app);
}
Also used : Curator(com.yahoo.vespa.curator.Curator) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet)

Example 5 with ApplicationSet

use of com.yahoo.vespa.config.server.application.ApplicationSet in project vespa by vespa-engine.

the class RemoteSessionTest method require_that_applications_are_loaded.

@Test
public void require_that_applications_are_loaded() throws IOException, SAXException {
    RemoteSession session = createSession(3, Arrays.asList(new MockModelFactory(), new VespaModelFactory(new NullConfigModelRegistry())), Clock.systemUTC());
    session.loadPrepared();
    ApplicationSet applicationSet = session.ensureApplicationLoaded();
    assertNotNull(applicationSet);
    assertThat(applicationSet.getApplicationGeneration(), is(3l));
    assertThat(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getId().application().value(), is("foo"));
    assertNotNull(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getModel());
    session.deactivate();
    applicationSet = session.ensureApplicationLoaded();
    assertNotNull(applicationSet);
    assertThat(applicationSet.getApplicationGeneration(), is(3l));
    assertThat(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getId().application().value(), is("foo"));
    assertNotNull(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getModel());
}
Also used : VespaModelFactory(com.yahoo.vespa.model.VespaModelFactory) NullConfigModelRegistry(com.yahoo.config.model.NullConfigModelRegistry) ApplicationSet(com.yahoo.vespa.config.server.application.ApplicationSet) Test(org.junit.Test)

Aggregations

ApplicationSet (com.yahoo.vespa.config.server.application.ApplicationSet)5 DeployLogger (com.yahoo.config.application.api.DeployLogger)1 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)1 ApplicationId (com.yahoo.config.provision.ApplicationId)1 Slime (com.yahoo.slime.Slime)1 ServerCache (com.yahoo.vespa.config.server.ServerCache)1 Application (com.yahoo.vespa.config.server.application.Application)1 TenantApplications (com.yahoo.vespa.config.server.application.TenantApplications)1 ConfigChangeActions (com.yahoo.vespa.config.server.configchange.ConfigChangeActions)1 DeployHandlerLogger (com.yahoo.vespa.config.server.deploy.DeployHandlerLogger)1 PrepareResult (com.yahoo.vespa.config.server.http.v2.PrepareResult)1 LocalSession (com.yahoo.vespa.config.server.session.LocalSession)1 RemoteSession (com.yahoo.vespa.config.server.session.RemoteSession)1 SilentDeployLogger (com.yahoo.vespa.config.server.session.SilentDeployLogger)1 Curator (com.yahoo.vespa.curator.Curator)1 VespaModel (com.yahoo.vespa.model.VespaModel)1 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)1 Test (org.junit.Test)1