diff options
author | Jon Marius Venstad <venstad@gmail.com> | 2021-04-26 16:34:48 +0200 |
---|---|---|
committer | Jon Marius Venstad <venstad@gmail.com> | 2021-04-26 16:34:48 +0200 |
commit | 73a999fb02a1eeaa7af91f78fb8304a4ff2d92a5 (patch) | |
tree | 109650bcb9322f1b48e07e27a90b3d439502c1e9 /controller-api | |
parent | ac9a1c3af6585ed311ec78961e5b8c872eda3486 (diff) |
Revert "Merge pull request #17592 from vespa-engine/jonmv/apache-config-server-client"
This reverts commit 8be3013179c6418f27bcf3f62dea8995a5e981ed, reversing
changes made to 6a9da01a5465826c380d2497e8fa4eb3e51d8e04.
Diffstat (limited to 'controller-api')
-rw-r--r-- | controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java | 53 |
1 files changed, 24 insertions, 29 deletions
diff --git a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java index 5e4d3345b7a..4240b0d9fa6 100644 --- a/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java +++ b/controller-api/src/main/java/com/yahoo/vespa/hosted/controller/api/integration/configserver/ConfigServerException.java @@ -1,32 +1,38 @@ -// 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.hosted.controller.api.integration.configserver; -import com.yahoo.slime.Inspector; -import com.yahoo.slime.SlimeUtils; -import org.apache.hc.core5.http.ClassicHttpRequest; - -import java.util.stream.Stream; +import java.net.URI; +import java.util.Objects; /** - * An exception due to server error, a bad request, or similar. - * - * @author jonmv + * @author Tony Vaagenes */ public class ConfigServerException extends RuntimeException { - private final ErrorCode code; - private final String message; + private final URI serverUri; + private final ErrorCode errorCode; + private final String serverMessage; - public ConfigServerException(ErrorCode code, String message, String context) { - super(context + ": " + message); - this.code = code; - this.message = message; + public ConfigServerException(URI serverUri, String context, String serverMessage, ErrorCode errorCode, Throwable cause) { + super(context + ": " + serverMessage, cause); + this.serverUri = Objects.requireNonNull(serverUri); + this.errorCode = Objects.requireNonNull(errorCode); + this.serverMessage = Objects.requireNonNull(serverMessage); } - public ErrorCode code() { return code; } + public ErrorCode getErrorCode() { + return errorCode; + } - public String message() { return message; } + public URI getServerUri() { + return serverUri; + } + public String getServerMessage() { + return serverMessage; + } + + // TODO: Copied from Vespa. Expose these in Vespa and use them here public enum ErrorCode { APPLICATION_LOCK_FAILURE, BAD_REQUEST, @@ -40,18 +46,7 @@ public class ConfigServerException extends RuntimeException { UNKNOWN_VESPA_VERSION, PARENT_HOST_NOT_READY, CERTIFICATE_NOT_READY, - LOAD_BALANCER_NOT_READY, - INCOMPLETE_RESPONSE - } - - public static ConfigServerException readException(int statusCode, byte[] body, ClassicHttpRequest request) { - Inspector root = SlimeUtils.jsonToSlime(body).get(); - String codeName = root.field("error-code").asString(); - ErrorCode code = Stream.of(ErrorCode.values()) - .filter(value -> value.name().equals(codeName)) - .findAny().orElse(ErrorCode.INCOMPLETE_RESPONSE); - String message = root.field("message").valid() ? root.field("message").asString() : "(no message)"; - return new ConfigServerException(code, message, request + " failed with status " + statusCode); + LOAD_BALANCER_NOT_READY } } |