diff options
author | Jon Bratseth <bratseth@gmail.com> | 2020-07-01 08:47:30 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2020-07-01 08:47:30 +0200 |
commit | 906cbed5b431c8df1325441907c1602241f3f6ef (patch) | |
tree | 111b065933e15081d9e55193fa8bc23e54202594 /container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcSearchInvoker.java | |
parent | 2ef3ab5fa7017e5fea5cdec223bcf98a9edf7550 (diff) |
Formatting changes only#
Diffstat (limited to 'container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcSearchInvoker.java')
-rw-r--r-- | container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcSearchInvoker.java | 49 |
1 files changed, 27 insertions, 22 deletions
diff --git a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcSearchInvoker.java b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcSearchInvoker.java index e1e3389eb5a..6ffc809bc45 100644 --- a/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcSearchInvoker.java +++ b/container-search/src/main/java/com/yahoo/search/dispatch/rpc/RpcSearchInvoker.java @@ -44,42 +44,35 @@ public class RpcSearchInvoker extends SearchInvoker implements Client.ResponseRe this.maxHits = maxHits; } - static class Context { - final Compressor.Compression compressionResult; - final int payloadLength; - Context(RpcResourcePool resourcePool, Query query, byte [] payload) { - this.payloadLength = payload.length; - compressionResult = resourcePool.compress(query, payload); - } - } - @Override - protected Object sendSearchRequest(Query query, Object context_in) { + protected Object sendSearchRequest(Query query, Object incomingContext) { this.query = query; Client.NodeConnection nodeConnection = resourcePool.getConnection(node.key()); if (nodeConnection == null) { responses.add(Client.ResponseOrError.fromError("Could not send search to unknown node " + node.key())); responseAvailable(); - return context_in; + return incomingContext; } query.trace(false, 5, "Sending search request with jrt/protobuf to node with dist key ", node.key()); - Context context; - if (context_in instanceof Context) { - context = (Context) context_in; - } else { - context = new Context(resourcePool, query, - ProtobufSerialization.serializeSearchRequest(query, - Math.min(query.getHits(), maxHits), - searcher.getServerId())); - } + RpcContext context = getContext(incomingContext); double timeoutSeconds = ((double) query.getTimeLeft() - 3.0) / 1000.0; - nodeConnection.request(RPC_METHOD, context.compressionResult.type(), context.payloadLength, - context.compressionResult.data(), this, timeoutSeconds); + nodeConnection.request(RPC_METHOD, context.compressedPayload.type(), context.payloadLength, + context.compressedPayload.data(), this, timeoutSeconds); return context; } + private RpcContext getContext(Object incomingContext) { + if (incomingContext instanceof RpcContext) + return (RpcContext)incomingContext; + + return new RpcContext(resourcePool, query, + ProtobufSerialization.serializeSearchRequest(query, + Math.min(query.getHits(), maxHits), + searcher.getServerId())); + } + @Override protected InvokerResult getSearchResult(Execution execution) throws IOException { long timeLeftMs = query.getTimeLeft(); @@ -124,4 +117,16 @@ public class RpcSearchInvoker extends SearchInvoker implements Client.ResponseRe return searcher.getName(); } + static class RpcContext { + + final Compressor.Compression compressedPayload; + final int payloadLength; + + RpcContext(RpcResourcePool resourcePool, Query query, byte[] payload) { + this.payloadLength = payload.length; + compressedPayload = resourcePool.compress(query, payload); + } + + } + } |