diff options
7 files changed, 10 insertions, 50 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigActivationListener.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigActivationListener.java index 604758f7bf9..e52089f5400 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigActivationListener.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ConfigActivationListener.java @@ -4,35 +4,17 @@ package com.yahoo.vespa.config.server; import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.server.application.ApplicationSet; -import java.util.Collection; - /** * A ConfigActivationListener is used to signal to a component that config has been - * activated. It only exists because the RpcServer cannot distinguish between a - * successful activation of a new application and an activation of the same application. + * activated for an application or that an application has been removed. It only exists + * because the RpcServer cannot distinguish between a successful activation of a new + * application and an activation of the same application. * * @author Ulf Lilleengen */ public interface ConfigActivationListener { /** - * Signals the listener that hosts used by a particular application has changed. - * - * @param applicationId application id - * @param newHosts a {@link Collection} of hosts used by an application. - */ - void hostsUpdated(ApplicationId applicationId, Collection<String> newHosts); - - /** - * Verifies that given hosts are available for use by an application. - * - * @param applicationId application id - * @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); - - /** * Configs has been activated for an application: Either an application * has been deployed for the first time, or it has been externally or internally redeployed. * 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 83ca81f75c0..ab33e4692f0 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 @@ -219,7 +219,7 @@ public class TenantApplications implements RequestHandler, HostValidator { List<Application> applications = applicationSet.getAllApplications(); if (applications.isEmpty()) throw new IllegalArgumentException("application set cannot be empty"); - configActivationListener.hostsUpdated(applications.get(0).getId(), applicationSet.getAllHosts()); + hostRegistry.update(applications.get(0).getId(), applicationSet.getAllHosts()); configActivationListener.configActivated(applicationSet); } @@ -277,7 +277,7 @@ public class TenantApplications implements RequestHandler, HostValidator { } private void configActivationListenersOnRemove(ApplicationId applicationId) { - configActivationListener.hostsUpdated(applicationId, hostRegistry.getHosts(applicationId)); + hostRegistry.removeHosts(applicationId); configActivationListener.applicationRemoved(applicationId); } @@ -398,7 +398,6 @@ public class TenantApplications implements RequestHandler, HostValidator { @Override public void verifyHosts(ApplicationId applicationId, Collection<String> newHosts) { hostRegistry.verifyHosts(applicationId, newHosts); - configActivationListener.verifyHostsAreAvailable(applicationId, newHosts); } public ApplicationId getApplicationIdForHostName(String hostname) { 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 aac34238b90..2d731370b70 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 @@ -44,11 +44,9 @@ import com.yahoo.vespa.filedistribution.FileDownloader; import com.yahoo.vespa.filedistribution.FileReceiver; import com.yahoo.vespa.filedistribution.FileReferenceData; import com.yahoo.vespa.filedistribution.FileReferenceDownload; - import java.nio.ByteBuffer; import java.time.Duration; import java.util.Arrays; -import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; @@ -320,17 +318,6 @@ public class RpcServer implements Runnable, ConfigActivationListener, TenantList } @Override - public void hostsUpdated(ApplicationId applicationId, Collection<String> newHosts) { - log.log(Level.FINE, () -> "Updating hosts in tenant host registry '" + hostRegistry + "' with " + newHosts); - hostRegistry.update(applicationId, newHosts); - } - - @Override - public void verifyHostsAreAvailable(ApplicationId applicationId, Collection<String> newHosts) { - hostRegistry.verifyHosts(applicationId, newHosts); - } - - @Override public void applicationRemoved(ApplicationId applicationId) { superModelRequestHandler.removeApplication(applicationId); configActivated(applicationId); @@ -350,6 +337,7 @@ public class RpcServer implements Runnable, ConfigActivationListener, TenantList */ 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.getApplicationId(hostname); if (applicationId == null) { @@ -445,7 +433,6 @@ public class RpcServer implements Runnable, ConfigActivationListener, TenantList log.log(Level.FINE, () -> TenantRepository.logPre(tenant) + "Tenant deleted, removing request handler and cleaning host registry"); tenants.remove(tenant); - hostRegistry.removeHosts(tenant); } @Override 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 00a10a97dc3..4833a62aa37 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 @@ -401,6 +401,7 @@ public class TenantRepository { } private void notifyRemovedTenant(TenantName name) { + hostRegistry.removeHosts(name); tenantListener.onTenantDelete(name); } 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 85e64b4a32d..728f3e8510f 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 @@ -203,15 +203,6 @@ public class TenantApplicationsTest { } @Override - public void hostsUpdated(ApplicationId applicationId, Collection<String> newHosts) { - tenantHosts.put(applicationId.tenant().value(), newHosts); - } - - @Override - public void verifyHostsAreAvailable(ApplicationId applicationId, Collection<String> newHosts) { - } - - @Override public void applicationRemoved(ApplicationId applicationId) { removed.incrementAndGet(); } 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 8607fc0e2dc..9190cbc0d8a 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 @@ -38,10 +38,10 @@ import java.io.File; import java.io.IOException; import java.util.Optional; +import static com.yahoo.vespa.config.server.rpc.RpcServer.ChunkedFileReceiver.createMetaRequest; import static com.yahoo.vespa.filedistribution.FileReferenceData.CompressionType.gzip; import static com.yahoo.vespa.filedistribution.FileReferenceData.CompressionType.lz4; import static com.yahoo.vespa.filedistribution.FileReferenceData.Type.compressed; -import static com.yahoo.vespa.config.server.rpc.RpcServer.ChunkedFileReceiver.createMetaRequest; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -84,7 +84,7 @@ public class RpcServerTest { public void testEmptySentinelConfigWhenAppDeletedOnHostedVespa() throws IOException, InterruptedException { ConfigserverConfig.Builder configBuilder = new ConfigserverConfig.Builder().canReturnEmptySentinelConfig(true); try (RpcTester tester = new RpcTester(applicationId, temporaryFolder, configBuilder)) { - tester.rpcServer().onTenantDelete(tenantName); + tester.hostRegistry.removeHosts(applicationId); tester.rpcServer().onTenantsLoaded(); JRTClientConfigRequest clientReq = createSentinelRequest(); 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 c40af30d1f4..8770970308a 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 @@ -54,7 +54,7 @@ public class RpcTester implements AutoCloseable { private final ApplicationId applicationId; private final TenantName tenantName; private final TenantRepository tenantRepository; - private final HostRegistry hostRegistry = new HostRegistry(); + final HostRegistry hostRegistry = new HostRegistry(); private final ApplicationRepository applicationRepository; private final List<Integer> allocatedPorts = new ArrayList<>(); |