diff --git a/src/main/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListener.java b/src/main/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListener.java index 73d465ee..8f186769 100644 --- a/src/main/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListener.java +++ b/src/main/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListener.java @@ -119,20 +119,16 @@ public boolean isEnabled() { } @Override - public void onPhaseStart(SearchPhaseContext context) { - } + public void onPhaseStart(SearchPhaseContext context) {} @Override - public void onPhaseEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) { - } + public void onPhaseEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) {} @Override - public void onPhaseFailure(SearchPhaseContext context, Throwable cause) { - } + public void onPhaseFailure(SearchPhaseContext context, Throwable cause) {} @Override - public void onRequestStart(SearchRequestContext searchRequestContext) { - } + public void onRequestStart(SearchRequestContext searchRequestContext) {} @Override public void onRequestEnd(final SearchPhaseContext context, final SearchRequestContext searchRequestContext) { @@ -147,9 +143,6 @@ public void onRequestFailure(final SearchPhaseContext context, final SearchReque private void constructSearchQueryRecord(final SearchPhaseContext context, final SearchRequestContext searchRequestContext) { SearchTask searchTask = context.getTask(); List tasksResourceUsages = searchRequestContext.getPhaseResourceUsage(); - if (clusterService.getTaskResourceTrackingService() != null) { - clusterService.getTaskResourceTrackingService().refreshResourceStats(searchTask); - } tasksResourceUsages.add( new TaskResourceInfo( searchTask.getAction(), diff --git a/src/test/java/org/opensearch/plugin/insights/QueryInsightsTestUtils.java b/src/test/java/org/opensearch/plugin/insights/QueryInsightsTestUtils.java index b43ef01d..9b97e5f3 100644 --- a/src/test/java/org/opensearch/plugin/insights/QueryInsightsTestUtils.java +++ b/src/test/java/org/opensearch/plugin/insights/QueryInsightsTestUtils.java @@ -48,8 +48,7 @@ final public class QueryInsightsTestUtils { - public QueryInsightsTestUtils() { - } + public QueryInsightsTestUtils() {} public static List generateQueryInsightRecords(int count) { return generateQueryInsightRecords(count, count, System.currentTimeMillis(), 0); diff --git a/src/test/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListenerTests.java b/src/test/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListenerTests.java index f9d4b11e..5c2ea577 100644 --- a/src/test/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListenerTests.java +++ b/src/test/java/org/opensearch/plugin/insights/core/listener/QueryInsightsListenerTests.java @@ -32,7 +32,6 @@ import org.opensearch.search.aggregations.support.ValueType; import org.opensearch.search.builder.SearchSourceBuilder; import org.opensearch.tasks.Task; -import org.opensearch.tasks.TaskResourceTrackingService; import org.opensearch.test.ClusterServiceUtils; import org.opensearch.test.OpenSearchTestCase; import org.opensearch.threadpool.TestThreadPool; @@ -66,7 +65,6 @@ public class QueryInsightsListenerTests extends OpenSearchTestCase { private final SearchRequest searchRequest = mock(SearchRequest.class); private final QueryInsightsService queryInsightsService = mock(QueryInsightsService.class); private final TopQueriesService topQueriesService = mock(TopQueriesService.class); - private final TaskResourceTrackingService taskResourceTrackingService = mock(TaskResourceTrackingService.class); private final ThreadPool threadPool = new TestThreadPool("QueryInsightsThreadPool"); private ClusterService clusterService; @@ -79,7 +77,6 @@ public void setup() { ClusterState state = ClusterStateCreationUtils.stateWithActivePrimary("test", true, 1 + randomInt(3), randomInt(2)); clusterService = ClusterServiceUtils.createClusterService(threadPool, state.getNodes().getLocalNode(), clusterSettings); ClusterServiceUtils.setState(clusterService, state); - clusterService.setTaskResourceTrackingService(taskResourceTrackingService); when(queryInsightsService.isCollectionEnabled(MetricType.LATENCY)).thenReturn(true); when(queryInsightsService.getTopQueriesService(MetricType.LATENCY)).thenReturn(topQueriesService); @@ -142,7 +139,6 @@ public void testOnRequestEnd() throws InterruptedException { assertEquals(searchSourceBuilder.toString(), generatedRecord.getAttributes().get(Attribute.SOURCE)); Map labels = (Map) generatedRecord.getAttributes().get(Attribute.LABELS); assertEquals("userLabel", labels.get(Task.X_OPAQUE_ID)); - verify(taskResourceTrackingService, times(1)).refreshResourceStats(task); } public void testConcurrentOnRequestEnd() throws InterruptedException { @@ -204,7 +200,6 @@ public void testConcurrentOnRequestEnd() throws InterruptedException { countDownLatch.await(); verify(queryInsightsService, times(numRequests)).addRecord(any()); - verify(taskResourceTrackingService, times(numRequests)).refreshResourceStats(task); } public void testSetEnabled() {