aboutsummaryrefslogtreecommitdiffstats
path: root/configserver
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2020-07-03 07:45:49 +0200
committerHarald Musum <musum@verizonmedia.com>2020-07-03 07:45:49 +0200
commitb29fb812be8cde17bb88dff266899eaa76535959 (patch)
tree914b45b0b77250950361b2dc1e6d270c2b949409 /configserver
parentcb9dd27481a9a4cd1f3cbef50ce9670f39985c0f (diff)
Remove ReloadHandler interface
Diffstat (limited to 'configserver')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ReloadHandler.java37
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java6
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSession.java6
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionRepository.java12
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java10
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java9
7 files changed, 19 insertions, 66 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadHandler.java
deleted file mode 100644
index 93af4b1d593..00000000000
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadHandler.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// 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;
-
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.vespa.config.server.application.ApplicationSet;
-
-import java.util.Set;
-
-/**
- * Interface representing a reload handler.
- *
- * @author Ulf Lilleengen
- */
-public interface ReloadHandler {
-
- /**
- * Reload config with the one contained in the application.
- *
- * @param applicationSet The set of applications to set as active.
- */
- void reloadConfig(ApplicationSet applicationSet);
-
- /**
- * Remove an application and resources related to it.
- *
- * @param applicationId to be removed
- */
- void removeApplication(ApplicationId applicationId);
-
- /**
- * Remove all applications except those specified in argument.
- *
- * @param applicationIds to be kept
- */
- void removeApplicationsExcept(Set<ApplicationId> applicationIds);
-
-}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java
index 795c6398354..638e3565602 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java
@@ -15,7 +15,6 @@ import com.yahoo.vespa.config.GetConfigRequest;
import com.yahoo.vespa.config.protocol.ConfigResponse;
import com.yahoo.vespa.config.server.GlobalComponentRegistry;
import com.yahoo.vespa.config.server.NotFoundException;
-import com.yahoo.vespa.config.server.ReloadHandler;
import com.yahoo.vespa.config.server.ReloadListener;
import com.yahoo.vespa.config.server.RequestHandler;
import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs;
@@ -59,7 +58,7 @@ import static java.util.stream.Collectors.toSet;
* @author Ulf Lilleengen
* @author jonmv
*/
-public class TenantApplications implements RequestHandler, ReloadHandler, HostValidator<ApplicationId> {
+public class TenantApplications implements RequestHandler, HostValidator<ApplicationId> {
private static final Logger log = Logger.getLogger(TenantApplications.class.getName());
@@ -258,7 +257,6 @@ public class TenantApplications implements RequestHandler, ReloadHandler, HostVa
*
* @param applicationSet the {@link ApplicationSet} to be reloaded
*/
- @Override
public void reloadConfig(ApplicationSet applicationSet) {
ApplicationId id = applicationSet.getId();
try (Lock lock = lock(id)) {
@@ -272,7 +270,6 @@ public class TenantApplications implements RequestHandler, ReloadHandler, HostVa
}
}
- @Override
public void removeApplication(ApplicationId applicationId) {
try (Lock lock = lock(applicationId)) {
if (exists(applicationId))
@@ -288,7 +285,6 @@ public class TenantApplications implements RequestHandler, ReloadHandler, HostVa
}
}
- @Override
public void removeApplicationsExcept(Set<ApplicationId> applications) {
for (ApplicationId activeApplication : applicationMapper.listApplicationIds()) {
if ( ! applications.contains(activeApplication)) {
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 763c77f2088..66ed721a3e1 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
@@ -8,8 +8,8 @@ import com.yahoo.config.provision.TenantName;
import com.yahoo.lang.SettableOptional;
import com.yahoo.transaction.Transaction;
import com.yahoo.vespa.config.server.GlobalComponentRegistry;
-import com.yahoo.vespa.config.server.ReloadHandler;
import com.yahoo.vespa.config.server.application.ApplicationSet;
+import com.yahoo.vespa.config.server.application.TenantApplications;
import com.yahoo.vespa.config.server.modelfactory.ActivatedModelsBuilder;
import com.yahoo.vespa.curator.Curator;
import org.apache.zookeeper.KeeperException;
@@ -81,12 +81,12 @@ public class RemoteSession extends Session {
return sessionZooKeeperClient.createWriteStatusTransaction(Status.DELETE);
}
- void makeActive(ReloadHandler reloadHandler) {
+ void makeActive(TenantApplications tenantApplications) {
Curator.CompletionWaiter waiter = sessionZooKeeperClient.getActiveWaiter();
log.log(Level.FINE, () -> logPre() + "Getting session from repo: " + getSessionId());
ApplicationSet app = ensureApplicationLoaded();
log.log(Level.FINE, () -> logPre() + "Reloading config for " + getSessionId());
- reloadHandler.reloadConfig(app);
+ tenantApplications.reloadConfig(app);
log.log(Level.FINE, () -> logPre() + "Notifying " + waiter);
notifyCompletion(waiter);
log.log(Level.INFO, logPre() + "Session activated: " + getSessionId());
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 c35fcb3cf21..8a7be7ef176 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
@@ -17,7 +17,6 @@ import com.yahoo.transaction.AbstractTransaction;
import com.yahoo.transaction.NestedTransaction;
import com.yahoo.transaction.Transaction;
import com.yahoo.vespa.config.server.GlobalComponentRegistry;
-import com.yahoo.vespa.config.server.ReloadHandler;
import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.application.ApplicationSet;
import com.yahoo.vespa.config.server.application.TenantApplications;
@@ -73,8 +72,6 @@ public class SessionRepository {
private static final FilenameFilter sessionApplicationsFilter = (dir, name) -> name.matches("\\d+");
private static final long nonExistingActiveSession = 0;
-
-
private final SessionCache<LocalSession> localSessionCache = new SessionCache<>();
private final SessionCache<RemoteSession> remoteSessionCache = new SessionCache<>();
private final Map<Long, SessionStateWatcher> sessionStateWatchers = new HashMap<>();
@@ -84,7 +81,6 @@ public class SessionRepository {
private final Executor zkWatcherExecutor;
private final TenantFileSystemDirs tenantFileSystemDirs;
private final BooleanFlag distributeApplicationPackage;
- private final ReloadHandler reloadHandler;
private final MetricUpdater metrics;
private final Curator.DirectoryCache directoryCache;
private final TenantApplications applicationRepo;
@@ -97,7 +93,6 @@ public class SessionRepository {
public SessionRepository(TenantName tenantName,
GlobalComponentRegistry componentRegistry,
TenantApplications applicationRepo,
- ReloadHandler reloadHandler,
FlagSource flagSource,
SessionPreparer sessionPreparer) {
this.tenantName = tenantName;
@@ -111,7 +106,6 @@ public class SessionRepository {
this.applicationRepo = applicationRepo;
this.sessionPreparer = sessionPreparer;
this.distributeApplicationPackage = Flags.CONFIGSERVER_DISTRIBUTE_APPLICATION_PACKAGE.bindTo(flagSource);
- this.reloadHandler = reloadHandler;
this.metrics = componentRegistry.getMetrics().getOrCreateMetricUpdater(Metrics.createDimensions(tenantName));
this.locksPath = TenantRepository.getLocksPath(tenantName);
@@ -351,7 +345,7 @@ public class SessionRepository {
for (ApplicationId applicationId : applicationRepo.activeApplications()) {
if (applicationRepo.requireActiveSessionOf(applicationId) == session.getSessionId()) {
log.log(Level.FINE, () -> "Found active application for session " + session.getSessionId() + " , loading it");
- reloadHandler.reloadConfig(session.ensureApplicationLoaded());
+ applicationRepo.reloadConfig(session.ensureApplicationLoaded());
log.log(Level.INFO, session.logPre() + "Application activated successfully: " + applicationId + " (generation " + session.getSessionId() + ")");
return;
}
@@ -626,7 +620,7 @@ public class SessionRepository {
if (sessionStateWatchers.containsKey(sessionId)) {
localSession.ifPresent(session -> sessionStateWatchers.get(sessionId).addLocalSession(session));
} else {
- sessionStateWatchers.put(sessionId, new SessionStateWatcher(fileCache, reloadHandler, remoteSession,
+ sessionStateWatchers.put(sessionId, new SessionStateWatcher(fileCache, applicationRepo, remoteSession,
localSession, metrics, zkWatcherExecutor, this));
}
}
@@ -636,8 +630,6 @@ public class SessionRepository {
return getLocalSessions().toString();
}
- public ReloadHandler getReloadHandler() { return reloadHandler; }
-
/** Returns the lock for session operations for the given session id. */
public Lock lock(long sessionId) {
return curator.lock(lockPath(sessionId), Duration.ofMinutes(1)); // These locks shouldn't be held for very long.
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
index 1cbab9be1a8..65c62a392b7 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionStateWatcher.java
@@ -2,7 +2,7 @@
package com.yahoo.vespa.config.server.session;
import com.yahoo.text.Utf8;
-import com.yahoo.vespa.config.server.ReloadHandler;
+import com.yahoo.vespa.config.server.application.TenantApplications;
import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
import com.yahoo.vespa.curator.Curator;
import org.apache.curator.framework.recipes.cache.ChildData;
@@ -26,7 +26,7 @@ public class SessionStateWatcher {
private static final Logger log = Logger.getLogger(SessionStateWatcher.class.getName());
private final Curator.FileCache fileCache;
- private final ReloadHandler reloadHandler;
+ private final TenantApplications tenantApplications;
private final RemoteSession remoteSession;
private final MetricUpdater metrics;
private final Executor zkWatcherExecutor;
@@ -34,14 +34,14 @@ public class SessionStateWatcher {
private Optional<LocalSession> localSession;
SessionStateWatcher(Curator.FileCache fileCache,
- ReloadHandler reloadHandler,
+ TenantApplications tenantApplications,
RemoteSession remoteSession,
Optional<LocalSession> localSession,
MetricUpdater metrics,
Executor zkWatcherExecutor,
SessionRepository sessionRepository) {
this.fileCache = fileCache;
- this.reloadHandler = reloadHandler;
+ this.tenantApplications = tenantApplications;
this.remoteSession = remoteSession;
this.localSession = localSession;
this.metrics = metrics;
@@ -60,7 +60,7 @@ public class SessionStateWatcher {
remoteSession.loadPrepared();
} else if (newStatus.equals(Status.ACTIVATE)) {
createLocalSession(sessionId);
- remoteSession.makeActive(reloadHandler);
+ remoteSession.makeActive(tenantApplications);
} else if (newStatus.equals(Status.DEACTIVATE)) {
remoteSession.deactivate();
} else if (newStatus.equals(Status.DELETE)) {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java
index 33bbda33230..33ce8f52834 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java
@@ -219,8 +219,9 @@ public class TenantRepository {
componentRegistry.getConfigserverConfig(),
componentRegistry.getHostRegistries().createApplicationHostRegistry(tenantName),
new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName));
- SessionRepository sessionRepository = new SessionRepository(tenantName, componentRegistry,
- applicationRepo, applicationRepo,
+ SessionRepository sessionRepository = new SessionRepository(tenantName,
+ componentRegistry,
+ applicationRepo,
componentRegistry.getFlagSource(),
componentRegistry.getSessionPreparer());
log.log(Level.INFO, "Adding tenant '" + tenantName + "'" + ", created " + created);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
index 8d0285ac12b..f372b21b065 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
@@ -15,6 +15,7 @@ import com.yahoo.vespa.config.server.ServerCache;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.Application;
import com.yahoo.vespa.config.server.application.ApplicationSet;
+import com.yahoo.vespa.config.server.application.TenantApplications;
import com.yahoo.vespa.config.server.application.TenantApplicationsTest;
import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
import com.yahoo.vespa.curator.Curator;
@@ -82,10 +83,10 @@ public class TenantRepositoryTest {
@Test
public void testListenersAdded() throws IOException, SAXException {
- Tenant tenant = tenantRepository.getTenant(tenant1);
- tenant.getApplicationRepo().createApplication(ApplicationId.defaultId());
- tenant.getApplicationRepo().createPutTransaction(ApplicationId.defaultId(), 4).commit();
- tenant.getSessionRepository().getReloadHandler().reloadConfig(ApplicationSet.fromSingle(
+ TenantApplications applicationRepo = tenantRepository.getTenant(tenant1).getApplicationRepo();
+ applicationRepo.createApplication(ApplicationId.defaultId());
+ applicationRepo.createPutTransaction(ApplicationId.defaultId(), 4).commit();
+ applicationRepo.reloadConfig(ApplicationSet.fromSingle(
new Application(new VespaModel(MockApplicationPackage.createEmpty()),
new ServerCache(),
4L,