diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2018-02-03 10:47:53 +0100 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2018-02-03 10:47:53 +0100 |
commit | 039ae6fbba7556ba0e8128faa74260056c078869 (patch) | |
tree | 9656504e0172fc6786929bc1e9788160039f3231 | |
parent | db04b94cb72b730e437a6ed8968e09adfb0c68e1 (diff) |
Try to differentiate between client and server errors.
6 files changed, 32 insertions, 5 deletions
diff --git a/container-core/src/main/java/com/yahoo/container/jdisc/VespaHeaders.java b/container-core/src/main/java/com/yahoo/container/jdisc/VespaHeaders.java index ecb36ade5eb..b39fd7f5db7 100644 --- a/container-core/src/main/java/com/yahoo/container/jdisc/VespaHeaders.java +++ b/container-core/src/main/java/com/yahoo/container/jdisc/VespaHeaders.java @@ -6,6 +6,7 @@ import static com.yahoo.container.protect.Error.BACKEND_COMMUNICATION_ERROR; import static com.yahoo.container.protect.Error.BAD_REQUEST; import static com.yahoo.container.protect.Error.FORBIDDEN; import static com.yahoo.container.protect.Error.ILLEGAL_QUERY; +import static com.yahoo.container.protect.Error.INSUFFICIENT_STORAGE; import static com.yahoo.container.protect.Error.INTERNAL_SERVER_ERROR; import static com.yahoo.container.protect.Error.INVALID_QUERY_PARAMETER; import static com.yahoo.container.protect.Error.NOT_FOUND; @@ -159,6 +160,8 @@ public final class VespaHeaders { return new Tuple2<>(true, Response.Status.BAD_REQUEST); if (error.getCode() == INTERNAL_SERVER_ERROR.code) return new Tuple2<>(true, Response.Status.INTERNAL_SERVER_ERROR); + if (error.getCode() == INSUFFICIENT_STORAGE.code) + return new Tuple2<>(true, Response.Status.INSUFFICIENT_STORAGE); return NO_MATCH; } diff --git a/container-core/src/main/java/com/yahoo/container/protect/Error.java b/container-core/src/main/java/com/yahoo/container/protect/Error.java index 46b49b1623a..b39a33b1346 100644 --- a/container-core/src/main/java/com/yahoo/container/protect/Error.java +++ b/container-core/src/main/java/com/yahoo/container/protect/Error.java @@ -26,7 +26,8 @@ public enum Error { FORBIDDEN(15), NOT_FOUND(16), BAD_REQUEST(17), - INTERNAL_SERVER_ERROR(18); + INTERNAL_SERVER_ERROR(18), + INSUFFICIENT_STORAGE(19); public final int code; diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java index c24398388d5..649913d4f1c 100755 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemove.java @@ -7,8 +7,10 @@ import com.yahoo.cloud.config.ClusterListConfig; import com.yahoo.cloud.config.SlobroksConfig; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; +import com.yahoo.container.protect.Error; import com.yahoo.document.DocumentId; import com.yahoo.document.config.DocumentmanagerConfig; +import com.yahoo.documentapi.messagebus.protocol.DocumentProtocol; import com.yahoo.feedapi.FeedContext; import com.yahoo.feedapi.MessagePropertyProcessor; import com.yahoo.feedapi.SingleSender; @@ -78,7 +80,7 @@ public class VespaFeedHandlerRemove extends VespaFeedHandlerBase { long millis = getTimeoutMillis(request); boolean completed = sender.waitForPending(millis); if ( ! completed) - response.addError("Timed out after "+millis+" ms waiting for responses"); + response.addError(Error.TIMEOUT, "Timed out after "+millis+" ms waiting for responses"); return response; } diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java index 2f0526a21ef..04ca6798b4c 100644 --- a/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java +++ b/vespaclient-container-plugin/src/main/java/com/yahoo/feedhandler/VespaFeedHandlerRemoveLocation.java @@ -7,6 +7,7 @@ import com.yahoo.cloud.config.ClusterListConfig; import com.yahoo.cloud.config.SlobroksConfig; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; +import com.yahoo.container.protect.Error; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.documentapi.messagebus.protocol.RemoveLocationMessage; import com.yahoo.feedapi.FeedContext; @@ -78,7 +79,7 @@ public class VespaFeedHandlerRemoveLocation extends VespaFeedHandlerBase { long millis = getTimeoutMillis(request); boolean completed = sender.waitForPending(millis); if ( ! completed) - response.addError("Timed out after "+millis+" ms waiting for responses"); + response.addError(Error.TIMEOUT, "Timed out after "+millis+" ms waiting for responses"); return response; } diff --git a/vespaclient-core/src/main/java/com/yahoo/feedhandler/FeedResponse.java b/vespaclient-core/src/main/java/com/yahoo/feedhandler/FeedResponse.java index c235fdfce72..7f65179de2d 100755 --- a/vespaclient-core/src/main/java/com/yahoo/feedhandler/FeedResponse.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedhandler/FeedResponse.java @@ -11,6 +11,7 @@ import com.yahoo.documentapi.messagebus.protocol.UpdateDocumentMessage; import com.yahoo.feedapi.SharedSender; import com.yahoo.log.LogLevel; import com.yahoo.messagebus.Error; +import com.yahoo.messagebus.ErrorCode; import com.yahoo.messagebus.Message; import com.yahoo.messagebus.Reply; import com.yahoo.search.result.ErrorMessage; @@ -122,7 +123,7 @@ public final class FeedResponse extends HttpResponse implements SharedSender.Res String str = out.toString(); log.finest(str); - addError(str); + addError(convertErrorCode(err.getCode()), str); } if (abortOnError) { isAborted = true; @@ -149,6 +150,11 @@ public final class FeedResponse extends HttpResponse implements SharedSender.Res errors.add(error); return this; } + public FeedResponse addError(com.yahoo.container.protect.Error code, String error) { + errorMessages.add(new ErrorMessage(code.code, error)); + errors.add(error); + return this; + } public List<String> getErrorList() { return errors; @@ -162,6 +168,19 @@ public final class FeedResponse extends HttpResponse implements SharedSender.Res return errors.anyMatch(e -> e.getCode() != DocumentProtocol.ERROR_TEST_AND_SET_CONDITION_FAILED); } + private static com.yahoo.container.protect.Error convertErrorCode(int error) { + // We should try to enumerate these error a bit finer. + // Like busy, no space etc. + if (error == DocumentProtocol.ERROR_NO_SPACE) { + return com.yahoo.container.protect.Error.INSUFFICIENT_STORAGE; + } else if (error >= ErrorCode.TRANSIENT_ERROR && (error < ErrorCode.FATAL_ERROR)) { + return com.yahoo.container.protect.Error.INTERNAL_SERVER_ERROR; + } if (error >= ErrorCode.FATAL_ERROR && (error < ErrorCode.ERROR_LIMIT)) { + return com.yahoo.container.protect.Error.INTERNAL_SERVER_ERROR; + } + return com.yahoo.container.protect.Error.INTERNAL_SERVER_ERROR; + } + public boolean isSuccess() { return errors.isEmpty(); } diff --git a/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java b/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java index 4b7d913c0f4..8180bfd84ea 100755 --- a/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java +++ b/vespaclient-core/src/main/java/com/yahoo/feedhandler/VespaFeedHandler.java @@ -8,6 +8,7 @@ import com.yahoo.cloud.config.SlobroksConfig; import com.yahoo.container.jdisc.EmptyResponse; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; +import com.yahoo.container.protect.Error; import com.yahoo.document.config.DocumentmanagerConfig; import com.yahoo.feedapi.DocprocMessageProcessor; import com.yahoo.feedapi.FeedContext; @@ -106,7 +107,7 @@ public final class VespaFeedHandler extends VespaFeedHandlerBase { long millis = getTimeoutMillis(request); boolean completed = sender.waitForPending(millis); if (!completed) { - response.addError("Timed out after " + millis + " ms waiting for responses"); + response.addError(Error.TIMEOUT, "Timed out after " + millis + " ms waiting for responses"); } response.done(); return response; |