Skip to content

Commit

Permalink
remove task resource tracking fix
Browse files Browse the repository at this point in the history
Signed-off-by: Chenyang Ji <cyji@amazon.com>
  • Loading branch information
ansjcy committed Jul 16, 2024
1 parent ee61f8a commit 4724b5b
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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<TaskResourceInfo> tasksResourceUsages = searchRequestContext.getPhaseResourceUsage();
if (clusterService.getTaskResourceTrackingService() != null) {
clusterService.getTaskResourceTrackingService().refreshResourceStats(searchTask);
}
tasksResourceUsages.add(
new TaskResourceInfo(
searchTask.getAction(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@

final public class QueryInsightsTestUtils {

public QueryInsightsTestUtils() {
}
public QueryInsightsTestUtils() {}

public static List<SearchQueryRecord> generateQueryInsightRecords(int count) {
return generateQueryInsightRecords(count, count, System.currentTimeMillis(), 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand All @@ -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);

Expand Down Expand Up @@ -142,7 +139,6 @@ public void testOnRequestEnd() throws InterruptedException {
assertEquals(searchSourceBuilder.toString(), generatedRecord.getAttributes().get(Attribute.SOURCE));
Map<String, String> labels = (Map<String, String>) generatedRecord.getAttributes().get(Attribute.LABELS);
assertEquals("userLabel", labels.get(Task.X_OPAQUE_ID));
verify(taskResourceTrackingService, times(1)).refreshResourceStats(task);
}

public void testConcurrentOnRequestEnd() throws InterruptedException {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 4724b5b

Please sign in to comment.