diff options
author | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-07-06 15:13:37 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@yahoo-inc.com> | 2016-07-06 15:13:37 +0200 |
commit | 773186478a6f76b0c7c358a75f1fe966e6c62abd (patch) | |
tree | d438c4489fe7008b49fa63df538e4a8eb53c557d /configserver | |
parent | 5bb63fcb4013d0c8d9e6ae93e0c76ce0bfaf11e7 (diff) |
Refactor
Diffstat (limited to 'configserver')
33 files changed, 115 insertions, 119 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/Tenant.java b/configserver/src/main/java/com/yahoo/vespa/config/server/Tenant.java index cabf4bed323..36659682a7e 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/Tenant.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/Tenant.java @@ -6,7 +6,7 @@ import com.yahoo.config.provision.Deployer; import com.yahoo.config.provision.TenantName; import com.yahoo.log.LogLevel; import com.yahoo.path.Path; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.vespa.config.server.session.LocalSessionRepo; import com.yahoo.vespa.config.server.session.RemoteSessionRepo; @@ -35,7 +35,7 @@ public class Tenant implements TenantHandlerProvider { private final Path path; private final SessionFactory sessionFactory; private final LocalSessionRepo localSessionRepo; - private final ApplicationRepo applicationRepo; + private final TenantApplications applicationRepo; private final ActivateLock activateLock; private final RequestHandler requestHandler; private final ReloadHandler reloadHandler; @@ -49,7 +49,7 @@ public class Tenant implements TenantHandlerProvider { RemoteSessionRepo remoteSessionRepo, RequestHandler requestHandler, ReloadHandler reloadHandler, - ApplicationRepo applicationRepo, + TenantApplications applicationRepo, Curator curator, TenantFileSystemDirs tenantFileSystemDirs) { this.name = name; @@ -121,7 +121,7 @@ public class Tenant implements TenantHandlerProvider { return getName().value(); } - public ApplicationRepo getApplicationRepo() { + public TenantApplications getApplicationRepo() { return applicationRepo; } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/TenantBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/TenantBuilder.java index 78ec368f2fb..a6f704fb601 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/TenantBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/TenantBuilder.java @@ -5,8 +5,8 @@ import com.yahoo.concurrent.ThreadFactoryFactory; import com.yahoo.path.Path; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.application.ApplicationRepo; -import com.yahoo.vespa.config.server.application.ZKApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; +import com.yahoo.vespa.config.server.application.ZKTenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.session.*; @@ -34,7 +34,7 @@ public class TenantBuilder { private LocalSessionRepo localSessionRepo; private SessionFactory sessionFactory; private LocalSessionLoader localSessionLoader; - private ApplicationRepo applicationRepo; + private TenantApplications applicationRepo; private SessionCounter sessionCounter; private ReloadHandler reloadHandler; private RequestHandler requestHandler; @@ -68,7 +68,7 @@ public class TenantBuilder { return this; } - public TenantBuilder withApplicationRepo(ApplicationRepo applicationRepo) { + public TenantBuilder withApplicationRepo(TenantApplications applicationRepo) { this.applicationRepo = applicationRepo; return this; } @@ -130,7 +130,7 @@ public class TenantBuilder { private void createApplicationRepo() { if (applicationRepo == null) { - applicationRepo = ZKApplicationRepo.create(componentRegistry.getCurator(), tenantPath.append(Tenant.APPLICATIONS), reloadHandler, tenant); + applicationRepo = ZKTenantApplications.create(componentRegistry.getCurator(), tenantPath.append(Tenant.APPLICATIONS), reloadHandler, tenant); } } @@ -195,7 +195,7 @@ public class TenantBuilder { return localSessionRepo; } - public ApplicationRepo getApplicationRepo() { + public TenantApplications getApplicationRepo() { return applicationRepo; } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java index f2fca3bc3a9..e76065c0510 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ApplicationRepo.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java @@ -8,12 +8,12 @@ import com.yahoo.vespa.curator.transaction.CuratorTransaction; import java.util.List; /** - * Manages the list of active applications in a config server. + * The applications of a tenant * * @author lulf * @since 5.1 */ -public interface ApplicationRepo { +public interface TenantApplications { /** * List the active applications in this config server. diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKApplicationRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKTenantApplications.java index 46278120b0d..b86f61ab78d 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKApplicationRepo.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKTenantApplications.java @@ -25,35 +25,36 @@ import java.util.concurrent.Executors; import java.util.logging.Logger; /** - * Application repo backed by zookeeper. + * The applications of a tenant, backed by ZooKeeper * * @author lulf * @since 5.1 */ -public class ZKApplicationRepo implements ApplicationRepo, PathChildrenCacheListener { +// TODO: Merge into interface and separate out curator layer instead +public class ZKTenantApplications implements TenantApplications, PathChildrenCacheListener { - private static final Logger log = Logger.getLogger(ZKApplicationRepo.class.getName()); + private static final Logger log = Logger.getLogger(ZKTenantApplications.class.getName()); private final Curator curator; - private final Path root; - private final ExecutorService pathChildrenExecutor = Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(ZKApplicationRepo.class.getName())); + private final Path tenantRoot; + private final ExecutorService pathChildrenExecutor = Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(ZKTenantApplications.class.getName())); private final Curator.DirectoryCache directoryCache; private final ReloadHandler reloadHandler; private final TenantName tenant; - private ZKApplicationRepo(Curator curator, Path root, ReloadHandler reloadHandler, TenantName tenant) throws Exception { + private ZKTenantApplications(Curator curator, Path tenantRoot, ReloadHandler reloadHandler, TenantName tenant) throws Exception { this.curator = curator; - this.root = root; + this.tenantRoot = tenantRoot; this.reloadHandler = reloadHandler; this.tenant = tenant; rewriteApplicationIds(); - this.directoryCache = curator.createDirectoryCache(root.getAbsolute(), false, false, pathChildrenExecutor); + this.directoryCache = curator.createDirectoryCache(tenantRoot.getAbsolute(), false, false, pathChildrenExecutor); this.directoryCache.start(); this.directoryCache.addListener(this); } private void rewriteApplicationIds() { try { - List<String> appNodes = curator.framework().getChildren().forPath(root.getAbsolute()); + List<String> appNodes = curator.framework().getChildren().forPath(tenantRoot.getAbsolute()); for (String appNode : appNodes) { Optional<ApplicationId> appId = parseApplication(appNode); appId.filter(id -> shouldBeRewritten(appNode, id)) @@ -65,7 +66,7 @@ public class ZKApplicationRepo implements ApplicationRepo, PathChildrenCacheList } private long readSessionId(ApplicationId appId, String appNode) { - String path = root.append(appNode).getAbsolute(); + String path = tenantRoot.append(appNode).getAbsolute(); try { return Long.parseLong(Utf8.toString(curator.framework().getData().forPath(path))); } catch (Exception e) { @@ -78,8 +79,8 @@ public class ZKApplicationRepo implements ApplicationRepo, PathChildrenCacheList } private void rewriteApplicationId(ApplicationId appId, String origNode, long sessionId) { - String newPath = root.append(appId.serializedForm()).getAbsolute(); - String oldPath = root.append(origNode).getAbsolute(); + String newPath = tenantRoot.append(appId.serializedForm()).getAbsolute(); + String oldPath = tenantRoot.append(origNode).getAbsolute(); try (CuratorTransaction transaction = new CuratorTransaction(curator)) { if (curator.framework().checkExists().forPath(newPath) == null) { transaction.add(CuratorOperations.create(newPath, Utf8.toAsciiBytes(sessionId))); @@ -91,9 +92,9 @@ public class ZKApplicationRepo implements ApplicationRepo, PathChildrenCacheList } } - public static ApplicationRepo create(Curator curator, Path root, ReloadHandler reloadHandler, TenantName tenant) { + public static TenantApplications create(Curator curator, Path root, ReloadHandler reloadHandler, TenantName tenant) { try { - return new ZKApplicationRepo(curator, root, reloadHandler, tenant); + return new ZKTenantApplications(curator, root, reloadHandler, tenant); } catch (Exception e) { throw new RuntimeException(Tenants.logPre(tenant)+"Error creating application repo", e); } @@ -102,7 +103,7 @@ public class ZKApplicationRepo implements ApplicationRepo, PathChildrenCacheList @Override public List<ApplicationId> listApplications() { try { - List<String> appNodes = curator.framework().getChildren().forPath(root.getAbsolute()); + List<String> appNodes = curator.framework().getChildren().forPath(tenantRoot.getAbsolute()); List<ApplicationId> applicationIds = new ArrayList<>(); for (String appNode : appNodes) { parseApplication(appNode).ifPresent(applicationIds::add); @@ -125,9 +126,9 @@ public class ZKApplicationRepo implements ApplicationRepo, PathChildrenCacheList @Override public Transaction createPutApplicationTransaction(ApplicationId applicationId, long sessionId) { if (listApplications().contains(applicationId)) { - return new CuratorTransaction(curator).add(CuratorOperations.setData(root.append(applicationId.serializedForm()).getAbsolute(), Utf8.toAsciiBytes(sessionId))); + return new CuratorTransaction(curator).add(CuratorOperations.setData(tenantRoot.append(applicationId.serializedForm()).getAbsolute(), Utf8.toAsciiBytes(sessionId))); } else { - return new CuratorTransaction(curator).add(CuratorOperations.create(root.append(applicationId.serializedForm()).getAbsolute(), Utf8.toAsciiBytes(sessionId))); + return new CuratorTransaction(curator).add(CuratorOperations.create(tenantRoot.append(applicationId.serializedForm()).getAbsolute(), Utf8.toAsciiBytes(sessionId))); } } @@ -138,7 +139,7 @@ public class ZKApplicationRepo implements ApplicationRepo, PathChildrenCacheList @Override public CuratorTransaction deleteApplication(ApplicationId applicationId) { - Path path = root.append(applicationId.serializedForm()); + Path path = tenantRoot.append(applicationId.serializedForm()); return CuratorTransaction.from(CuratorOperations.delete(path.getAbsolute()), curator); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/counter/package-info.java b/configserver/src/main/java/com/yahoo/vespa/config/server/counter/package-info.java deleted file mode 100644 index 219e1008f3a..00000000000 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/counter/package-info.java +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * @author andreer - */ -@ExportPackage -package com.yahoo.vespa.config.server.counter; - -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployer.java index 5efc4521061..6ed9fddfc20 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/Deployer.java @@ -12,7 +12,7 @@ import com.yahoo.vespa.config.server.Rotations; import com.yahoo.vespa.config.server.Tenant; import com.yahoo.vespa.config.server.Tenants; import com.yahoo.vespa.config.server.TimeoutBudget; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; import com.yahoo.vespa.config.server.session.LocalSession; import com.yahoo.vespa.config.server.session.LocalSessionRepo; @@ -94,7 +94,7 @@ public class Deployer implements com.yahoo.config.provision.Deployer { Optional<Tenant> owner = Optional.ofNullable(tenants.tenantsCopy().get(applicationId.tenant())); if ( ! owner.isPresent()) return false; - ApplicationRepo applicationRepo = owner.get().getApplicationRepo(); + TenantApplications applicationRepo = owner.get().getApplicationRepo(); if ( ! applicationRepo.listApplications().contains(applicationId)) return false; // TODO: Push lookup logic down diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java index 9a6f373a807..a753db90a7a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/ModelContextImpl.java @@ -21,6 +21,7 @@ import java.util.Set; * @author lulf */ public class ModelContextImpl implements ModelContext { + private final ApplicationPackage applicationPackage; private final Optional<Model> previousModel; private final Optional<ApplicationPackage> permanentApplicationPackage; @@ -157,4 +158,5 @@ public class ModelContextImpl implements ModelContext { return rotations; } } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java index 246e15cae46..af5bb08f596 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java @@ -18,7 +18,7 @@ import com.yahoo.vespa.config.server.Tenants; import com.yahoo.vespa.config.server.TimeoutBudget; import com.yahoo.vespa.config.server.application.Application; import com.yahoo.vespa.config.server.application.ApplicationConvergenceChecker; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.application.LogServerLogGrabber; import com.yahoo.vespa.config.server.deploy.Deployer; import com.yahoo.vespa.config.server.http.ContentHandler; @@ -165,7 +165,7 @@ public class ApplicationHandler extends HttpHandler { } private Application getApplication(Tenant tenant, ApplicationId applicationId) { - ApplicationRepo applicationRepo = tenant.getApplicationRepo(); + TenantApplications applicationRepo = tenant.getApplicationRepo(); RemoteSessionRepo remoteSessionRepo = tenant.getRemoteSessionRepo(); long sessionId = applicationRepo.getSessionIdForApplication(applicationId); RemoteSession session = remoteSessionRepo.getSession(sessionId, 0); @@ -173,7 +173,7 @@ public class ApplicationHandler extends HttpHandler { } private List<ApplicationId> listApplicationIds(Tenant tenant) { - ApplicationRepo applicationRepo = tenant.getApplicationRepo(); + TenantApplications applicationRepo = tenant.getApplicationRepo(); return applicationRepo.listApplications(); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandler.java index e77c3928f11..a9330a08186 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandler.java @@ -12,7 +12,7 @@ import com.yahoo.jdisc.Response; import com.yahoo.vespa.config.server.Tenant; import com.yahoo.vespa.config.server.Tenants; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.http.HttpHandler; import com.yahoo.vespa.config.server.http.Utils; @@ -52,7 +52,7 @@ public class ListApplicationsHandler extends HttpHandler { private List<ApplicationId> listApplicationIds(TenantName tenantName) { Tenant tenant = Utils.checkThatTenantExists(tenants, tenantName); - ApplicationRepo applicationRepo = tenant.getApplicationRepo(); + TenantApplications applicationRepo = tenant.getApplicationRepo(); return applicationRepo.listApplications(); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java index c4f4a5139b5..0aee7e7314b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandler.java @@ -14,7 +14,7 @@ import com.yahoo.slime.Slime; import com.yahoo.vespa.config.server.Tenant; import com.yahoo.vespa.config.server.Tenants; import com.yahoo.vespa.config.server.TimeoutBudget; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.http.BadRequestException; import com.yahoo.vespa.config.server.http.SessionCreate; import com.yahoo.vespa.config.server.http.SessionHandler; @@ -66,7 +66,7 @@ public class SessionCreateHandler extends SessionHandler { } private static LocalSession getExistingSession(Tenant tenant, HttpRequest request) { - ApplicationRepo applicationRepo = tenant.getApplicationRepo(); + TenantApplications applicationRepo = tenant.getApplicationRepo(); LocalSessionRepo localSessionRepo = tenant.getLocalSessionRepo(); ApplicationId applicationId = getFromProperty(request); return SessionHandler.getSessionFromRequest(localSessionRepo, applicationRepo.getSessionIdForApplication(applicationId)); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java index 9e4e58e7751..f25ebe02172 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandler.java @@ -14,7 +14,7 @@ import com.yahoo.slime.Slime; import com.yahoo.vespa.config.server.ApplicationSet; import com.yahoo.vespa.config.server.Tenant; import com.yahoo.vespa.config.server.Tenants; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; import com.yahoo.vespa.config.server.configchange.RefeedActions; import com.yahoo.vespa.config.server.configchange.RefeedActionsFormatter; @@ -101,7 +101,7 @@ public class SessionPrepareHandler extends SessionHandler { private static Optional<ApplicationSet> getCurrentActiveApplicationSet(Tenant tenant, ApplicationId appId) { Optional<ApplicationSet> currentActiveApplicationSet = Optional.empty(); - ApplicationRepo applicationRepo = tenant.getApplicationRepo(); + TenantApplications applicationRepo = tenant.getApplicationRepo(); try { long currentActiveSessionId = applicationRepo.getSessionIdForApplication(appId); final RemoteSession currentActiveSession = tenant.getRemoteSessionRepo().getSession(currentActiveSessionId); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/TenantHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/TenantHandler.java index e373eb4478f..cab09fe0486 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/TenantHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/TenantHandler.java @@ -11,7 +11,7 @@ import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.logging.AccessLog; import com.yahoo.yolean.Exceptions; import com.yahoo.vespa.config.server.Tenant; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.http.BadRequestException; import com.yahoo.vespa.config.server.http.HttpHandler; import com.yahoo.vespa.config.server.http.InternalServerException; @@ -73,7 +73,7 @@ public class TenantHandler extends HttpHandler { protected HttpResponse handleDELETE(HttpRequest request) { TenantName tenantName = getExistingTenant(request); Tenant tenant = Utils.checkThatTenantExists(tenants, tenantName); - ApplicationRepo applicationRepo = tenant.getApplicationRepo(); + TenantApplications applicationRepo = tenant.getApplicationRepo(); final List<ApplicationId> activeApplications = applicationRepo.listApplications(); if (activeApplications.isEmpty()) { try { 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 667fe249925..9f9f931fa68 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 @@ -14,13 +14,11 @@ import com.yahoo.path.Path; import com.yahoo.vespa.config.server.*; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; import com.yahoo.vespa.curator.Curator; -import com.yahoo.vespa.curator.transaction.CuratorTransaction; import java.io.File; -import java.util.List; import java.util.Optional; /** @@ -34,7 +32,7 @@ import java.util.Optional; public class LocalSession extends Session implements Comparable<LocalSession> { private final ApplicationPackage applicationPackage; - private final ApplicationRepo applicationRepo; + private final TenantApplications applicationRepo; private final SessionZooKeeperClient zooKeeperClient; private final SessionPreparer sessionPreparer; private final SessionContext sessionContext; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java index b5b6244cb5e..7114768c760 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/LocalSessionRepo.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server.session; import com.yahoo.log.LogLevel; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import java.io.File; @@ -32,10 +32,10 @@ public class LocalSessionRepo extends SessionRepo<LocalSession> { }; private final long sessionLifetime; // in seconds - private final ApplicationRepo applicationRepo; + private final TenantApplications applicationRepo; private final Clock clock; - public LocalSessionRepo(TenantFileSystemDirs tenantFileSystemDirs, LocalSessionLoader loader, ApplicationRepo applicationRepo, Clock clock, long sessionLifeTime) { + public LocalSessionRepo(TenantFileSystemDirs tenantFileSystemDirs, LocalSessionLoader loader, TenantApplications applicationRepo, Clock clock, long sessionLifeTime) { this(applicationRepo, clock, sessionLifeTime); loadSessions(tenantFileSystemDirs.path(), loader); } @@ -68,13 +68,13 @@ public class LocalSessionRepo extends SessionRepo<LocalSession> { } // Constructor only for testing - public LocalSessionRepo(ApplicationRepo applicationRepo, Clock clock, long sessionLifetime) { + public LocalSessionRepo(TenantApplications applicationRepo, Clock clock, long sessionLifetime) { this.applicationRepo = applicationRepo; this.sessionLifetime = sessionLifetime; this.clock = clock; } - public LocalSessionRepo(ApplicationRepo applicationRepo) { + public LocalSessionRepo(TenantApplications applicationRepo) { this(applicationRepo, Clock.systemUTC(), TimeUnit.DAYS.toMillis(1)); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java index a143eea2221..a0d739688cd 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionRepo.java @@ -15,7 +15,7 @@ import com.yahoo.vespa.curator.Curator; import com.yahoo.yolean.Exceptions; import com.yahoo.vespa.config.server.ReloadHandler; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import com.yahoo.vespa.config.server.zookeeper.ConfigCurator; @@ -42,13 +42,13 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> implements Nod private final ReloadHandler reloadHandler; private final MetricUpdater metrics; private final Curator.DirectoryCache directoryCache; - private final ApplicationRepo applicationRepo; + private final TenantApplications applicationRepo; public static RemoteSessionRepo create(Curator curator, RemoteSessionFactory remoteSessionFactory, ReloadHandler reloadHandler, Path sessionsPath, - ApplicationRepo applicationRepo, + TenantApplications applicationRepo, MetricUpdater metrics, ExecutorService executorService) throws Exception { return new RemoteSessionRepo(curator, remoteSessionFactory, reloadHandler, sessionsPath, applicationRepo, metrics, executorService); @@ -60,7 +60,7 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> implements Nod * @param remoteSessionFactory a {@link com.yahoo.vespa.config.server.session.RemoteSessionFactory} * @param reloadHandler a {@link com.yahoo.vespa.config.server.ReloadHandler} * @param sessionsPath a {@link com.yahoo.path.Path} to the sessions dir. - * @param applicationRepo an {@link com.yahoo.vespa.config.server.application.ApplicationRepo} object. + * @param applicationRepo an {@link TenantApplications} object. * @param executorService an {@link ExecutorService} to run callbacks from ZooKeeper. * @throws java.lang.Exception if creating the repo fails */ @@ -68,7 +68,7 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> implements Nod RemoteSessionFactory remoteSessionFactory, ReloadHandler reloadHandler, Path sessionsPath, - ApplicationRepo applicationRepo, + TenantApplications applicationRepo, MetricUpdater metricUpdater, ExecutorService executorService) throws Exception { this.curator = curator; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionContext.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionContext.java index dd908eaa559..2ca315ccb6e 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionContext.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionContext.java @@ -5,7 +5,7 @@ import com.yahoo.config.application.api.ApplicationPackage; import com.yahoo.vespa.config.server.HostValidator; import com.yahoo.vespa.config.server.SuperModelGenerationCounter; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import java.io.File; @@ -20,12 +20,12 @@ public class SessionContext { private final ApplicationPackage applicationPackage; private final SessionZooKeeperClient sessionZooKeeperClient; private final File serverDBSessionDir; - private final ApplicationRepo applicationRepo; + private final TenantApplications applicationRepo; private final HostValidator<ApplicationId> hostRegistry; private final SuperModelGenerationCounter superModelGenerationCounter; public SessionContext(ApplicationPackage applicationPackage, SessionZooKeeperClient sessionZooKeeperClient, - File serverDBSessionDir, ApplicationRepo applicationRepo, + File serverDBSessionDir, TenantApplications applicationRepo, HostValidator<ApplicationId> hostRegistry, SuperModelGenerationCounter superModelGenerationCounter) { this.applicationPackage = applicationPackage; this.sessionZooKeeperClient = sessionZooKeeperClient; @@ -47,7 +47,7 @@ public class SessionContext { return serverDBSessionDir; } - public ApplicationRepo getApplicationRepo() { + public TenantApplications getApplicationRepo() { return applicationRepo; } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java index 981948c0f27..af61e4e81ed 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/SessionFactoryImpl.java @@ -12,7 +12,7 @@ import com.yahoo.path.Path; import com.yahoo.vespa.config.server.*; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.vespa.config.server.zookeeper.SessionCounter; import com.yahoo.vespa.config.server.zookeeper.ConfigCurator; @@ -39,7 +39,7 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { private final Curator curator; private final ConfigCurator configCurator; private final SessionCounter sessionCounter; - private final ApplicationRepo applicationRepo; + private final TenantApplications applicationRepo; private final Path sessionsPath; private final TenantFileSystemDirs tenantFileSystemDirs; private final HostValidator<ApplicationId> hostRegistry; @@ -51,7 +51,7 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { public SessionFactoryImpl(GlobalComponentRegistry globalComponentRegistry, SessionCounter sessionCounter, Path sessionsPath, - ApplicationRepo applicationRepo, + TenantApplications applicationRepo, TenantFileSystemDirs tenantFileSystemDirs, HostValidator<ApplicationId> hostRegistry, TenantName tenant) { this.hostRegistry = hostRegistry; this.tenant = tenant; diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java b/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java index 2a09e46d821..21dd0b17d7a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/version/VersionState.java @@ -58,4 +58,5 @@ public class VersionState { public String toString() { return String.format("Current version:%s, stored version:%s", currentVersion(), storedVersion()); } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java index 4aedb487352..629c045f5f2 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/ZKApplicationFile.java @@ -19,6 +19,7 @@ import java.util.logging.Logger; * @since 5.1 */ class ZKApplicationFile extends ApplicationFile { + private static final Logger log = Logger.getLogger("ZKApplicationFile"); private final ZKLiveApp zkApp; private final ObjectMapper mapper = new ObjectMapper(); @@ -172,4 +173,5 @@ class ZKApplicationFile extends ApplicationFile { if (other == this) return 0; return this.getPath().getName().compareTo((other).getPath().getName()); } + } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/TenantTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TenantTest.java index c4eb8786917..987b26be2de 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/TenantTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/TenantTest.java @@ -3,7 +3,7 @@ package com.yahoo.vespa.config.server; import com.google.common.testing.EqualsTester; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.http.v2.TestTenantBuilder; import org.junit.Before; import org.junit.Test; @@ -53,7 +53,7 @@ public class TenantTest extends TestWithCurator { @Test public void close() { - MemoryApplicationRepo repo = (MemoryApplicationRepo) t1.getApplicationRepo(); + MemoryTenantApplications repo = (MemoryTenantApplications) t1.getApplicationRepo(); assertTrue(repo.isOpen()); t1.close(); assertFalse(repo.isOpen()); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/MemoryApplicationRepo.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/MemoryTenantApplications.java index 89252657760..8a4ca32fa12 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/MemoryApplicationRepo.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/MemoryTenantApplications.java @@ -11,12 +11,12 @@ import java.util.List; import java.util.Map; /** - * In memory {@link ApplicationRepo} to be used when testing. + * In memory {@link TenantApplications} to be used when testing. * * @author lulf * @since 5.1 */ -public class MemoryApplicationRepo implements ApplicationRepo { +public class MemoryTenantApplications implements TenantApplications { private final Map<ApplicationId, Long> applications = new LinkedHashMap<>(); private boolean isOpen = true; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationRepoTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java index 50ef49b2572..82953b7e2ad 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/ApplicationRepoTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java @@ -21,14 +21,14 @@ import static org.junit.Assert.*; * @author lulf * @since 5.1 */ -public class ApplicationRepoTest extends TestWithCurator { +public class TenantApplicationsTest extends TestWithCurator { @Test public void require_that_applications_are_read_from_zookeeper() throws Exception { curatorFramework.create().creatingParentsIfNeeded().forPath("/foo:dev:baz:bim", Utf8.toAsciiBytes(3)); curatorFramework.create().creatingParentsIfNeeded().forPath("/bar:test:bim:quux", Utf8.toAsciiBytes(4)); curatorFramework.create().creatingParentsIfNeeded().forPath("/bario:staging:bala:bong", Utf8.toAsciiBytes(5)); - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); List<ApplicationId> applications = repo.listApplications(); assertThat(applications.size(), is(3)); assertThat(applications.get(0).application().value(), is("bario")); @@ -43,7 +43,7 @@ public class ApplicationRepoTest extends TestWithCurator { public void require_that_legacy_application_ids_are_rewritten() throws Exception { curatorFramework.create().creatingParentsIfNeeded().forPath("/foo:default:baz:bim", Utf8.toAsciiBytes(3)); curatorFramework.create().creatingParentsIfNeeded().forPath("/bar:test:bim:quux", Utf8.toAsciiBytes(4)); - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); List<ApplicationId> applications = repo.listApplications(); assertThat(applications.size(), is(2)); assertThat(applications.get(0).application().value(), is("bar")); @@ -61,7 +61,7 @@ public class ApplicationRepoTest extends TestWithCurator { curatorFramework.create().creatingParentsIfNeeded().forPath("/foo:default:baz:bim", Utf8.toAsciiBytes(3)); curatorFramework.create().creatingParentsIfNeeded().forPath("/foo:prod:baz:bim", Utf8.toAsciiBytes(3)); curatorFramework.create().creatingParentsIfNeeded().forPath("/bar:test:bim:quux", Utf8.toAsciiBytes(4)); - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); List<ApplicationId> applications = repo.listApplications(); assertThat(applications.size(), is(2)); assertThat(repo.getSessionIdForApplication(applications.get(0)), is(4l)); @@ -72,7 +72,7 @@ public class ApplicationRepoTest extends TestWithCurator { public void require_that_invalid_entries_are_skipped() throws Exception { curatorFramework.create().creatingParentsIfNeeded().forPath("/foo:dev:baz:bim"); curatorFramework.create().creatingParentsIfNeeded().forPath("/invalid"); - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); List<ApplicationId> applications = repo.listApplications(); assertThat(applications.size(), is(1)); assertThat(applications.get(0).application().value(), is("foo")); @@ -81,7 +81,7 @@ public class ApplicationRepoTest extends TestWithCurator { @Test(expected = IllegalArgumentException.class) public void require_that_requesting_session_for_unknown_application_throws_exception() throws Exception { curatorFramework.create().creatingParentsIfNeeded().forPath("/foo:dev:baz:bim"); - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); repo.getSessionIdForApplication(new ApplicationId.Builder() .tenant("exist") .applicationName("tenant").instanceName("here").build()); @@ -90,7 +90,7 @@ public class ApplicationRepoTest extends TestWithCurator { @Test(expected = IllegalArgumentException.class) public void require_that_requesting_session_for_empty_application_throws_exception() throws Exception { curatorFramework.create().creatingParentsIfNeeded().forPath("/foo:dev:baz:bim"); - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); repo.getSessionIdForApplication(new ApplicationId.Builder() .tenant("tenant") .applicationName("foo").instanceName("bim").build()); @@ -98,7 +98,7 @@ public class ApplicationRepoTest extends TestWithCurator { @Test public void require_that_application_ids_can_be_written() throws Exception { - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); repo.createPutApplicationTransaction(createAppplicationId("myapp"), 3l).commit(); String path = "/mytenant:myapp:myinst"; assertTrue(curatorFramework.checkExists().forPath(path) != null); @@ -110,7 +110,7 @@ public class ApplicationRepoTest extends TestWithCurator { @Test public void require_that_application_ids_can_be_deleted() throws Exception { - ApplicationRepo repo = createZKAppRepo(); + TenantApplications repo = createZKAppRepo(); ApplicationId id1 = createAppplicationId("myapp"); ApplicationId id2 = createAppplicationId("myapp2"); repo.createPutApplicationTransaction(id1, 1).commit(); @@ -124,9 +124,9 @@ public class ApplicationRepoTest extends TestWithCurator { @Test public void require_that_repos_behave_similarly() throws Exception { - ApplicationRepo zkRepo = createZKAppRepo(); - ApplicationRepo memRepo = new MemoryApplicationRepo(); - for (ApplicationRepo repo : Arrays.asList(zkRepo, memRepo)) { + TenantApplications zkRepo = createZKAppRepo(); + TenantApplications memRepo = new MemoryTenantApplications(); + for (TenantApplications repo : Arrays.asList(zkRepo, memRepo)) { ApplicationId id1 = createAppplicationId("myapp"); ApplicationId id2 = createAppplicationId("myapp2"); repo.createPutApplicationTransaction(id1, 4).commit(); @@ -158,7 +158,7 @@ public class ApplicationRepoTest extends TestWithCurator { curatorFramework.create().creatingParentsIfNeeded().forPath("/bar:dev:bim:quux", Utf8.toAsciiBytes(4)); curatorFramework.create().creatingParentsIfNeeded().forPath("/bario:staging:bala:bong", Utf8.toAsciiBytes(5)); MockReloadHandler reloadHandler = new MockReloadHandler(); - ApplicationRepo repo = createZKAppRepo(reloadHandler); + TenantApplications repo = createZKAppRepo(reloadHandler); assertNull(reloadHandler.lastRemoved); repo.deleteApplication(new ApplicationId.Builder() .tenant("mytenant") @@ -172,12 +172,12 @@ public class ApplicationRepoTest extends TestWithCurator { assertThat(reloadHandler.lastRemoved.serializedForm(), is("mytenant:bar:quux")); } - private ApplicationRepo createZKAppRepo() { + private TenantApplications createZKAppRepo() { return createZKAppRepo(new MockReloadHandler()); } - private ApplicationRepo createZKAppRepo(MockReloadHandler reloadHandler) { - return ZKApplicationRepo.create(curator, Path.createRoot(), reloadHandler, TenantName.from("mytenant")); + private TenantApplications createZKAppRepo(MockReloadHandler reloadHandler) { + return ZKTenantApplications.create(curator, Path.createRoot(), reloadHandler, TenantName.from("mytenant")); } private static ApplicationId createAppplicationId(String name) { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java index 2e5576869b5..6634e8a8b54 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionActiveHandlerTestBase.java @@ -20,7 +20,7 @@ import com.yahoo.config.provision.*; import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry; import com.yahoo.vespa.config.server.SuperModelGenerationCounter; import com.yahoo.vespa.config.server.TestComponentRegistry; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.vespa.config.server.deploy.ZooKeeperClient; import com.yahoo.vespa.config.server.session.*; @@ -51,7 +51,7 @@ public abstract class SessionActiveHandlerTestBase extends SessionHandlerTest { protected RemoteSessionRepo remoteSessionRepo; protected LocalSessionRepo localRepo; protected PathProvider pathProvider; - protected ApplicationRepo applicationRepo; + protected TenantApplications applicationRepo; protected String activatedMessage = " activated."; protected String tenantMessage = ""; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionCreateHandlerTestBase.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionCreateHandlerTestBase.java index 74211196174..7cac6756bd4 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionCreateHandlerTestBase.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/SessionCreateHandlerTestBase.java @@ -9,7 +9,7 @@ import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.io.IOUtils; import com.yahoo.vespa.config.server.CompressedApplicationInputStreamTest; import com.yahoo.vespa.config.server.TimeoutBudget; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.session.LocalSession; import com.yahoo.vespa.config.server.session.LocalSessionRepo; import com.yahoo.vespa.config.server.session.SessionFactory; @@ -48,7 +48,7 @@ public abstract class SessionCreateHandlerTestBase extends SessionHandlerTest { public File testApp = new File("src/test/apps/app"); public LocalSessionRepo localSessionRepo; - public ApplicationRepo applicationRepo; + public TenantApplications applicationRepo; static { postHeaders.put(SessionCreate.contentTypeHeader, SessionCreate.APPLICATION_X_GZIP); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java index 2e75d1b02e6..5150bcb661f 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java @@ -8,7 +8,7 @@ import com.yahoo.jdisc.http.HttpRequest.Method; import com.yahoo.container.logging.AccessLog; import com.yahoo.jdisc.Response; import com.yahoo.vespa.config.server.*; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.http.SessionHandlerTest; import org.junit.Test; import org.junit.Before; @@ -26,7 +26,7 @@ import static com.yahoo.jdisc.http.HttpRequest.Method.*; * @since 5.1 */ public class ListApplicationsHandlerTest { - private ApplicationRepo applicationRepo, applicationRepo2; + private TenantApplications applicationRepo, applicationRepo2; private ListApplicationsHandler handler; @Before diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java index eb312636225..5766528eff2 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java @@ -34,7 +34,7 @@ import static org.hamcrest.CoreMatchers.*; import static org.junit.Assert.*; import com.yahoo.path.Path; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.http.SessionActiveHandlerTestBase; import com.yahoo.vespa.config.server.http.SessionHandler; import com.yahoo.vespa.config.server.http.SessionCreateHandlerTestBase.MockSessionFactory; @@ -47,7 +47,7 @@ public class SessionActiveHandlerTest extends SessionActiveHandlerTestBase { public void setup() throws Exception { tenant = TenantName.from("activatetest"); remoteSessionRepo = new RemoteSessionRepo(); - applicationRepo = new MemoryApplicationRepo(); + applicationRepo = new MemoryTenantApplications(); curator = new MockCurator(); configCurator = ConfigCurator.create(curator); localRepo = new LocalSessionRepo(applicationRepo); 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 e31d485f4df..412a2d3e56e 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 @@ -8,7 +8,7 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.logging.AccessLog; import com.yahoo.vespa.config.server.*; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.http.SessionCreateHandlerTestBase; import com.yahoo.vespa.config.server.http.SessionHandlerTest; import com.yahoo.vespa.config.server.session.*; @@ -34,7 +34,7 @@ public class SessionCreateHandlerTest extends SessionCreateHandlerTestBase { @Before public void setupRepo() throws Exception { - applicationRepo = new MemoryApplicationRepo(); + applicationRepo = new MemoryTenantApplications(); localSessionRepo = new LocalSessionRepo(applicationRepo); pathPrefix = "/application/v2/tenant/" + tenant + "/session/"; createdMessage = " for tenant '" + tenant + "' created.\""; diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java index 3307c016939..7682e5c1ba8 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java @@ -19,8 +19,8 @@ import com.yahoo.slime.Slime; import com.yahoo.transaction.Transaction; import com.yahoo.vespa.config.server.ApplicationSet; import com.yahoo.vespa.config.server.HostRegistry; -import com.yahoo.vespa.config.server.application.ApplicationRepo; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; import com.yahoo.vespa.config.server.configchange.MockRefeedAction; import com.yahoo.vespa.config.server.configchange.MockRestartAction; @@ -55,7 +55,7 @@ public class SessionPrepareHandlerTest extends SessionPrepareHandlerTestBase { @Before public void setupRepo() throws Exception { - ApplicationRepo applicationRepo = new MemoryApplicationRepo(); + TenantApplications applicationRepo = new MemoryTenantApplications(); curator = new MockCurator(); localRepo = new LocalSessionRepo(applicationRepo); pathPrefix = "/application/v2/tenant/" + tenant + "/session/"; @@ -77,7 +77,7 @@ public class SessionPrepareHandlerTest extends SessionPrepareHandlerTestBase { @Test public void require_that_preparing_with_multiple_tenants_work() throws Exception { - ApplicationRepo applicationRepoDefault = new MemoryApplicationRepo(); + TenantApplications applicationRepoDefault = new MemoryTenantApplications(); LocalSessionRepo localRepoDefault = new LocalSessionRepo(applicationRepoDefault); final TenantName tenantName = TenantName.defaultName(); addTenant(tenantName, localRepoDefault, new RemoteSessionRepo(), new SessionCreateHandlerTestBase.MockSessionFactory()); @@ -193,7 +193,7 @@ public class SessionPrepareHandlerTest extends SessionPrepareHandlerTestBase { builder.createTenant(tenantName).withSessionFactory(sessionFactory) .withLocalSessionRepo(localSessionRepo) .withRemoteSessionRepo(remoteSessionRepo) - .withApplicationRepo(new MemoryApplicationRepo()); + .withApplicationRepo(new MemoryTenantApplications()); return builder; } diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java index a128fa6c891..80ba632bd5c 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TestTenantBuilder.java @@ -6,7 +6,7 @@ import com.google.common.collect.Collections2; import com.yahoo.config.provision.TenantName; import com.yahoo.path.Path; import com.yahoo.vespa.config.server.*; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.http.SessionCreateHandlerTestBase; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.vespa.config.server.session.LocalSessionRepo; @@ -31,7 +31,7 @@ public class TestTenantBuilder { } public TenantBuilder createTenant(TenantName tenantName) { - MemoryApplicationRepo applicationRepo = new MemoryApplicationRepo(); + MemoryTenantApplications applicationRepo = new MemoryTenantApplications(); TenantBuilder builder = TenantBuilder.create(componentRegistry, tenantName, Path.createRoot().append(tenantName.value())) .withSessionFactory(new SessionCreateHandlerTestBase.MockSessionFactory()) .withLocalSessionRepo(new LocalSessionRepo(applicationRepo)) diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java index 84fce1c09fe..09af0e6bfc9 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/LocalSessionRepoTest.java @@ -6,7 +6,7 @@ import com.yahoo.path.Path; import com.yahoo.test.ManualClock; import com.yahoo.vespa.config.server.*; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.io.IOUtils; import com.yahoo.vespa.config.server.http.SessionHandlerTest; @@ -53,10 +53,10 @@ public class LocalSessionRepoTest extends TestWithCurator { Path.fromString("counter"), Path.fromString("sessions")), Path.createRoot(), - new MemoryApplicationRepo(), + new MemoryTenantApplications(), tenantFileSystemDirs, new HostRegistry<>(), tenantName); - repo = new LocalSessionRepo(tenantFileSystemDirs, loader, new MemoryApplicationRepo(), clock, 5); + repo = new LocalSessionRepo(tenantFileSystemDirs, loader, new MemoryTenantApplications(), clock, 5); } @Test 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 4f638d54d46..d2c46304ae4 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 @@ -8,7 +8,7 @@ import com.yahoo.path.Path; import com.yahoo.config.model.application.provider.*; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.server.*; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.vespa.config.server.deploy.ZooKeeperClient; import com.yahoo.vespa.curator.Curator; @@ -162,7 +162,7 @@ public class LocalSessionTest { zkClient.feedZKFileRegistries(Collections.singletonMap(Version.fromIntValues(0, 0, 0), new MockFileRegistry())); File sessionDir = new File(tenantFileSystemDirs.path(), String.valueOf(sessionId)); sessionDir.createNewFile(); - return new LocalSession(tenant, sessionId, preparer, new SessionContext(FilesApplicationPackage.fromFile(testApp), zkc, sessionDir, new MemoryApplicationRepo(), new HostRegistry<>(), superModelGenerationCounter)); + return new LocalSession(tenant, sessionId, preparer, new SessionContext(FilesApplicationPackage.fromFile(testApp), zkc, sessionDir, new MemoryTenantApplications(), new HostRegistry<>(), superModelGenerationCounter)); } private void doPrepare(LocalSession session) { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java index 27df54b2174..239bfea3618 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/RemoteSessionRepoTest.java @@ -11,7 +11,7 @@ import com.yahoo.text.Utf8; import com.yahoo.transaction.Transaction; import com.yahoo.vespa.config.server.*; -import com.yahoo.vespa.config.server.application.ApplicationRepo; +import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.curator.Curator; import org.junit.Before; import org.junit.Test; @@ -85,7 +85,7 @@ public class RemoteSessionRepoTest extends TestWithCurator { @Test public void testBadApplicationRepoOnActivate() throws Exception { - ApplicationRepo applicationRepo = new FailingApplicationRepo(); + TenantApplications applicationRepo = new FailingTenantApplications(); curator.framework().create().forPath("/mytenant"); Tenant tenant = TenantBuilder.create(new TestComponentRegistry(curator), TenantName.from("mytenant"), Path.fromString("mytenant")) .withApplicationRepo(applicationRepo) @@ -132,7 +132,7 @@ public class RemoteSessionRepoTest extends TestWithCurator { } while (System.currentTimeMillis() < endTime && !ok); } - private class FailingApplicationRepo implements ApplicationRepo { + private class FailingTenantApplications implements TenantApplications { @Override public List<ApplicationId> listApplications() { diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java index ba69281c342..eb98fc4f6e0 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java @@ -19,7 +19,7 @@ import com.yahoo.path.Path; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.server.*; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.config.server.application.MemoryApplicationRepo; +import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; import com.yahoo.vespa.config.server.configchange.MockRestartAction; import com.yahoo.vespa.config.server.configchange.RestartActions; @@ -234,7 +234,7 @@ public class SessionPreparerTest extends TestWithCurator { } private SessionContext getContext(FilesApplicationPackage app) throws IOException { - return new SessionContext(app, new SessionZooKeeperClient(curator, appPath), app.getAppDir(), new MemoryApplicationRepo(), new HostRegistry<>(), new SuperModelGenerationCounter(curator)); + return new SessionContext(app, new SessionZooKeeperClient(curator, appPath), app.getAppDir(), new MemoryTenantApplications(), new HostRegistry<>(), new SuperModelGenerationCounter(curator)); } private FilesApplicationPackage getApplicationPackage(File testFile) throws IOException { |