diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-04-15 12:20:52 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-04-15 12:20:52 +0200 |
commit | f6b90d5e48dfc894bb7c5299522f5cea0ec0c658 (patch) | |
tree | 4b133c3a092b403778d67ce9ebfcef6c6e3e236e /vespa-http-client | |
parent | 1ee3a5aa8d674b1456b684c583a96092be91a344 (diff) |
Nonfunctional changes only
Diffstat (limited to 'vespa-http-client')
5 files changed, 35 insertions, 74 deletions
diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/FeedClient.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/FeedClient.java index 8e820a89eb1..8cd22fe2e5c 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/FeedClient.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/FeedClient.java @@ -30,7 +30,7 @@ public interface FeedClient extends AutoCloseable { * produced faster than the can be handled. Transient failured are retried internally by this client. * Exactly one callback will always be received for each (completed) call to this. * - * @param documentId the document id of the document. + * @param documentId the document id of the document * @param documentData the document data as JSON or XML (as specified when using the factory to create the API) */ default void stream(String documentId, CharSequence documentData) { @@ -43,7 +43,7 @@ public interface FeedClient extends AutoCloseable { * produced faster than the can be handled. Transient failured are retried internally by this client. * Exactly one callback will always be received for each (completed) call to this. * - * @param documentId the document id of the document. + * @param documentId the document id of the document * @param documentData the document data as JSON or XML (as specified when using the factory to create the API) * @param context a context object which will be accessible in the result of the callback, or null if none */ @@ -57,7 +57,7 @@ public interface FeedClient extends AutoCloseable { * produced faster than the can be handled. Transient failured are retried internally by this client. * Exactly one callback will always be received for each (completed) call to this. * - * @param documentId the document id of the document. + * @param documentId the document id of the document * @param operationId the id to use for this operation, or null to let the client decide an operation id. * This id must be unique for every operation. Passing the operation id allows clients * to prepare to receive a response for it before issuing the operation to the client. @@ -74,9 +74,9 @@ public interface FeedClient extends AutoCloseable { void close(); /** - * Returns stats about the cluster. + * Returns stats about the cluster * - * @return JSON string with information about cluster. + * @return JSON string with information about cluster */ String getStatsAsJson(); @@ -132,7 +132,7 @@ public interface FeedClient extends AutoCloseable { * Document specific errors will be reported back through {@link #onCompletion(String, Result)}. * * @see FeedEndpointException - * @param exception An exception specifying endpoint and cause. See {@link FeedEndpointException} for details. + * @param exception an exception specifying endpoint and cause. See {@link FeedEndpointException} for details. */ default void onEndpointException(FeedEndpointException exception) {} diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java index d4f3732fcd7..e0929e445a6 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java @@ -34,11 +34,7 @@ public class Result { public Result(Document document, Collection<Detail> values, StringBuilder localTrace) { this.document = document; this.details = Collections.unmodifiableList(new ArrayList<>(values)); - boolean totalSuccess = true; - for (Detail d : details) { - if (d.getResultType() != ResultType.OPERATION_EXECUTED) {totalSuccess = false; } - } - this.success = totalSuccess; + this.success = details.stream().allMatch(d -> d.getResultType() == ResultType.OPERATION_EXECUTED); this.localTrace = localTrace == null ? null : localTrace.toString(); } @@ -70,18 +66,12 @@ public class Result { public List<Detail> getDetails() { return details; } - /** - * Checks if operation has been set up with local tracing. - * - * @return true if operation has local trace. - */ + /** Returns whether the operation has been set up with local tracing */ public boolean hasLocalTrace() { return localTrace != null; } - /** - * Information in a Result for a single operation sent to a single endpoint. - */ + /** Information in a Result for a single operation sent to a single endpoint. */ public static final class Detail { private final ResultType resultType; @@ -104,44 +94,27 @@ public class Result { this.traceMessage = null; } - /** - * Returns the endpoint from which the result was received. - * - * @return the endpoint from which the result was received. - */ + /** Returns the endpoint from which the result was received. */ public Endpoint getEndpoint() { return endpoint; } - /** - * Check if operation was successful. - * - * @return true if the operation was successful. - */ + /** Returns whether the operation was successful */ public boolean isSuccess() { return resultType == ResultType.OPERATION_EXECUTED; } - /** - * Returns the result of the operation. - */ + /** Returns the result of the operation */ public ResultType getResultType() { return resultType; } - /** - * Returns any exception related to this Detail, if unsuccessful. Might be null. - * - * @return any exception related to this Detail, if unsuccessful. Might be null. - */ + /** Returns any exception related to this Detail, if unsuccessful. Might be null. */ public Exception getException() { return exception; } - /** - * Returns trace message if any from gateway. - * @return null or trace message. - */ + /** Returns any trace message produces, or null if none */ public String getTraceMessage() { return traceMessage; } diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Encoder.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Encoder.java index 135b2021a16..7bb65827b51 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Encoder.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Encoder.java @@ -15,10 +15,8 @@ public final class Encoder { /** * ISO 646.irv:1991 safe quoting into a StringBuilder instance. * - * @param input - * the string to encode - * @param output - * the destination buffer + * @param input the string to encode + * @param output the destination buffer * @return the destination buffer given as input */ public static StringBuilder encode(String input, StringBuilder output) { @@ -47,28 +45,20 @@ public final class Encoder { /** * ISO 646.irv:1991 safe unquoting into a StringBuilder instance. * - * @param input - * the string to decode - * @param output - * the destination buffer + * @param input the string to decode + * @param output the destination buffer * @return the destination buffer given as input - * @throws IllegalArgumentException - * if the input string contains unexpected or invalid data + * @throws IllegalArgumentException if the input string contains unexpected or invalid data */ public static StringBuilder decode(String input, StringBuilder output) { for (int i = 0; i < input.length(); i = input.offsetByCodePoints(i, 1)) { int c = input.codePointAt(i); - if (c > '~') { - throw new IllegalArgumentException("Input contained character above printable ASCII."); - } - switch (c) { - case '{': - i = decode(input, i, output); - break; - default: - output.append((char) c); - break; - } + if (c > '~') + throw new IllegalArgumentException("Input contained character above printable ASCII at position " + i); + if (c == '{') + i = decode(input, i, output); + else + output.append((char) c); } return output; } diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ClusterConnection.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ClusterConnection.java index 6e1f3419e8e..67f84231606 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ClusterConnection.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ClusterConnection.java @@ -26,8 +26,8 @@ public class ClusterConnection implements AutoCloseable { private final List<IOThread> ioThreads = new ArrayList<>(); private final int clusterId; - private static JsonFactory jsonFactory = new JsonFactory(); - private static ObjectMapper objectMapper = new ObjectMapper(); + private static final JsonFactory jsonFactory = new JsonFactory(); + private static final ObjectMapper objectMapper = new ObjectMapper(); public ClusterConnection(OperationProcessor operationProcessor, FeedParams feedParams, @@ -58,13 +58,12 @@ public class ClusterConnection implements AutoCloseable { if (connectionParams.isDryRun()) { gatewayConnection = new DryRunGatewayConnection(endpoint); } else { - gatewayConnection = new ApacheGatewayConnection( - endpoint, - feedParams, - cluster.getRoute(), - connectionParams, - new ApacheGatewayConnection.HttpClientFactory(connectionParams, endpoint.isUseSsl()), - operationProcessor.getClientId() + gatewayConnection = new ApacheGatewayConnection(endpoint, + feedParams, + cluster.getRoute(), + connectionParams, + new ApacheGatewayConnection.HttpClientFactory(connectionParams, endpoint.isUseSsl()), + operationProcessor.getClientId() ); } if (documentQueue == null) { @@ -89,10 +88,9 @@ public class ClusterConnection implements AutoCloseable { } public void post(Document document) throws EndpointIOException { - String documentIdStr = document.getDocumentId(); // The same document ID must always go to the same destination // In noHandshakeMode this has no effect as the documentQueue is shared between the IOThreads. - int hash = documentIdStr.hashCode() & 0x7FFFFFFF; // Strip sign bit + int hash = document.getDocumentId().hashCode() & 0x7FFFFFFF; // Strip sign bit IOThread ioThread = ioThreads.get(hash % ioThreads.size()); try { ioThread.post(document); @@ -165,4 +163,5 @@ public class ClusterConnection implements AutoCloseable { public int hashCode() { return clusterId; } + } diff --git a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java index 77ed8464284..5f3348557a9 100644 --- a/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java +++ b/vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java @@ -174,7 +174,6 @@ class IOThread implements Runnable, AutoCloseable { return "I/O thread (for " + endpoint + ")"; } - List<Document> getNextDocsForFeeding(long maxWaitUnits, TimeUnit timeUnit) { List<Document> docsForSendChunk = new ArrayList<>(); int chunkSizeBytes = 0; |