use of com.yahoo.vespa.config.server.session.LocalSessionRepo in project vespa by vespa-engine.
the class ApplicationRepository method remove.
/**
* Removes a previously deployed application
*
* @return true if the application was found and removed, false if it was not present
* @throws RuntimeException if the remove transaction fails. This method is exception safe.
*/
public boolean remove(ApplicationId applicationId) {
Optional<Tenant> owner = Optional.ofNullable(tenants.getTenant(applicationId.tenant()));
if (!owner.isPresent())
return false;
TenantApplications tenantApplications = owner.get().getApplicationRepo();
if (!tenantApplications.listApplications().contains(applicationId))
return false;
// TODO: Push lookup logic down
long sessionId = tenantApplications.getSessionIdForApplication(applicationId);
LocalSessionRepo localSessionRepo = owner.get().getLocalSessionRepo();
LocalSession session = localSessionRepo.getSession(sessionId);
if (session == null)
return false;
NestedTransaction transaction = new NestedTransaction();
localSessionRepo.removeSession(session.getSessionId(), transaction);
// TODO: Not unit tested
session.delete(transaction);
// TODO: Not unit tested
transaction.add(new Rotations(owner.get().getCurator(), owner.get().getPath()).delete(applicationId));
// (When rotations are updated in zk, we need to redeploy the zone app, on the right config server
// this is done asynchronously in application maintenance by the node repository)
transaction.add(tenantApplications.deleteApplication(applicationId));
hostProvisioner.ifPresent(provisioner -> provisioner.remove(transaction, applicationId));
transaction.onCommitted(() -> log.log(LogLevel.INFO, "Deleted " + applicationId));
transaction.commit();
return true;
}
use of com.yahoo.vespa.config.server.session.LocalSessionRepo in project vespa by vespa-engine.
the class ApplicationRepository method createSessionFromExisting.
public long createSessionFromExisting(Tenant tenant, DeployLogger logger, TimeoutBudget timeoutBudget, ApplicationId applicationId) {
LocalSessionRepo localSessionRepo = tenant.getLocalSessionRepo();
SessionFactory sessionFactory = tenant.getSessionFactory();
LocalSession fromSession = getExistingSession(tenant, applicationId);
LocalSession session = sessionFactory.createSessionFromExisting(fromSession, logger, timeoutBudget);
localSessionRepo.addSession(session);
return session.getSessionId();
}
use of com.yahoo.vespa.config.server.session.LocalSessionRepo in project vespa by vespa-engine.
the class SessionCreateHandlerTest method setupRepo.
@Before
public void setupRepo() throws Exception {
applicationRepo = new MemoryTenantApplications();
localSessionRepo = new LocalSessionRepo(Clock.systemUTC());
pathPrefix = "/application/v2/tenant/" + tenant + "/session/";
createdMessage = " for tenant '" + tenant + "' created.\"";
tenantMessage = ",\"tenant\":\"test\"";
}
use of com.yahoo.vespa.config.server.session.LocalSessionRepo in project vespa by vespa-engine.
the class ApplicationRepository method createSession.
public long createSession(Tenant tenant, TimeoutBudget timeoutBudget, File applicationDirectory, String applicationName) {
LocalSessionRepo localSessionRepo = tenant.getLocalSessionRepo();
SessionFactory sessionFactory = tenant.getSessionFactory();
LocalSession session = sessionFactory.createSession(applicationDirectory, applicationName, timeoutBudget);
localSessionRepo.addSession(session);
return session.getSessionId();
}
use of com.yahoo.vespa.config.server.session.LocalSessionRepo in project vespa by vespa-engine.
the class TestTenantBuilder method createTenant.
public TenantBuilder createTenant(TenantName tenantName) {
MemoryTenantApplications applicationRepo = new MemoryTenantApplications();
TenantBuilder builder = TenantBuilder.create(componentRegistry, tenantName).withSessionFactory(new SessionCreateHandlerTest.MockSessionFactory()).withLocalSessionRepo(new LocalSessionRepo(componentRegistry.getClock())).withRemoteSessionRepo(new RemoteSessionRepo(tenantName)).withApplicationRepo(applicationRepo);
tenantMap.put(tenantName, builder);
return builder;
}
Aggregations