forked from opensearch-project/OpenSearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add query group stats constructs (opensearch-project#15343)
* add query group stats constructs Signed-off-by: Kaushal Kumar <[email protected]> * add changelog entry Signed-off-by: Kaushal Kumar <[email protected]> * add packageinfo for stats Signed-off-by: Kaushal Kumar <[email protected]> * add total cancellations Signed-off-by: Kaushal Kumar <[email protected]> * add more granular level rejections Signed-off-by: Kaushal Kumar <[email protected]> * add toXContent test cases Signed-off-by: Kaushal Kumar <[email protected]> * move ResourceType enum to wlm Signed-off-by: Kaushal Kumar <[email protected]> * update the comment for query group stats Signed-off-by: Kaushal Kumar <[email protected]> --------- Signed-off-by: Kaushal Kumar <[email protected]>
- Loading branch information
1 parent
279b4ec
commit 9e77040
Showing
22 changed files
with
517 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
server/src/main/java/org/opensearch/wlm/stats/QueryGroupState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
package org.opensearch.wlm.stats; | ||
|
||
import org.opensearch.common.metrics.CounterMetric; | ||
import org.opensearch.wlm.ResourceType; | ||
|
||
import java.util.EnumMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* This class will keep the point in time view of the query group stats | ||
*/ | ||
public class QueryGroupState { | ||
/** | ||
* completions at the query group level, this is a cumulative counter since the Opensearch start time | ||
*/ | ||
final CounterMetric completions = new CounterMetric(); | ||
|
||
/** | ||
* rejections at the query group level, this is a cumulative counter since the OpenSearch start time | ||
*/ | ||
final CounterMetric totalRejections = new CounterMetric(); | ||
|
||
/** | ||
* this will track the cumulative failures in a query group | ||
*/ | ||
final CounterMetric failures = new CounterMetric(); | ||
|
||
/** | ||
* This will track total number of cancellations in the query group due to all resource type breaches | ||
*/ | ||
final CounterMetric totalCancellations = new CounterMetric(); | ||
|
||
/** | ||
* This is used to store the resource type state both for CPU and MEMORY | ||
*/ | ||
private final Map<ResourceType, ResourceTypeState> resourceState; | ||
|
||
public QueryGroupState() { | ||
resourceState = new EnumMap<>(ResourceType.class); | ||
for (ResourceType resourceType : ResourceType.values()) { | ||
if (resourceType.hasStatsEnabled()) { | ||
resourceState.put(resourceType, new ResourceTypeState(resourceType)); | ||
} | ||
} | ||
} | ||
|
||
/** | ||
* | ||
* @return completions in the query group | ||
*/ | ||
public long getCompletions() { | ||
return completions.count(); | ||
} | ||
|
||
/** | ||
* | ||
* @return rejections in the query group | ||
*/ | ||
public long getTotalRejections() { | ||
return totalRejections.count(); | ||
} | ||
|
||
/** | ||
* | ||
* @return failures in the query group | ||
*/ | ||
public long getFailures() { | ||
return failures.count(); | ||
} | ||
|
||
public long getTotalCancellations() { | ||
return totalCancellations.count(); | ||
} | ||
|
||
/** | ||
* getter for query group resource state | ||
* @return the query group resource state | ||
*/ | ||
public Map<ResourceType, ResourceTypeState> getResourceState() { | ||
return resourceState; | ||
} | ||
|
||
/** | ||
* This class holds the resource level stats for the query group | ||
*/ | ||
public static class ResourceTypeState { | ||
final ResourceType resourceType; | ||
final CounterMetric cancellations = new CounterMetric(); | ||
final CounterMetric rejections = new CounterMetric(); | ||
|
||
public ResourceTypeState(ResourceType resourceType) { | ||
this.resourceType = resourceType; | ||
} | ||
} | ||
} |
Oops, something went wrong.