diff options
author | Harald Musum <musum@yahoo-inc.com> | 2016-12-09 12:21:44 +0100 |
---|---|---|
committer | Harald Musum <musum@yahoo-inc.com> | 2016-12-09 12:21:44 +0100 |
commit | 18c0a07fb40a5db2f1521c9389606b72773c2ced (patch) | |
tree | a1d6c414008a23325f1c675b0620114991710105 /configserver | |
parent | 75c6f3bd447a730261bf3e0fb20215a1db44b97f (diff) |
Move more stuff out of http layer
Diffstat (limited to 'configserver')
4 files changed, 11 insertions, 17 deletions
diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java index 5241dd78d35..91b0fdc207b 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/ApplicationRepository.java @@ -1,10 +1,9 @@ // Copyright 2016 Yahoo Inc. 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; - import com.yahoo.config.application.api.DeployLogger; import com.yahoo.config.provision.ApplicationId; +import com.yahoo.config.provision.HostFilter; import com.yahoo.config.provision.Provisioner; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpRequest; @@ -191,4 +190,9 @@ public class ApplicationRepository implements com.yahoo.config.provision.Deploye return session; } + public void restart(ApplicationId applicationId, HostFilter hostFilter) { + if (hostProvisioner.isPresent()) + hostProvisioner.get().restart(applicationId, hostFilter); + } + } diff --git a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java index e9432e9cf81..18a3b8fb207 100644 --- a/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java +++ b/configserver/src/main/java/com/yahoo/vespa/config/server/http/v2/ApplicationHandler.java @@ -4,7 +4,6 @@ package com.yahoo.vespa.config.server.http.v2; import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.ApplicationName; import com.yahoo.config.provision.HostFilter; -import com.yahoo.config.provision.Provisioner; import com.yahoo.config.provision.TenantName; import com.yahoo.config.provision.Zone; import com.yahoo.container.jdisc.HttpRequest; @@ -23,7 +22,6 @@ import com.yahoo.vespa.config.server.http.HttpHandler; import com.yahoo.vespa.config.server.http.JSONResponse; import com.yahoo.vespa.config.server.http.NotFoundException; import com.yahoo.vespa.config.server.http.Utils; -import com.yahoo.vespa.config.server.provision.HostProvisionerProvider; import java.io.IOException; import java.io.OutputStream; @@ -31,7 +29,6 @@ import java.nio.charset.StandardCharsets; import java.time.Clock; import java.time.Duration; import java.util.List; -import java.util.Optional; import java.util.concurrent.Executor; /** @@ -46,18 +43,15 @@ public class ApplicationHandler extends HttpHandler { private static final String REQUEST_PROPERTY_TIMEOUT = "timeout"; private final Tenants tenants; - private final Optional<Provisioner> hostProvisioner; private final Zone zone; private final ApplicationRepository applicationRepository; public ApplicationHandler(Executor executor, AccessLog accessLog, Tenants tenants, - HostProvisionerProvider hostProvisionerProvider, Zone zone, ApplicationRepository applicationRepository) { super(executor, accessLog); this.tenants = tenants; - this.hostProvisioner = hostProvisionerProvider.getHostProvisioner(); this.zone = zone; this.applicationRepository = applicationRepository; } @@ -103,22 +97,21 @@ public class ApplicationHandler extends HttpHandler { ApplicationId applicationId = getApplicationIdFromRequest(request); Tenant tenant = verifyTenantAndApplication(applicationId); if (request.getUri().getPath().endsWith("restart")) - return handlePostRestart(request, applicationId); + return restart(request, applicationId); if (request.getUri().getPath().endsWith("log")) - return handlePostLog(request, applicationId, tenant); + return grabLog(request, applicationId, tenant); throw new NotFoundException("Illegal POST request '" + request.getUri() + "': Must end by /restart or /log"); } - private HttpResponse handlePostRestart(HttpRequest request, ApplicationId applicationId) { + private HttpResponse restart(HttpRequest request, ApplicationId applicationId) { if (getBindingMatch(request).groupCount() != 7) throw new NotFoundException("Illegal POST restart request '" + request.getUri() + "': Must have 6 arguments but had " + ( getBindingMatch(request).groupCount()-1 ) ); - if (hostProvisioner.isPresent()) - hostProvisioner.get().restart(applicationId, hostFilterFrom(request)); + applicationRepository.restart(applicationId, hostFilterFrom(request)); return new JSONResponse(Response.Status.OK); // return empty } - private HttpResponse handlePostLog(HttpRequest request, ApplicationId applicationId, Tenant tenant) { + private HttpResponse grabLog(HttpRequest request, ApplicationId applicationId, Tenant tenant) { if (getBindingMatch(request).groupCount() != 7) throw new NotFoundException("Illegal POST log request '" + request.getUri() + "': Must have 6 arguments but had " + ( getBindingMatch(request).groupCount()-1 ) ); 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 486d81f9f42..c629765f8fe 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 @@ -58,7 +58,6 @@ public class ApplicationContentHandlerTest extends ContentHandlerTestBase { handler = new ApplicationHandler(command -> command.run(), AccessLog.voidAccessLog(), testTenantBuilder.createTenants(), - HostProvisionerProvider.empty(), Zone.defaultZone(), new ApplicationRepository(testTenantBuilder.createTenants(), HostProvisionerProvider.empty(), 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 7ad691d648c..7a73e975e23 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 @@ -97,7 +97,6 @@ public class ApplicationHandlerTest { Runnable::run, AccessLog.voidAccessLog(), tenants, - HostProvisionerProvider.withProvisioner(provisioner), Zone.defaultZone(), new ApplicationRepository(tenants, HostProvisionerProvider.withProvisioner(provisioner), @@ -111,7 +110,6 @@ public class ApplicationHandlerTest { Runnable::run, AccessLog.voidAccessLog(), tenants, - HostProvisionerProvider.withProvisioner(provisioner), Zone.defaultZone(), new ApplicationRepository(tenants, HostProvisionerProvider.withProvisioner(provisioner), |