diff --git a/server/src/main/java/org/opensearch/node/Node.java b/server/src/main/java/org/opensearch/node/Node.java index 7d963cd8d9577..6af8f2c827393 100644 --- a/server/src/main/java/org/opensearch/node/Node.java +++ b/server/src/main/java/org/opensearch/node/Node.java @@ -1135,8 +1135,13 @@ protected Node( tracer ); - final QueryGroupService queryGroupService = new QueryGroupService(transportService.getLocalNode(), clusterService); // We will need to replace - // this with actual instance of the + final QueryGroupService queryGroupService = new QueryGroupService(transportService.getLocalNode(), clusterService); // We will + // need to + // replace + // this with + // actual + // instance + // of the // queryGroupService queryGroupServiceSetOnce.set(queryGroupService); diff --git a/server/src/main/java/org/opensearch/wlm/QueryGroupService.java b/server/src/main/java/org/opensearch/wlm/QueryGroupService.java index c37ae6cd4c04a..e5942aac0b4fa 100644 --- a/server/src/main/java/org/opensearch/wlm/QueryGroupService.java +++ b/server/src/main/java/org/opensearch/wlm/QueryGroupService.java @@ -8,6 +8,7 @@ package org.opensearch.wlm; +import org.opensearch.ResourceNotFoundException; import org.opensearch.cluster.metadata.QueryGroup; import org.opensearch.cluster.node.DiscoveryNode; import org.opensearch.cluster.service.ClusterService; @@ -63,7 +64,13 @@ public void incrementFailuresFor(final String queryGroupId) { */ public QueryGroupStats nodeStats(Set queryGroupIds, Boolean requestedBreached) { final Map statsHolderMap = new HashMap<>(); - + if (!queryGroupIds.contains("_all")) { + for (String id : queryGroupIds) { + if (!queryGroupStateMap.containsKey(id)) { + throw new ResourceNotFoundException("QueryGroup with id " + id + " does not exist"); + } + } + } queryGroupStateMap.forEach((queryGroupId, currentState) -> { boolean shouldInclude = (queryGroupIds.size() == 1 && queryGroupIds.contains("_all")) || queryGroupIds.contains(queryGroupId);