blob: b1fe4d3cac2f5b28ca1b458a08c4ed3aabab7d0f (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.documentapi.metrics;
import com.yahoo.document.restapi.OperationHandlerImpl;
import java.util.Set;
/**
* Enum with possible outcomes of a single document feeding operation:
* <ul>
* <li>OK: Document was successfully added/updated/removed</li>
* <li>REQUEST_ERROR: User-made error, for example invalid document format</li>
* <li>SERVER_ERROR: Server-made error, for example insufficient disk space</li>
* </ul>
*
* @author freva
*/
public enum DocumentOperationStatus {
OK, REQUEST_ERROR, SERVER_ERROR;
public static DocumentOperationStatus fromHttpStatusCode(int httpStatus) {
switch (httpStatus / 100) {
case 2: return OK;
case 4: return REQUEST_ERROR;
case 5: return SERVER_ERROR;
default: return null;
}
}
public static DocumentOperationStatus fromMessageBusErrorCodes(Set<Integer> errorCodes) {
return fromHttpStatusCode(OperationHandlerImpl.getHTTPStatusCode(errorCodes));
}
}
|