From 57b679baaea7bc41ad04a0c6dc9e4158f0dbb37f Mon Sep 17 00:00:00 2001 From: Siddhant Deshmukh Date: Thu, 18 Jul 2024 13:14:34 -0700 Subject: [PATCH] Address review comments Signed-off-by: Siddhant Deshmukh --- ...estOperationsCompositeListenerFactory.java | 5 +++-- .../action/search/TransportSearchAction.java | 4 ++-- .../SearchTaskResourceOperationsListener.java | 19 +++---------------- 3 files changed, 8 insertions(+), 20 deletions(-) diff --git a/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsCompositeListenerFactory.java b/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsCompositeListenerFactory.java index 842a0e2dc61fe..f9d7f5c6b6b2f 100644 --- a/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsCompositeListenerFactory.java +++ b/server/src/main/java/org/opensearch/action/search/SearchRequestOperationsCompositeListenerFactory.java @@ -69,8 +69,9 @@ public SearchRequestOperationsListener.CompositeListener buildCompositeListener( final SearchRequestOperationsListener... perRequestListeners ) { final List searchListenersList = Stream.concat( - Arrays.stream(perRequestListeners), - searchRequestListenersList.stream() + searchRequestListenersList.stream(), + Arrays.stream(perRequestListeners) + ) .filter((searchRequestOperationsListener -> searchRequestOperationsListener.isEnabled(searchRequest))) .collect(Collectors.toList()); 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 c250b3893f199..d5cfcce0fd793 100644 --- a/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java +++ b/server/src/main/java/org/opensearch/action/search/TransportSearchAction.java @@ -86,7 +86,7 @@ import org.opensearch.search.profile.ProfileShardResult; import org.opensearch.search.profile.SearchProfileShardResults; import org.opensearch.tasks.CancellableTask; -import org.opensearch.tasks.SearchTaskResourceOperationsListener; +import org.opensearch.tasks.SearchTaskRequestOperationsListener; import org.opensearch.tasks.Task; import org.opensearch.tasks.TaskResourceTrackingService; import org.opensearch.telemetry.metrics.MetricsRegistry; @@ -435,7 +435,7 @@ private void executeRequest( originalSearchRequest, logger, TraceableSearchRequestOperationsListener.create(tracer, requestSpan), - new SearchTaskResourceOperationsListener(taskResourceTrackingService) + new SearchTaskRequestOperationsListener(taskResourceTrackingService) ); SearchRequestContext searchRequestContext = new SearchRequestContext( requestOperationsListeners, diff --git a/server/src/main/java/org/opensearch/tasks/SearchTaskResourceOperationsListener.java b/server/src/main/java/org/opensearch/tasks/SearchTaskResourceOperationsListener.java index e7f752c7af183..7c336fb1c7210 100644 --- a/server/src/main/java/org/opensearch/tasks/SearchTaskResourceOperationsListener.java +++ b/server/src/main/java/org/opensearch/tasks/SearchTaskResourceOperationsListener.java @@ -13,31 +13,18 @@ import org.opensearch.action.search.SearchRequestOperationsListener; /** - * SearchTaskResourceOperationsListener subscriber for operations on search tasks resource usages. + * SearchTaskRequestOperationsListener subscriber for operations on search tasks resource usages. * Listener ensures to refreshResourceStats on request end capturing the search task resource usage * upon request completion. * - * @PublicApi */ -public final class SearchTaskResourceOperationsListener extends SearchRequestOperationsListener { +public final class SearchTaskRequestOperationsListener extends SearchRequestOperationsListener { private final TaskResourceTrackingService taskResourceTrackingService; - public SearchTaskResourceOperationsListener(TaskResourceTrackingService taskResourceTrackingService) { + public SearchTaskRequestOperationsListener(TaskResourceTrackingService taskResourceTrackingService) { this.taskResourceTrackingService = taskResourceTrackingService; } - @Override - protected void onPhaseStart(SearchPhaseContext context) {} - - @Override - protected void onPhaseEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) {} - - @Override - protected void onPhaseFailure(SearchPhaseContext context, Throwable cause) {} - - @Override - public void onRequestStart(SearchRequestContext searchRequestContext) {} - @Override public void onRequestEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) { taskResourceTrackingService.refreshResourceStats(context.getTask());