diff options
author | Harald Musum <musum@verizonmedia.com> | 2020-10-19 15:04:13 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-19 15:04:13 +0200 |
commit | 8d336d5a9246d954910161f5b104bf350b045b3b (patch) | |
tree | 989a34ac8325430db05e984bb4acf55ac9ec27fc /configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java | |
parent | e71727da8dcc1eba0fce1b067772fe6c1c5b6f01 (diff) |
Revert "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.java | 61 |
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; + } + +} |