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