summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJon Bratseth <bratseth@gmail.com>2020-04-15 12:20:52 +0200
committerJon Bratseth <bratseth@gmail.com>2020-04-15 12:20:52 +0200
commitf6b90d5e48dfc894bb7c5299522f5cea0ec0c658 (patch)
tree4b133c3a092b403778d67ce9ebfcef6c6e3e236e
parent1ee3a5aa8d674b1456b684c583a96092be91a344 (diff)
Nonfunctional changes only
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentOperation.java5
-rw-r--r--document/src/main/java/com/yahoo/document/DocumentPut.java3
-rw-r--r--documentapi/src/main/java/com/yahoo/documentapi/DocumentOpVisitorResponse.java2
-rwxr-xr-xdocumentapi/src/main/java/com/yahoo/documentapi/SyncSession.java63
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/FeedClient.java12
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/Result.java43
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/Encoder.java32
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/ClusterConnection.java21
-rw-r--r--vespa-http-client/src/main/java/com/yahoo/vespa/http/client/core/communication/IOThread.java1
9 files changed, 69 insertions, 113 deletions
diff --git a/document/src/main/java/com/yahoo/document/DocumentOperation.java b/document/src/main/java/com/yahoo/document/DocumentOperation.java
index 8209322c472..bb1e5d2b357 100644
--- a/document/src/main/java/com/yahoo/document/DocumentOperation.java
+++ b/document/src/main/java/com/yahoo/document/DocumentOperation.java
@@ -4,10 +4,7 @@ package com.yahoo.document;
/**
* Base class for "document operations".
* These include "put" (DocumentPut), "update" (DocumentUpdate), "remove" (DocumentRemove)
- * and "get" (DocumentGet). The latter only for internal use.
- * Historically, put operations were represented by the Document class alone,
- * but since it doesn't make much sense to put a *test and set* condition in Document,
- * a more uniform interface for document operations was needed.
+ * and "get" (DocumentGet).
*
* @author Vegard Sjonfjell
*/
diff --git a/document/src/main/java/com/yahoo/document/DocumentPut.java b/document/src/main/java/com/yahoo/document/DocumentPut.java
index 5906a9ca0ba..c5ce2e7e181 100644
--- a/document/src/main/java/com/yahoo/document/DocumentPut.java
+++ b/document/src/main/java/com/yahoo/document/DocumentPut.java
@@ -30,7 +30,8 @@ public class DocumentPut extends DocumentOperation {
/**
* Copy constructor
- * @param other DocumentPut to copy
+ *
+ * @param other the DocumentPut to copy
*/
public DocumentPut(DocumentPut other) {
super(other);
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/DocumentOpVisitorResponse.java b/documentapi/src/main/java/com/yahoo/documentapi/DocumentOpVisitorResponse.java
index f5641b915f4..4316003acc6 100644
--- a/documentapi/src/main/java/com/yahoo/documentapi/DocumentOpVisitorResponse.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/DocumentOpVisitorResponse.java
@@ -10,6 +10,7 @@ import com.yahoo.document.DocumentOperation;
* @author Arne H Juul
*/
public class DocumentOpVisitorResponse extends VisitorResponse {
+
private DocumentOperation op;
/**
@@ -25,4 +26,5 @@ public class DocumentOpVisitorResponse extends VisitorResponse {
/** @return the document operation */
public DocumentOperation getDocumentOperation() { return op; }
+
}
diff --git a/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java b/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java
index 6c4306b683c..cc0f6dc7cd5 100755
--- a/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java
+++ b/documentapi/src/main/java/com/yahoo/documentapi/SyncSession.java
@@ -23,15 +23,15 @@ public interface SyncSession extends Session {
* Puts a document. When this method returns, the document is safely
* received. This enables setting condition compared to using Document.
*
- * @param documentPut The DocumentPut operation
+ * @param documentPut the DocumentPut operation
*/
void put(DocumentPut documentPut);
/**
* Puts a document. When this method returns, the document is safely received.
*
- * @param documentPut The DocumentPut operation
- * @param priority The priority with which to perform this operation.
+ * @param documentPut the DocumentPut operation
+ * @param priority the priority with which to perform this operation
*/
default void put(DocumentPut documentPut, DocumentProtocol.Priority priority) {
put(documentPut);
@@ -40,11 +40,9 @@ public interface SyncSession extends Session {
/**
* Gets a document.
*
- * @param id The id of the document to get.
- * @return The known document having this id, or null if there is no
- * document having this id.
- * @throws UnsupportedOperationException Thrown if this access does not
- * support retrieving.
+ * @param id the id of the document to get.
+ * @return the known document having this id, or null if there is no document having this id
+ * @throws UnsupportedOperationException thrown if this access does not support retrieving
*/
default Document get(DocumentId id) { return get(id, null); }
@@ -64,8 +62,8 @@ public interface SyncSession extends Session {
/**
* Gets a document with timeout.
*
- * @param id The id of the document to get
- * @param timeout Timeout. If timeout is null, an unspecified default will be used
+ * @param id the id of the document to get
+ * @param timeout timeout. If timeout is null, an unspecified default will be used
* @return the document with this id, or null if there is none
* @throws UnsupportedOperationException thrown if this access does not support retrieving
* @throws DocumentAccessException on any messagebus error, including timeout ({@link com.yahoo.messagebus.ErrorCode#TIMEOUT}).
@@ -75,53 +73,50 @@ public interface SyncSession extends Session {
/**
* Gets a document with timeout.
*
- * @param id The id of the document to get.
- * @param fieldSet A comma-separated list of fields to retrieve
- * @param priority The priority with which to perform this operation.
- * @param timeout Timeout. If timeout is null, an unspecified default will be used.
- * @return The known document having this id, or null if there is no
- * document having this id.
- * @throws UnsupportedOperationException Thrown if this access does not support retrieving.
- * @throws DocumentAccessException on any messagebus error, including timeout ({@link com.yahoo.messagebus.ErrorCode#TIMEOUT}).
+ * @param id the id of the document to get
+ * @param fieldSet a comma-separated list of fields to retrieve
+ * @param priority the priority with which to perform this operation
+ * @param timeout timeout. If timeout is null, an unspecified default will be used
+ * @return the known document having this id, or null if there is no document having this id
+ * @throws UnsupportedOperationException thrown if this access does not support retrieving
+ * @throws DocumentAccessException on any messagebus error, including timeout ({@link com.yahoo.messagebus.ErrorCode#TIMEOUT})
*/
Document get(DocumentId id, String fieldSet, DocumentProtocol.Priority priority, Duration timeout);
/**
- * <p>Removes a document if it is present and condition is fulfilled.</p>
+ * Removes a document if it is present and condition is fulfilled.
+ *
* @param documentRemove document to delete
- * @return true if the document with this id was removed, false otherwise.
+ * @return true if the document with this id was removed, false otherwise
*/
boolean remove(DocumentRemove documentRemove);
/**
* Removes a document if it is present.
*
- * @param documentRemove Document remove operation
- * @param priority The priority with which to perform this operation.
- * @return true If the document with this id was removed, false otherwise.
- * @throws UnsupportedOperationException Thrown if this access does not
- * support removal.
+ * @param documentRemove document remove operation
+ * @param priority the priority with which to perform this operation
+ * @return true if the document with this id was removed, false otherwise.
+ * @throws UnsupportedOperationException thrown if this access does not support removal
*/
boolean remove(DocumentRemove documentRemove, DocumentProtocol.Priority priority);
/**
* Updates a document.
*
- * @param update The updates to perform.
- * @return True, if the document was found and updated.
- * @throws UnsupportedOperationException Thrown if this access does not
- * support update.
+ * @param update the updates to perform
+ * @return true, if the document was found and updated
+ * @throws UnsupportedOperationException thrown if this access does not support update
*/
boolean update(DocumentUpdate update);
/**
* Updates a document.
*
- * @param update The updates to perform.
- * @param priority The priority with which to perform this operation.
- * @return True, if the document was found and updated.
- * @throws UnsupportedOperationException Thrown if this access does not
- * support update.
+ * @param update the updates to perform.
+ * @param priority the priority with which to perform this operation
+ * @return true, if the document was found and updated
+ * @throws UnsupportedOperationException thrown if this access does not support update
*/
boolean update(DocumentUpdate update, DocumentProtocol.Priority priority);
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;