diff options
10 files changed, 148 insertions, 145 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index b437e961104..eb268546580 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -90,6 +90,7 @@ import java.util.stream.Collectors; import static com.yahoo.config.model.api.container.ContainerServiceType.CLUSTERCONTROLLER_CONTAINER; import static com.yahoo.config.model.api.container.ContainerServiceType.CONTAINER; import static com.yahoo.config.model.api.container.ContainerServiceType.LOGSERVER_CONTAINER; +import static com.yahoo.vespa.curator.Curator.CompletionWaiter; import static com.yahoo.vespa.config.server.filedistribution.FileDistributionUtil.getFileReferencesOnDisk; import static com.yahoo.vespa.config.server.tenant.TenantRepository.HOSTED_VESPA_TENANT; import static com.yahoo.yolean.Exceptions.uncheck; @@ -344,6 +345,54 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye return Deployment.prepared(session, this, hostProvisioner, tenant, timeout, clock, false); } + public Transaction deactivateCurrentActivateNew(Session active, LocalSession prepared, boolean ignoreStaleSessionFailure) { + SessionRepository sessionRepository = tenantRepository.getTenant(prepared.getTenantName()).getSessionRepository(); + Transaction transaction = sessionRepository.createActivateTransaction(prepared); + if (active != null) { + checkIfActiveHasChanged(prepared, active, ignoreStaleSessionFailure); + checkIfActiveIsNewerThanSessionToBeActivated(prepared.getSessionId(), active.getSessionId()); + transaction.add(active.createDeactivateTransaction().operations()); + } + return transaction; + } + + static void checkIfActiveHasChanged(LocalSession session, Session currentActiveSession, boolean ignoreStaleSessionFailure) { + long activeSessionAtCreate = session.getActiveSessionAtCreate(); + log.log(Level.FINE, currentActiveSession.logPre() + "active session id at create time=" + activeSessionAtCreate); + if (activeSessionAtCreate == 0) return; // No active session at create + + long sessionId = session.getSessionId(); + long currentActiveSessionSessionId = currentActiveSession.getSessionId(); + log.log(Level.FINE, currentActiveSession.logPre() + "sessionId=" + sessionId + + ", current active session=" + currentActiveSessionSessionId); + if (currentActiveSession.isNewerThan(activeSessionAtCreate) && + currentActiveSessionSessionId != sessionId) { + String errMsg = currentActiveSession.logPre() + "Cannot activate session " + + sessionId + " because the currently active session (" + + currentActiveSessionSessionId + ") has changed since session " + sessionId + + " was created (was " + activeSessionAtCreate + " at creation time)"; + if (ignoreStaleSessionFailure) { + log.warning(errMsg + " (Continuing because of force.)"); + } else { + throw new ActivationConflictException(errMsg); + } + } + } + + private static boolean isValidSession(Session session) { + return session != null; + } + + // As of now, config generation is based on session id, and config generation must be a monotonically + // increasing number + static void checkIfActiveIsNewerThanSessionToBeActivated(long sessionId, long currentActiveSessionId) { + if (sessionId < currentActiveSessionId) { + throw new ActivationConflictException("It is not possible to activate session " + sessionId + + ", because it is older than current active session (" + + currentActiveSessionId + ")"); + } + } + // ---------------- Application operations ---------------------------------------------------------------- /** @@ -605,6 +654,17 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye // ---------------- Session operations ---------------------------------------------------------------- + + + public CompletionWaiter activate(LocalSession session, Session previousActiveSession, ApplicationId applicationId, boolean ignoreSessionStaleFailure) { + CompletionWaiter waiter = session.getSessionZooKeeperClient().createActiveWaiter(); + NestedTransaction transaction = new NestedTransaction(); + transaction.add(deactivateCurrentActivateNew(previousActiveSession, session, ignoreSessionStaleFailure)); + hostProvisioner.ifPresent(provisioner -> provisioner.activate(transaction, applicationId, session.getAllocatedHosts().getHosts())); + transaction.commit(); + return waiter; + } + /** * Gets the active Session for the given application id. * diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java index 01a95e8ecdd..8c2e6027691 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployment.java @@ -9,9 +9,6 @@ import com.yahoo.config.provision.DockerImage; import com.yahoo.config.provision.HostFilter; import com.yahoo.config.provision.Provisioner; import java.util.logging.Level; -import com.yahoo.transaction.NestedTransaction; -import com.yahoo.transaction.Transaction; -import com.yahoo.vespa.config.server.ActivationConflictException; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.ApplicationRepository.ActionTimer; import com.yahoo.vespa.config.server.TimeoutBudget; @@ -145,11 +142,7 @@ public class Deployment implements com.yahoo.config.provision.Deployment { CompletionWaiter waiter; try (Lock lock = tenant.getApplicationRepo().lock(applicationId)) { previousActiveSession = applicationRepository.getActiveSession(applicationId); - waiter = session.createActiveWaiter(); - NestedTransaction transaction = new NestedTransaction(); - transaction.add(deactivateCurrentActivateNew(previousActiveSession, session, ignoreSessionStaleFailure)); - hostProvisioner.ifPresent(provisioner -> provisioner.activate(transaction, applicationId, session.getAllocatedHosts().getHosts())); - transaction.commit(); + waiter = applicationRepository.activate(session, previousActiveSession, applicationId, ignoreSessionStaleFailure); } catch (RuntimeException e) { throw e; @@ -189,51 +182,4 @@ public class Deployment implements com.yahoo.config.provision.Deployment { } } - private static Transaction deactivateCurrentActivateNew(Session active, LocalSession prepared, boolean ignoreStaleSessionFailure) { - Transaction transaction = prepared.createActivateTransaction(); - if (isValidSession(active)) { - checkIfActiveHasChanged(prepared, active, ignoreStaleSessionFailure); - checkIfActiveIsNewerThanSessionToBeActivated(prepared.getSessionId(), active.getSessionId()); - transaction.add(active.createDeactivateTransaction().operations()); - } - return transaction; - } - - private static boolean isValidSession(Session session) { - return session != null; - } - - private static void checkIfActiveHasChanged(LocalSession session, Session currentActiveSession, boolean ignoreStaleSessionFailure) { - long activeSessionAtCreate = session.getActiveSessionAtCreate(); - log.log(Level.FINE, currentActiveSession.logPre() + "active session id at create time=" + activeSessionAtCreate); - if (activeSessionAtCreate == 0) return; // No active session at create - - long sessionId = session.getSessionId(); - long currentActiveSessionSessionId = currentActiveSession.getSessionId(); - log.log(Level.FINE, currentActiveSession.logPre() + "sessionId=" + sessionId + - ", current active session=" + currentActiveSessionSessionId); - if (currentActiveSession.isNewerThan(activeSessionAtCreate) && - currentActiveSessionSessionId != sessionId) { - String errMsg = currentActiveSession.logPre() + "Cannot activate session " + - sessionId + " because the currently active session (" + - currentActiveSessionSessionId + ") has changed since session " + sessionId + - " was created (was " + activeSessionAtCreate + " at creation time)"; - if (ignoreStaleSessionFailure) { - log.warning(errMsg + " (Continuing because of force.)"); - } else { - throw new ActivationConflictException(errMsg); - } - } - } - - // As of now, config generation is based on session id, and config generation must be a monotonically - // increasing number - private static void checkIfActiveIsNewerThanSessionToBeActivated(long sessionId, long currentActiveSessionId) { - if (sessionId < currentActiveSessionId) { - throw new ActivationConflictException("It is not possible to activate session " + sessionId + - ", because it is older than current active session (" + - currentActiveSessionId + ")"); - } - } - } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java index 96324ea4320..f842578b657 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSession.java @@ -1,15 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; -import com.yahoo.config.application.api.ApplicationFile; -import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.provision.TenantName; -import com.yahoo.path.Path; -import com.yahoo.transaction.Transaction; -import com.yahoo.vespa.config.server.application.TenantApplications; - -import static com.yahoo.vespa.curator.Curator.CompletionWaiter; /** * A LocalSession is a session that has been created locally on this configserver. A local session can be edited and @@ -22,65 +15,14 @@ import static com.yahoo.vespa.curator.Curator.CompletionWaiter; // TODO: Separate the "application store" and "session" aspects - the latter belongs in the HTTP layer -bratseth public class LocalSession extends Session { - protected final ApplicationPackage applicationPackage; - private final TenantApplications applicationRepo; - /** * Creates a session. This involves loading the application, validating it and distributing it. * * @param sessionId The session id for this session. */ public LocalSession(TenantName tenant, long sessionId, ApplicationPackage applicationPackage, - SessionZooKeeperClient sessionZooKeeperClient, - TenantApplications applicationRepo) { - super(tenant, sessionId, sessionZooKeeperClient); - this.applicationPackage = applicationPackage; - this.applicationRepo = applicationRepo; - } - - public ApplicationFile getApplicationFile(Path relativePath, Mode mode) { - if (mode.equals(Mode.WRITE)) { - markSessionEdited(); - } - return applicationPackage.getFile(relativePath); - } - - void setPrepared() { - setStatus(Session.Status.PREPARE); - } - - private Transaction createSetStatusTransaction(Status status) { - return sessionZooKeeperClient.createWriteStatusTransaction(status); - } - - private void setStatus(Session.Status newStatus) { - sessionZooKeeperClient.writeStatus(newStatus); - } - - public CompletionWaiter createActiveWaiter() { - return sessionZooKeeperClient.createActiveWaiter(); - } - - public Transaction createActivateTransaction() { - Transaction transaction = createSetStatusTransaction(Status.ACTIVATE); - transaction.add(applicationRepo.createPutTransaction(sessionZooKeeperClient.readApplicationId(), getSessionId()).operations()); - return transaction; + SessionZooKeeperClient sessionZooKeeperClient) { + super(tenant, sessionId, sessionZooKeeperClient, applicationPackage); } - private void markSessionEdited() { - setStatus(Session.Status.NEW); - } - - public long getActiveSessionAtCreate() { - return applicationPackage.getMetaData().getPreviousActiveGeneration(); - } - - public enum Mode { - READ, WRITE - } - - public ApplicationMetaData getMetaData() { return applicationPackage.getMetaData(); } - - public ApplicationPackage getApplicationPackage() { return applicationPackage; } - } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java index 9677c7cf20e..013daa86767 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java @@ -1,7 +1,6 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.session; -import com.yahoo.config.application.api.ApplicationMetaData; import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.TenantName; @@ -118,8 +117,4 @@ public class RemoteSession extends Session { transaction.close(); } - public ApplicationMetaData getMetaData() { - return sessionZooKeeperClient.loadApplicationPackage().getMetaData(); - } - } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java index a6818d1e43f..0fc85b5e51a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/Session.java @@ -3,11 +3,15 @@ package com.yahoo.vespa.config.server.session; import com.yahoo.component.Version; import com.yahoo.config.FileReference; +import com.yahoo.config.application.api.ApplicationFile; +import com.yahoo.config.application.api.ApplicationMetaData; +import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.AthenzDomain; import com.yahoo.config.provision.DockerImage; import com.yahoo.config.provision.TenantName; +import com.yahoo.path.Path; import com.yahoo.transaction.Transaction; import com.yahoo.vespa.config.server.tenant.TenantRepository; @@ -27,13 +31,24 @@ public abstract class Session implements Comparable<Session> { private final long sessionId; protected final TenantName tenant; protected final SessionZooKeeperClient sessionZooKeeperClient; + protected final Optional<ApplicationPackage> applicationPackage; protected Session(TenantName tenant, long sessionId, SessionZooKeeperClient sessionZooKeeperClient) { this.tenant = tenant; this.sessionId = sessionId; this.sessionZooKeeperClient = sessionZooKeeperClient; + this.applicationPackage = Optional.empty(); } + protected Session(TenantName tenant, long sessionId, SessionZooKeeperClient sessionZooKeeperClient, + ApplicationPackage applicationPackage) { + this.tenant = tenant; + this.sessionId = sessionId; + this.sessionZooKeeperClient = sessionZooKeeperClient; + this.applicationPackage = Optional.of(applicationPackage); + } + + public final long getSessionId() { return sessionId; } @@ -42,11 +57,19 @@ public abstract class Session implements Comparable<Session> { return sessionZooKeeperClient.readStatus(); } + public SessionZooKeeperClient getSessionZooKeeperClient() { + return sessionZooKeeperClient; + } + @Override public String toString() { return "Session,id=" + sessionId; } + public long getActiveSessionAtCreate() { + return getMetaData().getPreviousActiveGeneration(); + } + /** * The status of this session. */ @@ -135,6 +158,31 @@ public abstract class Session implements Comparable<Session> { // Note: Assumes monotonically increasing session ids public boolean isNewerThan(long sessionId) { return getSessionId() > sessionId; } + public ApplicationMetaData getMetaData() { + return applicationPackage.isPresent() + ? applicationPackage.get().getMetaData() + : sessionZooKeeperClient.loadApplicationPackage().getMetaData(); + } + + public ApplicationPackage getApplicationPackage() { + return applicationPackage.orElseThrow(() -> new RuntimeException("No application package found for " + this)); + } + + public ApplicationFile getApplicationFile(Path relativePath, LocalSession.Mode mode) { + if (mode.equals(Session.Mode.WRITE)) { + markSessionEdited(); + } + return getApplicationPackage().getFile(relativePath); + } + + private void markSessionEdited() { + setStatus(Session.Status.NEW); + } + + void setStatus(Session.Status newStatus) { + sessionZooKeeperClient.writeStatus(newStatus); + } + @Override public int compareTo(Session rhs) { Long lhsId = getSessionId(); @@ -142,4 +190,8 @@ public abstract class Session implements Comparable<Session> { return lhsId.compareTo(rhsId); } + public enum Mode { + READ, WRITE + } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java index dccb4aa42c3..b38d90d470f 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java @@ -165,7 +165,7 @@ public class SessionRepository { getSessionAppDir(sessionId), session.getApplicationPackage(), sessionZooKeeperClient) .getConfigChangeActions(); - session.setPrepared(); + setPrepared(session); waiter.awaitCompletion(params.getTimeoutBudget().timeLeft()); return actions; } @@ -488,7 +488,7 @@ public class SessionRepository { SessionZooKeeperClient sessionZKClient = createSessionZooKeeperClient(sessionId); sessionZKClient.createNewSession(clock.instant()); Curator.CompletionWaiter waiter = sessionZKClient.getUploadWaiter(); - LocalSession session = new LocalSession(tenantName, sessionId, applicationPackage, sessionZKClient, applicationRepo); + LocalSession session = new LocalSession(tenantName, sessionId, applicationPackage, sessionZKClient); waiter.awaitCompletion(timeoutBudget.timeLeft()); return session; } @@ -546,7 +546,7 @@ public class SessionRepository { ApplicationPackage applicationPackage = createApplicationPackage(applicationFile, applicationId, sessionId, currentlyActiveSessionId, false); SessionZooKeeperClient sessionZooKeeperClient = createSessionZooKeeperClient(sessionId); - return new LocalSession(tenantName, sessionId, applicationPackage, sessionZooKeeperClient, applicationRepo); + return new LocalSession(tenantName, sessionId, applicationPackage, sessionZooKeeperClient); } catch (Exception e) { throw new RuntimeException("Error creating session " + sessionId, e); } @@ -595,7 +595,7 @@ public class SessionRepository { File sessionDir = getAndValidateExistingSessionAppDir(sessionId); ApplicationPackage applicationPackage = FilesApplicationPackage.fromFile(sessionDir); SessionZooKeeperClient sessionZKClient = createSessionZooKeeperClient(sessionId); - return new LocalSession(tenantName, sessionId, applicationPackage, sessionZKClient, applicationRepo); + return new LocalSession(tenantName, sessionId, applicationPackage, sessionZKClient); } /** @@ -696,6 +696,20 @@ public class SessionRepository { return locksPath.append(String.valueOf(sessionId)); } + public Transaction createActivateTransaction(Session session) { + Transaction transaction = createSetStatusTransaction(session, Session.Status.ACTIVATE); + transaction.add(applicationRepo.createPutTransaction(session.sessionZooKeeperClient.readApplicationId(), session.getSessionId()).operations()); + return transaction; + } + + private Transaction createSetStatusTransaction(Session session, Session.Status status) { + return session.sessionZooKeeperClient.createWriteStatusTransaction(status); + } + + void setPrepared(Session session) { + session.setStatus(Session.Status.PREPARE); + } + private static class FileTransaction extends AbstractTransaction { public static FileTransaction from(FileOperation operation) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java index 1b9527f4376..27440b3765b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionZooKeeperClient.java @@ -53,7 +53,8 @@ public class SessionZooKeeperClient { private final String serverId; // hostname private final Optional<NodeFlavors> nodeFlavors; - // Only for testing when cache loader does not need cache entries. + // Only for testing + // TODO: Remove, use the constructor below public SessionZooKeeperClient(Curator curator, Path sessionPath) { this(curator, ConfigCurator.create(curator), sessionPath, "1", Optional.empty()); } @@ -93,7 +94,7 @@ public class SessionZooKeeperClient { return createCompletionWaiter(PREPARE_BARRIER); } - Curator.CompletionWaiter createActiveWaiter() { + public Curator.CompletionWaiter createActiveWaiter() { return createCompletionWaiter(ACTIVE_BARRIER); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index 50a8cac2837..e42fb78f595 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -325,6 +325,10 @@ public class ApplicationRepositoryTest { { PrepareResult prepareResult = deployApp(testApp); + + assertNotNull(applicationRepository.getActiveSession(applicationId())); + assertNotNull(sessionRepository.getLocalSession(prepareResult.sessionId())); + try { applicationRepository.delete(applicationId(), Duration.ZERO); fail("Should have gotten an exception"); @@ -334,8 +338,7 @@ public class ApplicationRepositoryTest { // No active session or remote session (deleted in step above), but an exception was thrown above // A new delete should cleanup and be successful - RemoteSession activeSession = applicationRepository.getActiveSession(applicationId()); - assertNull(activeSession); + assertNull(applicationRepository.getActiveSession(applicationId())); assertNull(sessionRepository.getLocalSession(prepareResult.sessionId())); assertTrue(applicationRepository.delete(applicationId())); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java index d2f09b802da..c6d241ee534 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java @@ -12,7 +12,7 @@ import com.yahoo.vespa.config.server.application.CompressedApplicationInputStrea import com.yahoo.vespa.config.server.application.OrchestratorMock; import com.yahoo.vespa.config.server.http.HttpErrorResponse; import com.yahoo.vespa.config.server.http.SessionHandlerTest; -import com.yahoo.vespa.config.server.session.LocalSession; +import com.yahoo.vespa.config.server.session.Session; import com.yahoo.vespa.config.server.tenant.TenantRepository; import org.junit.Before; import org.junit.Ignore; @@ -135,7 +135,7 @@ public class SessionCreateHandlerTest extends SessionHandlerTest { public void require_that_handler_unpacks_application() throws IOException { File outFile = CompressedApplicationInputStreamTest.createTarFile(); createHandler().handle(post(outFile)); - ApplicationFile applicationFile = applicationRepository.getApplicationFileFromSession(tenant, 2, "services.xml", LocalSession.Mode.READ); + ApplicationFile applicationFile = applicationRepository.getApplicationFileFromSession(tenant, 2, "services.xml", Session.Mode.READ); assertTrue(applicationFile.exists()); } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java index a2ef6aeb578..cf01c9b6713 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionTest.java @@ -77,31 +77,21 @@ public class LocalSessionTest { } @Test - public void require_that_session_status_is_updated() throws Exception { - LocalSession session = createSession(TenantName.defaultName(), 3); - assertThat(session.getStatus(), is(Session.Status.NEW)); - doPrepare(session); - assertThat(session.getStatus(), is(Session.Status.PREPARE)); - session.createActivateTransaction().commit(); - assertThat(session.getStatus(), is(Session.Status.ACTIVATE)); - } - - @Test public void require_that_marking_session_modified_changes_status_to_new() throws Exception { LocalSession session = createSession(TenantName.defaultName(), 3); doPrepare(session); assertThat(session.getStatus(), is(Session.Status.PREPARE)); - session.getApplicationFile(Path.createRoot(), LocalSession.Mode.READ); + session.getApplicationFile(Path.createRoot(), Session.Mode.READ); assertThat(session.getStatus(), is(Session.Status.PREPARE)); - session.getApplicationFile(Path.createRoot(), LocalSession.Mode.WRITE); + session.getApplicationFile(Path.createRoot(), Session.Mode.WRITE); assertThat(session.getStatus(), is(Session.Status.NEW)); } @Test public void require_that_application_file_can_be_fetched() throws Exception { LocalSession session = createSession(TenantName.defaultName(), 3); - ApplicationFile f1 = session.getApplicationFile(Path.fromString("services.xml"), LocalSession.Mode.READ); - ApplicationFile f2 = session.getApplicationFile(Path.fromString("services2.xml"), LocalSession.Mode.READ); + ApplicationFile f1 = session.getApplicationFile(Path.fromString("services.xml"), Session.Mode.READ); + ApplicationFile f2 = session.getApplicationFile(Path.fromString("services2.xml"), Session.Mode.READ); assertTrue(f1.exists()); assertFalse(f2.exists()); } @@ -127,7 +117,7 @@ public class LocalSessionTest { zkClient.write(Collections.singletonMap(new Version(0, 0, 0), new MockFileRegistry())); TenantApplications applications = tenantRepository.getTenant(tenantName).getApplicationRepo(); applications.createApplication(applicationId()); - LocalSession session = new LocalSession(tenant, sessionId, FilesApplicationPackage.fromFile(testApp), zkc, applications); + LocalSession session = new LocalSession(tenant, sessionId, FilesApplicationPackage.fromFile(testApp), zkc); session.setApplicationId(applicationId()); return session; } |