aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-10-21 08:25:26 +0200
committerGitHub <noreply@github.com>2020-10-21 08:25:26 +0200
commit0a0dd27fa223bf7a06e03a1760b4c592aae5b136 (patch)
tree4a932487ac3ab2afaa7c3b1e9bd20aaacca43907 /configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
parent33c66735b26b168281d4f515742921ef43392725 (diff)
Revert "Reapply "Merge LocalSession and RemoteSession""
Diffstat (limited to 'configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java61
1 files changed, 61 insertions, 0 deletions
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
new file mode 100644
index 00000000000..de5f1392242
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java
@@ -0,0 +1,61 @@
+// Copyright Verizon Media. 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.provision.TenantName;
+import com.yahoo.vespa.config.server.application.ApplicationSet;
+
+import java.util.Objects;
+import java.util.Optional;
+
+/**
+ * A RemoteSession represents a session created on another config server. This session can
+ * be regarded as read only, and this interface only allows reading information about a session.
+ *
+ * @author Ulf Lilleengen
+ */
+public class RemoteSession extends Session {
+
+ private final Optional<ApplicationSet> applicationSet;
+
+ /**
+ * Creates a session. This involves loading the application, validating it and distributing it.
+ *
+ * @param tenant The name of the tenant creating session
+ * @param sessionId The session id for this session.
+ * @param zooKeeperClient a SessionZooKeeperClient instance
+ */
+ RemoteSession(TenantName tenant, long sessionId, SessionZooKeeperClient zooKeeperClient) {
+ this(tenant, sessionId, zooKeeperClient, Optional.empty());
+ }
+
+ /**
+ * Creates a remote session, with application set
+ *
+ * @param tenant The name of the tenant creating session
+ * @param sessionId The session id for this session.
+ * @param zooKeeperClient a SessionZooKeeperClient instance
+ * @param applicationSet current application set for this session
+ */
+ RemoteSession(TenantName tenant, long sessionId, SessionZooKeeperClient zooKeeperClient, Optional<ApplicationSet> applicationSet) {
+ super(tenant, sessionId, zooKeeperClient);
+ this.applicationSet = applicationSet;
+ }
+
+ @Override
+ Optional<ApplicationSet> applicationSet() { return applicationSet; }
+
+ public synchronized RemoteSession activated(ApplicationSet applicationSet) {
+ Objects.requireNonNull(applicationSet, "applicationSet cannot be null");
+ return new RemoteSession(tenant, sessionId, sessionZooKeeperClient, Optional.of(applicationSet));
+ }
+
+ public synchronized RemoteSession deactivated() {
+ return new RemoteSession(tenant, sessionId, sessionZooKeeperClient, Optional.empty());
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + ",application set=" + applicationSet;
+ }
+
+}