diff options
author | Harald Musum <musum@oath.com> | 2018-04-27 09:16:13 +0200 |
---|---|---|
committer | Harald Musum <musum@oath.com> | 2018-04-27 09:16:13 +0200 |
commit | d66e9892c1bf3920ad402152e4a8c6870dd1ff77 (patch) | |
tree | 4e68c3c18ffb21816fe789a66734f17c5be68f44 /configserver/src/main | |
parent | e34eafa914c22654beeb33f6c536fe0b216f3fb7 (diff) |
Rename tenant repo
Diffstat (limited to 'configserver/src/main')
36 files changed, 161 insertions, 179 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 43be4e279f0..2347faf233b 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 @@ -45,7 +45,7 @@ import com.yahoo.vespa.config.server.session.SessionFactory; import com.yahoo.vespa.config.server.session.SilentDeployLogger; import com.yahoo.vespa.config.server.tenant.Rotations; import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.io.File; import java.io.IOException; @@ -77,7 +77,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye private static final Logger log = Logger.getLogger(ApplicationRepository.class.getName()); - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Optional<Provisioner> hostProvisioner; private final ApplicationConvergenceChecker convergeChecker; private final HttpProxy httpProxy; @@ -88,32 +88,32 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye private final FileDistributionStatus fileDistributionStatus; @Inject - public ApplicationRepository(Tenants tenants, + public ApplicationRepository(TenantRepository tenantRepository, HostProvisionerProvider hostProvisionerProvider, ApplicationConvergenceChecker applicationConvergenceChecker, HttpProxy httpProxy, ConfigserverConfig configserverConfig) { - this(tenants, hostProvisionerProvider.getHostProvisioner(), + this(tenantRepository, hostProvisionerProvider.getHostProvisioner(), applicationConvergenceChecker, httpProxy, configserverConfig, Clock.systemUTC(), new FileDistributionStatus()); } // For testing - public ApplicationRepository(Tenants tenants, + public ApplicationRepository(TenantRepository tenantRepository, Provisioner hostProvisioner, Clock clock) { - this(tenants, Optional.of(hostProvisioner), + this(tenantRepository, Optional.of(hostProvisioner), new ApplicationConvergenceChecker(), new HttpProxy(new SimpleHttpFetcher()), new ConfigserverConfig(new ConfigserverConfig.Builder()), clock, new FileDistributionStatus()); } - private ApplicationRepository(Tenants tenants, + private ApplicationRepository(TenantRepository tenantRepository, Optional<Provisioner> hostProvisioner, ApplicationConvergenceChecker applicationConvergenceChecker, HttpProxy httpProxy, ConfigserverConfig configserverConfig, Clock clock, FileDistributionStatus fileDistributionStatus) { - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.hostProvisioner = hostProvisioner; this.convergeChecker = applicationConvergenceChecker; this.httpProxy = httpProxy; @@ -134,7 +134,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye DeployLogger logger = new DeployHandlerLogger(deployLog.get().setArray("log"), prepareParams.isVerbose(), applicationId); ConfigChangeActions actions = session.prepare(logger, prepareParams, currentActiveApplicationSet, tenant.getPath(), now); logConfigChangeActions(actions, logger); - log.log(LogLevel.INFO, Tenants.logPre(applicationId) + "Session " + sessionId + " prepared successfully. "); + log.log(LogLevel.INFO, TenantRepository.logPre(applicationId) + "Session " + sessionId + " prepared successfully. "); return new PrepareResult(sessionId, actions, deployLog); } @@ -146,7 +146,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } public PrepareResult deploy(CompressedApplicationInputStream in, PrepareParams prepareParams) { - Tenant tenant = tenants.getTenant(prepareParams.getApplicationId().tenant()); + Tenant tenant = tenantRepository.getTenant(prepareParams.getApplicationId().tenant()); return deploy(tenant, in, prepareParams, false, false, clock.instant()); } @@ -181,7 +181,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye */ @Override public Optional<com.yahoo.config.provision.Deployment> deployFromLocalActive(ApplicationId application, Duration timeout) { - Tenant tenant = tenants.getTenant(application.tenant()); + Tenant tenant = tenantRepository.getTenant(application.tenant()); if (tenant == null) return Optional.empty(); LocalSession activeSession = getActiveSession(tenant, application); if (activeSession == null) return Optional.empty(); @@ -222,7 +222,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye * @throws RuntimeException if the remove transaction fails. This method is exception safe. */ public boolean remove(ApplicationId applicationId) { - Optional<Tenant> owner = Optional.ofNullable(tenants.getTenant(applicationId.tenant())); + Optional<Tenant> owner = Optional.ofNullable(tenantRepository.getTenant(applicationId.tenant())); if ( ! owner.isPresent()) return false; TenantApplications tenantApplications = owner.get().getApplicationRepo(); @@ -277,7 +277,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye } public ApplicationFile getApplicationFileFromSession(TenantName tenantName, long sessionId, String path, LocalSession.Mode mode) { - Tenant tenant = tenants.getTenant(tenantName); + Tenant tenant = tenantRepository.getTenant(tenantName); return getLocalSession(tenant, sessionId).getApplicationFile(Path.fromString(path), mode); } @@ -307,7 +307,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye * @return the active session, or null if there is no active session for the given application id. */ public LocalSession getActiveSession(ApplicationId applicationId) { - return getActiveSession(tenants.getTenant(applicationId.tenant()), applicationId); + return getActiveSession(tenantRepository.getTenant(applicationId.tenant()), applicationId); } public long getSessionIdForApplication(Tenant tenant, ApplicationId applicationId) { @@ -354,10 +354,10 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye public Tenant verifyTenantAndApplication(ApplicationId applicationId) { TenantName tenantName = applicationId.tenant(); - if (!tenants.checkThatTenantExists(tenantName)) { + if (!tenantRepository.checkThatTenantExists(tenantName)) { throw new IllegalArgumentException("Tenant " + tenantName + " was not found."); } - Tenant tenant = tenants.getTenant(tenantName); + Tenant tenant = tenantRepository.getTenant(tenantName); List<ApplicationId> applicationIds = listApplicationIds(tenant); if (!applicationIds.contains(applicationId)) { throw new IllegalArgumentException("No such application id: " + applicationId); @@ -439,7 +439,7 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye new DaemonThreadFactory("redeploy apps")); // Keep track of deployment per application Map<ApplicationId, Future<?>> futures = new HashMap<>(); - tenants.getAllTenants() + tenantRepository.getAllTenants() .forEach(tenant -> listApplicationIds(tenant) .forEach(appId -> deployFromLocalActive(appId).ifPresent( deployment -> futures.put(appId,executor.submit(deployment::activate))))); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java b/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java index 931fbebf0ba..ea14b9194e8 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/GetConfigContext.java @@ -4,7 +4,7 @@ package com.yahoo.vespa.config.server; import com.yahoo.vespa.config.protocol.Trace; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; /** * Contains the context for serving getconfig requests so that this information does not have to be looked up multiple times. @@ -53,6 +53,6 @@ public class GetConfigContext { * @return log msg preamble */ public String logPre() { - return Tenants.logPre(app); + return TenantRepository.logPre(app); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java index f8f11416811..c2b4d2f9e62 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/Application.java @@ -17,7 +17,7 @@ import com.yahoo.vespa.config.protocol.ConfigResponse; import com.yahoo.vespa.config.protocol.DefContent; import com.yahoo.vespa.config.server.rpc.ConfigResponseFactory; import com.yahoo.vespa.config.server.ServerCache; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.rpc.UncompressedConfigResponseFactory; import com.yahoo.vespa.config.server.UnknownConfigDefinitionException; import com.yahoo.vespa.config.server.modelfactory.ModelResult; @@ -147,7 +147,7 @@ public class Application implements ModelResult { } private void debug(String message) { - log.log(LogLevel.DEBUG, Tenants.logPre(getId())+message); + log.log(LogLevel.DEBUG, TenantRepository.logPre(getId())+message); } private ConfigDefinition getTargetDef(GetConfigRequest req) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKTenantApplications.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKTenantApplications.java index d6f34650f8f..27306289a9e 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKTenantApplications.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/ZKTenantApplications.java @@ -10,7 +10,7 @@ import com.yahoo.path.Path; import com.yahoo.text.Utf8; import com.yahoo.transaction.Transaction; import com.yahoo.vespa.config.server.ReloadHandler; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.curator.Curator; import com.yahoo.vespa.curator.transaction.CuratorOperations; import com.yahoo.vespa.curator.transaction.CuratorTransaction; @@ -58,9 +58,9 @@ public class ZKTenantApplications implements TenantApplications, PathChildrenCac public static TenantApplications create(Curator curator, ReloadHandler reloadHandler, TenantName tenant) { try { - return new ZKTenantApplications(curator, Tenants.getApplicationsPath(tenant), reloadHandler, tenant); + return new ZKTenantApplications(curator, TenantRepository.getApplicationsPath(tenant), reloadHandler, tenant); } catch (Exception e) { - throw new RuntimeException(Tenants.logPre(tenant) + "Error creating application repo", e); + throw new RuntimeException(TenantRepository.logPre(tenant) + "Error creating application repo", e); } } @@ -69,7 +69,7 @@ public class ZKTenantApplications implements TenantApplications, PathChildrenCac try { return Long.parseLong(Utf8.toString(curator.framework().getData().forPath(path))); } catch (Exception e) { - throw new IllegalArgumentException(Tenants.logPre(appId) + "Unable to read the session id from '" + path + "'", e); + throw new IllegalArgumentException(TenantRepository.logPre(appId) + "Unable to read the session id from '" + path + "'", e); } } @@ -83,7 +83,7 @@ public class ZKTenantApplications implements TenantApplications, PathChildrenCac } return applicationIds; } catch (Exception e) { - throw new RuntimeException(Tenants.logPre(tenant)+"Unable to list applications", e); + throw new RuntimeException(TenantRepository.logPre(tenant)+"Unable to list applications", e); } } @@ -91,7 +91,7 @@ public class ZKTenantApplications implements TenantApplications, PathChildrenCac try { return Optional.of(ApplicationId.fromSerializedForm(appNode)); } catch (IllegalArgumentException e) { - log.log(LogLevel.INFO, Tenants.logPre(tenant)+"Unable to parse application with id '" + appNode + "', ignoring."); + log.log(LogLevel.INFO, TenantRepository.logPre(tenant)+"Unable to parse application with id '" + appNode + "', ignoring."); return Optional.empty(); } } @@ -145,11 +145,11 @@ public class ZKTenantApplications implements TenantApplications, PathChildrenCac private void applicationRemoved(ApplicationId applicationId) { reloadHandler.removeApplication(applicationId); - log.log(LogLevel.INFO, Tenants.logPre(applicationId) + "Application removed: " + applicationId); + log.log(LogLevel.INFO, TenantRepository.logPre(applicationId) + "Application removed: " + applicationId); } private void applicationAdded(ApplicationId applicationId) { - log.log(LogLevel.DEBUG, Tenants.logPre(applicationId) + "Application added: " + applicationId); + log.log(LogLevel.DEBUG, TenantRepository.logPre(applicationId) + "Application added: " + applicationId); } public void removeUnusedApplications() { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/DeployHandlerLogger.java b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/DeployHandlerLogger.java index 1b4c91e8882..9a61494af07 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/DeployHandlerLogger.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/deploy/DeployHandlerLogger.java @@ -6,7 +6,7 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.log.LogLevel; import com.yahoo.slime.Cursor; import com.yahoo.slime.Slime; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.util.logging.Level; import java.util.logging.Logger; @@ -39,7 +39,7 @@ public class DeployHandlerLogger implements DeployLogger { !verbose) { return; } - String fullMsg = Tenants.logPre(app) + message; + String fullMsg = TenantRepository.logPre(app) + message; Cursor entry = logroot.addObject(); entry.setLong("time", System.currentTimeMillis()); entry.setString("level", level.getName()); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandler.java index 8ac992821fd..8ad7a85619c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandler.java @@ -8,7 +8,7 @@ import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.protocol.ConfigResponse; import com.yahoo.vespa.config.server.RequestHandler; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.util.Optional; @@ -29,8 +29,8 @@ public class HttpGetConfigHandler extends HttpHandler { @SuppressWarnings("unused") // injected @Inject - public HttpGetConfigHandler(HttpHandler.Context ctx, Tenants tenants) { - this(ctx, tenants.defaultTenant().getRequestHandler()); + public HttpGetConfigHandler(HttpHandler.Context ctx, TenantRepository tenantRepository) { + this(ctx, tenantRepository.defaultTenant().getRequestHandler()); } @Override diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandler.java index 64361c0771c..fb3b993b8ba 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandler.java @@ -4,19 +4,17 @@ package com.yahoo.vespa.config.server.http; import com.google.inject.Inject; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.slime.Cursor; import com.yahoo.slime.JsonFormat; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.server.RequestHandler; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.config.provision.ApplicationId; import java.io.IOException; import java.io.OutputStream; import java.util.*; -import java.util.concurrent.Executor; import static com.yahoo.jdisc.http.HttpResponse.Status.*; @@ -32,8 +30,8 @@ public class HttpListConfigsHandler extends HttpHandler { private final RequestHandler requestHandler; @Inject - public HttpListConfigsHandler(HttpHandler.Context ctx, Tenants tenants) { - this(ctx, tenants.defaultTenant().getRequestHandler()); + public HttpListConfigsHandler(HttpHandler.Context ctx, TenantRepository tenantRepository) { + this(ctx, tenantRepository.defaultTenant().getRequestHandler()); } public HttpListConfigsHandler(HttpHandler.Context ctx, RequestHandler requestHandler) { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListNamedConfigsHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListNamedConfigsHandler.java index 81163d79341..4602153fab1 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListNamedConfigsHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/HttpListNamedConfigsHandler.java @@ -5,16 +5,14 @@ import com.google.inject.Inject; import com.yahoo.collections.Tuple2; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.jdisc.application.BindingMatch; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.server.RequestHandler; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.config.provision.ApplicationId; import java.util.Optional; import java.util.Set; -import java.util.concurrent.Executor; /** * Handler for a list configs of given name operation. Lists all configs in model for a given config name. @@ -33,8 +31,8 @@ public class HttpListNamedConfigsHandler extends HttpHandler { @Inject public HttpListNamedConfigsHandler(HttpHandler.Context ctx, - Tenants tenants) { - this(ctx, tenants.defaultTenant().getRequestHandler()); + TenantRepository tenantRepository) { + this(ctx, tenantRepository.defaultTenant().getRequestHandler()); } @Override diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/Utils.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/Utils.java index e5bf8e22020..d0da7fcd4bd 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/Utils.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/Utils.java @@ -5,7 +5,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.jdisc.application.BindingMatch; import com.yahoo.jdisc.application.UriPattern; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.net.URI; @@ -43,8 +43,8 @@ public class Utils { return request.getUri().getScheme() + "://" + request.getHost() + ":" + request.getPort() + pathPrefix; } - public static void checkThatTenantExists(Tenants tenants, TenantName tenantName) { - if ( ! tenants.checkThatTenantExists(tenantName)) + public static void checkThatTenantExists(TenantRepository tenantRepository, TenantName tenantName) { + if ( ! tenantRepository.checkThatTenantExists(tenantName)) throw new NotFoundException("Tenant '" + tenantName + "' was not found."); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java index 4c1d0744848..9c19b4dce87 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationApiHandler.java @@ -13,7 +13,7 @@ import com.yahoo.vespa.config.server.http.SessionHandler; import com.yahoo.vespa.config.server.http.Utils; import com.yahoo.vespa.config.server.session.PrepareParams; import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.time.Duration; import java.time.Instant; @@ -30,18 +30,18 @@ public class ApplicationApiHandler extends SessionHandler { public final static String APPLICATION_X_GZIP = "application/x-gzip"; public final static String APPLICATION_ZIP = "application/zip"; public final static String contentTypeHeader = "Content-Type"; - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Duration zookeeperBarrierTimeout; private final Zone zone; @Inject public ApplicationApiHandler(Context ctx, ApplicationRepository applicationRepository, - Tenants tenants, + TenantRepository tenantRepository, ConfigserverConfig configserverConfig, Zone zone) { super(ctx, applicationRepository); - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.zookeeperBarrierTimeout = Duration.ofSeconds(configserverConfig.zookeeper().barrierTimeout()); this.zone = zone; } @@ -84,8 +84,8 @@ public class ApplicationApiHandler extends SessionHandler { private Tenant getExistingTenant(HttpRequest request) { TenantName tenantName = Utils.getTenantNameFromSessionRequest(request); - Utils.checkThatTenantExists(tenants, tenantName); - return tenants.getTenant(tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); + return tenantRepository.getTenant(tenantName); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpConfigRequests.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpConfigRequests.java index 59270afd397..8b482997044 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpConfigRequests.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpConfigRequests.java @@ -9,7 +9,7 @@ import com.yahoo.jdisc.application.UriPattern; import com.yahoo.jdisc.application.UriPattern.Match; import com.yahoo.vespa.config.server.RequestHandler; import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.http.NotFoundException; /** @@ -45,8 +45,8 @@ public class HttpConfigRequests { } - static RequestHandler getRequestHandler(Tenants tenants, TenantRequest request) { - Tenant tenant = tenants.getTenant(request.getApplicationId().tenant()); + static RequestHandler getRequestHandler(TenantRepository tenantRepository, TenantRequest request) { + Tenant tenant = tenantRepository.getTenant(request.getApplicationId().tenant()); if (tenant==null) throw new NotFoundException("No such tenant: "+request.getApplicationId().tenant()); return tenant.getRequestHandler(); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandler.java index 0ca720c9710..e8e02a4cbdc 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandler.java @@ -4,17 +4,15 @@ package com.yahoo.vespa.config.server.http.v2; import com.google.inject.Inject; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.protocol.ConfigResponse; import com.yahoo.vespa.config.server.RequestHandler; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.http.HttpConfigRequest; import com.yahoo.vespa.config.server.http.HttpConfigResponse; import com.yahoo.vespa.config.server.http.HttpHandler; import java.util.Optional; -import java.util.concurrent.Executor; /** * HTTP handler for a getConfig operation @@ -24,20 +22,20 @@ import java.util.concurrent.Executor; */ public class HttpGetConfigHandler extends HttpHandler { - private final Tenants tenants; + private final TenantRepository tenantRepository; @Inject public HttpGetConfigHandler(HttpHandler.Context ctx, - Tenants tenants) + TenantRepository tenantRepository) { super(ctx); - this.tenants = tenants; + this.tenantRepository = tenantRepository; } @Override public HttpResponse handleGET(HttpRequest req) { HttpConfigRequest request = HttpConfigRequest.createFromRequestV2(req); - RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenants, request); + RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenantRepository, request); HttpConfigRequest.validateRequestKey(request.getConfigKey(), requestHandler, request.getApplicationId()); return HttpConfigResponse.createFromConfig(resolveConfig(request, requestHandler)); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandler.java index 2a9e2b1ecf4..71be471193a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandler.java @@ -4,19 +4,18 @@ package com.yahoo.vespa.config.server.http.v2; import java.io.IOException; import java.io.OutputStream; import java.util.*; -import java.util.concurrent.Executor; + import com.google.inject.Inject; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.path.Path; import com.yahoo.slime.Cursor; import com.yahoo.slime.JsonFormat; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.server.RequestHandler; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.server.http.HttpConfigResponse; import com.yahoo.vespa.config.server.http.HttpHandler; @@ -30,22 +29,22 @@ import static com.yahoo.jdisc.http.HttpResponse.Status.*; * @since 5.3 */ public class HttpListConfigsHandler extends HttpHandler { - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Zone zone; @Inject public HttpListConfigsHandler(HttpHandler.Context ctx, - Tenants tenants, Zone zone) + TenantRepository tenantRepository, Zone zone) { super(ctx); - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.zone = zone; } @Override public HttpResponse handleGET(HttpRequest req) { HttpListConfigsRequest listReq = HttpListConfigsRequest.createFromListRequest(req); - RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenants, listReq); + RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenantRepository, listReq); ApplicationId appId = listReq.getApplicationId(); Set<ConfigKey<?>> configs = requestHandler.listConfigs(appId, Optional.empty(), listReq.isRecursive()); String urlBase = getUrlBase(req, listReq, appId, zone); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListNamedConfigsHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListNamedConfigsHandler.java index 0a55d3585e0..bbc2efe9c36 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListNamedConfigsHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/HttpListNamedConfigsHandler.java @@ -3,16 +3,14 @@ package com.yahoo.vespa.config.server.http.v2; import java.util.Optional; import java.util.Set; -import java.util.concurrent.Executor; import com.google.inject.Inject; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.vespa.config.ConfigKey; import com.yahoo.vespa.config.server.RequestHandler; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.server.http.HttpConfigRequest; import com.yahoo.vespa.config.server.http.HttpHandler; @@ -25,22 +23,22 @@ import com.yahoo.vespa.config.server.http.HttpHandler; */ public class HttpListNamedConfigsHandler extends HttpHandler { - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Zone zone; @Inject public HttpListNamedConfigsHandler(HttpHandler.Context ctx, - Tenants tenants, Zone zone) + TenantRepository tenantRepository, Zone zone) { super(ctx); - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.zone = zone; } @Override public HttpResponse handleGET(HttpRequest req) { HttpListConfigsRequest listReq = HttpListConfigsRequest.createFromNamedListRequest(req); - RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenants, listReq); + RequestHandler requestHandler = HttpConfigRequests.getRequestHandler(tenantRepository, listReq); ApplicationId appId = listReq.getApplicationId(); HttpConfigRequest.validateRequestKey(listReq.getKey(), requestHandler, appId); Set<ConfigKey<?>> configs = requestHandler.listNamedConfigs(appId, Optional.empty(), listReq.getKey(), listReq.isRecursive()); 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 42872881088..63298553db4 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 @@ -8,10 +8,9 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.jdisc.Response; import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.http.HttpHandler; @@ -19,7 +18,6 @@ import com.yahoo.vespa.config.server.http.Utils; import java.util.Collection; import java.util.List; -import java.util.concurrent.Executor; /** * Handler for listing currently active applications for a tenant. @@ -28,14 +26,14 @@ import java.util.concurrent.Executor; * @since 5.1 */ public class ListApplicationsHandler extends HttpHandler { - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Zone zone; @Inject public ListApplicationsHandler(HttpHandler.Context ctx, - Tenants tenants, Zone zone) { + TenantRepository tenantRepository, Zone zone) { super(ctx); - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.zone = zone; } @@ -55,8 +53,8 @@ public class ListApplicationsHandler extends HttpHandler { } private List<ApplicationId> listApplicationIds(TenantName tenantName) { - Utils.checkThatTenantExists(tenants, tenantName); - Tenant tenant = tenants.getTenant(tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); + Tenant tenant = tenantRepository.getTenant(tenantName); TenantApplications applicationRepo = tenant.getApplicationRepo(); return applicationRepo.listApplications(); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandler.java index 07e9d1bd236..e482bec9ed9 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandler.java @@ -15,7 +15,7 @@ import com.yahoo.jdisc.handler.ResponseHandler; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.TimeoutBudget; import com.yahoo.vespa.config.server.http.SessionHandler; import com.yahoo.vespa.config.server.http.Utils; @@ -30,24 +30,24 @@ public class SessionActiveHandler extends SessionHandler { private static final Duration DEFAULT_ACTIVATE_TIMEOUT = Duration.ofMinutes(2); - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Zone zone; @Inject public SessionActiveHandler(SessionHandler.Context ctx, ApplicationRepository applicationRepository, - Tenants tenants, + TenantRepository tenantRepository, Zone zone) { super(ctx, applicationRepository); - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.zone = zone; } @Override protected HttpResponse handlePUT(HttpRequest request) { final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request); - Utils.checkThatTenantExists(tenants, tenantName); - Tenant tenant = tenants.getTenant(tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); + Tenant tenant = tenantRepository.getTenant(tenantName); TimeoutBudget timeoutBudget = getTimeoutBudget(request, DEFAULT_ACTIVATE_TIMEOUT); final Long sessionId = getSessionIdV2(request); ApplicationId applicationId = applicationRepository.activate(tenant, sessionId, timeoutBudget, diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java index 524eb01e625..2d3a394217c 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandler.java @@ -6,16 +6,13 @@ import com.yahoo.config.application.api.ApplicationFile; import com.yahoo.config.provision.TenantName; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.logging.AccessLog; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.http.ContentRequest; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.http.ContentHandler; import com.yahoo.vespa.config.server.http.SessionHandler; import com.yahoo.vespa.config.server.http.Utils; -import java.util.concurrent.Executor; - /** * A handler that will return content or content status for files or directories * in the session's application package @@ -24,16 +21,16 @@ import java.util.concurrent.Executor; * @since 5.1 */ public class SessionContentHandler extends SessionHandler { - private final Tenants tenants; + private final TenantRepository tenantRepository; private final ContentHandler contentHandler = new ContentHandler(); @Inject public SessionContentHandler(SessionHandler.Context ctx, ApplicationRepository applicationRepository, - Tenants tenants) + TenantRepository tenantRepository) { super(ctx, applicationRepository); - this.tenants = tenants; + this.tenantRepository = tenantRepository; } @Override @@ -52,7 +49,7 @@ public class SessionContentHandler extends SessionHandler { } private void validateRequest(TenantName tenantName) { - Utils.checkThatTenantExists(tenants, tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); } private SessionContentRequestV2 getContentRequest(HttpRequest request) { 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 316160df6ac..07858d3864c 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 @@ -13,9 +13,8 @@ import com.yahoo.log.LogLevel; import com.yahoo.slime.Slime; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.deploy.DeployHandlerLogger; -import com.yahoo.vespa.config.server.http.CompressedApplicationInputStream; import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.TimeoutBudget; import com.yahoo.vespa.config.server.http.BadRequestException; import com.yahoo.vespa.config.server.http.SessionHandler; @@ -35,16 +34,16 @@ public class SessionCreateHandler extends SessionHandler { private static final String fromPattern = "http://*/application/v2/tenant/*/application/*/environment/*/region/*/instance/*"; - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Duration zookeeperBarrierTimeout; @Inject public SessionCreateHandler(SessionHandler.Context ctx, ApplicationRepository applicationRepository, - Tenants tenants, + TenantRepository tenantRepository, ConfigserverConfig configserverConfig) { super(ctx, applicationRepository); - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.zookeeperBarrierTimeout = Duration.ofSeconds(configserverConfig.zookeeper().barrierTimeout()); } @@ -52,8 +51,8 @@ public class SessionCreateHandler extends SessionHandler { protected HttpResponse handlePOST(HttpRequest request) { Slime deployLog = createDeployLog(); final TenantName tenantName = Utils.getTenantNameFromSessionRequest(request); - Utils.checkThatTenantExists(tenants, tenantName); - Tenant tenant = tenants.getTenant(tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); + Tenant tenant = tenantRepository.getTenant(tenantName); TimeoutBudget timeoutBudget = SessionHandler.getTimeoutBudget(request, zookeeperBarrierTimeout); DeployLogger logger = createLogger(request, deployLog, tenantName); long sessionId; 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 1eca5bc7acc..8a3ad96c078 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 @@ -9,7 +9,7 @@ import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.session.PrepareParams; import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.http.SessionHandler; import com.yahoo.vespa.config.server.http.Utils; @@ -23,16 +23,16 @@ import java.time.Instant; */ public class SessionPrepareHandler extends SessionHandler { - private final Tenants tenants; + private final TenantRepository tenantRepository; private final Duration zookeeperBarrierTimeout; @Inject public SessionPrepareHandler(SessionHandler.Context ctx, ApplicationRepository applicationRepository, - Tenants tenants, + TenantRepository tenantRepository, ConfigserverConfig configserverConfig) { super(ctx, applicationRepository); - this.tenants = tenants; + this.tenantRepository = tenantRepository; this.zookeeperBarrierTimeout = Duration.ofSeconds(configserverConfig.zookeeper().barrierTimeout()); } @@ -62,7 +62,7 @@ public class SessionPrepareHandler extends SessionHandler { private Tenant getExistingTenant(HttpRequest request) { TenantName tenantName = Utils.getTenantNameFromSessionRequest(request); - Utils.checkThatTenantExists(tenants, tenantName); - return tenants.getTenant(tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); + return tenantRepository.getTenant(tenantName); } } 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 91ad514f9ab..3857fea9d14 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 @@ -10,13 +10,13 @@ import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.jdisc.application.BindingMatch; import com.yahoo.vespa.config.server.tenant.Tenant; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.yolean.Exceptions; 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; import com.yahoo.vespa.config.server.http.Utils; -import com.yahoo.vespa.config.server.tenant.Tenants; /** * Handler to create, get and delete a tenant, and listing of tenants. @@ -26,19 +26,19 @@ import com.yahoo.vespa.config.server.tenant.Tenants; public class TenantHandler extends HttpHandler { private static final String TENANT_NAME_REGEXP = "[\\w-]+"; - private final Tenants tenants; + private final TenantRepository tenantRepository; @Inject - public TenantHandler(HttpHandler.Context ctx, Tenants tenants) { + public TenantHandler(HttpHandler.Context ctx, TenantRepository tenantRepository) { super(ctx); - this.tenants = tenants; + this.tenantRepository = tenantRepository; } @Override protected HttpResponse handlePUT(HttpRequest request) { TenantName tenantName = getAndValidateTenantFromRequest(request); try { - tenants.addTenant(tenantName); + tenantRepository.addTenant(tenantName); } catch (Exception e) { throw new InternalServerException(Exceptions.toMessageString(e)); } @@ -49,10 +49,10 @@ public class TenantHandler extends HttpHandler { protected HttpResponse handleGET(HttpRequest request) { if (isGetTenantRequest(request)) { final TenantName tenantName = getTenantNameFromRequest(request); - Utils.checkThatTenantExists(tenants, tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); return new TenantGetResponse(tenantName); } else if (isListTenantsRequest(request)) { - return new ListTenantsResponse(tenants.getAllTenantNames()); + return new ListTenantsResponse(tenantRepository.getAllTenantNames()); } else { throw new BadRequestException(request.getUri().toString()); } @@ -61,14 +61,14 @@ public class TenantHandler extends HttpHandler { @Override protected HttpResponse handleDELETE(HttpRequest request) { final TenantName tenantName = getTenantNameFromRequest(request); - Utils.checkThatTenantExists(tenants, tenantName); + Utils.checkThatTenantExists(tenantRepository, tenantName); // TODO: Move logic to ApplicationRepository - Tenant tenant = tenants.getTenant(tenantName); + Tenant tenant = tenantRepository.getTenant(tenantName); TenantApplications applicationRepo = tenant.getApplicationRepo(); final List<ApplicationId> activeApplications = applicationRepo.listApplications(); if (activeApplications.isEmpty()) { try { - tenants.deleteTenant(tenantName); + tenantRepository.deleteTenant(tenantName); } catch (IllegalArgumentException e) { throw e; } catch (Exception e) { @@ -101,7 +101,7 @@ public class TenantHandler extends HttpHandler { } private void checkThatTenantDoesNotExist(TenantName tenantName) { - if (tenants.checkThatTenantExists(tenantName)) + if (tenantRepository.checkThatTenantExists(tenantName)) throw new BadRequestException("There already exists a tenant '" + tenantName + "'"); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/model/RoutingProducer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/model/RoutingProducer.java index 850b3f99d16..51e685c86c8 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/model/RoutingProducer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/model/RoutingProducer.java @@ -7,7 +7,7 @@ import com.yahoo.config.model.api.HostInfo; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.util.Map; @@ -40,7 +40,7 @@ public class RoutingProducer implements RoutingConfig.Producer { } private boolean isHostedVespaRoutingApplication(ApplicationId applicationId) { - return Tenants.HOSTED_VESPA_TENANT.equals(applicationId.tenant()) && + return TenantRepository.HOSTED_VESPA_TENANT.equals(applicationId.tenant()) && (ROUTING_APPLICATION.equals(applicationId.application())); } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java index 08fd0a7afda..9d583d27341 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/modelfactory/ActivatedModelsBuilder.java @@ -12,12 +12,11 @@ import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.AllocatedHosts; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Version; -import com.yahoo.config.provision.Zone; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.server.GlobalComponentRegistry; import com.yahoo.vespa.config.server.tenant.Rotations; import com.yahoo.vespa.config.server.ServerCache; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.application.Application; import com.yahoo.vespa.config.server.application.PermanentApplicationPackage; import com.yahoo.vespa.config.server.deploy.ModelContextImpl; @@ -109,7 +108,7 @@ public class ActivatedModelsBuilder extends ModelsBuilder<Application> { applicationId, configserverConfig, zone(), - new Rotations(curator, Tenants.getTenantPath(tenant)).readRotationsFromZooKeeper(applicationId)); + new Rotations(curator, TenantRepository.getTenantPath(tenant)).readRotationsFromZooKeeper(applicationId)); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponses.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponses.java index 8aaf053247e..fd155188884 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponses.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/DelayedConfigResponses.java @@ -10,7 +10,7 @@ import com.yahoo.vespa.config.server.GetConfigContext; import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import com.yahoo.vespa.config.server.monitoring.Metrics; import com.yahoo.config.provision.ApplicationId; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import java.util.*; import java.util.concurrent.*; @@ -104,7 +104,7 @@ public class DelayedConfigResponses { public ApplicationId getAppId() { return app; } String logPre() { - return Tenants.logPre(app); + return TenantRepository.logPre(app); } synchronized void cancelAndRemove() { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java index 5a1352de17d..b37d013cc6b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/GetConfigProcessor.java @@ -13,7 +13,7 @@ import com.yahoo.vespa.config.UnknownConfigIdException; import com.yahoo.vespa.config.protocol.*; import com.yahoo.vespa.config.server.GetConfigContext; import com.yahoo.vespa.config.server.UnknownConfigDefinitionException; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.util.ConfigUtils; import java.util.Optional; @@ -102,7 +102,7 @@ class GetConfigProcessor implements Runnable { return; } - this.logPre = Tenants.logPre(context.applicationId()); + this.logPre = TenantRepository.logPre(context.applicationId()); ConfigResponse config; try { config = rpcServer.resolveConfig(request, context, vespaVersion); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java index d612a0fb8f2..9de587ac17b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java @@ -40,7 +40,7 @@ import com.yahoo.vespa.config.server.monitoring.MetricUpdater; import com.yahoo.vespa.config.server.monitoring.MetricUpdaterFactory; import com.yahoo.vespa.config.server.tenant.TenantHandlerProvider; import com.yahoo.vespa.config.server.tenant.TenantListener; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.filedistribution.FileDownloader; import com.yahoo.vespa.filedistribution.FileReceiver; import com.yahoo.vespa.filedistribution.FileReferenceData; @@ -222,13 +222,13 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { @Override public void configActivated(TenantName tenant, ApplicationSet applicationSet) { ApplicationId applicationId = applicationSet.getId(); - configReloaded(delayedConfigResponses.drainQueue(applicationId), Tenants.logPre(applicationId)); + configReloaded(delayedConfigResponses.drainQueue(applicationId), TenantRepository.logPre(applicationId)); reloadSuperModel(tenant, applicationSet); } private void reloadSuperModel(TenantName tenant, ApplicationSet applicationSet) { superModelRequestHandler.reloadConfig(tenant, applicationSet); - configReloaded(delayedConfigResponses.drainQueue(ApplicationId.global()), Tenants.logPre(ApplicationId.global())); + configReloaded(delayedConfigResponses.drainQueue(ApplicationId.global()), TenantRepository.logPre(ApplicationId.global())); } private void configReloaded(List<DelayedConfigResponses.DelayedConfigResponse> responses, String logPre) { @@ -286,8 +286,8 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { @Override public void applicationRemoved(ApplicationId applicationId) { superModelRequestHandler.removeApplication(applicationId); - configReloaded(delayedConfigResponses.drainQueue(applicationId), Tenants.logPre(applicationId)); - configReloaded(delayedConfigResponses.drainQueue(ApplicationId.global()), Tenants.logPre(ApplicationId.global())); + configReloaded(delayedConfigResponses.drainQueue(applicationId), TenantRepository.logPre(applicationId)); + configReloaded(delayedConfigResponses.drainQueue(ApplicationId.global()), TenantRepository.logPre(ApplicationId.global())); } public void respond(JRTServerConfigRequest request) { @@ -370,7 +370,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { } TenantName tenant = optionalTenant.orElse(TenantName.defaultName()); // perhaps needed for non-hosted? if ( ! hasRequestHandler(tenant)) { - String msg = Tenants.logPre(tenant) + "Unable to find request handler for tenant. Requested from host '" + request.getClientHostName() + "'"; + String msg = TenantRepository.logPre(tenant) + "Unable to find request handler for tenant. Requested from host '" + request.getClientHostName() + "'"; metrics.incUnknownHostRequests(); trace.trace(TRACELEVEL, msg); log.log(LogLevel.WARNING, msg); @@ -401,7 +401,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { @Override public void onTenantDelete(TenantName tenant) { - log.log(LogLevel.DEBUG, Tenants.logPre(tenant)+"Tenant deleted, removing request handler and cleaning host registry"); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant)+"Tenant deleted, removing request handler and cleaning host registry"); if (tenantProviders.containsKey(tenant)) { tenantProviders.remove(tenant); } @@ -416,7 +416,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener { @Override public void onTenantCreate(TenantName tenant, TenantHandlerProvider tenantHandlerProvider) { - log.log(LogLevel.DEBUG, Tenants.logPre(tenant)+"Tenant created, adding request handler"); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant)+"Tenant created, adding request handler"); tenantProviders.put(tenant, tenantHandlerProvider); } 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 308ca31f278..d294e462c44 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 @@ -18,7 +18,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.config.server.application.ApplicationSet; import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.configchange.ConfigChangeActions; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.curator.Curator; import java.io.File; @@ -178,9 +178,9 @@ public class LocalSession extends Session implements Comparable<LocalSession> { @Override public String logPre() { if (getApplicationId().equals(ApplicationId.defaultId())) { - return Tenants.logPre(getTenant()); + return TenantRepository.logPre(getTenant()); } else { - return Tenants.logPre(getApplicationId()); + return TenantRepository.logPre(getApplicationId()); } } 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 5f3cf46e0de..454b98ddc05 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 @@ -7,7 +7,7 @@ import com.yahoo.vespa.config.server.*; import com.yahoo.log.LogLevel; import com.yahoo.vespa.config.server.application.ApplicationSet; import com.yahoo.vespa.config.server.modelfactory.ActivatedModelsBuilder; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.curator.Curator; import org.apache.zookeeper.KeeperException; @@ -90,10 +90,10 @@ public class RemoteSession extends Session { @Override public String logPre() { if (applicationSet != null) { - return Tenants.logPre(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getId()); + return TenantRepository.logPre(applicationSet.getForVersionOrLatest(Optional.empty(), Instant.now()).getId()); } - return Tenants.logPre(getTenant()); + return TenantRepository.logPre(getTenant()); } public void confirmUpload() { diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionFactory.java b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionFactory.java index e96ddb4b094..44641b79d65 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionFactory.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/session/RemoteSessionFactory.java @@ -6,7 +6,7 @@ import com.yahoo.path.Path; import com.yahoo.config.model.api.ConfigDefinitionRepo; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.vespa.config.server.GlobalComponentRegistry; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.zookeeper.ConfigCurator; import com.yahoo.vespa.curator.Curator; @@ -32,7 +32,7 @@ public class RemoteSessionFactory { this.componentRegistry = componentRegistry; this.curator = componentRegistry.getCurator(); this.configCurator = componentRegistry.getConfigCurator(); - this.sessionsPath = Tenants.getSessionsPath(tenant); + this.sessionsPath = TenantRepository.getSessionsPath(tenant); this.tenant = tenant; this.defRepo = componentRegistry.getConfigDefinitionRepo(); this.configserverConfig = componentRegistry.getConfigserverConfig(); 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 bbb8dc8292d..b71e85021c3 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 @@ -14,7 +14,7 @@ import com.yahoo.log.LogLevel; import com.yahoo.path.Path; import com.yahoo.transaction.NestedTransaction; import com.yahoo.vespa.config.server.application.ApplicationSet; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.curator.Curator; import com.yahoo.yolean.Exceptions; import com.yahoo.vespa.config.server.ReloadHandler; @@ -63,7 +63,7 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> implements Nod MetricUpdater metricUpdater, ExecutorService executorService) { this.curator = curator; - this.sessionsPath = Tenants.getSessionsPath(tenant); + this.sessionsPath = TenantRepository.getSessionsPath(tenant); this.applicationRepo = applicationRepo; this.remoteSessionFactory = remoteSessionFactory; this.reloadHandler = reloadHandler; @@ -79,7 +79,7 @@ public class RemoteSessionRepo extends SessionRepo<RemoteSession> implements Nod this.curator = null; this.remoteSessionFactory = null; this.reloadHandler = null; - this.sessionsPath = Tenants.getSessionsPath(tenantName); + this.sessionsPath = TenantRepository.getSessionsPath(tenantName); this.metrics = null; this.directoryCache = null; this.applicationRepo = null; 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 1e9c3847679..653df81f296 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 @@ -2,7 +2,7 @@ package com.yahoo.vespa.config.server.session; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; /** * A session represents an instance of an application that can be edited, prepared and activated. This @@ -65,7 +65,7 @@ public abstract class Session { * @return log preamble */ public String logPre() { - return Tenants.logPre(getTenant()); + return TenantRepository.logPre(getTenant()); } } 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 9bbaf35bce9..def78a3d9d8 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 @@ -16,8 +16,7 @@ import com.yahoo.config.provision.TenantName; import com.yahoo.vespa.config.server.application.TenantApplications; import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs; import com.yahoo.vespa.config.server.host.HostValidator; -import com.yahoo.vespa.config.server.tenant.Tenant; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; import com.yahoo.vespa.config.server.zookeeper.SessionCounter; import com.yahoo.vespa.config.server.zookeeper.ConfigCurator; import com.yahoo.vespa.curator.Curator; @@ -67,7 +66,7 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { this.curator = globalComponentRegistry.getCurator(); this.configCurator = globalComponentRegistry.getConfigCurator(); this.sessionCounter = sessionCounter; - this.sessionsPath = Tenants.getSessionsPath(tenant); + this.sessionsPath = TenantRepository.getSessionsPath(tenant); this.applicationRepo = applicationRepo; this.tenantFileSystemDirs = tenantFileSystemDirs; this.superModelGenerationCounter = globalComponentRegistry.getSuperModelGenerationCounter(); @@ -107,15 +106,15 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { SessionZooKeeperClient sessionZKClient, TimeoutBudget timeoutBudget, Clock clock) { - log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Creating session " + sessionId + " in ZooKeeper"); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Creating session " + sessionId + " in ZooKeeper"); sessionZKClient.createNewSession(clock.instant().toEpochMilli(), TimeUnit.MILLISECONDS); - log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Creating upload waiter for session " + sessionId); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Creating upload waiter for session " + sessionId); Curator.CompletionWaiter waiter = sessionZKClient.getUploadWaiter(); - log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Done creating upload waiter for session " + sessionId); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Done creating upload waiter for session " + sessionId); LocalSession session = new LocalSession(tenant, sessionId, sessionPreparer, new SessionContext(applicationPackage, sessionZKClient, getSessionAppDir(sessionId), applicationRepo, hostRegistry, superModelGenerationCounter)); - log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Waiting on upload waiter for session " + sessionId); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Waiting on upload waiter for session " + sessionId); waiter.awaitCompletion(timeoutBudget.timeLeft()); - log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Done waiting on upload waiter for session " + sessionId); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Done waiting on upload waiter for session " + sessionId); return session; } @@ -138,7 +137,7 @@ public class SessionFactoryImpl implements SessionFactory, LocalSessionLoader { private LocalSession create(File applicationFile, String applicationName, long currentlyActiveSession, TimeoutBudget timeoutBudget) { long sessionId = sessionCounter.nextSessionId(); Path sessionIdPath = sessionsPath.append(String.valueOf(sessionId)); - log.log(LogLevel.DEBUG, Tenants.logPre(tenant) + "Next session id is " + sessionId + " , sessionIdPath=" + sessionIdPath.getAbsolute()); + log.log(LogLevel.DEBUG, TenantRepository.logPre(tenant) + "Next session id is " + sessionId + " , sessionIdPath=" + sessionIdPath.getAbsolute()); try { ensureZKPathDoesNotExist(sessionIdPath); SessionZooKeeperClient sessionZooKeeperClient = new SessionZooKeeperClient(curator, diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java index 934ba9b754d..daa0b4f4830 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantBuilder.java @@ -48,7 +48,7 @@ public class TenantBuilder { private TenantBuilder(GlobalComponentRegistry componentRegistry, TenantName tenant) { this.componentRegistry = componentRegistry; - this.tenantPath = Tenants.getTenantPath(tenant); + this.tenantPath = TenantRepository.getTenantPath(tenant); this.tenant = tenant; } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java index e599f46e208..caa15699bbf 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/Tenants.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java @@ -43,7 +43,7 @@ import java.util.logging.Logger; * implemented support for it). * * This instance is called from two different threads, the http handler threads and the zookeeper watcher threads. - * To create or delete a tenant, the handler calls {@link Tenants#addTenant} and {@link Tenants#deleteTenant} methods. + * To create or delete a tenant, the handler calls {@link TenantRepository#addTenant} and {@link TenantRepository#deleteTenant} methods. * This will delete shared state from zookeeper, and return, so it does not mean a tenant is immediately deleted. * * Once a tenant is deleted from zookeeper, the zookeeper watcher thread will get notified on all config servers, and @@ -52,8 +52,7 @@ import java.util.logging.Logger; * @author Vegard Havdal * @author Ulf Lilleengen */ -// TODO: Rename to TenantRepository -public class Tenants implements ConnectionStateListener, PathChildrenCacheListener { +public class TenantRepository implements ConnectionStateListener, PathChildrenCacheListener { public static final TenantName HOSTED_VESPA_TENANT = TenantName.from("hosted-vespa"); private static final TenantName DEFAULT_TENANT = TenantName.defaultName(); @@ -61,7 +60,7 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen private static final Path tenantsPath = Path.fromString("/config/v2/tenants/"); private static final Path vespaPath = Path.fromString("/vespa"); private static final Duration checkForRemovedApplicationsInterval = Duration.ofMinutes(1); - private static final Logger log = Logger.getLogger(Tenants.class.getName()); + private static final Logger log = Logger.getLogger(TenantRepository.class.getName()); private final Map<TenantName, Tenant> tenants = new LinkedHashMap<>(); private final GlobalComponentRegistry globalComponentRegistry; @@ -69,7 +68,7 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen private final Curator curator; private final MetricUpdater metricUpdater; - private final ExecutorService pathChildrenExecutor = Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(Tenants.class.getName())); + private final ExecutorService pathChildrenExecutor = Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(TenantRepository.class.getName())); private final ScheduledExecutorService checkForRemovedApplicationsService = new ScheduledThreadPoolExecutor(1); private final Curator.DirectoryCache directoryCache; @@ -80,7 +79,7 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen * @param globalComponentRegistry a {@link com.yahoo.vespa.config.server.GlobalComponentRegistry} */ @Inject - public Tenants(GlobalComponentRegistry globalComponentRegistry) { + public TenantRepository(GlobalComponentRegistry globalComponentRegistry) { this.globalComponentRegistry = globalComponentRegistry; this.curator = globalComponentRegistry.getCurator(); metricUpdater = globalComponentRegistry.getMetrics().getOrCreateMetricUpdater(Collections.emptyMap()); @@ -110,7 +109,7 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen * @param tenants a collection of {@link Tenant}s */ // TODO: Get rid of the second argument and let callers use addTenant() instead - public Tenants(GlobalComponentRegistry globalComponentRegistry, Collection<Tenant> tenants) { + public TenantRepository(GlobalComponentRegistry globalComponentRegistry, Collection<Tenant> tenants) { this.globalComponentRegistry = globalComponentRegistry; this.curator = globalComponentRegistry.getCurator(); metricUpdater = globalComponentRegistry.getMetrics().getOrCreateMetricUpdater(Collections.emptyMap()); @@ -132,7 +131,7 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen for (Tenant t : newTenants) { tenants.put(t.getName(), t); } - log.log(LogLevel.DEBUG, "Tenants at startup: " + tenants); + log.log(LogLevel.DEBUG, "TenantRepository at startup: " + tenants); metricUpdater.setTenants(this.tenants.size()); return tenants; } @@ -261,9 +260,9 @@ public class Tenants implements ConnectionStateListener, PathChildrenCacheListen * Removes the given tenant from ZooKeeper and filesystem. Assumes that tenant exists. * * @param name name of the tenant - * @return this Tenants instance + * @return this TenantRepository instance */ - public synchronized Tenants deleteTenant(TenantName name) { + public synchronized TenantRepository deleteTenant(TenantName name) { if (name.equals(DEFAULT_TENANT)) throw new IllegalArgumentException("Deleting 'default' tenant is not allowed"); log.log(LogLevel.DEBUG, "Deleting tenant '" + name + "'"); diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java index 0a3fefbf53a..d379665f54a 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRequestHandler.java @@ -65,7 +65,7 @@ public class TenantRequestHandler implements RequestHandler, ReloadHandler, Host public ConfigResponse resolveConfig(ApplicationId appId, GetConfigRequest req, Optional<Version> vespaVersion) { Application application = getApplication(appId, vespaVersion); if (log.isLoggable(LogLevel.DEBUG)) { - log.log(LogLevel.DEBUG, Tenants.logPre(appId) + "Resolving for tenant '" + tenant + "' with handler for application '" + application + "'"); + log.log(LogLevel.DEBUG, TenantRepository.logPre(appId) + "Resolving for tenant '" + tenant + "' with handler for application '" + application + "'"); } return application.resolveConfig(req, responseFactory); } @@ -195,7 +195,7 @@ public class TenantRequestHandler implements RequestHandler, ReloadHandler, Host try { return applicationMapper.getForVersion(appId, vespaVersion, clock.instant()); } catch (VersionDoesNotExistException ex) { - throw new NotFoundException(String.format("%sNo such application (id %s): %s", Tenants.logPre(tenant), appId, ex.getMessage())); + throw new NotFoundException(String.format("%sNo such application (id %s): %s", TenantRepository.logPre(tenant), appId, ex.getMessage())); } } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java index b8f5acdb225..2a25553d456 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/zookeeper/SessionCounter.java @@ -2,7 +2,7 @@ package com.yahoo.vespa.config.server.zookeeper; import com.yahoo.config.provision.TenantName; -import com.yahoo.vespa.config.server.tenant.Tenants; +import com.yahoo.vespa.config.server.tenant.TenantRepository; /** * A counter keeping track of session ids in an atomic fashion across multiple config servers. @@ -13,8 +13,8 @@ public class SessionCounter extends InitializedCounter { public SessionCounter(ConfigCurator configCurator, TenantName tenantName) { super(configCurator, - Tenants.getTenantPath(tenantName).append("sessionCounter").getAbsolute(), - Tenants.getSessionsPath(tenantName).getAbsolute()); + TenantRepository.getTenantPath(tenantName).append("sessionCounter").getAbsolute(), + TenantRepository.getSessionsPath(tenantName).getAbsolute()); } /** diff --git a/configserver/src/main/resources/configserver-app/services.xml b/configserver/src/main/resources/configserver-app/services.xml index 9419a09ce7e..a9e67738d96 100644 --- a/configserver/src/main/resources/configserver-app/services.xml +++ b/configserver/src/main/resources/configserver-app/services.xml @@ -28,7 +28,7 @@ <component id="com.yahoo.vespa.config.server.provision.HostProvisionerProvider" bundle="configserver" /> <component id="com.yahoo.vespa.curator.Curator" bundle="configserver" /> <component id="com.yahoo.vespa.config.server.InjectedGlobalComponentRegistry" bundle="configserver" /> - <component id="com.yahoo.vespa.config.server.tenant.Tenants" bundle="configserver" /> + <component id="com.yahoo.vespa.config.server.tenant.TenantRepository" bundle="configserver" /> <component id="com.yahoo.vespa.config.server.application.PermanentApplicationPackage" bundle="configserver" /> <component id="com.yahoo.vespa.config.server.host.HostRegistries" bundle="configserver" /> <component id="com.yahoo.vespa.config.server.ApplicationRepository" bundle="configserver" /> |