From 069828f0e60a057718c4a62afb543d7abe436502 Mon Sep 17 00:00:00 2001 From: Vacha Shah Date: Sat, 18 Nov 2023 01:00:14 +0000 Subject: [PATCH] Cleaning up sysouts, comments and writing TODOs Signed-off-by: Vacha Shah --- .../search/AbstractSearchAsyncAction.java | 5 - .../action/search/ExpandSearchPhase.java | 2 - .../ProtobufAbstractSearchAsyncAction.java | 5 - ...otobufSearchQueryThenFetchAsyncAction.java | 1 - .../search/ProtobufTransportSearchAction.java | 8 -- .../action/search/TransportSearchAction.java | 8 -- .../support/ProtobufTransportAction.java | 1 - .../action/support/TransportAction.java | 3 - .../opensearch/client/node/NodeClient.java | 2 - .../client/support/AbstractClient.java | 1 - .../opensearch/index/query/Rewriteable.java | 4 +- .../ProtobufRestCancellableNodeClient.java | 4 - .../action/RestCancellableNodeClient.java | 4 - .../search/ProtobufRestSearchAction.java | 3 - .../rest/action/search/RestSearchAction.java | 3 - .../org/opensearch/search/SearchService.java | 10 -- .../search/fetch/FetchSearchResult.java | 2 +- .../search/fetch/QueryFetchSearchResult.java | 3 - .../internal/ProtobufShardSearchRequest.java | 95 +------------------ .../search/internal/ShardSearchRequest.java | 5 - .../search/query/QuerySearchResult.java | 3 +- .../tasks/ProtobufTaskAwareRequest.java | 6 -- .../opensearch/tasks/TaskAwareRequest.java | 8 -- .../org/opensearch/tasks/TaskManager.java | 12 +-- .../opensearch/transport/InboundHandler.java | 4 - .../opensearch/transport/OutboundHandler.java | 29 ------ 26 files changed, 9 insertions(+), 222 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java index ebd7c16639add..5ed202f557998 100644 --- a/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/AbstractSearchAsyncAction.java @@ -194,9 +194,7 @@ long buildTookInMillis() { * This is the main entry point for a search. This method starts the search execution of the initial phase. */ public final void start() { - System.out.println("AbstractSearchAsyncAction start"); if (getNumShards() == 0) { - System.out.println("Number of shards is 0"); // no search shards to search on, bail with empty response // (it happens with search across _all with no indices around and consistent with broadcast operations) int trackTotalHitsUpTo = request.source() == null ? SearchContext.DEFAULT_TRACK_TOTAL_HITS_UP_TO @@ -224,7 +222,6 @@ public final void start() { @Override public final void run() { - System.out.println("AbstractSearchAsyncAction run: running the phase coming from phase.recordAndRun()"); for (final SearchShardIterator iterator : toSkipShardsIts) { assert iterator.skip(); skipShard(iterator); @@ -428,8 +425,6 @@ public final void executeNextPhase(SearchPhase currentPhase, SearchPhase nextPha } private void executePhase(SearchPhase phase) { - System.out.println("Execute Phase"); - System.out.println("Phase: " + phase); try { phase.run(); } catch (Exception e) { diff --git a/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java b/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java index 4468c0e97bdf6..618a5620ce093 100644 --- a/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java +++ b/server/src/main/java/org/opensearch/action/search/ExpandSearchPhase.java @@ -80,8 +80,6 @@ private boolean isCollapseRequest() { @Override public void run() { - System.out.println("ExpandSearchPhase run"); - System.out.println("Is collapse request: " + isCollapseRequest()); if (isCollapseRequest() && searchResponse.hits().getHits().length > 0) { SearchRequest searchRequest = context.getRequest(); CollapseBuilder collapseBuilder = searchRequest.source().collapse(); diff --git a/server/src/main/java/org/opensearch/action/search/ProtobufAbstractSearchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/ProtobufAbstractSearchAsyncAction.java index 0e05bbf58375f..d86e2957e3b18 100644 --- a/server/src/main/java/org/opensearch/action/search/ProtobufAbstractSearchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/ProtobufAbstractSearchAsyncAction.java @@ -170,9 +170,7 @@ long buildTookInMillis() { * This is the main entry point for a search. This method starts the search execution of the initial phase. */ public final void start() { - System.out.println("ProtobufAbstractSearchAsyncAction start"); if (getNumShards() == 0) { - System.out.println("Number of shards is 0"); // no search shards to search on, bail with empty response // (it happens with search across _all with no indices around and consistent with broadcast operations) int trackTotalHitsUpTo = request.source() == null ? SearchContext.DEFAULT_TRACK_TOTAL_HITS_UP_TO @@ -200,7 +198,6 @@ public final void start() { @Override public final void run() { - System.out.println("ProtobufAbstractSearchAsyncAction run: running the phase coming from phase.recordAndRun()"); for (final SearchShardIterator iterator : toSkipShardsIts) { assert iterator.skip(); skipShard(iterator); @@ -404,8 +401,6 @@ public final void executeNextPhase(SearchPhase currentPhase, SearchPhase nextPha } private void executePhase(SearchPhase phase) { - System.out.println("Execute Phase"); - System.out.println("Phase: " + phase); try { phase.run(); } catch (Exception e) { diff --git a/server/src/main/java/org/opensearch/action/search/ProtobufSearchQueryThenFetchAsyncAction.java b/server/src/main/java/org/opensearch/action/search/ProtobufSearchQueryThenFetchAsyncAction.java index 01147f8724f57..a109172e6b5e2 100644 --- a/server/src/main/java/org/opensearch/action/search/ProtobufSearchQueryThenFetchAsyncAction.java +++ b/server/src/main/java/org/opensearch/action/search/ProtobufSearchQueryThenFetchAsyncAction.java @@ -153,7 +153,6 @@ private ProtobufShardSearchRequest rewriteShardSearchRequest(ProtobufShardSearch // set the current best bottom field doc if (bottomSortCollector.getBottomSortValues() != null) { // request.setBottomSortValues(bottomSortCollector.getBottomSortValues()); - System.out.println("Bottom sort values is not null......now what????"); } return request; } diff --git a/server/src/main/java/org/opensearch/action/search/ProtobufTransportSearchAction.java b/server/src/main/java/org/opensearch/action/search/ProtobufTransportSearchAction.java index d33cebb1969d6..89e1287aff424 100644 --- a/server/src/main/java/org/opensearch/action/search/ProtobufTransportSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/ProtobufTransportSearchAction.java @@ -250,7 +250,6 @@ long buildTookInMillis() { @Override protected void doExecute(ProtobufTask task, ProtobufSearchRequest searchRequest, ActionListener listener) { - System.out.println("ProtobufTransportSearchAction doExecute"); // only if task is of type ProtobufCancellableTask and support cancellation on timeout, treat this request eligible for timeout based // cancellation. There may be other top level requests like AsyncSearch which is using ProtobufSearchRequest internally and has it's own // cancellation mechanism. For such cases, the ProtobufSearchRequest when created can override the createTask and set the @@ -361,7 +360,6 @@ private void executeRequest( SearchAsyncActionProvider searchAsyncActionProvider, ActionListener originalListener ) { - System.out.println("TrasportSearchAction executeRequest"); final long relativeStartNanos = System.nanoTime(); final SearchTimeProvider timeProvider = new SearchTimeProvider( originalSearchRequest.getOrCreateAbsoluteStartMillis(), @@ -762,8 +760,6 @@ private void executeLocalSearch( SearchContextId searchContext, SearchAsyncActionProvider searchAsyncActionProvider ) { - System.out.println("Task is: " + task.getClass().getName()); - System.out.println("Task is: " + task); executeSearch( (ProtobufSearchTask) task, timeProvider, @@ -896,7 +892,6 @@ private void executeSearch( @Nullable SearchContextId searchContext, SearchAsyncActionProvider searchAsyncActionProvider ) { - System.out.println("ProtobufTransportSearchAction executeSearch"); clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.READ); // TODO: I think startTime() should become part of ActionRequest and that should be used both for index name @@ -986,9 +981,6 @@ private void executeSearch( concreteLocalIndices, localShardIterators.size() + remoteShardIterators.size() ); - System.out.println("Going to ProtobufAbstractSearchAsyncAction"); - System.out.println("Search request: " + searchRequest); - System.out.println("Cluster state: " + clusterState); searchAsyncActionProvider.asyncSearchAction( task, searchRequest, diff --git a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java index 07cdc0a158511..4b7268856d826 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java @@ -276,7 +276,6 @@ long buildTookInMillis() { @Override protected void doExecute(Task task, SearchRequest searchRequest, ActionListener listener) { - System.out.println("TransportSearchAction doExecute"); // only if task is of type CancellableTask and support cancellation on timeout, treat this request eligible for timeout based // cancellation. There may be other top level requests like AsyncSearch which is using SearchRequest internally and has it's own // cancellation mechanism. For such cases, the SearchRequest when created can override the createTask and set the @@ -387,7 +386,6 @@ private void executeRequest( SearchAsyncActionProvider searchAsyncActionProvider, ActionListener originalListener ) { - System.out.println("TrasportSearchAction executeRequest"); final long relativeStartNanos = System.nanoTime(); final SearchTimeProvider timeProvider = new SearchTimeProvider( originalSearchRequest.getOrCreateAbsoluteStartMillis(), @@ -788,8 +786,6 @@ private void executeLocalSearch( SearchContextId searchContext, SearchAsyncActionProvider searchAsyncActionProvider ) { - System.out.println("Task is: " + task.getClass().getName()); - System.out.println("Task is: " + task); executeSearch( (SearchTask) task, timeProvider, @@ -922,7 +918,6 @@ private void executeSearch( @Nullable SearchContextId searchContext, SearchAsyncActionProvider searchAsyncActionProvider ) { - System.out.println("TransportSearchAction executeSearch"); clusterState.blocks().globalBlockedRaiseException(ClusterBlockLevel.READ); // TODO: I think startTime() should become part of ActionRequest and that should be used both for index name @@ -1012,9 +1007,6 @@ private void executeSearch( concreteLocalIndices, localShardIterators.size() + remoteShardIterators.size() ); - System.out.println("Going to AbstractSearchAsyncAction"); - System.out.println("Search request: " + searchRequest); - System.out.println("Cluster state: " + clusterState); searchAsyncActionProvider.asyncSearchAction( task, searchRequest, diff --git a/server/src/main/java/org/opensearch/action/support/ProtobufTransportAction.java b/server/src/main/java/org/opensearch/action/support/ProtobufTransportAction.java index 45ea84321d113..d0156218dc381 100644 --- a/server/src/main/java/org/opensearch/action/support/ProtobufTransportAction.java +++ b/server/src/main/java/org/opensearch/action/support/ProtobufTransportAction.java @@ -72,7 +72,6 @@ public final ProtobufTask execute(Request request, ActionListener list try { task = taskManager.registerProtobuf("transport", actionName, request); - System.out.println("Protobuf task registered from execute is " + task); } catch (TaskCancelledException e) { unregisterChildNode.close(); throw e; diff --git a/server/src/main/java/org/opensearch/action/support/TransportAction.java b/server/src/main/java/org/opensearch/action/support/TransportAction.java index 21652555b3b7a..e2f5ecda101b8 100644 --- a/server/src/main/java/org/opensearch/action/support/TransportAction.java +++ b/server/src/main/java/org/opensearch/action/support/TransportAction.java @@ -95,10 +95,8 @@ public final Task execute(Request request, ActionListener listener) { final Releasable unregisterChildNode = registerChildNode(request.getParentTask()); final Task task; - System.out.println("TransportAction execute"); try { task = taskManager.register("transport", actionName, request); - System.out.println("Task registered from execute is " + task); } catch (TaskCancelledException e) { unregisterChildNode.close(); throw e; @@ -212,7 +210,6 @@ private RequestFilterChain(TransportAction action, Logger log @Override public void proceed(Task task, String actionName, Request request, ActionListener listener) { - System.out.println("RequestFilterChain proceed"); int i = index.getAndIncrement(); try { if (i < this.action.filters.length) { diff --git a/server/src/main/java/org/opensearch/client/node/NodeClient.java b/server/src/main/java/org/opensearch/client/node/NodeClient.java index 18dd65d5d86a0..60551ade09416 100644 --- a/server/src/main/java/org/opensearch/client/node/NodeClient.java +++ b/server/src/main/java/org/opensearch/client/node/NodeClient.java @@ -107,7 +107,6 @@ public Task exe Request request, ActionListener listener ) { - System.out.println("NodeClient executeLocally"); return transportAction(action).execute(request, listener); } @@ -145,7 +144,6 @@ private Transpo if (transportAction == null) { throw new IllegalStateException("failed to find action [" + action + "] to execute"); } - System.out.println("Getting transport action: " + transportAction); return transportAction; } diff --git a/server/src/main/java/org/opensearch/client/support/AbstractClient.java b/server/src/main/java/org/opensearch/client/support/AbstractClient.java index 49528f16219aa..40489e29ed9b5 100644 --- a/server/src/main/java/org/opensearch/client/support/AbstractClient.java +++ b/server/src/main/java/org/opensearch/client/support/AbstractClient.java @@ -473,7 +473,6 @@ public final vo Request request, ActionListener listener ) { - System.out.println("Abstract client execute"); doExecute(action, request, listener); } diff --git a/server/src/main/java/org/opensearch/index/query/Rewriteable.java b/server/src/main/java/org/opensearch/index/query/Rewriteable.java index 66278f085eeb8..0a00c49e5ebb5 100644 --- a/server/src/main/java/org/opensearch/index/query/Rewriteable.java +++ b/server/src/main/java/org/opensearch/index/query/Rewriteable.java @@ -112,11 +112,9 @@ static > void rewriteAndFetch( ActionListener rewriteResponse, int iteration ) { - System.out.println("In rewriteAndFetch"); - System.out.println("Original: " + original.getClass()); - System.out.println("Context: " + context.getClass()); T builder = original; try { + // TODO: add this logic back once it works for proto messages // for (T rewrittenBuilder = builder.rewrite(context); rewrittenBuilder != builder; rewrittenBuilder = builder.rewrite(context)) { // builder = rewrittenBuilder; // if (iteration++ >= MAX_REWRITE_ROUNDS) { diff --git a/server/src/main/java/org/opensearch/rest/action/ProtobufRestCancellableNodeClient.java b/server/src/main/java/org/opensearch/rest/action/ProtobufRestCancellableNodeClient.java index bbbb86ed1499d..fdb1c868bead1 100644 --- a/server/src/main/java/org/opensearch/rest/action/ProtobufRestCancellableNodeClient.java +++ b/server/src/main/java/org/opensearch/rest/action/ProtobufRestCancellableNodeClient.java @@ -78,10 +78,6 @@ public listener ) { - System.out.println("RestCancellableNodeClient execute"); - System.out.println("Action: " + action); - System.out.println("Request: " + request); - System.out.println("Listener: " + listener); CloseListener closeListener = httpChannels.computeIfAbsent(httpChannel, channel -> new CloseListener()); TaskHolder taskHolder = new TaskHolder(); ProtobufTask task = client.executeLocally(action, request, new ActionListener() { diff --git a/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java b/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java index 14da0aa91c22a..ad84b6db0ed3e 100644 --- a/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java +++ b/server/src/main/java/org/opensearch/rest/action/RestCancellableNodeClient.java @@ -101,10 +101,6 @@ public void doE Request request, ActionListener listener ) { - System.out.println("RestCancellableNodeClient execute"); - System.out.println("Action: " + action); - System.out.println("Request: " + request); - System.out.println("Listener: " + listener); CloseListener closeListener = httpChannels.computeIfAbsent(httpChannel, channel -> new CloseListener()); TaskHolder taskHolder = new TaskHolder(); Task task = client.executeLocally(action, request, new ActionListener() { diff --git a/server/src/main/java/org/opensearch/rest/action/search/ProtobufRestSearchAction.java b/server/src/main/java/org/opensearch/rest/action/search/ProtobufRestSearchAction.java index 5db97a57dbc3f..7cf867ef69b61 100644 --- a/server/src/main/java/org/opensearch/rest/action/search/ProtobufRestSearchAction.java +++ b/server/src/main/java/org/opensearch/rest/action/search/ProtobufRestSearchAction.java @@ -90,7 +90,6 @@ public List routes() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final ProtobufNodeClient client) throws IOException { - System.out.println("In protobuf search API"); ProtobufSearchRequest searchRequest = new ProtobufSearchRequest(); /* * We have to pull out the call to `source().size(size)` because @@ -111,7 +110,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final Proto return channel -> { ProtobufRestCancellableNodeClient cancelClient = new ProtobufRestCancellableNodeClient(client, request.getHttpChannel()); - System.out.println("Cancel client execute"); cancelClient.execute(ProtobufSearchAction.INSTANCE, searchRequest, new RestStatusToXContentListener<>(channel)); }; } @@ -193,7 +191,6 @@ public static void parseSearchRequest( } searchRequest.setCancelAfterTimeInterval(request.paramAsTime("cancel_after_time_interval", null)); - System.out.println("Search request is: " + searchRequest.toString()); } /** diff --git a/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java b/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java index ba9497e41d8ff..744bdcb3a3acc 100644 --- a/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java +++ b/server/src/main/java/org/opensearch/rest/action/search/RestSearchAction.java @@ -112,7 +112,6 @@ public List routes() { @Override public RestChannelConsumer prepareRequest(final RestRequest request, final NodeClient client) throws IOException { - System.out.println("In search API"); SearchRequest searchRequest = new SearchRequest(); /* * We have to pull out the call to `source().size(size)` because @@ -133,7 +132,6 @@ public RestChannelConsumer prepareRequest(final RestRequest request, final NodeC return channel -> { RestCancellableNodeClient cancelClient = new RestCancellableNodeClient(client, request.getHttpChannel()); - System.out.println("Cancel client execute"); cancelClient.execute(SearchAction.INSTANCE, searchRequest, new RestStatusToXContentListener<>(channel)); }; } @@ -215,7 +213,6 @@ public static void parseSearchRequest( } searchRequest.setCancelAfterTimeInterval(request.paramAsTime("cancel_after_time_interval", null)); - System.out.println("Search request is: " + searchRequest.toString()); } /** diff --git a/server/src/main/java/org/opensearch/search/SearchService.java b/server/src/main/java/org/opensearch/search/SearchService.java index aec0c0bac11ae..b2182ba87789f 100644 --- a/server/src/main/java/org/opensearch/search/SearchService.java +++ b/server/src/main/java/org/opensearch/search/SearchService.java @@ -624,7 +624,6 @@ public void onFailure(Exception exc) { } private IndexShard getShard(ShardSearchRequest request) { - System.out.println("getShard"); if (request.readerId() != null) { return findReaderContext(request.readerId(), request).indexShard(); } else { @@ -633,7 +632,6 @@ private IndexShard getShard(ShardSearchRequest request) { } private IndexShard getShardProtobuf(ProtobufShardSearchRequest request) { - System.out.println("getShardProtobuf"); if (request.readerId() != null) { return findReaderContext(request.readerId(), request).indexShard(); } else { @@ -953,8 +951,6 @@ public void executeFetchPhaseProtobuf(ProtobufShardFetchRequest request, Protobu } private ReaderContext getReaderContext(ShardSearchContextId id) { - System.out.println("getReaderContext"); - System.out.println(id.getSessionId()); if (sessionId.equals(id.getSessionId()) == false && id.getSessionId().isEmpty() == false) { throw new SearchContextMissingException(id); } @@ -962,8 +958,6 @@ private ReaderContext getReaderContext(ShardSearchContextId id) { } private ReaderContext findReaderContext(ShardSearchContextId id, TransportRequest request) throws SearchContextMissingException { - System.out.println("findReaderContext"); - System.out.println(id); final ReaderContext reader = getReaderContext(id); if (reader == null) { throw new SearchContextMissingException(id); @@ -2009,8 +2003,6 @@ public static boolean canRewriteToMatchNone(SearchSourceBuilder source) { } private void rewriteAndFetchShardRequest(IndexShard shard, ShardSearchRequest request, ActionListener listener) { - System.out.println("SearchService rewriteAndFetchShardRequest"); - System.out.println("ShardSearchRequest: " + request); ActionListener actionListener = ActionListener.wrap(r -> { if (request.readerId() != null) { listener.onResponse(request); @@ -2026,8 +2018,6 @@ private void rewriteAndFetchShardRequest(IndexShard shard, ShardSearchRequest re } private void rewriteAndFetchShardRequestProtobuf(IndexShard shard, ProtobufShardSearchRequest request, ActionListener listener) { - System.out.println("SearchService rewriteAndFetchShardRequestProtobuf"); - System.out.println("ProtobufShardSearchRequest: " + request); ActionListener actionListener = ActionListener.wrap(r -> { if (request.readerId() != null) { listener.onResponse(request); diff --git a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java index 498170e759b72..8e67622e032f6 100644 --- a/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/FetchSearchResult.java @@ -55,7 +55,7 @@ */ public final class FetchSearchResult extends SearchPhaseResult { - // TODO: proto message + // TODO: Write SearchHits as a proto message private SearchHits hits; // client side counter private transient int counter; diff --git a/server/src/main/java/org/opensearch/search/fetch/QueryFetchSearchResult.java b/server/src/main/java/org/opensearch/search/fetch/QueryFetchSearchResult.java index ded344eba4cf6..89e6e75df8963 100644 --- a/server/src/main/java/org/opensearch/search/fetch/QueryFetchSearchResult.java +++ b/server/src/main/java/org/opensearch/search/fetch/QueryFetchSearchResult.java @@ -50,7 +50,6 @@ */ public final class QueryFetchSearchResult extends SearchPhaseResult { - // TODO: proto message private final QuerySearchResult queryResult; private final FetchSearchResult fetchResult; @@ -72,8 +71,6 @@ public QueryFetchSearchResult(byte[] in) throws IOException { public QueryFetchSearchResult(QuerySearchResult queryResult, FetchSearchResult fetchResult) { this.queryResult = queryResult; this.fetchResult = fetchResult; - System.out.println("QueryResult: " + queryResult); - System.out.println("FetchResult: " + fetchResult); if (queryResult.response() != null && fetchResult.response() != null) { this.queryFetchSearchResult = QueryFetchSearchResultProto.QueryFetchSearchResult.newBuilder() .setQueryResult(queryResult.response()) diff --git a/server/src/main/java/org/opensearch/search/internal/ProtobufShardSearchRequest.java b/server/src/main/java/org/opensearch/search/internal/ProtobufShardSearchRequest.java index 29f9b64364091..4aa2ee813f5e6 100644 --- a/server/src/main/java/org/opensearch/search/internal/ProtobufShardSearchRequest.java +++ b/server/src/main/java/org/opensearch/search/internal/ProtobufShardSearchRequest.java @@ -71,29 +71,6 @@ public class ProtobufShardSearchRequest extends TransportRequest implements Indi public static final ToXContent.Params FORMAT_PARAMS = new ToXContent.MapParams(Collections.singletonMap("pretty", "false")); private ShardSearchRequestProto.ShardSearchRequest shardSearchRequestProto; - // private final String clusterAlias; - // private final ShardId shardId; - // private final int numberOfShards; - // private final SearchType searchType; - // private final Scroll scroll; - // private final float indexBoost; - // private final Boolean requestCache; - // private final long nowInMillis; - // private long inboundNetworkTime; - // private long outboundNetworkTime; - // private final boolean allowPartialSearchResults; - // private final String[] indexRoutings; - // private final String preference; - // private final OriginalIndices originalIndices; - - // private boolean canReturnNullResponseIfMatchNoDocs; - // private SearchSortValuesAndFormats bottomSortValues; - - // these are the only mutable fields, as they are subject to rewriting - // private AliasFilter aliasFilter; - // private SearchSourceBuilder source; - // private final ShardSearchContextId readerId; - // private final TimeValue keepAlive; public ProtobufShardSearchRequest( OriginalIndices originalIndices, @@ -195,27 +172,7 @@ private ProtobufShardSearchRequest( @Nullable String clusterAlias, ShardSearchContextId readerId, TimeValue keepAlive - ) { - // this.shardId = shardId; - // this.numberOfShards = numberOfShards; - // this.searchType = searchType; - // this.source = source; - // this.requestCache = requestCache; - // this.aliasFilter = aliasFilter; - // this.indexBoost = indexBoost; - // this.allowPartialSearchResults = allowPartialSearchResults; - // this.indexRoutings = indexRoutings; - // this.preference = preference; - // this.scroll = scroll; - // this.nowInMillis = nowInMillis; - // this.inboundNetworkTime = 0; - // this.outboundNetworkTime = 0; - // this.clusterAlias = clusterAlias; - // this.originalIndices = originalIndices; - // this.readerId = readerId; - // this.keepAlive = keepAlive; - // assert keepAlive == null || readerId != null : "readerId: " + readerId + " keepAlive: " + keepAlive; - + ) { ShardSearchRequestProto.OriginalIndices originalIndicesProto = ShardSearchRequestProto.OriginalIndices.newBuilder() .addAllIndices(Arrays.stream(originalIndices.indices()).collect(Collectors.toList())) .setIndicesOptions(ShardSearchRequestProto.OriginalIndices.IndicesOptions.newBuilder() @@ -238,7 +195,6 @@ private ProtobufShardSearchRequest( .build(); ShardSearchRequestProto.ShardSearchContextId.Builder shardSearchContextId = ShardSearchRequestProto.ShardSearchContextId.newBuilder(); - System.out.println("Reader id: " + readerId); if (readerId != null) { shardSearchContextId.setSessionId(readerId.getSessionId()); shardSearchContextId.setId(readerId.getId()); @@ -249,6 +205,7 @@ private ProtobufShardSearchRequest( builder.setShardId(shardIdProto); builder.setNumberOfShards(numberOfShards); builder.setSearchType(ShardSearchRequestProto.ShardSearchRequest.SearchType.QUERY_THEN_FETCH); + // TODO: Write SearchSourceBuilder as a proto message builder.setSource(ByteString.copyFrom(convertToBytes(source))); builder.setInboundNetworkTime(0); builder.setOutboundNetworkTime(0); @@ -258,6 +215,7 @@ private ProtobufShardSearchRequest( } if (aliasFilter != null) { + // TODO: Write AliasFilter as a proto message builder.setAliasFilter(ByteString.copyFrom(convertToBytes(aliasFilter))); } builder.setIndexBoost(indexBoost); @@ -275,6 +233,7 @@ private ProtobufShardSearchRequest( } if (scroll != null) { + // TODO: Write Scroll as a proto message builder.setScroll(ByteString.copyFrom(convertToBytes(scroll))); } builder.setNowInMillis(nowInMillis); @@ -286,7 +245,6 @@ private ProtobufShardSearchRequest( builder.setReaderId(shardSearchContextId.build()); } - System.out.println("Keep alive: " + keepAlive); if (keepAlive != null) { builder.setTimeValue(keepAlive.getStringRep()); } @@ -326,44 +284,6 @@ public void writeTo(OutputStream out) throws IOException { out.write(this.shardSearchRequestProto.toByteArray()); } - // protected final void innerWriteTo(StreamOutput out, boolean asKey) throws IOException { - // shardId.writeTo(out); - // out.writeByte(searchType.id()); - // if (!asKey) { - // out.writeVInt(numberOfShards); - // } - // out.writeOptionalWriteable(scroll); - // out.writeOptionalWriteable(source); - // if (out.getVersion().before(Version.V_2_0_0)) { - // // types not supported so send an empty array to previous versions - // out.writeStringArray(Strings.EMPTY_ARRAY); - // } - // aliasFilter.writeTo(out); - // out.writeFloat(indexBoost); - // if (asKey == false) { - // out.writeVLong(nowInMillis); - // } - // out.writeOptionalBoolean(requestCache); - // if (asKey == false && out.getVersion().onOrAfter(Version.V_2_0_0)) { - // out.writeVLong(inboundNetworkTime); - // out.writeVLong(outboundNetworkTime); - // } - // out.writeOptionalString(clusterAlias); - // out.writeBoolean(allowPartialSearchResults); - // if (asKey == false) { - // out.writeStringArray(indexRoutings); - // out.writeOptionalString(preference); - // } - // if (asKey == false) { - // out.writeBoolean(canReturnNullResponseIfMatchNoDocs); - // out.writeOptionalWriteable(bottomSortValues); - // } - // if (asKey == false) { - // out.writeOptionalWriteable(readerId); - // out.writeOptionalTimeValue(keepAlive); - // } - // } - @Override public String[] indices() { if (this.shardSearchRequestProto.getOriginalIndices() == null) { @@ -509,9 +429,7 @@ public void canReturnNullResponseIfMatchNoDocs(boolean value) { * otherwise, using the most up to date point-in-time reader. */ public ShardSearchContextId readerId() { - System.out.println("Getting readerId"); if (this.shardSearchRequestProto.hasReaderId() == false) { - System.out.println("Returning null since the readerId is null"); return null; } return new ShardSearchContextId(this.shardSearchRequestProto.getReaderId().getSessionId(), this.shardSearchRequestProto.getReaderId().getId()); @@ -573,12 +491,9 @@ static class RequestRewritable implements Rewriteable { @Override public Rewriteable rewrite(QueryRewriteContext ctx) throws IOException { - // System.out.println("Rewriting protobuf request source"); + // TODO: add the rewriteable logic back once it is written for proto messages // SearchSourceBuilder newSource = request.source() == null ? null : Rewriteable.rewrite(request.source(), ctx); - // System.out.println("Rewriting protobuf request source done"); - // System.out.println("Rewriting protobuf request alias filter"); // AliasFilter newAliasFilter = Rewriteable.rewrite(request.getAliasFilter(), ctx); - // System.out.println("Rewriting protobuf request alias filter done"); SearchSourceBuilder newSource = request.source(); AliasFilter newAliasFilter = request.getAliasFilter(); diff --git a/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java b/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java index e0e3eaf170d58..d2f6bc234e752 100644 --- a/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java +++ b/server/src/main/java/org/opensearch/search/internal/ShardSearchRequest.java @@ -262,7 +262,6 @@ public ShardSearchRequest(StreamInput in) throws IOException { canReturnNullResponseIfMatchNoDocs = in.readBoolean(); bottomSortValues = in.readOptionalWriteable(SearchSortValuesAndFormats::new); readerId = in.readOptionalWriteable(ShardSearchContextId::new); - System.out.println("Reader id: " + readerId); keepAlive = in.readOptionalTimeValue(); originalIndices = OriginalIndices.readOriginalIndices(in); assert keepAlive == null || readerId != null : "readerId: " + readerId + " keepAlive: " + keepAlive; @@ -521,12 +520,8 @@ static class RequestRewritable implements Rewriteable { @Override public Rewriteable rewrite(QueryRewriteContext ctx) throws IOException { - System.out.println("Rewriting request source"); SearchSourceBuilder newSource = request.source() == null ? null : Rewriteable.rewrite(request.source(), ctx); - System.out.println("Rewriting request source done"); - System.out.println("Rewriting request alias filter"); AliasFilter newAliasFilter = Rewriteable.rewrite(request.getAliasFilter(), ctx); - System.out.println("Rewriting request alias filter done"); QueryShardContext shardContext = ctx.convertToShardContext(); diff --git a/server/src/main/java/org/opensearch/search/query/QuerySearchResult.java b/server/src/main/java/org/opensearch/search/query/QuerySearchResult.java index 81329db62d303..7dc6a980f9e18 100644 --- a/server/src/main/java/org/opensearch/search/query/QuerySearchResult.java +++ b/server/src/main/java/org/opensearch/search/query/QuerySearchResult.java @@ -89,6 +89,7 @@ public final class QuerySearchResult extends SearchPhaseResult { private Suggest suggest; private boolean searchTimedOut; private Boolean terminatedEarly = null; + // TODO: Write ProfileShardResult as a proto message private ProfileShardResult profileShardResults; private boolean hasProfileResults; private long serviceTimeEWMA = -1; @@ -121,7 +122,6 @@ public QuerySearchResult(byte[] in) throws IOException { public QuerySearchResult(ShardSearchContextId contextId, SearchShardTarget shardTarget, ShardSearchRequest shardSearchRequest) { this.contextId = contextId; setSearchShardTarget(shardTarget); - System.out.println("search shard target: " + shardTarget); isNull = false; setShardSearchRequest(shardSearchRequest); this.querySearchResult = null; @@ -130,7 +130,6 @@ public QuerySearchResult(ShardSearchContextId contextId, SearchShardTarget shard public QuerySearchResult(ShardSearchContextId contextId, SearchShardTarget shardTarget, ProtobufShardSearchRequest shardSearchRequest) { this.contextId = contextId; setSearchShardTarget(shardTarget); - System.out.println("search shard target: " + shardTarget); isNull = false; setProtobufShardSearchRequest(shardSearchRequest); ShardSearchRequestProto.ShardId shardIdProto = ShardSearchRequestProto.ShardId.newBuilder() diff --git a/server/src/main/java/org/opensearch/tasks/ProtobufTaskAwareRequest.java b/server/src/main/java/org/opensearch/tasks/ProtobufTaskAwareRequest.java index c212120e2a2c2..4e55ecbc5b4ea 100644 --- a/server/src/main/java/org/opensearch/tasks/ProtobufTaskAwareRequest.java +++ b/server/src/main/java/org/opensearch/tasks/ProtobufTaskAwareRequest.java @@ -39,12 +39,6 @@ default void setProtobufParentTask(String parentTaskNode, long parentTaskId) { * Returns the task object that should be used to keep track of the processing of the request. */ default ProtobufTask createProtobufTask(long id, String type, String action, ProtobufTaskId parentTaskId, Map headers) { - System.out.println("Creating protobuf task"); - System.out.println("id: " + id); - System.out.println("type: " + type); - System.out.println("action: " + action); - System.out.println("parentTaskId: " + parentTaskId); - System.out.println("headers: " + headers); return new ProtobufTask(id, type, action, getTaskDescription(), parentTaskId, headers); } diff --git a/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java b/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java index d2dd99b7f7892..baf2d1d94ea04 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java +++ b/server/src/main/java/org/opensearch/tasks/TaskAwareRequest.java @@ -62,14 +62,6 @@ default void setParentTask(String parentTaskNode, long parentTaskId) { * Returns the task object that should be used to keep track of the processing of the request. */ default Task createTask(long id, String type, String action, TaskId parentTaskId, Map headers) { - if (action.contains("search")) { - System.out.println("Creating task"); - System.out.println("id: " + id); - System.out.println("type: " + type); - System.out.println("action: " + action); - System.out.println("parentTaskId: " + parentTaskId); - System.out.println("headers: " + headers); - } return new Task(id, type, action, getDescription(), parentTaskId, headers); } diff --git a/server/src/main/java/org/opensearch/tasks/TaskManager.java b/server/src/main/java/org/opensearch/tasks/TaskManager.java index 9a130f80a6db2..b5d6ed8ff82ef 100644 --- a/server/src/main/java/org/opensearch/tasks/TaskManager.java +++ b/server/src/main/java/org/opensearch/tasks/TaskManager.java @@ -211,11 +211,6 @@ public void setTaskResourceConsumersEnabled(boolean taskResourceConsumersEnabled * Registers a task without parent task */ public Task register(String type, String action, TaskAwareRequest request) { - if (action.contains("search")) { - System.out.println("Registering task in TaskManager"); - System.out.println("type: " + type); - System.out.println("action: " + action); - } Map headers = new HashMap<>(); long headerSize = 0; long maxSize = maxHeaderSize.getBytes(); @@ -294,12 +289,7 @@ private void registerCancellableTask(Task task) { /** * Registers a task without parent task */ - public ProtobufTask registerProtobuf(String type, String action, ProtobufTaskAwareRequest request) { - if (action.contains("search")) { - System.out.println("Registering protobuf task in TaskManager"); - System.out.println("type: " + type); - System.out.println("action: " + action); - } + public ProtobufTask registerProtobuf(String type, String action, ProtobufTaskAwareRequest request) { Map headers = new HashMap<>(); long headerSize = 0; long maxSize = maxHeaderSize.getBytes(); diff --git a/server/src/main/java/org/opensearch/transport/InboundHandler.java b/server/src/main/java/org/opensearch/transport/InboundHandler.java index 12e308be511b7..dc54f77c9a787 100644 --- a/server/src/main/java/org/opensearch/transport/InboundHandler.java +++ b/server/src/main/java/org/opensearch/transport/InboundHandler.java @@ -332,8 +332,6 @@ private void handleRequestProtobuf( sendErrorResponse(action, transportChannel, e); } } else if (receivedMessage.hasShardSearchRequest()) { - System.out.println("ShardSearchRequest received"); - System.out.println(receivedMessage.getShardSearchRequest()); final ShardSearchRequest shardSearchReq = receivedMessage.getShardSearchRequest(); ProtobufShardSearchRequest protobufShardSearchRequest = new ProtobufShardSearchRequest(shardSearchReq); final T request = (T) protobufShardSearchRequest; @@ -608,8 +606,6 @@ private void handleProtobufResponse( threadPool.executor(executor).execute(() -> doHandleResponse(handler, response)); } } else if (receivedMessage.hasQueryFetchSearchResult()) { - System.out.println("Incoming message has the protobuf query fetch search result"); - System.out.println("QueryFetchSearchResult: " + receivedMessage.getQueryFetchSearchResult()); final QueryFetchSearchResult queryFetchSearchResult = receivedMessage.getQueryFetchSearchResult(); org.opensearch.search.fetch.QueryFetchSearchResult queryFetchSearchResult2 = new org.opensearch.search.fetch.QueryFetchSearchResult(queryFetchSearchResult); final T response = (T) queryFetchSearchResult2; diff --git a/server/src/main/java/org/opensearch/transport/OutboundHandler.java b/server/src/main/java/org/opensearch/transport/OutboundHandler.java index 94d8860989f8d..cb946700d23aa 100644 --- a/server/src/main/java/org/opensearch/transport/OutboundHandler.java +++ b/server/src/main/java/org/opensearch/transport/OutboundHandler.java @@ -135,16 +135,6 @@ void sendRequest( isHandshake, compressRequest ); - if (request.getClass().toString().contains("Search")) { - System.out.println("OutboundHandler sendRequest"); - System.out.println("Node: " + node); - System.out.println("Channel: " + channel); - System.out.println("RequestId: " + requestId); - System.out.println("Action: " + action); - System.out.println("Request: " + request); - System.out.println("Options: " + options); - System.out.println("OutboundMessage: " + message); - } ActionListener listener = ActionListener.wrap(() -> messageListener.onRequestSent(node, requestId, action, request, options)); String canonicalName = request.getClass().getCanonicalName(); if (canonicalName.contains("ProtobufClusterState")) { @@ -190,9 +180,7 @@ void sendRequest( ); sendProtobufMessage(channel, protobufMessage, listener); } else if (canonicalName.contains("ProtobufShardSearch")){ - System.out.println("OutboundHandler sendRequest for shardsearchrequest"); ProtobufShardSearchRequest protobufShardSearchRequest = (ProtobufShardSearchRequest) request; - System.out.println("ProtobufShardSearchRequest: " + protobufShardSearchRequest); byte[] bytes = new byte[1]; bytes[0] = 0; ProtobufOutboundMessage protobufMessage = new ProtobufOutboundMessage( @@ -204,7 +192,6 @@ void sendRequest( features, action ); - System.out.println("ProtobufOutboundMessage: " + protobufMessage); sendProtobufMessage(channel, protobufMessage, listener); } else { sendMessage(channel, message, listener); @@ -237,15 +224,6 @@ void sendResponse( isHandshake, compress ); - if (response.getClass().toString().contains("Search")) { - System.out.println("OutboundHandler sendResponse"); - System.out.println("NodeVersion: " + nodeVersion); - System.out.println("Features: " + features); - System.out.println("Channel: " + channel); - System.out.println("RequestId: " + requestId); - System.out.println("Action: " + action); - System.out.println("Response: " + response); - } ActionListener listener = ActionListener.wrap(() -> messageListener.onResponseSent(requestId, action, response)); String canonicalName = response.getClass().getCanonicalName(); if (canonicalName.contains("ProtobufClusterState")) { @@ -293,7 +271,6 @@ void sendResponse( } else if (canonicalName.contains("QueryFetchSearchResult")) { QueryFetchSearchResult queryFetchSearchResult = (QueryFetchSearchResult) response; if (queryFetchSearchResult.response() != null) { - System.out.println("QueryFetchSearchResult: " + queryFetchSearchResult.response()); byte[] bytes = new byte[1]; bytes[0] = 1; ProtobufOutboundMessage protobufMessage = new ProtobufOutboundMessage( @@ -305,14 +282,8 @@ void sendResponse( features, action ); - System.out.println("Outbound message for search response"); - System.out.println(protobufMessage); sendProtobufMessage(channel, protobufMessage, listener); } else { - System.out.println("Query result"); - System.out.println(queryFetchSearchResult.queryResult()); - System.out.println("Fetch result"); - System.out.println(queryFetchSearchResult.fetchResult()); sendMessage(channel, message, listener); } } else {