Skip to content

Commit

Permalink
rename a field in QueryGroupTask
Browse files Browse the repository at this point in the history
Signed-off-by: Kaushal Kumar <[email protected]>
kaushalmahi12 committed Jan 28, 2025
1 parent a7b50d3 commit 6973d28
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions server/src/main/java/org/opensearch/wlm/QueryGroupTask.java
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ public class QueryGroupTask extends CancellableTask {
public static final Supplier<String> DEFAULT_QUERY_GROUP_ID_SUPPLIER = () -> "DEFAULT_QUERY_GROUP";
private final LongSupplier nanoTimeSupplier;
private String queryGroupId;
private boolean isEligibleForTracking = false;
private boolean isQueryGroupSet = false;

public QueryGroupTask(long id, String type, String action, String description, TaskId parentTaskId, Map<String, String> headers) {
this(id, type, action, description, parentTaskId, headers, NO_TIMEOUT, System::nanoTime);
@@ -82,7 +82,7 @@ public final String getQueryGroupId() {
* @param threadContext current threadContext
*/
public final void setQueryGroupId(final ThreadContext threadContext) {
isEligibleForTracking = true;
isQueryGroupSet = true;
if (threadContext != null && threadContext.getHeader(QUERY_GROUP_ID_HEADER) != null) {
this.queryGroupId = threadContext.getHeader(QUERY_GROUP_ID_HEADER);
} else {
@@ -94,8 +94,8 @@ public long getElapsedTime() {
return nanoTimeSupplier.getAsLong() - getStartTimeNanos();
}

public boolean isEligibleForTracking() {
return isEligibleForTracking;
public boolean isQueryGroupSet() {
return isQueryGroupSet;
}

@Override
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ private Map<String, List<QueryGroupTask>> getTasksGroupedByQueryGroup() {
.stream()
.filter(QueryGroupTask.class::isInstance)
.map(QueryGroupTask.class::cast)
.filter(QueryGroupTask::isEligibleForTracking)
.filter(QueryGroupTask::isQueryGroupSet)
.collect(Collectors.groupingBy(QueryGroupTask::getQueryGroupId, Collectors.mapping(task -> task, Collectors.toList())));
}
}
Original file line number Diff line number Diff line change
@@ -146,7 +146,7 @@ private <T extends QueryGroupTask> T createMockTask(Class<T> type, long cpuUsage
when(task.getTotalResourceUtilization(ResourceStats.MEMORY)).thenReturn(heapUsage);
when(task.getStartTimeNanos()).thenReturn((long) 0);
when(task.getElapsedTime()).thenReturn(clock.getTime());
when(task.isEligibleForTracking()).thenReturn(true);
when(task.isQueryGroupSet()).thenReturn(true);

AtomicBoolean isCancelled = new AtomicBoolean(false);
doAnswer(invocation -> {

0 comments on commit 6973d28

Please sign in to comment.