aboutsummaryrefslogtreecommitdiffstats
path: root/configserver/src
diff options
context:
space:
mode:
authorHarald Musum <musum@verizonmedia.com>2021-01-12 15:52:28 +0100
committerGitHub <noreply@github.com>2021-01-12 15:52:28 +0100
commit9a8f17a7502b9183d54927d5776bb9384f2ea812 (patch)
treec4fd167bb7fe8e908dcaea04b40fee83a956222b /configserver/src
parent00df4dedab5ea94283cbd2d2f359b01774402ffb (diff)
Revert "Reapply "Remove unnecessary component" [run-systemtest]""
Diffstat (limited to 'configserver/src')
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java5
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java16
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java15
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java22
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistries.java34
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistry.java29
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/RpcServer.java24
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java8
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java18
-rw-r--r--configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java9
-rw-r--r--configserver/src/main/resources/configserver-app/services.xml1
-rw-r--r--configserver/src/test/apps/app-jdisc-only-restart/hosts.xml2
-rw-r--r--configserver/src/test/apps/app-jdisc-only/hosts.xml2
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java25
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java19
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java28
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java73
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java15
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ListApplicationsHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionActiveHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionPrepareHandlerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java4
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java3
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java16
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java55
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java29
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionPreparerTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java6
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java5
-rw-r--r--configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java3
-rw-r--r--configserver/src/test/resources/deploy/advancedapp/services.xml2
44 files changed, 304 insertions, 250 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java
index 49a61eb8dee..1eb18773898 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/GlobalComponentRegistry.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;
import com.yahoo.cloud.config.ConfigserverConfig;
@@ -9,7 +9,7 @@ import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.Zone;
import com.yahoo.container.jdisc.secretstore.SecretStore;
import com.yahoo.vespa.config.server.application.PermanentApplicationPackage;
-import com.yahoo.vespa.config.server.host.HostRegistry;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.session.SessionPreparer;
@@ -38,6 +38,7 @@ public interface GlobalComponentRegistry {
ReloadListener getReloadListener();
ConfigDefinitionRepo getStaticConfigDefinitionRepo();
PermanentApplicationPackage getPermanentApplicationPackage();
+ HostRegistries getHostRegistries();
ModelFactoryRegistry getModelFactoryRegistry();
Optional<Provisioner> getHostProvisioner();
Zone getZone();
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java
index 5760eae866c..9badd19009f 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistry.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;
import com.google.inject.Inject;
@@ -11,7 +11,7 @@ import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.Zone;
import com.yahoo.container.jdisc.secretstore.SecretStore;
import com.yahoo.vespa.config.server.application.PermanentApplicationPackage;
-import com.yahoo.vespa.config.server.host.HostRegistry;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.provision.HostProvisionerProvider;
@@ -44,6 +44,7 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
private final ConfigserverConfig configserverConfig;
private final ConfigDefinitionRepo staticConfigDefinitionRepo;
private final PermanentApplicationPackage permanentApplicationPackage;
+ private final HostRegistries hostRegistries;
private final Optional<Provisioner> hostProvisioner;
private final Zone zone;
private final ConfigServerDB configServerDB;
@@ -51,7 +52,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
private final SecretStore secretStore;
private final StripedExecutor<TenantName> zkWatcherExecutor;
private final ExecutorService zkCacheExecutor;
- private final HostRegistry hostRegistry;
@SuppressWarnings("WeakerAccess")
@Inject
@@ -62,14 +62,15 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
SessionPreparer sessionPreparer,
RpcServer rpcServer,
ConfigserverConfig configserverConfig,
+ SuperModelGenerationCounter superModelGenerationCounter,
ConfigDefinitionRepo staticConfigDefinitionRepo,
PermanentApplicationPackage permanentApplicationPackage,
+ HostRegistries hostRegistries,
HostProvisionerProvider hostProvisionerProvider,
Zone zone,
ConfigServerDB configServerDB,
FlagSource flagSource,
- SecretStore secretStore,
- HostRegistry hostRegistry) {
+ SecretStore secretStore) {
this.curator = curator;
this.configCurator = configCurator;
this.metrics = metrics;
@@ -79,6 +80,7 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
this.configserverConfig = configserverConfig;
this.staticConfigDefinitionRepo = staticConfigDefinitionRepo;
this.permanentApplicationPackage = permanentApplicationPackage;
+ this.hostRegistries = hostRegistries;
this.hostProvisioner = hostProvisionerProvider.getHostProvisioner();
this.zone = zone;
this.configServerDB = configServerDB;
@@ -86,7 +88,6 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
this.secretStore = secretStore;
this.zkWatcherExecutor = new StripedExecutor<>();
this.zkCacheExecutor = Executors.newFixedThreadPool(1, ThreadFactoryFactory.getThreadFactory(TenantRepository.class.getName()));
- this.hostRegistry = hostRegistry;
}
@Override
@@ -108,6 +109,8 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
@Override
public PermanentApplicationPackage getPermanentApplicationPackage() { return permanentApplicationPackage; }
@Override
+ public HostRegistries getHostRegistries() { return hostRegistries; }
+ @Override
public ModelFactoryRegistry getModelFactoryRegistry() { return modelFactoryRegistry; }
@Override
@@ -143,5 +146,4 @@ public class InjectedGlobalComponentRegistry implements GlobalComponentRegistry
public SecretStore getSecretStore() {
return secretStore;
}
-
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java
index 7cdb596780a..773a4862033 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ReloadListener.java
@@ -1,7 +1,8 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;
import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.config.server.application.ApplicationSet;
import java.util.Collection;
@@ -16,21 +17,21 @@ import java.util.Collection;
public interface ReloadListener {
/**
- * Signals the listener that hosts used by a particular tenant.
+ * Signal the listener that hosts used by by a particular tenant.
*
- * @param applicationId application id
+ * @param tenant Name of tenant.
* @param newHosts a {@link Collection} of hosts used by tenant.
*/
- void hostsUpdated(ApplicationId applicationId, Collection<String> newHosts);
+ void hostsUpdated(TenantName tenant, Collection<String> newHosts);
/**
- * Verifies that given hosts are available for use by tenant.
+ * Verify that given hosts are available for use by tenant.
*
- * @param applicationId application id
+ * @param tenant tenant that wants to allocate hosts.
* @param newHosts a {@link java.util.Collection} of hosts that tenant wants to allocate.
* @throws java.lang.IllegalArgumentException if one or more of the hosts are in use by another tenant.
*/
- void verifyHostsAreAvailable(ApplicationId applicationId, Collection<String> newHosts);
+ void verifyHostsAreAvailable(TenantName tenant, Collection<String> newHosts);
/**
* Configs has been activated for an application: Either an application
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java
index 0e5315c0dcc..5a34217dbdd 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/application/TenantApplications.java
@@ -27,6 +27,7 @@ import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.Lock;
import com.yahoo.vespa.curator.transaction.CuratorTransaction;
import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.recipes.cache.ChildData;
import org.apache.curator.framework.recipes.cache.PathChildrenCacheEvent;
import java.nio.file.Files;
@@ -61,7 +62,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica
private final TenantName tenant;
private final ReloadListener reloadListener;
private final ConfigResponseFactory responseFactory;
- private final HostRegistry hostRegistry;
+ private final HostRegistry<ApplicationId> hostRegistry;
private final ApplicationMapper applicationMapper = new ApplicationMapper();
private final MetricUpdater tenantMetricUpdater;
private final Clock clock;
@@ -69,7 +70,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica
public TenantApplications(TenantName tenant, Curator curator, StripedExecutor<TenantName> zkWatcherExecutor,
ExecutorService zkCacheExecutor, Metrics metrics, ReloadListener reloadListener,
- ConfigserverConfig configserverConfig, HostRegistry hostRegistry,
+ ConfigserverConfig configserverConfig, HostRegistry<ApplicationId> hostRegistry,
TenantFileSystemDirs tenantFileSystemDirs, Clock clock) {
this.database = new ApplicationCuratorDatabase(tenant, curator);
this.tenant = tenant;
@@ -87,7 +88,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica
}
// For testing only
- public static TenantApplications create(GlobalComponentRegistry componentRegistry, HostRegistry hostRegistry, TenantName tenantName) {
+ public static TenantApplications create(GlobalComponentRegistry componentRegistry, TenantName tenantName) {
return new TenantApplications(tenantName,
componentRegistry.getCurator(),
componentRegistry.getZkWatcherExecutor(),
@@ -95,7 +96,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica
componentRegistry.getMetrics(),
componentRegistry.getReloadListener(),
componentRegistry.getConfigserverConfig(),
- hostRegistry,
+ componentRegistry.getHostRegistries().createApplicationHostRegistry(tenantName),
new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName),
componentRegistry.getClock());
}
@@ -221,10 +222,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica
}
private void notifyReloadListeners(ApplicationSet applicationSet) {
- if (applicationSet.getAllApplications().isEmpty()) throw new IllegalArgumentException("application set cannot be empty");
-
- reloadListener.hostsUpdated(applicationSet.getAllApplications().get(0).toApplicationInfo().getApplicationId(),
- applicationSet.getAllHosts());
+ reloadListener.hostsUpdated(tenant, hostRegistry.getAllHosts());
reloadListener.configActivated(applicationSet);
}
@@ -273,7 +271,7 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica
}
private void reloadListenersOnRemove(ApplicationId applicationId) {
- reloadListener.hostsUpdated(applicationId, hostRegistry.getHostsForKey(applicationId));
+ reloadListener.hostsUpdated(tenant, hostRegistry.getAllHosts());
reloadListener.applicationRemoved(applicationId);
}
@@ -384,9 +382,9 @@ public class TenantApplications implements RequestHandler, HostValidator<Applica
}
@Override
- public void verifyHosts(ApplicationId applicationId, Collection<String> newHosts) {
- hostRegistry.verifyHosts(applicationId, newHosts);
- reloadListener.verifyHostsAreAvailable(applicationId, newHosts);
+ public void verifyHosts(ApplicationId key, Collection<String> newHosts) {
+ hostRegistry.verifyHosts(key, newHosts);
+ reloadListener.verifyHostsAreAvailable(tenant, newHosts);
}
public HostValidator<ApplicationId> getHostValidator() {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistries.java b/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistries.java
new file mode 100644
index 00000000000..c25ab0315a3
--- /dev/null
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistries.java
@@ -0,0 +1,34 @@
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+package com.yahoo.vespa.config.server.host;
+
+import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.config.provision.TenantName;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * Component to hold host registries.
+ *
+ * @author hmusum
+ */
+public class HostRegistries {
+
+ private final HostRegistry<TenantName> tenantHostRegistry = new HostRegistry<>();
+ private final Map<TenantName, HostRegistry<ApplicationId>> applicationHostRegistries = new ConcurrentHashMap<>();
+
+ public HostRegistry<TenantName> getTenantHostRegistry() {
+ return tenantHostRegistry;
+ }
+
+ public HostRegistry<ApplicationId> getApplicationHostRegistry(TenantName tenant) {
+ return applicationHostRegistries.get(tenant);
+ }
+
+ public HostRegistry<ApplicationId> createApplicationHostRegistry(TenantName tenant) {
+ HostRegistry<ApplicationId> applicationIdHostRegistry = new HostRegistry<>();
+ applicationHostRegistries.put(tenant, applicationIdHostRegistry);
+ return applicationIdHostRegistry;
+ }
+
+}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistry.java b/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistry.java
index 03321bb264f..ec37f2598e0 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistry.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/host/HostRegistry.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.host;
import java.util.*;
@@ -7,9 +7,6 @@ import java.util.logging.Logger;
import java.util.stream.Collectors;
import com.google.common.collect.Collections2;
-import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.TenantName;
-
import java.util.logging.Level;
/**
@@ -18,20 +15,20 @@ import java.util.logging.Level;
*
* @author Ulf Lilleengen
*/
-public class HostRegistry implements HostValidator<ApplicationId> {
+public class HostRegistry<T> implements HostValidator<T> {
private static final Logger log = Logger.getLogger(HostRegistry.class.getName());
- private final Map<String, ApplicationId> host2KeyMap = new ConcurrentHashMap<>();
+ private final Map<String, T> host2KeyMap = new ConcurrentHashMap<>();
- public ApplicationId getKeyForHost(String hostName) {
+ public T getKeyForHost(String hostName) {
return host2KeyMap.get(hostName);
}
- public synchronized void update(ApplicationId key, Collection<String> newHosts) {
+ public synchronized void update(T key, Collection<String> newHosts) {
verifyHosts(key, newHosts);
Collection<String> currentHosts = getHostsForKey(key);
- log.log(Level.INFO, () -> "Setting hosts for key '" + key + "', " +
+ log.log(Level.FINE, () -> "Setting hosts for key '" + key + "', " +
"newHosts: " + newHosts + ", " +
"currentHosts: " + currentHosts);
Collection<String> removedHosts = getRemovedHosts(newHosts, currentHosts);
@@ -40,7 +37,7 @@ public class HostRegistry implements HostValidator<ApplicationId> {
}
@Override
- public synchronized void verifyHosts(ApplicationId key, Collection<String> newHosts) {
+ public synchronized void verifyHosts(T key, Collection<String> newHosts) {
for (String host : newHosts) {
if (hostAlreadyTaken(host, key)) {
throw new IllegalArgumentException("'" + key + "' tried to allocate host '" + host +
@@ -49,26 +46,22 @@ public class HostRegistry implements HostValidator<ApplicationId> {
}
}
- public synchronized void removeHostsForKey(ApplicationId key) {
+ public synchronized void removeHostsForKey(T key) {
host2KeyMap.entrySet().removeIf(entry -> entry.getValue().equals(key));
}
- public synchronized void removeHostsForKey(TenantName key) {
- host2KeyMap.entrySet().removeIf(entry -> entry.getValue().tenant().equals(key));
- }
-
public synchronized Collection<String> getAllHosts() {
return Collections.unmodifiableCollection(new ArrayList<>(host2KeyMap.keySet()));
}
- public synchronized Collection<String> getHostsForKey(ApplicationId key) {
+ synchronized Collection<String> getHostsForKey(T key) {
return host2KeyMap.entrySet().stream()
.filter(entry -> entry.getValue().equals(key))
.map(Map.Entry::getKey)
.collect(Collectors.toSet());
}
- private boolean hostAlreadyTaken(String host, ApplicationId key) {
+ private boolean hostAlreadyTaken(String host, T key) {
return host2KeyMap.containsKey(host) && !key.equals(host2KeyMap.get(host));
}
@@ -83,7 +76,7 @@ public class HostRegistry implements HostValidator<ApplicationId> {
}
}
- private void addHosts(ApplicationId key, Collection<String> newHosts) {
+ private void addHosts(T key, Collection<String> newHosts) {
for (String host : newHosts) {
log.log(Level.FINE, () -> "Adding " + host);
host2KeyMap.put(host, key);
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 370ae72bbbd..e64859e7267 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
@@ -34,6 +34,7 @@ import com.yahoo.vespa.config.server.RequestHandler;
import com.yahoo.vespa.config.server.SuperModelRequestHandler;
import com.yahoo.vespa.config.server.application.ApplicationSet;
import com.yahoo.vespa.config.server.filedistribution.FileServer;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
import com.yahoo.vespa.config.server.monitoring.MetricUpdaterFactory;
@@ -91,7 +92,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
private final DelayedConfigResponses delayedConfigResponses;
- private final HostRegistry hostRegistry;
+ private final HostRegistry<TenantName> hostRegistry;
private final Map<TenantName, Tenant> tenants = new ConcurrentHashMap<>();
private final Map<ApplicationId, ApplicationState> applicationStateMap = new ConcurrentHashMap<>();
private final SuperModelRequestHandler superModelRequestHandler;
@@ -121,7 +122,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
*/
@Inject
public RpcServer(ConfigserverConfig config, SuperModelRequestHandler superModelRequestHandler,
- MetricUpdaterFactory metrics, HostRegistry hostRegistry,
+ MetricUpdaterFactory metrics, HostRegistries hostRegistries,
HostLivenessTracker hostLivenessTracker, FileServer fileServer, RpcAuthorizer rpcAuthorizer,
RpcRequestHandlerProvider handlerProvider) {
this.superModelRequestHandler = superModelRequestHandler;
@@ -135,7 +136,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
0, TimeUnit.SECONDS, workQueue, ThreadFactoryFactory.getDaemonThreadFactory(THREADPOOL_NAME));
delayedConfigResponses = new DelayedConfigResponses(this, config.numDelayedResponseThreads());
spec = new Spec(null, config.rpcport());
- this.hostRegistry = hostRegistry;
+ hostRegistry = hostRegistries.getTenantHostRegistry();
this.useRequestVersion = config.useVespaVersionInRequest();
this.hostedVespa = config.hostedVespa();
this.canReturnEmptySentinelConfig = config.canReturnEmptySentinelConfig();
@@ -302,14 +303,14 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
}
@Override
- public void hostsUpdated(ApplicationId applicationId, Collection<String> newHosts) {
+ public void hostsUpdated(TenantName tenant, Collection<String> newHosts) {
log.log(Level.FINE, "Updating hosts in tenant host registry '" + hostRegistry + "' with " + newHosts);
- hostRegistry.update(applicationId, newHosts);
+ hostRegistry.update(tenant, newHosts);
}
@Override
- public void verifyHostsAreAvailable(ApplicationId applicationId, Collection<String> newHosts) {
- hostRegistry.verifyHosts(applicationId, newHosts);
+ public void verifyHostsAreAvailable(TenantName tenant, Collection<String> newHosts) {
+ hostRegistry.verifyHosts(tenant, newHosts);
}
@Override
@@ -333,8 +334,8 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
Optional<TenantName> resolveTenant(JRTServerConfigRequest request, Trace trace) {
if ("*".equals(request.getConfigKey().getConfigId())) return Optional.of(ApplicationId.global().tenant());
String hostname = request.getClientHostName();
- ApplicationId applicationId = hostRegistry.getKeyForHost(hostname);
- if (applicationId == null) {
+ TenantName tenant = hostRegistry.getKeyForHost(hostname);
+ if (tenant == null) {
if (GetConfigProcessor.logDebug(trace)) {
String message = "Did not find tenant for host '" + hostname + "', using " + TenantName.defaultName();
log.log(Level.FINE, message);
@@ -343,7 +344,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
}
return Optional.empty();
}
- return Optional.of(applicationId.tenant());
+ return Optional.of(tenant);
}
public ConfigResponse resolveConfig(JRTServerConfigRequest request, GetConfigContext context, Optional<Version> vespaVersion) {
@@ -424,8 +425,7 @@ public class RpcServer implements Runnable, ReloadListener, TenantListener {
@Override
public void onTenantDelete(TenantName tenant) {
- log.log(Level.FINE, TenantRepository.logPre(tenant) +
- "Tenant deleted, removing request handler and cleaning host registry");
+ log.log(Level.FINE, TenantRepository.logPre(tenant)+"Tenant deleted, removing request handler and cleaning host registry");
tenants.remove(tenant);
hostRegistry.removeHostsForKey(tenant);
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java
index b00b6db4226..8d1d4f58e37 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/DefaultRpcAuthorizerProvider.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.rpc.security;
import com.google.inject.Inject;
@@ -6,7 +6,7 @@ import com.yahoo.cloud.config.ConfigserverConfig;
import com.yahoo.config.provision.security.NodeIdentifier;
import com.yahoo.container.di.componentgraph.Provider;
import com.yahoo.security.tls.TransportSecurityUtils;
-import com.yahoo.vespa.config.server.host.HostRegistry;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.rpc.RequestHandlerProvider;
/**
@@ -21,13 +21,13 @@ public class DefaultRpcAuthorizerProvider implements Provider<RpcAuthorizer> {
@Inject
public DefaultRpcAuthorizerProvider(ConfigserverConfig config,
NodeIdentifier nodeIdentifier,
- HostRegistry hostRegistry,
+ HostRegistries hostRegistries,
RequestHandlerProvider handlerProvider) {
boolean useMultiTenantAuthorizer =
TransportSecurityUtils.isTransportSecurityEnabled() && config.multitenant() && config.hostedVespa();
this.rpcAuthorizer =
useMultiTenantAuthorizer
- ? new MultiTenantRpcAuthorizer(nodeIdentifier, hostRegistry, handlerProvider, getThreadPoolSize(config))
+ ? new MultiTenantRpcAuthorizer(nodeIdentifier, hostRegistries, handlerProvider, getThreadPoolSize(config))
: new NoopRpcAuthorizer();
}
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java
index 8353e3fab1f..49a8df3d0e4 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizer.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.rpc.security;
import com.yahoo.cloud.config.SentinelConfig;
@@ -16,6 +16,7 @@ import com.yahoo.security.tls.TransportSecurityUtils;
import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.protocol.JRTServerConfigRequestV3;
import com.yahoo.vespa.config.server.RequestHandler;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.rpc.RequestHandlerProvider;
@@ -33,6 +34,7 @@ import java.util.logging.Logger;
import static com.yahoo.vespa.config.server.rpc.security.AuthorizationException.Type;
import static com.yahoo.yolean.Exceptions.throwUnchecked;
+
/**
* A {@link RpcAuthorizer} that perform access control for configserver RPC methods when TLS and multi-tenant mode are enabled.
*
@@ -43,22 +45,22 @@ public class MultiTenantRpcAuthorizer implements RpcAuthorizer {
private static final Logger log = Logger.getLogger(MultiTenantRpcAuthorizer.class.getName());
private final NodeIdentifier nodeIdentifier;
- private final HostRegistry hostRegistry;
+ private final HostRegistry<TenantName> hostRegistry;
private final RequestHandlerProvider handlerProvider;
private final Executor executor;
public MultiTenantRpcAuthorizer(NodeIdentifier nodeIdentifier,
- HostRegistry hostRegistry,
+ HostRegistries hostRegistries,
RequestHandlerProvider handlerProvider,
int threadPoolSize) {
this(nodeIdentifier,
- hostRegistry,
+ hostRegistries.getTenantHostRegistry(),
handlerProvider,
Executors.newFixedThreadPool(threadPoolSize, new DaemonThreadFactory("multi-tenant-rpc-authorizer-")));
}
MultiTenantRpcAuthorizer(NodeIdentifier nodeIdentifier,
- HostRegistry hostRegistry,
+ HostRegistry<TenantName> hostRegistry,
RequestHandlerProvider handlerProvider,
Executor executor) {
this.nodeIdentifier = nodeIdentifier;
@@ -106,14 +108,14 @@ public class MultiTenantRpcAuthorizer implements RpcAuthorizer {
return; // global config access ok
} else {
String hostname = configRequest.getClientHostName();
- ApplicationId applicationId = hostRegistry.getKeyForHost(hostname);
- if (applicationId == null) {
+ Optional<TenantName> tenantName = Optional.ofNullable(hostRegistry.getKeyForHost(hostname));
+ if (tenantName.isEmpty()) {
if (isConfigKeyForSentinelConfig(configKey)) {
return; // config processor will return empty sentinel config for unknown nodes
}
throw new AuthorizationException(Type.SILENT, String.format("Host '%s' not found in host registry for [%s]", hostname, configKey));
}
- RequestHandler tenantHandler = getTenantHandler(applicationId.tenant());
+ RequestHandler tenantHandler = getTenantHandler(tenantName.get());
ApplicationId resolvedApplication = tenantHandler.resolveApplicationId(hostname);
ApplicationId peerOwner = applicationId(peerIdentity);
if (peerOwner.equals(resolvedApplication)) {
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java
index a2fa7851173..5c15b72eaac 100644
--- a/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java
+++ b/configserver/src/main/java/com/yahoo/vespa/config/server/tenant/TenantRepository.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.tenant;
import com.google.common.collect.ImmutableSet;
@@ -14,7 +14,6 @@ import com.yahoo.transaction.Transaction;
import com.yahoo.vespa.config.server.GlobalComponentRegistry;
import com.yahoo.vespa.config.server.application.TenantApplications;
import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
import com.yahoo.vespa.config.server.session.SessionRepository;
import com.yahoo.vespa.curator.Curator;
@@ -79,7 +78,6 @@ public class TenantRepository {
private final Map<TenantName, Tenant> tenants = Collections.synchronizedMap(new LinkedHashMap<>());
private final GlobalComponentRegistry componentRegistry;
- private final HostRegistry hostRegistry;
private final List<TenantListener> tenantListeners = Collections.synchronizedList(new ArrayList<>());
private final Curator curator;
@@ -97,9 +95,8 @@ public class TenantRepository {
* @param componentRegistry a {@link com.yahoo.vespa.config.server.GlobalComponentRegistry}
*/
@Inject
- public TenantRepository(GlobalComponentRegistry componentRegistry, HostRegistry hostRegistry) {
+ public TenantRepository(GlobalComponentRegistry componentRegistry) {
this.componentRegistry = componentRegistry;
- this.hostRegistry = hostRegistry;
ConfigserverConfig configserverConfig = componentRegistry.getConfigserverConfig();
this.bootstrapExecutor = Executors.newFixedThreadPool(configserverConfig.numParallelTenantLoaders(),
new DaemonThreadFactory("bootstrap tenants"));
@@ -231,7 +228,7 @@ public class TenantRepository {
componentRegistry.getMetrics(),
componentRegistry.getReloadListener(),
componentRegistry.getConfigserverConfig(),
- hostRegistry,
+ componentRegistry.getHostRegistries().createApplicationHostRegistry(tenantName),
new TenantFileSystemDirs(componentRegistry.getConfigServerDB(), tenantName),
componentRegistry.getClock());
SessionRepository sessionRepository = new SessionRepository(tenantName,
diff --git a/configserver/src/main/resources/configserver-app/services.xml b/configserver/src/main/resources/configserver-app/services.xml
index 0ac548c54d8..dac10ac4e59 100644
--- a/configserver/src/main/resources/configserver-app/services.xml
+++ b/configserver/src/main/resources/configserver-app/services.xml
@@ -27,6 +27,7 @@
<component id="com.yahoo.vespa.config.server.InjectedGlobalComponentRegistry" 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" />
<component id="com.yahoo.vespa.config.server.version.VersionState" bundle="configserver" />
<component id="com.yahoo.vespa.config.server.zookeeper.ConfigCurator" bundle="configserver" />
diff --git a/configserver/src/test/apps/app-jdisc-only-restart/hosts.xml b/configserver/src/test/apps/app-jdisc-only-restart/hosts.xml
index ab70b288ba6..f4256c9fc81 100644
--- a/configserver/src/test/apps/app-jdisc-only-restart/hosts.xml
+++ b/configserver/src/test/apps/app-jdisc-only-restart/hosts.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<hosts>
- <host name="mytesthost2">
+ <host name="mytesthost">
<alias>node1</alias>
</host>
</hosts>
diff --git a/configserver/src/test/apps/app-jdisc-only/hosts.xml b/configserver/src/test/apps/app-jdisc-only/hosts.xml
index ab70b288ba6..f4256c9fc81 100644
--- a/configserver/src/test/apps/app-jdisc-only/hosts.xml
+++ b/configserver/src/test/apps/app-jdisc-only/hosts.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -->
<hosts>
- <host name="mytesthost2">
+ <host name="mytesthost">
<alias>node1</alias>
</host>
</hosts>
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
index b45569c95b8..0cab49a9f00 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java
@@ -32,7 +32,6 @@ import com.yahoo.vespa.config.protocol.VespaVersion;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
import com.yahoo.vespa.config.server.deploy.DeployTester;
import com.yahoo.vespa.config.server.deploy.TenantFileSystemDirs;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.v2.PrepareResult;
import com.yahoo.vespa.config.server.session.LocalSession;
import com.yahoo.vespa.config.server.session.PrepareParams;
@@ -128,7 +127,7 @@ public class ApplicationRepositoryTest {
.flagSource(flagSource)
.clock(clock)
.build();
- tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT);
tenantRepository.addTenant(tenant1);
tenantRepository.addTenant(tenant2);
@@ -193,7 +192,7 @@ public class ApplicationRepositoryTest {
PrepareResult result = prepareAndActivate(testAppJdiscOnlyRestart);
assertTrue(result.configChangeActions().getRefeedActions().isEmpty());
assertTrue(result.configChangeActions().getRestartActions().isEmpty());
- assertEquals(HostFilter.hostname("mytesthost2"), provisioner.lastRestartFilter());
+ assertEquals(HostFilter.hostname("mytesthost"), provisioner.lastRestartFilter());
}
@Test
@@ -346,7 +345,7 @@ public class ApplicationRepositoryTest {
// Deploy another app (with id fooId)
ApplicationId fooId = applicationId(tenant2);
PrepareParams prepareParams2 = new PrepareParams.Builder().applicationId(fooId).build();
- deployApp(testAppJdiscOnly, prepareParams2);
+ deployApp(testApp, prepareParams2);
assertNotNull(applicationRepository.getActiveSession(fooId));
// Delete app with id fooId, should not affect original app
@@ -531,14 +530,14 @@ public class ApplicationRepositoryTest {
list.add(new NetworkPorts.Allocation(19081, "logserver", "admin/logserver", "unused/1"));
list.add(new NetworkPorts.Allocation(19082, "logserver", "admin/logserver", "unused/2"));
list.add(new NetworkPorts.Allocation(19083, "logserver", "admin/logserver", "unused/3"));
- list.add(new NetworkPorts.Allocation(19089, "logd", "hosts/mytesthost2/logd", "http"));
- list.add(new NetworkPorts.Allocation(19090, "configproxy", "hosts/mytesthost2/configproxy", "rpc"));
- list.add(new NetworkPorts.Allocation(19092, "metricsproxy-container", "admin/metrics/mytesthost2", "http"));
- list.add(new NetworkPorts.Allocation(19093, "metricsproxy-container", "admin/metrics/mytesthost2", "http/1"));
- list.add(new NetworkPorts.Allocation(19094, "metricsproxy-container", "admin/metrics/mytesthost2", "rpc/admin"));
- list.add(new NetworkPorts.Allocation(19095, "metricsproxy-container", "admin/metrics/mytesthost2", "rpc/metrics"));
- list.add(new NetworkPorts.Allocation(19097, "config-sentinel", "hosts/mytesthost2/sentinel", "rpc"));
- list.add(new NetworkPorts.Allocation(19098, "config-sentinel", "hosts/mytesthost2/sentinel", "http"));
+ list.add(new NetworkPorts.Allocation(19089, "logd", "hosts/mytesthost/logd", "http"));
+ list.add(new NetworkPorts.Allocation(19090, "configproxy", "hosts/mytesthost/configproxy", "rpc"));
+ list.add(new NetworkPorts.Allocation(19092, "metricsproxy-container", "admin/metrics/mytesthost", "http"));
+ list.add(new NetworkPorts.Allocation(19093, "metricsproxy-container", "admin/metrics/mytesthost", "http/1"));
+ list.add(new NetworkPorts.Allocation(19094, "metricsproxy-container", "admin/metrics/mytesthost", "rpc/admin"));
+ list.add(new NetworkPorts.Allocation(19095, "metricsproxy-container", "admin/metrics/mytesthost", "rpc/metrics"));
+ list.add(new NetworkPorts.Allocation(19097, "config-sentinel", "hosts/mytesthost/sentinel", "rpc"));
+ list.add(new NetworkPorts.Allocation(19098, "config-sentinel", "hosts/mytesthost/sentinel", "http"));
list.add(new NetworkPorts.Allocation(19099, "slobrok", "admin/slobrok.0", "rpc"));
list.add(new NetworkPorts.Allocation(19100, "container", "container/container.0", "http/1"));
list.add(new NetworkPorts.Allocation(19101, "container", "container/container.0", "messaging"));
@@ -548,7 +547,7 @@ public class ApplicationRepositoryTest {
AllocatedHosts info = session.getAllocatedHosts();
assertNotNull(info);
assertThat(info.getHosts().size(), is(1));
- assertTrue(info.getHosts().contains(new HostSpec("mytesthost2",
+ assertTrue(info.getHosts().contains(new HostSpec("mytesthost",
Collections.emptyList(),
Optional.empty())));
Optional<NetworkPorts> portsCopy = info.getHosts().iterator().next().networkPorts();
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java
index 4f6642610dd..bf54c2b309e 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/InjectedGlobalComponentRegistryTest.java
@@ -8,12 +8,12 @@ import com.yahoo.config.provision.Zone;
import com.yahoo.vespa.config.server.application.PermanentApplicationPackage;
import com.yahoo.vespa.config.server.filedistribution.FileServer;
import com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker;
-import com.yahoo.vespa.config.server.host.HostRegistry;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.provision.HostProvisionerProvider;
-import com.yahoo.vespa.config.server.rpc.RpcRequestHandlerProvider;
import com.yahoo.vespa.config.server.rpc.RpcServer;
+import com.yahoo.vespa.config.server.rpc.RpcRequestHandlerProvider;
import com.yahoo.vespa.config.server.rpc.security.NoopRpcAuthorizer;
import com.yahoo.vespa.config.server.session.SessionPreparer;
import com.yahoo.vespa.config.server.session.SessionTest;
@@ -46,6 +46,7 @@ public class InjectedGlobalComponentRegistryTest {
private RpcServer rpcServer;
private ConfigDefinitionRepo defRepo;
private PermanentApplicationPackage permanentApplicationPackage;
+ private HostRegistries hostRegistries;
private GlobalComponentRegistry globalComponentRegistry;
private ModelFactoryRegistry modelFactoryRegistry;
private Zone zone;
@@ -64,21 +65,20 @@ public class InjectedGlobalComponentRegistryTest {
.configServerDBDir(temporaryFolder.newFolder("serverdb").getAbsolutePath())
.configDefinitionsDir(temporaryFolder.newFolder("configdefinitions").getAbsolutePath()));
sessionPreparer = new SessionTest.MockSessionPreparer();
- HostRegistry hostRegistry = new HostRegistry();
rpcServer = new RpcServer(configserverConfig, null, Metrics.createTestMetrics(),
- hostRegistry, new ConfigRequestHostLivenessTracker(),
+ new HostRegistries(), new ConfigRequestHostLivenessTracker(),
new FileServer(temporaryFolder.newFolder("filereferences")),
new NoopRpcAuthorizer(), new RpcRequestHandlerProvider());
+ SuperModelGenerationCounter generationCounter = new SuperModelGenerationCounter(curator);
defRepo = new StaticConfigDefinitionRepo();
permanentApplicationPackage = new PermanentApplicationPackage(configserverConfig);
+ hostRegistries = new HostRegistries();
HostProvisionerProvider hostProvisionerProvider = HostProvisionerProvider.withProvisioner(new MockProvisioner());
zone = Zone.defaultZone();
globalComponentRegistry =
- new InjectedGlobalComponentRegistry(curator, configCurator, metrics, modelFactoryRegistry, sessionPreparer,
- rpcServer, configserverConfig, defRepo, permanentApplicationPackage,
- hostProvisionerProvider, zone,
- new ConfigServerDB(configserverConfig), new InMemoryFlagSource(),
- new MockSecretStore(), hostRegistry);
+ new InjectedGlobalComponentRegistry(curator, configCurator, metrics, modelFactoryRegistry, sessionPreparer, rpcServer, configserverConfig,
+ generationCounter, defRepo, permanentApplicationPackage, hostRegistries, hostProvisionerProvider, zone,
+ new ConfigServerDB(configserverConfig), new InMemoryFlagSource(), new MockSecretStore());
}
@Test
@@ -92,6 +92,7 @@ public class InjectedGlobalComponentRegistryTest {
assertThat(globalComponentRegistry.getTenantListener().hashCode(), is(rpcServer.hashCode()));
assertThat(globalComponentRegistry.getStaticConfigDefinitionRepo(), is(defRepo));
assertThat(globalComponentRegistry.getPermanentApplicationPackage(), is(permanentApplicationPackage));
+ assertThat(globalComponentRegistry.getHostRegistries(), is(hostRegistries));
assertThat(globalComponentRegistry.getZone(), is (zone));
assertTrue(globalComponentRegistry.getHostProvisioner().isPresent());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
index c58bd6d6b0a..965374f2aa4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/SuperModelControllerTest.java
@@ -83,6 +83,34 @@ public class SuperModelControllerTest {
}
@Test
+ public void test_lb_config_multiple_apps_legacy_super_model() throws IOException, SAXException {
+ Map<ApplicationId, ApplicationInfo> models = new LinkedHashMap<>();
+ TenantName t1 = TenantName.from("t1");
+ TenantName t2 = TenantName.from("t2");
+ File testApp1 = new File("src/test/resources/deploy/app");
+ File testApp2 = new File("src/test/resources/deploy/advancedapp");
+ File testApp3 = new File("src/test/resources/deploy/advancedapp");
+
+ ApplicationId simple = applicationId("mysimpleapp", t1);
+ ApplicationId advanced = applicationId("myadvancedapp", t1);
+ ApplicationId tooAdvanced = applicationId("minetooadvancedapp", t2);
+ models.put(simple, createApplicationInfo(testApp1, simple, 4L));
+ models.put(advanced, createApplicationInfo(testApp2, advanced, 4L));
+ models.put(tooAdvanced, createApplicationInfo(testApp3, tooAdvanced, 4L));
+
+ SuperModel superModel = new SuperModel(models, true);
+ SuperModelController han = new SuperModelController(new SuperModelConfigProvider(superModel, Zone.defaultZone(), new InMemoryFlagSource()), new TestConfigDefinitionRepo(), 2, new UncompressedConfigResponseFactory());
+ LbServicesConfig.Builder lb = new LbServicesConfig.Builder();
+ han.getSuperModel().getConfig(lb);
+ LbServicesConfig lbc = new LbServicesConfig(lb);
+ assertThat(lbc.tenants().size(), is(2));
+ assertThat(lbc.tenants("t1").applications().size(), is(2));
+ assertThat(lbc.tenants("t2").applications().size(), is(1));
+ assertThat(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default").hosts().size(), is(1));
+ assertQrServer(lbc.tenants("t2").applications("minetooadvancedapp:prod:default:default"));
+ }
+
+ @Test
public void test_lb_config_multiple_apps() throws IOException, SAXException {
Map<ApplicationId, ApplicationInfo> models = new LinkedHashMap<>();
TenantName t1 = TenantName.from("t1");
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java
index 0221cf9abfc..e6652c3c5e1 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/TestComponentRegistry.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server;
import com.yahoo.cloud.config.ConfigserverConfig;
@@ -12,12 +12,12 @@ import com.yahoo.config.provision.Zone;
import com.yahoo.container.jdisc.secretstore.SecretStore;
import com.yahoo.vespa.config.server.application.PermanentApplicationPackage;
import com.yahoo.vespa.config.server.application.TenantApplicationsTest;
-import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory;
-import com.yahoo.vespa.config.server.filedistribution.MockFileDistributionFactory;
-import com.yahoo.vespa.config.server.host.HostRegistry;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.provision.HostProvisionerProvider;
+import com.yahoo.vespa.config.server.filedistribution.FileDistributionFactory;
+import com.yahoo.vespa.config.server.filedistribution.MockFileDistributionFactory;
import com.yahoo.vespa.config.server.session.SessionPreparer;
import com.yahoo.vespa.config.server.tenant.MockTenantListener;
import com.yahoo.vespa.config.server.tenant.TenantListener;
@@ -50,6 +50,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry {
private final ReloadListener reloadListener;
private final TenantListener tenantListener;
private final PermanentApplicationPackage permanentApplicationPackage;
+ private final HostRegistries hostRegistries;
private final FileDistributionFactory fileDistributionFactory;
private final ModelFactoryRegistry modelFactoryRegistry;
private final Optional<Provisioner> hostProvisioner;
@@ -65,6 +66,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry {
ModelFactoryRegistry modelFactoryRegistry,
PermanentApplicationPackage permanentApplicationPackage,
FileDistributionFactory fileDistributionFactory,
+ HostRegistries hostRegistries,
ConfigserverConfig configserverConfig,
SessionPreparer sessionPreparer,
Optional<Provisioner> hostProvisioner,
@@ -83,6 +85,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry {
this.tenantListener = tenantListener;
this.defRepo = defRepo;
this.permanentApplicationPackage = permanentApplicationPackage;
+ this.hostRegistries = hostRegistries;
this.fileDistributionFactory = fileDistributionFactory;
this.modelFactoryRegistry = modelFactoryRegistry;
this.hostProvisioner = hostProvisioner;
@@ -109,6 +112,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry {
private ReloadListener reloadListener = new TenantApplicationsTest.MockReloadListener();
private final MockTenantListener tenantListener = new MockTenantListener();
private Optional<PermanentApplicationPackage> permanentApplicationPackage = Optional.empty();
+ private final HostRegistries hostRegistries = new HostRegistries();
private final Optional<FileDistributionFactory> fileDistributionFactory = Optional.empty();
private ModelFactoryRegistry modelFactoryRegistry = new ModelFactoryRegistry(Collections.singletonList(new VespaModelFactory(new NullConfigModelRegistry())));
private Optional<Provisioner> hostProvisioner = Optional.empty();
@@ -184,7 +188,7 @@ public class TestComponentRegistry implements GlobalComponentRegistry {
configserverConfig, defRepo, curator,
zone, flagSource, secretStore);
return new TestComponentRegistry(curator, ConfigCurator.create(curator), metrics, modelFactoryRegistry,
- permApp, fileDistributionProvider, configserverConfig,
+ permApp, fileDistributionProvider, hostRegistries, configserverConfig,
sessionPreparer, hostProvisioner, defRepo, reloadListener, tenantListener,
zone, clock, secretStore, flagSource);
}
@@ -209,6 +213,8 @@ public class TestComponentRegistry implements GlobalComponentRegistry {
@Override
public PermanentApplicationPackage getPermanentApplicationPackage() { return permanentApplicationPackage; }
@Override
+ public HostRegistries getHostRegistries() { return hostRegistries;}
+ @Override
public ModelFactoryRegistry getModelFactoryRegistry() { return modelFactoryRegistry; }
@Override
public Optional<Provisioner> getHostProvisioner() {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java
index 4543d3b5673..947308962d4 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/application/TenantApplicationsTest.java
@@ -12,7 +12,6 @@ import com.yahoo.vespa.config.ConfigKey;
import com.yahoo.vespa.config.server.ReloadListener;
import com.yahoo.vespa.config.server.ServerCache;
import com.yahoo.vespa.config.server.TestComponentRegistry;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.model.TestModelFactory;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
@@ -76,11 +75,10 @@ public class TenantApplicationsTest {
.modelFactoryRegistry(createRegistry())
.reloadListener(listener)
.build();
- HostRegistry hostRegistry = new HostRegistry();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, hostRegistry);
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(TenantRepository.HOSTED_VESPA_TENANT);
tenantRepository.addTenant(tenantName);
- applications = TenantApplications.create(componentRegistry, hostRegistry, tenantName);
+ applications = TenantApplications.create(componentRegistry, tenantName);
}
@Test
@@ -153,12 +151,12 @@ public class TenantApplicationsTest {
}
@Override
- public void hostsUpdated(ApplicationId applicationId, Collection<String> newHosts) {
- tenantHosts.put(applicationId.tenant().value(), newHosts);
+ public void hostsUpdated(TenantName tenant, Collection<String> newHosts) {
+ tenantHosts.put(tenant.value(), newHosts);
}
@Override
- public void verifyHostsAreAvailable(ApplicationId applicationId, Collection<String> newHosts) {
+ public void verifyHostsAreAvailable(TenantName tenant, Collection<String> newHosts) {
}
@Override
@@ -173,7 +171,7 @@ public class TenantApplicationsTest {
@Test
public void testListConfigs() throws IOException, SAXException {
- applications = TenantApplications.create(componentRegistry, new HostRegistry(), TenantName.defaultName());
+ applications = TenantApplications.create(componentRegistry, TenantName.defaultName());
assertdefaultAppNotFound();
VespaModel model = new VespaModel(FilesApplicationPackage.fromFile(new File("src/test/apps/app")));
@@ -208,7 +206,7 @@ public class TenantApplicationsTest {
}
private TenantApplications createZKAppRepo() {
- return TenantApplications.create(componentRegistry, new HostRegistry(), tenantName);
+ return TenantApplications.create(componentRegistry, tenantName);
}
private static ApplicationId createApplicationId(String name) {
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java
index 54d23652349..5b5f830c737 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/deploy/DeployTester.java
@@ -26,7 +26,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.v2.PrepareResult;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.monitoring.Metrics;
@@ -290,7 +289,7 @@ public class DeployTester {
.zone(zone);
if (configserverConfig.hostedVespa()) testComponentRegistryBuilder.provisioner(provisioner);
- TenantRepository tenantRepository = new TenantRepository(testComponentRegistryBuilder.build(), new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(testComponentRegistryBuilder.build());
tenantRepository.addTenant(tenantName);
ApplicationRepository applicationRepository = new ApplicationRepository.Builder()
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java
index 173e9f3e148..63dfb1d01bd 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/host/HostRegistryTest.java
@@ -1,44 +1,37 @@
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.host;
-import com.yahoo.config.provision.ApplicationId;
-import org.junit.Test;
-
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.junit.Test;
+
import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThat;
+import static org.junit.Assert.*;
/**
* @author Ulf Lilleengen
*/
public class HostRegistryTest {
-
- private final ApplicationId foo = ApplicationId.from("foo", "app1", "default");
- private final ApplicationId bar = ApplicationId.from("bar", "app2", "default");
-
@Test
public void old_hosts_are_removed() {
- HostRegistry reg = new HostRegistry();
+ HostRegistry<String> reg = new HostRegistry<>();
assertNull(reg.getKeyForHost("foo.com"));
- reg.update(foo, List.of("foo.com", "bar.com", "baz.com"));
- assertGetKey(reg, "foo.com", foo);
- assertGetKey(reg, "bar.com", foo);
- assertGetKey(reg, "baz.com", foo);
+ reg.update("fookey", List.of("foo.com", "bar.com", "baz.com"));
+ assertGetKey(reg, "foo.com", "fookey");
+ assertGetKey(reg, "bar.com", "fookey");
+ assertGetKey(reg, "baz.com", "fookey");
assertThat(reg.getAllHosts().size(), is(3));
- reg.update(foo, List.of("bar.com", "baz.com"));
+ reg.update("fookey", List.of("bar.com", "baz.com"));
assertNull(reg.getKeyForHost("foo.com"));
- assertGetKey(reg, "bar.com", foo);
- assertGetKey(reg, "baz.com", foo);
+ assertGetKey(reg, "bar.com", "fookey");
+ assertGetKey(reg, "baz.com", "fookey");
assertThat(reg.getAllHosts().size(), is(2));
assertThat(reg.getAllHosts(), contains("bar.com", "baz.com"));
- reg.removeHostsForKey(foo);
+ reg.removeHostsForKey("fookey");
assertThat(reg.getAllHosts().size(), is(0));
assertNull(reg.getKeyForHost("foo.com"));
assertNull(reg.getKeyForHost("bar.com"));
@@ -46,51 +39,51 @@ public class HostRegistryTest {
@Test
public void multiple_keys_are_handled() {
- HostRegistry reg = new HostRegistry();
- reg.update(foo, List.of("foo.com", "bar.com"));
- reg.update(bar, List.of("baz.com", "quux.com"));
- assertGetKey(reg, "foo.com", foo);
- assertGetKey(reg, "bar.com", foo);
- assertGetKey(reg, "baz.com", bar);
- assertGetKey(reg, "quux.com", bar);
+ HostRegistry<String> reg = new HostRegistry<>();
+ reg.update("fookey", List.of("foo.com", "bar.com"));
+ reg.update("barkey", List.of("baz.com", "quux.com"));
+ assertGetKey(reg, "foo.com", "fookey");
+ assertGetKey(reg, "bar.com", "fookey");
+ assertGetKey(reg, "baz.com", "barkey");
+ assertGetKey(reg, "quux.com", "barkey");
}
@Test(expected = IllegalArgumentException.class)
public void keys_cannot_overlap() {
- HostRegistry reg = new HostRegistry();
- reg.update(foo, List.of("foo.com", "bar.com"));
- reg.update(bar, List.of("bar.com", "baz.com"));
+ HostRegistry<String> reg = new HostRegistry<>();
+ reg.update("fookey", List.of("foo.com", "bar.com"));
+ reg.update("barkey", List.of("bar.com", "baz.com"));
}
@Test
public void all_hosts_are_returned() {
- HostRegistry reg = new HostRegistry();
- reg.update(foo, List.of("foo.com", "bar.com"));
- reg.update(bar, List.of("baz.com", "quux.com"));
+ HostRegistry<String> reg = new HostRegistry<>();
+ reg.update("fookey", List.of("foo.com", "bar.com"));
+ reg.update("barkey", List.of("baz.com", "quux.com"));
assertThat(reg.getAllHosts().size(), is(4));
}
@Test
public void ensure_that_collection_is_copied() {
- HostRegistry reg = new HostRegistry();
+ HostRegistry<String> reg = new HostRegistry<>();
List<String> hosts = new ArrayList<>(List.of("foo.com", "bar.com", "baz.com"));
- reg.update(foo, hosts);
- assertThat(reg.getHostsForKey(foo).size(), is(3));
+ reg.update("fookey", hosts);
+ assertThat(reg.getHostsForKey("fookey").size(), is(3));
hosts.remove(2);
- assertThat(reg.getHostsForKey(foo).size(), is(3));
+ assertThat(reg.getHostsForKey("fookey").size(), is(3));
}
@Test
public void ensure_that_underlying_hosts_do_not_change() {
- HostRegistry reg = new HostRegistry();
- reg.update(foo, List.of("foo.com", "bar.com", "baz.com"));
+ HostRegistry<String> reg = new HostRegistry<>();
+ reg.update("fookey", List.of("foo.com", "bar.com", "baz.com"));
Collection<String> hosts = reg.getAllHosts();
assertThat(hosts.size(), is(3));
- reg.update(foo, List.of("foo.com"));
+ reg.update("fookey", List.of("foo.com"));
assertThat(hosts.size(), is(3));
}
- private void assertGetKey(HostRegistry reg, String host, ApplicationId expectedKey) {
+ private void assertGetKey(HostRegistry<String> reg, String host, String expectedKey) {
assertNotNull(reg.getKeyForHost(host));
assertThat(reg.getKeyForHost(host), is(expectedKey));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
index 6c5e25d0503..9b6ced7f0f6 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpGetConfigHandlerTest.java
@@ -11,7 +11,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.TestConfigDefinitionRepo;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
import org.junit.Before;
@@ -59,7 +58,7 @@ public class HttpGetConfigHandlerTest {
.configDefinitionRepo(new TestConfigDefinitionRepo())
.configServerConfig(configserverConfig)
.build();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenant);
ApplicationRepository applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java
index b55b250fc1c..203b70c2f85 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/HttpListConfigsHandlerTest.java
@@ -12,7 +12,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.TestConfigDefinitionRepo;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HttpListConfigsHandler.ListConfigsResponse;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
@@ -64,7 +63,7 @@ public class HttpListConfigsHandlerTest {
.configDefinitionRepo(new TestConfigDefinitionRepo())
.configServerConfig(configserverConfig)
.build();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenant);
ApplicationRepository applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
index 06bac6497a2..126dfe88141 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationContentHandlerTest.java
@@ -12,7 +12,6 @@ import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.ContentHandlerTestBase;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.session.Session;
@@ -37,12 +36,14 @@ import static org.junit.Assert.assertThat;
public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
private static final File testApp = new File("src/test/apps/content");
+ private static final File testApp2 = new File("src/test/apps/content2");
private final TenantName tenantName1 = TenantName.from("mofet");
private final TenantName tenantName2 = TenantName.from("bla");
private final String baseServer = "http://foo:1337";
private final ApplicationId appId1 = new ApplicationId.Builder().tenant(tenantName1).applicationName("foo").instanceName("quux").build();
+ private final ApplicationId appId2 = new ApplicationId.Builder().tenant(tenantName2).applicationName("foo").instanceName("quux").build();
private ApplicationRepository applicationRepository;
private ApplicationHandler handler;
@@ -63,7 +64,7 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
.build();
Clock clock = componentRegistry.getClock();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenantName1);
tenantRepository.addTenant(tenantName2);
@@ -76,6 +77,8 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
.build();
applicationRepository.deploy(testApp, prepareParams(appId1));
+ applicationRepository.deploy(testApp2, prepareParams(appId2));
+
handler = new ApplicationHandler(ApplicationHandler.testOnlyContext(),
Zone.defaultZone(),
applicationRepository);
@@ -110,6 +113,14 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase {
}
@Test
+ public void require_that_multiple_tenants_are_handled() throws IOException {
+ assertContent("/test.txt", "foo\n");
+ pathPrefix = createPath(appId2, Zone.defaultZone());
+ baseUrl = baseServer + pathPrefix;
+ assertContent("/test.txt", "bar\n");
+ }
+
+ @Test
public void require_that_get_does_not_set_write_flag() throws IOException {
Tenant tenant1 = applicationRepository.getTenant(appId1);
Session session = applicationRepository.getActiveLocalSession(tenant1, appId1);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
index f9b33791a36..a0c63c8bba1 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandlerTest.java
@@ -26,7 +26,6 @@ import com.yahoo.vespa.config.server.application.ClusterReindexing.Status;
import com.yahoo.vespa.config.server.application.HttpProxy;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
import com.yahoo.vespa.config.server.deploy.DeployTester;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
@@ -77,7 +76,6 @@ import static org.mockito.Mockito.when;
public class ApplicationHandlerTest {
private static final File testApp = new File("src/test/apps/app");
- private static final File testAppJdiscOnly = new File("src/test/apps/app-jdisc-only");
private final static TenantName mytenantName = TenantName.from("mytenant");
private final static ApplicationId myTenantApplicationId = ApplicationId.from(mytenantName, ApplicationName.defaultName(), InstanceName.defaultName());
@@ -110,7 +108,7 @@ public class ApplicationHandlerTest {
.configServerConfig(configserverConfig)
.clock(clock)
.build();
- tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(mytenantName);
provisioner = new MockProvisioner();
orchestrator = new OrchestratorMock();
@@ -152,7 +150,7 @@ public class ApplicationHandlerTest {
.instanceName("quux")
.build();
PrepareParams prepareParams2 = new PrepareParams.Builder().applicationId(fooId).build();
- applicationRepository.deploy(testAppJdiscOnly, prepareParams2);
+ applicationRepository.deploy(testApp, prepareParams2);
assertApplicationExists(fooId, Zone.defaultZone());
deleteAndAssertOKResponseMocked(fooId, true);
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java
index 6ef1a0b63cd..0b5c5d3d4da 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HostHandlerTest.java
@@ -14,7 +14,6 @@ import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.session.PrepareParams;
@@ -57,7 +56,7 @@ public class HostHandlerTest {
.zone(zone)
.configServerConfig(configserverConfig)
.build();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(mytenant);
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
index 68cd474412f..f3703c5397d 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpGetConfigHandlerTest.java
@@ -13,7 +13,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.TestConfigDefinitionRepo;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpConfigRequest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
@@ -67,7 +66,7 @@ public class HttpGetConfigHandlerTest {
.configDefinitionRepo(new TestConfigDefinitionRepo())
.configServerConfig(configserverConfig)
.build();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenant);
ApplicationRepository applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java
index 985a88ceed2..c1c9874c35c 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/HttpListConfigsHandlerTest.java
@@ -15,7 +15,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.TestConfigDefinitionRepo;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.v2.HttpListConfigsHandler.ListConfigsResponse;
@@ -71,7 +70,7 @@ public class HttpListConfigsHandlerTest {
.configDefinitionRepo(new TestConfigDefinitionRepo())
.configServerConfig(configserverConfig)
.build();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenant);
ApplicationRepository applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
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 232243c2b74..80a0b9edba6 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
@@ -12,7 +12,6 @@ import com.yahoo.jdisc.Response;
import com.yahoo.jdisc.http.HttpRequest.Method;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.TenantApplications;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
import org.junit.Before;
@@ -42,7 +41,7 @@ public class ListApplicationsHandlerTest {
@Before
public void setup() {
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(mytenant);
tenantRepository.addTenant(foobar);
applicationRepo = tenantRepository.getTenant(mytenant).getApplicationRepo();
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 8e9ef42352c..23b711adc02 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
@@ -15,7 +15,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HandlerTest;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.model.TestModelFactory;
@@ -80,7 +79,7 @@ public class SessionActiveHandlerTest {
.modelFactoryRegistry(new ModelFactoryRegistry(List.of((modelFactory))))
.configServerConfig(configserverConfig)
.build();
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenantName);
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
index ce086cbfb15..4f9b656dfb1 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionContentHandlerTest.java
@@ -14,7 +14,6 @@ import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.ContentHandlerTestBase;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
import com.yahoo.vespa.config.server.session.PrepareParams;
@@ -61,7 +60,7 @@ public class SessionContentHandlerTest extends ContentHandlerTestBase {
.configServerConfig(configserverConfig)
.build();
- tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenantName);
ApplicationRepository applicationRepository = new ApplicationRepository.Builder()
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 7efd448c3ed..84feecec669 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
@@ -11,7 +11,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.CompressedApplicationInputStreamTest;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
import com.yahoo.vespa.config.server.session.Session;
@@ -63,7 +62,7 @@ public class SessionCreateHandlerTest extends SessionHandlerTest {
@Before
public void setupRepo() {
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
.withProvisioner(new MockProvisioner())
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 ed65d8294b8..d24faa1b433 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,7 +19,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.TimeoutBudget;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.HttpErrorResponse;
import com.yahoo.vespa.config.server.http.SessionHandler;
import com.yahoo.vespa.config.server.http.SessionHandlerTest;
@@ -82,7 +81,7 @@ public class SessionPrepareHandlerTest extends SessionHandlerTest {
.build();
Clock clock = componentRegistry.getClock();
timeoutBudget = new TimeoutBudget(clock, Duration.ofSeconds(10));
- tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenant);
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
index a8cc989c802..3d1d2f95e88 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/TenantHandlerTest.java
@@ -19,7 +19,6 @@ import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.tenant.Tenant;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
@@ -57,8 +56,7 @@ public class TenantHandlerTest {
tenantRepository = new TenantRepository(new TestComponentRegistry.Builder()
.curator(new MockCurator())
.configServerConfig(configserverConfig)
- .build(),
- new HostRegistry());
+ .build());
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java
index 1d8f60bb683..1f93f1ce6fe 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/MaintainerTester.java
@@ -11,7 +11,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
import com.yahoo.vespa.config.server.deploy.DeployTester;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.session.PrepareParams;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
@@ -47,7 +46,7 @@ class MaintainerTester {
.provisioner(provisioner)
.modelFactoryRegistry(new ModelFactoryRegistry(List.of(new DeployTester.CountingModelFactory(clock))))
.build();
- tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ tenantRepository = new TenantRepository(componentRegistry);
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
.withProvisioner(provisioner)
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java
index a072bf62852..9bd7a25faf2 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/maintenance/TenantsMaintainerTest.java
@@ -56,8 +56,7 @@ public class TenantsMaintainerTest {
assertNotNull(tenantRepository.getTenant(TenantName.defaultName()));
assertNotNull(tenantRepository.getTenant(TenantRepository.HOSTED_VESPA_TENANT));
- // Delete app, add tenant again and deploy
- tester.applicationRepository().delete(applicationId(shouldNotBeDeleted));
+ // Add tenant again and deploy
tenantRepository.addTenant(shouldBeDeleted);
tester.deployApp(applicationPackage, prepareParams(shouldBeDeleted));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java
index 997633eeb53..7f4733f0b7c 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/MockRpcServer.java
@@ -1,4 +1,4 @@
-// Copyright Verizon Media. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
+// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.config.server.rpc;
import com.yahoo.cloud.config.ConfigserverConfig;
@@ -8,7 +8,7 @@ import com.yahoo.vespa.config.protocol.JRTServerConfigRequest;
import com.yahoo.vespa.config.server.GetConfigContext;
import com.yahoo.vespa.config.server.filedistribution.FileServer;
import com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker;
-import com.yahoo.vespa.config.server.host.HostRegistry;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.rpc.security.NoopRpcAuthorizer;
@@ -37,7 +37,7 @@ public class MockRpcServer extends RpcServer {
super(createConfig(port),
null,
Metrics.createTestMetrics(),
- new HostRegistry(),
+ new HostRegistries(),
new ConfigRequestHostLivenessTracker(),
new FileServer(tempDir),
new NoopRpcAuthorizer(),
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
index 5a41eff3cc9..735eae2700f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcServerTest.java
@@ -64,19 +64,31 @@ public class RpcServerTest {
try (RpcTester tester = new RpcTester(applicationId, temporaryFolder)) {
ApplicationRepository applicationRepository = tester.applicationRepository();
applicationRepository.deploy(testApp, new PrepareParams.Builder().applicationId(applicationId).build());
+ TenantApplications applicationRepo = tester.tenant().getApplicationRepo();
+ RemoteSession activeSession = applicationRepository.getActiveRemoteSession(applicationId);
+ ApplicationSet applicationSet = tester.tenant().getSessionRepository().ensureApplicationLoaded(activeSession);
+ applicationRepo.activateApplication(applicationSet, activeSession.getSessionId());
testPrintStatistics(tester);
testGetConfig(tester);
testEnabled(tester);
testApplicationNotLoadedErrorWhenAppDeleted(tester);
+ testEmptySentinelConfigWhenAppDeletedOnHostedVespa();
}
}
- private void testApplicationNotLoadedErrorWhenAppDeleted(RpcTester tester) {
- tester.applicationRepository().delete(applicationId);
+ private void testApplicationNotLoadedErrorWhenAppDeleted(RpcTester tester) throws InterruptedException, IOException {
+ tester.rpcServer().onTenantDelete(tenantName);
+ tester.rpcServer().onTenantsLoaded();
JRTClientConfigRequest clientReq = createSimpleRequest();
tester.performRequest(clientReq.getRequest());
assertFalse(clientReq.validateResponse());
assertThat(clientReq.errorCode(), is(ErrorCode.APPLICATION_NOT_LOADED));
+ tester.stopRpc();
+ tester.createAndStartRpcServer();
+ tester.rpcServer().onTenantsLoaded();
+ clientReq = createSimpleRequest();
+ tester.performRequest(clientReq.getRequest());
+ assertTrue(clientReq.validateResponse());
}
@Test
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java
index 06c224b5a09..2b2ed13fcfe 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/RpcTester.java
@@ -12,6 +12,7 @@ import com.yahoo.jrt.Supervisor;
import com.yahoo.jrt.Transport;
import com.yahoo.net.HostName;
import com.yahoo.test.ManualClock;
+import com.yahoo.vespa.config.GenerationCounter;
import com.yahoo.vespa.config.server.ApplicationRepository;
import com.yahoo.vespa.config.server.MemoryGenerationCounter;
import com.yahoo.vespa.config.server.MockProvisioner;
@@ -23,7 +24,7 @@ import com.yahoo.vespa.config.server.TestConfigDefinitionRepo;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
import com.yahoo.vespa.config.server.filedistribution.FileServer;
import com.yahoo.vespa.config.server.host.ConfigRequestHostLivenessTracker;
-import com.yahoo.vespa.config.server.host.HostRegistry;
+import com.yahoo.vespa.config.server.host.HostRegistries;
import com.yahoo.vespa.config.server.monitoring.Metrics;
import com.yahoo.vespa.config.server.rpc.security.NoopRpcAuthorizer;
import com.yahoo.vespa.config.server.tenant.Tenant;
@@ -54,15 +55,15 @@ public class RpcTester implements AutoCloseable {
private final ManualClock clock = new ManualClock(Instant.ofEpochMilli(100));
private final String myHostname = HostName.getLocalhost();
private final HostLivenessTracker hostLivenessTracker = new ConfigRequestHostLivenessTracker(clock);
+ private final GenerationCounter generationCounter;
private final Spec spec;
- private final RpcServer rpcServer;
+ private RpcServer rpcServer;
private Thread t;
private Supervisor sup;
private final ApplicationId applicationId;
private final TenantName tenantName;
private final TenantRepository tenantRepository;
- private final HostRegistry hostRegistry = new HostRegistry();
private final ApplicationRepository applicationRepository;
private final List<Integer> allocatedPorts = new ArrayList<>();
@@ -84,26 +85,23 @@ public class RpcTester implements AutoCloseable {
.configDefinitionsDir(temporaryFolder.newFolder().getAbsolutePath())
.fileReferencesDir(temporaryFolder.newFolder().getAbsolutePath());
configserverConfig = new ConfigserverConfig(configBuilder);
- rpcServer = createRpcServer(configserverConfig);
TestComponentRegistry componentRegistry = new TestComponentRegistry.Builder()
.configDefinitionRepo(new TestConfigDefinitionRepo())
.configServerConfig(configserverConfig)
- .reloadListener(rpcServer)
.build();
- tenantRepository = new TenantRepository(componentRegistry, hostRegistry);
+ tenantRepository = new TenantRepository(componentRegistry);
tenantRepository.addTenant(tenantName);
- startRpcServer();
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
- .withConfigserverConfig(configserverConfig)
.withProvisioner(new MockProvisioner())
.withOrchestrator(new OrchestratorMock())
.build();
+ generationCounter = new MemoryGenerationCounter();
+ createAndStartRpcServer();
assertFalse(hostLivenessTracker.lastRequestFrom(myHostname).isPresent());
}
public void close() {
- rpcServer.stop();
for (Integer port : allocatedPorts) {
PortRangeAllocator.releasePort(port);
}
@@ -115,25 +113,24 @@ public class RpcTester implements AutoCloseable {
return port;
}
- RpcServer createRpcServer(ConfigserverConfig config) throws IOException {
- return new RpcServer(config,
- new SuperModelRequestHandler(new TestConfigDefinitionRepo(),
- configserverConfig,
- new SuperModelManager(
- config,
- Zone.defaultZone(),
- new MemoryGenerationCounter(),
- new InMemoryFlagSource())),
- Metrics.createTestMetrics(),
- hostRegistry,
- hostLivenessTracker,
- new FileServer(temporaryFolder.newFolder()),
- new NoopRpcAuthorizer(),
- new RpcRequestHandlerProvider());
- }
-
- void startRpcServer() {
- hostRegistry.update(applicationId, List.of("localhost"));
+ void createAndStartRpcServer() throws IOException {
+ HostRegistries hostRegistries = new HostRegistries();
+ hostRegistries.createApplicationHostRegistry(tenantName).update(applicationId, List.of("localhost"));
+ hostRegistries.getTenantHostRegistry().update(tenantName, List.of("localhost"));
+ rpcServer = new RpcServer(configserverConfig,
+ new SuperModelRequestHandler(new TestConfigDefinitionRepo(),
+ configserverConfig,
+ new SuperModelManager(
+ configserverConfig,
+ Zone.defaultZone() ,
+ generationCounter,
+ new InMemoryFlagSource())),
+ Metrics.createTestMetrics(),
+ hostRegistries,
+ hostLivenessTracker,
+ new FileServer(temporaryFolder.newFolder()),
+ new NoopRpcAuthorizer(),
+ new RpcRequestHandlerProvider());
rpcServer.onTenantCreate(tenantRepository.getTenant(tenantName));
t = new Thread(rpcServer);
t.start();
@@ -168,7 +165,7 @@ public class RpcTester implements AutoCloseable {
void performRequest(Request req) {
clock.advance(Duration.ofMillis(10));
- sup.connect(spec).invokeSync(req, 10.0);
+ sup.connect(spec).invokeSync(req, 120.0);
if (req.methodName().equals(RpcServer.getConfigMethodName))
assertEquals(clock.instant(), hostLivenessTracker.lastRequestFrom(myHostname).get());
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java
index 12debc347de..9e1edb35b8f 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/rpc/security/MultiTenantRpcAuthorizerTest.java
@@ -7,6 +7,7 @@ import com.yahoo.config.FileReference;
import com.yahoo.config.provision.ApplicationId;
import com.yahoo.config.provision.HostName;
import com.yahoo.config.provision.NodeType;
+import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.security.NodeIdentifier;
import com.yahoo.config.provision.security.NodeIdentifierException;
import com.yahoo.config.provision.security.NodeIdentity;
@@ -65,7 +66,7 @@ public class MultiTenantRpcAuthorizerTest {
@Test
public void configserver_can_access_files_and_config() throws InterruptedException, ExecutionException {
RpcAuthorizer authorizer = createAuthorizer(new NodeIdentity.Builder(NodeType.config).build(),
- new HostRegistry());
+ new HostRegistry<>());
Request configRequest = createConfigRequest(new ConfigKey<>("name", "configid", "namespace"), HOSTNAME);
authorizer.authorizeConfigRequest(configRequest)
@@ -82,8 +83,8 @@ public class MultiTenantRpcAuthorizerTest {
.applicationId(APPLICATION_ID)
.build();
- HostRegistry hostRegistry = new HostRegistry();
- hostRegistry.update(APPLICATION_ID, List.of(HOSTNAME.value()));
+ HostRegistry<TenantName> hostRegistry = new HostRegistry<>();
+ hostRegistry.update(APPLICATION_ID.tenant(), List.of(HOSTNAME.value()));
RpcAuthorizer authorizer = createAuthorizer(identity, hostRegistry);
@@ -98,7 +99,7 @@ public class MultiTenantRpcAuthorizerTest {
@Test
public void proxy_node_can_access_lbservice_config() throws ExecutionException, InterruptedException {
- RpcAuthorizer authorizer = createAuthorizer(new NodeIdentity.Builder(NodeType.proxy).build(), new HostRegistry());
+ RpcAuthorizer authorizer = createAuthorizer(new NodeIdentity.Builder(NodeType.proxy).build(), new HostRegistry<>());
Request configRequest = createConfigRequest(
new ConfigKey<>(LbServicesConfig.CONFIG_DEF_NAME, "*", LbServicesConfig.CONFIG_DEF_NAMESPACE),
@@ -109,7 +110,7 @@ public class MultiTenantRpcAuthorizerTest {
@Test
public void tenant_node_cannot_access_lbservice_config() throws ExecutionException, InterruptedException {
- RpcAuthorizer authorizer = createAuthorizer(new NodeIdentity.Builder(NodeType.tenant).build(), new HostRegistry());
+ RpcAuthorizer authorizer = createAuthorizer(new NodeIdentity.Builder(NodeType.tenant).build(), new HostRegistry<>());
Request configRequest = createConfigRequest(
new ConfigKey<>(LbServicesConfig.CONFIG_DEF_NAME, "*", LbServicesConfig.CONFIG_DEF_NAMESPACE),
@@ -128,8 +129,8 @@ public class MultiTenantRpcAuthorizerTest {
.applicationId(APPLICATION_ID)
.build();
- HostRegistry hostRegistry = new HostRegistry();
- hostRegistry.update(APPLICATION_ID, List.of(HOSTNAME.value()));
+ HostRegistry<TenantName> hostRegistry = new HostRegistry<>();
+ hostRegistry.update(APPLICATION_ID.tenant(), List.of(HOSTNAME.value()));
RpcAuthorizer authorizer = createAuthorizer(identity, hostRegistry);
@@ -148,8 +149,8 @@ public class MultiTenantRpcAuthorizerTest {
.applicationId(EVIL_APP_ID)
.build();
- HostRegistry hostRegistry = new HostRegistry();
- hostRegistry.update(APPLICATION_ID, List.of(HOSTNAME.value()));
+ HostRegistry<TenantName> hostRegistry = new HostRegistry<>();
+ hostRegistry.update(APPLICATION_ID.tenant(), List.of(HOSTNAME.value()));
RpcAuthorizer authorizer = createAuthorizer(identity, hostRegistry);
@@ -168,7 +169,7 @@ public class MultiTenantRpcAuthorizerTest {
.applicationId(EVIL_APP_ID)
.build();
- HostRegistry hostRegistry = new HostRegistry();
+ HostRegistry<TenantName> hostRegistry = new HostRegistry<>();
RpcAuthorizer authorizer = createAuthorizer(identity, hostRegistry);
@@ -187,8 +188,8 @@ public class MultiTenantRpcAuthorizerTest {
.applicationId(EVIL_APP_ID)
.build();
- HostRegistry hostRegistry = new HostRegistry();
- hostRegistry.update(EVIL_APP_ID, List.of(HOSTNAME.value()));
+ HostRegistry<TenantName> hostRegistry = new HostRegistry<>();
+ hostRegistry.update(EVIL_APP_ID.tenant(), List.of(HOSTNAME.value()));
RpcAuthorizer authorizer = createAuthorizer(identity, hostRegistry);
@@ -207,7 +208,7 @@ public class MultiTenantRpcAuthorizerTest {
.applicationId(APPLICATION_ID)
.build();
- HostRegistry hostRegistry = new HostRegistry();
+ HostRegistry<TenantName> hostRegistry = new HostRegistry<>();
RpcAuthorizer authorizer = createAuthorizer(identity, hostRegistry);
@@ -218,7 +219,7 @@ public class MultiTenantRpcAuthorizerTest {
}
- private static RpcAuthorizer createAuthorizer(NodeIdentity identity, HostRegistry hostRegistry) {
+ private static RpcAuthorizer createAuthorizer(NodeIdentity identity, HostRegistry<TenantName> hostRegistry) {
return new MultiTenantRpcAuthorizer(
new StaticNodeIdentifier(identity),
hostRegistry,
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 90d3bddc88d..76958264d84 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
@@ -187,7 +187,7 @@ public class SessionPreparerTest {
@Test(expected = InvalidApplicationException.class)
public void require_exception_for_overlapping_host() throws IOException {
FilesApplicationPackage app = getApplicationPackage(testApp);
- HostRegistry hostValidator = new HostRegistry();
+ HostRegistry<ApplicationId> hostValidator = new HostRegistry<>();
hostValidator.update(applicationId("foo"), Collections.singletonList("mytesthost"));
preparer.prepare(hostValidator, new BaseDeployLogger(), new PrepareParams.Builder().applicationId(applicationId("default")).build(),
Optional.empty(), Instant.now(), app.getAppDir(), app, createSessionZooKeeperClient());
@@ -200,7 +200,7 @@ public class SessionPreparerTest {
if (level.equals(Level.WARNING) && message.contains("The host mytesthost is already in use")) logged.append("ok");
};
FilesApplicationPackage app = getApplicationPackage(testApp);
- HostRegistry hostValidator = new HostRegistry();
+ HostRegistry<ApplicationId> hostValidator = new HostRegistry<>();
ApplicationId applicationId = applicationId();
hostValidator.update(applicationId, Collections.singletonList("mytesthost"));
preparer.prepare(hostValidator, logger, new PrepareParams.Builder().applicationId(applicationId).build(),
@@ -367,7 +367,7 @@ public class SessionPreparerTest {
private PrepareResult prepare(File app, PrepareParams params, long sessionId) throws IOException {
FilesApplicationPackage applicationPackage = getApplicationPackage(app);
- return preparer.prepare(new HostRegistry(), getLogger(), params,
+ return preparer.prepare(new HostRegistry<>(), getLogger(), params,
Optional.empty(), Instant.now(), applicationPackage.getAppDir(),
applicationPackage, createSessionZooKeeperClient(sessionId));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
index b2cfd7015ba..bfcfc7d6e43 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/session/SessionRepositoryTest.java
@@ -20,7 +20,6 @@ import com.yahoo.vespa.config.server.MockProvisioner;
import com.yahoo.vespa.config.server.TestComponentRegistry;
import com.yahoo.vespa.config.server.application.ApplicationSet;
import com.yahoo.vespa.config.server.application.OrchestratorMock;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.http.InvalidApplicationException;
import com.yahoo.vespa.config.server.modelfactory.ModelFactoryRegistry;
import com.yahoo.vespa.config.server.tenant.TenantRepository;
@@ -61,7 +60,6 @@ public class SessionRepositoryTest {
private static final TenantName tenantName = TenantName.defaultName();
private static final ApplicationId applicationId = ApplicationId.from(tenantName.value(), "testApp", "default");
private static final File testApp = new File("src/test/apps/app");
- private static final File appJdiscOnly = new File("src/test/apps/app-jdisc-only");
private MockCurator curator;
private TenantRepository tenantRepository;
@@ -92,7 +90,7 @@ public class SessionRepositoryTest {
.build())
.flagSource(flagSource)
.build();
- tenantRepository = new TenantRepository(globalComponentRegistry, new HostRegistry());
+ tenantRepository = new TenantRepository(globalComponentRegistry);
tenantRepository.addTenant(SessionRepositoryTest.tenantName);
applicationRepository = new ApplicationRepository.Builder()
.withTenantRepository(tenantRepository)
@@ -137,7 +135,7 @@ public class SessionRepositoryTest {
// tenant is "newTenant"
TenantName newTenant = TenantName.from("newTenant");
tenantRepository.addTenant(newTenant);
- long sessionId = deploy(ApplicationId.from(newTenant.value(), "testapp", "default"), appJdiscOnly);
+ long sessionId = deploy(ApplicationId.from(newTenant.value(), "testapp", "default"));
SessionRepository sessionRepository2 = tenantRepository.getTenant(newTenant).getSessionRepository();
assertNotNull(sessionRepository2.getLocalSession(sessionId));
}
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
index dbc352128f5..4900c50f1d7 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantRepositoryTest.java
@@ -19,7 +19,6 @@ import com.yahoo.vespa.config.server.application.Application;
import com.yahoo.vespa.config.server.application.ApplicationSet;
import com.yahoo.vespa.config.server.application.TenantApplications;
import com.yahoo.vespa.config.server.application.TenantApplicationsTest;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import com.yahoo.vespa.config.server.monitoring.MetricUpdater;
import com.yahoo.vespa.curator.Curator;
import com.yahoo.vespa.curator.mock.MockCurator;
@@ -67,7 +66,7 @@ public class TenantRepositoryTest {
listener = (TenantApplicationsTest.MockReloadListener)globalComponentRegistry.getReloadListener();
tenantListener = (MockTenantListener)globalComponentRegistry.getTenantListener();
assertFalse(tenantListener.tenantsLoaded);
- tenantRepository = new TenantRepository(globalComponentRegistry, new HostRegistry());
+ tenantRepository = new TenantRepository(globalComponentRegistry);
assertTrue(tenantListener.tenantsLoaded);
tenantRepository.addTenant(tenant1);
tenantRepository.addTenant(tenant2);
@@ -202,7 +201,7 @@ public class TenantRepositoryTest {
private static class FailingDuringBootstrapTenantRepository extends TenantRepository {
public FailingDuringBootstrapTenantRepository(GlobalComponentRegistry globalComponentRegistry) {
- super(globalComponentRegistry, new HostRegistry());
+ super(globalComponentRegistry);
}
@Override
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java
index 1b754ca6695..ac596198fe5 100644
--- a/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java
+++ b/configserver/src/test/java/com/yahoo/vespa/config/server/tenant/TenantTest.java
@@ -4,7 +4,6 @@ package com.yahoo.vespa.config.server.tenant;
import com.google.common.testing.EqualsTester;
import com.yahoo.config.provision.TenantName;
import com.yahoo.vespa.config.server.TestComponentRegistry;
-import com.yahoo.vespa.config.server.host.HostRegistry;
import org.junit.Before;
import org.junit.Test;
@@ -33,7 +32,7 @@ public class TenantTest {
}
private Tenant createTenant(String name) {
- TenantRepository tenantRepository = new TenantRepository(componentRegistry, new HostRegistry());
+ TenantRepository tenantRepository = new TenantRepository(componentRegistry);
TenantName tenantName = TenantName.from(name);
tenantRepository.addTenant(tenantName);
return tenantRepository.getTenant(tenantName);
diff --git a/configserver/src/test/resources/deploy/advancedapp/services.xml b/configserver/src/test/resources/deploy/advancedapp/services.xml
index b8e93b14317..e3d5aea585b 100644
--- a/configserver/src/test/resources/deploy/advancedapp/services.xml
+++ b/configserver/src/test/resources/deploy/advancedapp/services.xml
@@ -22,7 +22,7 @@
<documents>
<document type="keyvalue" mode="index"/>
</documents>
- <nodes>
+ <nodes>>
<node hostalias="node1" distribution-key="0"/>
</nodes>
</content>