Search in sources :

Example 1 with LocalSessionRepo

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;
}
Also used : Tenant(com.yahoo.vespa.config.server.tenant.Tenant) LocalSessionRepo(com.yahoo.vespa.config.server.session.LocalSessionRepo) LocalSession(com.yahoo.vespa.config.server.session.LocalSession) NestedTransaction(com.yahoo.transaction.NestedTransaction) TenantApplications(com.yahoo.vespa.config.server.application.TenantApplications) Rotations(com.yahoo.vespa.config.server.tenant.Rotations)

Example 2 with LocalSessionRepo

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

Example 3 with LocalSessionRepo

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\"";
}
Also used : MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) LocalSessionRepo(com.yahoo.vespa.config.server.session.LocalSessionRepo) Before(org.junit.Before)

Example 4 with LocalSessionRepo

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

Example 5 with LocalSessionRepo

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;
}
Also used : RemoteSessionRepo(com.yahoo.vespa.config.server.session.RemoteSessionRepo) MemoryTenantApplications(com.yahoo.vespa.config.server.application.MemoryTenantApplications) LocalSessionRepo(com.yahoo.vespa.config.server.session.LocalSessionRepo) TenantBuilder(com.yahoo.vespa.config.server.tenant.TenantBuilder)

Aggregations

LocalSessionRepo (com.yahoo.vespa.config.server.session.LocalSessionRepo)6 MemoryTenantApplications (com.yahoo.vespa.config.server.application.MemoryTenantApplications)3 LocalSession (com.yahoo.vespa.config.server.session.LocalSession)3 RemoteSessionRepo (com.yahoo.vespa.config.server.session.RemoteSessionRepo)2 SessionFactory (com.yahoo.vespa.config.server.session.SessionFactory)2 Before (org.junit.Before)2 NullConfigModelRegistry (com.yahoo.config.model.NullConfigModelRegistry)1 NestedTransaction (com.yahoo.transaction.NestedTransaction)1 TestComponentRegistry (com.yahoo.vespa.config.server.TestComponentRegistry)1 TenantApplications (com.yahoo.vespa.config.server.application.TenantApplications)1 ModelFactoryRegistry (com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry)1 Rotations (com.yahoo.vespa.config.server.tenant.Rotations)1 Tenant (com.yahoo.vespa.config.server.tenant.Tenant)1 TenantBuilder (com.yahoo.vespa.config.server.tenant.TenantBuilder)1 MockCurator (com.yahoo.vespa.curator.mock.MockCurator)1 VespaModelFactory (com.yahoo.vespa.model.VespaModelFactory)1