summaryrefslogtreecommitdiffstats
path: root/container-search/src/main/java/com/yahoo/search/dispatch/Client.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch/Client.java')
-rw-r--r--container-search/src/main/java/com/yahoo/search/dispatch/Client.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/Client.java b/container-search/src/main/java/com/yahoo/search/dispatch/Client.java
index 431b36c2623..be625178d2f 100644
--- a/container-search/src/main/java/com/yahoo/search/dispatch/Client.java
+++ b/container-search/src/main/java/com/yahoo/search/dispatch/Client.java
@@ -18,6 +18,10 @@ interface Client {
int uncompressedLength, byte[] compressedSlime, RpcFillInvoker.GetDocsumsResponseReceiver responseReceiver,
double timeoutSeconds);
+ void search(NodeConnection node, CompressionType compression,
+ int uncompressedLength, byte[] compressedPayload, RpcSearchInvoker responseReceiver,
+ double timeoutSeconds);
+
/** Creates a connection to a particular node in this */
NodeConnection createConnection(String hostname, int port);
@@ -87,4 +91,54 @@ interface Client {
}
+ class SearchResponseOrError {
+ // One of these will be non empty and the other not
+ private Optional<SearchResponse> response;
+ private Optional<String> error;
+
+ public static SearchResponseOrError fromResponse(SearchResponse response) {
+ return new SearchResponseOrError(Optional.of(response), Optional.empty());
+ }
+
+ public static SearchResponseOrError fromError(String error) {
+ return new SearchResponseOrError(Optional.empty(), Optional.of(error));
+ }
+
+ private SearchResponseOrError(Optional<SearchResponse> response, Optional<String> error) {
+ this.response = response;
+ this.error = error;
+ }
+
+ /** Returns the response, or empty if there is an error */
+ public Optional<SearchResponse> response() { return response; }
+
+ /** Returns the error or empty if there is a response */
+ public Optional<String> error() { return error; }
+
+ }
+
+ class SearchResponse {
+ private final byte compression;
+ private final int uncompressedSize;
+ private final byte[] compressedPayload;
+
+ public SearchResponse(byte compression, int uncompressedSize, byte[] compressedPayload) {
+ this.compression = compression;
+ this.uncompressedSize = uncompressedSize;
+ this.compressedPayload = compressedPayload;
+ }
+
+ public byte compression() {
+ return compression;
+ }
+
+ public int uncompressedSize() {
+ return uncompressedSize;
+ }
+
+ public byte[] compressedPayload() {
+ return compressedPayload;
+ }
+ }
+
}