-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* add query group stats constructs * add changelog entry * add packageinfo for stats * add total cancellations * add more granular level rejections * add toXContent test cases * move ResourceType enum to wlm * update the comment for query group stats --------- (cherry picked from commit c0bcacb) Signed-off-by: Kaushal Kumar <ravi.kaushal97@gmail.com> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
c5a929d
commit c63ad5a
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.