Skip to content

Commit

Permalink
fix precommit errors
Browse files Browse the repository at this point in the history
Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com>
  • Loading branch information
kaushalmahi12 committed Oct 7, 2024
1 parent 623078a commit 2d7316b
Showing 1 changed file with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
import java.util.HashMap;
import java.util.Map;

/**
* This class is used to decouple {@link QueryGroupService} and {@link org.opensearch.wlm.cancellation.QueryGroupTaskCancellationService} to share the
* {@link QueryGroupState}s
*/
public class QueryGroupsStateAccessor {
// This map does not need to be concurrent since we will process the cluster state change serially and update
// this map with new additions and deletions of entries. QueryGroupState is thread safe
Expand All @@ -26,18 +30,34 @@ public QueryGroupsStateAccessor(Map<String, QueryGroupState> queryGroupStateMap)
this.queryGroupStateMap = queryGroupStateMap;
}

/**
* returns the query groups state
*/
public Map<String, QueryGroupState> getQueryGroupStateMap() {
return queryGroupStateMap;
}

/**
* return QueryGroupState for the given queryGroupId
* @param queryGroupId
* @return QueryGroupState for the given queryGroupId, if id is invalid return default query group state
*/
public QueryGroupState getQueryGroupState(String queryGroupId) {
return queryGroupStateMap.getOrDefault(queryGroupId, queryGroupStateMap.get(QueryGroupTask.DEFAULT_QUERY_GROUP_ID_SUPPLIER.get()));
}

/**
* adds new QueryGroupState against given queryGroupId
* @param queryGroupId
*/
public void addNewQueryGroup(String queryGroupId) {
this.queryGroupStateMap.putIfAbsent(queryGroupId, new QueryGroupState());
}

/**
* removes QueryGroupState against given queryGroupId
* @param queryGroupId
*/
public void removeQueryGroup(String queryGroupId) {
this.queryGroupStateMap.remove(queryGroupId);
}
Expand Down

0 comments on commit 2d7316b

Please sign in to comment.