aboutsummaryrefslogtreecommitdiffstats
path: root/controller-server/src
diff options
context:
space:
mode:
authorJon Marius Venstad <jonmv@users.noreply.github.com>2023-02-08 14:08:43 +0100
committerGitHub <noreply@github.com>2023-02-08 14:08:43 +0100
commit8ceff780883d070e7916ee6eb2a241f437faa339 (patch)
treeb1516fd53461ada7a059209ab7d7ffd7cf9c6b16 /controller-server/src
parentcdd1430c6eb50ef5fbe4e65881dbee936fb0a075 (diff)
parent6f5f4183b0ed20d54d4bb708813603228c1a180b (diff)
Merge pull request #25923 from vespa-engine/mpolden/cleanup
Misc cleanup
Diffstat (limited to 'controller-server/src')
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java6
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java33
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java62
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyResponse.java20
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/CsvResponse.java5
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java19
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java16
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiHandler.java8
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/Badges.java23
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/CliApiHandler.java8
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java2
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/AthenzRoleFilter.java4
-rw-r--r--controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java2
14 files changed, 65 insertions, 145 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java
index f4a1001d9ff..56b7ffd01f9 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/application/SystemApplication.java
@@ -33,7 +33,7 @@ public enum SystemApplication {
tenantHost(InfrastructureApplication.TENANT_HOST);
/** The tenant owning all system applications */
- public static final TenantName TENANT = TenantName.from(Constants.TENANT_NAME);
+ public static final TenantName TENANT = TenantName.from("hosted-vespa");
private final InfrastructureApplication application;
private final List<SystemApplication> dependencies;
@@ -95,8 +95,4 @@ public enum SystemApplication {
return Text.format("system application %s of type %s", id(), nodeType());
}
- private static class Constants {
- private static final String TENANT_NAME = "hosted-vespa";
- }
-
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java
index 8a6243a7224..5e36d6d6499 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/FormattedNotification.java
@@ -9,32 +9,13 @@ import java.util.Objects;
*
* @author enygaard
*/
-public class FormattedNotification {
- private final String prettyType;
- private final String messagePrefix;
- private final URI uri;
- private final Notification notification;
+public record FormattedNotification(Notification notification, String prettyType, String messagePrefix, URI uri) {
- public FormattedNotification(Notification notification, String prettyType, String messagePrefix, URI uri) {
- this.prettyType = Objects.requireNonNull(prettyType);
- this.messagePrefix = Objects.requireNonNull(messagePrefix);
- this.uri = Objects.requireNonNull(uri);
- this.notification = Objects.requireNonNull(notification);
+ public FormattedNotification {
+ Objects.requireNonNull(prettyType);
+ Objects.requireNonNull(messagePrefix);
+ Objects.requireNonNull(uri);
+ Objects.requireNonNull(notification);
}
- public String prettyType() {
- return prettyType;
- }
-
- public String messagePrefix() {
- return messagePrefix;
- }
-
- public URI uri() {
- return uri;
- }
-
- public Notification notification() {
- return notification;
- }
-} \ No newline at end of file
+}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java
index da423995b7e..53450783c8e 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/notification/Notification.java
@@ -13,12 +13,7 @@ import java.util.Objects;
*
* @author freva
*/
-public class Notification {
- private final Instant at;
- private final Type type;
- private final Level level;
- private final NotificationSource source;
- private final List<String> messages;
+public record Notification(Instant at, com.yahoo.vespa.hosted.controller.notification.Notification.Type type, com.yahoo.vespa.hosted.controller.notification.Notification.Level level, NotificationSource source, List<String> messages) {
public Notification(Instant at, Type type, Level level, NotificationSource source, List<String> messages) {
this.at = Objects.requireNonNull(at, "at cannot be null");
@@ -29,37 +24,6 @@ public class Notification {
if (messages.size() < 1) throw new IllegalArgumentException("messages cannot be empty");
}
- public Instant at() { return at; }
- public Type type() { return type; }
- public Level level() { return level; }
- public NotificationSource source() { return source; }
- public List<String> messages() { return messages; }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Notification that = (Notification) o;
- return at.equals(that.at) && type == that.type && level == that.level &&
- source.equals(that.source) && messages.equals(that.messages);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(at, type, level, source, messages);
- }
-
- @Override
- public String toString() {
- return "Notification{" +
- "at=" + at +
- ", type=" + type +
- ", level=" + level +
- ", source=" + source +
- ", messages=" + messages +
- '}';
- }
-
public enum Level {
// Must be ordered in order of importance
info, warning, error
@@ -67,22 +31,34 @@ public class Notification {
public enum Type {
- /** Related to contents of application package, e.g., usage of deprecated features/syntax */
+ /**
+ * Related to contents of application package, e.g., usage of deprecated features/syntax
+ */
applicationPackage,
- /** Related to contents of application package detectable by the controller on submission */
+ /**
+ * Related to contents of application package detectable by the controller on submission
+ */
submission,
- /** Related to contents of application test package, e.g., mismatch between deployment spec and provided tests */
+ /**
+ * Related to contents of application test package, e.g., mismatch between deployment spec and provided tests
+ */
testPackage,
- /** Related to deployment of application, e.g., system test failure, node allocation failure, internal errors, etc. */
+ /**
+ * Related to deployment of application, e.g., system test failure, node allocation failure, internal errors, etc.
+ */
deployment,
- /** Application cluster is (near) external feed blocked */
+ /**
+ * Application cluster is (near) external feed blocked
+ */
feedBlock,
- /** Application cluster is reindexing document(s) */
+ /**
+ * Application cluster is reindexing document(s)
+ */
reindex
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
index bc7e3f0e7d0..54d219a2a6d 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/ApplicationApiHandler.java
@@ -29,6 +29,7 @@ import com.yahoo.config.provision.ZoneEndpoint.AllowedUrn;
import com.yahoo.config.provision.zone.RoutingMethod;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.container.handler.metrics.JsonResponse;
+import com.yahoo.container.jdisc.EmptyResponse;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
@@ -50,7 +51,6 @@ import com.yahoo.slime.SlimeUtils;
import com.yahoo.text.Text;
import com.yahoo.vespa.athenz.api.OAuthCredentials;
import com.yahoo.vespa.athenz.client.zms.ZmsClientException;
-import com.yahoo.vespa.flags.Flags;
import com.yahoo.vespa.hosted.controller.Application;
import com.yahoo.vespa.hosted.controller.Controller;
import com.yahoo.vespa.hosted.controller.Instance;
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyResponse.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyResponse.java
deleted file mode 100644
index dbd4250669c..00000000000
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/application/EmptyResponse.java
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.vespa.hosted.controller.restapi.application;
-
-import com.yahoo.container.jdisc.HttpResponse;
-
-import java.io.OutputStream;
-
-/**
- * @author bratseth
- */
-public class EmptyResponse extends HttpResponse {
-
- public EmptyResponse() {
- super(200);
- }
-
- @Override
- public void render(OutputStream stream) {}
-
-}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/CsvResponse.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/CsvResponse.java
index 3643626761d..e97a51e58a2 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/CsvResponse.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/billing/CsvResponse.java
@@ -9,7 +9,11 @@ import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.util.List;
+/**
+ * @author ogronnesby
+ */
class CsvResponse extends HttpResponse {
+
private final String[] header;
private final List<Object[]> rows;
@@ -31,4 +35,5 @@ class CsvResponse extends HttpResponse {
public String getContentType() {
return "text/csv; encoding=utf-8";
}
+
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java
index 5148577880f..6d19316efd7 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/changemanagement/ChangeManagementApiHandler.java
@@ -46,18 +46,13 @@ public class ChangeManagementApiHandler extends AuditLoggingRequestHandler {
@Override
public HttpResponse auditAndHandle(HttpRequest request) {
try {
- switch (request.getMethod()) {
- case GET:
- return get(request);
- case POST:
- return post(request);
- case PATCH:
- return patch(request);
- case DELETE:
- return delete(request);
- default:
- return ErrorResponse.methodNotAllowed("Method '" + request.getMethod() + "' is unsupported");
- }
+ return switch (request.getMethod()) {
+ case GET -> get(request);
+ case POST -> post(request);
+ case PATCH -> patch(request);
+ case DELETE -> delete(request);
+ default -> ErrorResponse.methodNotAllowed("Method '" + request.getMethod() + "' is unsupported");
+ };
} catch (IllegalArgumentException e) {
return ErrorResponse.badRequest(Exceptions.toMessageString(e));
} catch (RuntimeException e) {
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java
index e764fed4653..3c832dc8873 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/configserver/ConfigServerApiHandler.java
@@ -55,17 +55,11 @@ public class ConfigServerApiHandler extends AuditLoggingRequestHandler {
@Override
public HttpResponse auditAndHandle(HttpRequest request) {
try {
- switch (request.getMethod()) {
- case GET:
- return get(request);
- case POST:
- case PUT:
- case DELETE:
- case PATCH:
- return proxy(request);
- default:
- return ErrorResponse.methodNotAllowed("Method '" + request.getMethod() + "' is unsupported");
- }
+ return switch (request.getMethod()) {
+ case GET -> get(request);
+ case POST, PUT, DELETE, PATCH -> proxy(request);
+ default -> ErrorResponse.methodNotAllowed("Method '" + request.getMethod() + "' is unsupported");
+ };
} catch (IllegalArgumentException e) {
return ErrorResponse.badRequest(Exceptions.toMessageString(e));
} catch (RuntimeException e) {
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiHandler.java
index 74a28276c79..c6eaf5abef7 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/BadgeApiHandler.java
@@ -52,10 +52,10 @@ public class BadgeApiHandler extends ThreadedHttpRequestHandler {
public HttpResponse handle(HttpRequest request) {
Method method = request.getMethod();
try {
- switch (method) {
- case GET: return get(request);
- default: return ErrorResponse.methodNotAllowed("Method '" + method + "' is unsupported");
- }
+ return switch (method) {
+ case GET -> get(request);
+ default -> ErrorResponse.methodNotAllowed("Method '" + method + "' is unsupported");
+ };
} catch (IllegalArgumentException|IllegalStateException e) {
return ErrorResponse.badRequest(Exceptions.toMessageString(e));
} catch (RuntimeException e) {
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/Badges.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/Badges.java
index eed12f61a76..814241a765c 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/Badges.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/Badges.java
@@ -2,7 +2,6 @@
package com.yahoo.vespa.hosted.controller.restapi.deployment;
import com.yahoo.config.provision.ApplicationId;
-import com.yahoo.config.provision.SystemName;
import com.yahoo.slime.ArrayTraverser;
import com.yahoo.slime.SlimeUtils;
import com.yahoo.vespa.hosted.controller.api.integration.deployment.JobType;
@@ -51,18 +50,16 @@ public class Badges {
}
static String colorOf(Run run, Optional<RunStatus> previous) {
- switch (run.status()) {
- case running: switch (previous.orElse(RunStatus.success)) {
- case success: return "url(#run-on-success)";
- case aborted:
- case noTests: return "url(#run-on-warning)";
- default: return "url(#run-on-failure)";
- }
- case success: return success;
- case aborted:
- case noTests: return warning;
- default: return failure;
- }
+ return switch (run.status()) {
+ case running -> switch (previous.orElse(RunStatus.success)) {
+ case success -> "url(#run-on-success)";
+ case aborted, noTests -> "url(#run-on-warning)";
+ default -> "url(#run-on-failure)";
+ };
+ case success -> success;
+ case aborted, noTests -> warning;
+ default -> failure;
+ };
}
static String nameOf(JobType type) {
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/CliApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/CliApiHandler.java
index 336352e931a..c67d0d04938 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/CliApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/CliApiHandler.java
@@ -34,10 +34,10 @@ public class CliApiHandler extends ThreadedHttpRequestHandler {
@Override
public HttpResponse handle(HttpRequest request) {
try {
- switch (request.getMethod()) {
- case GET: return get(request);
- default: return ErrorResponse.methodNotAllowed("Method '" + request.getMethod() + "' is not supported");
- }
+ return switch (request.getMethod()) {
+ case GET -> get(request);
+ default -> ErrorResponse.methodNotAllowed("Method '" + request.getMethod() + "' is not supported");
+ };
}
catch (IllegalArgumentException e) {
return ErrorResponse.badRequest(Exceptions.toMessageString(e));
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java
index 6946efdbe2a..759b2366229 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/deployment/DeploymentApiHandler.java
@@ -5,6 +5,7 @@ import com.yahoo.component.Version;
import com.yahoo.config.application.api.DeploymentInstanceSpec;
import com.yahoo.config.application.api.DeploymentSpec;
import com.yahoo.config.provision.ApplicationId;
+import com.yahoo.container.jdisc.EmptyResponse;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
@@ -25,7 +26,6 @@ import com.yahoo.vespa.hosted.controller.deployment.Run;
import com.yahoo.vespa.hosted.controller.deployment.RunStatus;
import com.yahoo.vespa.hosted.controller.deployment.Versions;
import com.yahoo.vespa.hosted.controller.restapi.ErrorResponses;
-import com.yahoo.vespa.hosted.controller.restapi.application.EmptyResponse;
import com.yahoo.vespa.hosted.controller.versions.DeploymentStatistics;
import com.yahoo.vespa.hosted.controller.versions.VespaVersion;
import com.yahoo.yolean.Exceptions;
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/AthenzRoleFilter.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/AthenzRoleFilter.java
index e23f0205e5a..c25502ab9bf 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/AthenzRoleFilter.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/filter/AthenzRoleFilter.java
@@ -6,7 +6,6 @@ import com.auth0.jwt.interfaces.DecodedJWT;
import com.auth0.jwt.interfaces.Payload;
import com.yahoo.component.annotation.Inject;
import com.yahoo.config.provision.ApplicationName;
-import com.yahoo.config.provision.SystemName;
import com.yahoo.config.provision.TenantName;
import com.yahoo.config.provision.zone.ZoneId;
import com.yahoo.jdisc.Response;
@@ -33,7 +32,6 @@ import com.yahoo.vespa.hosted.controller.tenant.Tenant;
import com.yahoo.yolean.Exceptions;
import java.net.URI;
-import java.security.Principal;
import java.security.cert.X509Certificate;
import java.time.Instant;
import java.util.ArrayList;
@@ -64,7 +62,6 @@ public class AthenzRoleFilter extends JsonSecurityRequestFilterBase {
private final AthenzFacade athenz;
private final TenantController tenants;
private final ExecutorService executor;
- private final SystemName systemName;
private final ZoneRegistry zones;
@Inject
@@ -72,7 +69,6 @@ public class AthenzRoleFilter extends JsonSecurityRequestFilterBase {
this.athenz = new AthenzFacade(athenzClientFactory);
this.tenants = controller.tenants();
this.executor = Executors.newCachedThreadPool();
- this.systemName = controller.system();
this.zones = controller.zoneRegistry();
}
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java
index c2e926f777b..a9787e28113 100644
--- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java
+++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/user/UserApiHandler.java
@@ -4,6 +4,7 @@ package com.yahoo.vespa.hosted.controller.restapi.user;
import com.yahoo.component.annotation.Inject;
import com.yahoo.config.provision.ApplicationName;
import com.yahoo.config.provision.TenantName;
+import com.yahoo.container.jdisc.EmptyResponse;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.container.jdisc.ThreadedHttpRequestHandler;
@@ -37,7 +38,6 @@ import com.yahoo.vespa.hosted.controller.api.role.SimplePrincipal;
import com.yahoo.vespa.hosted.controller.api.role.TenantRole;
import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId;
import com.yahoo.vespa.hosted.controller.restapi.ErrorResponses;
-import com.yahoo.vespa.hosted.controller.restapi.application.EmptyResponse;
import com.yahoo.vespa.hosted.controller.tenant.Tenant;
import com.yahoo.yolean.Exceptions;