-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '2.x' into backport/backport-14426-to-2.x
Signed-off-by: Pranshu Shukla <55992439+Pranshu-S@users.noreply.github.com>
- Loading branch information
Showing
3 changed files
with
42 additions
and
7 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
30 changes: 30 additions & 0 deletions
30
server/src/main/java/org/opensearch/action/search/SearchTaskRequestOperationsListener.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,30 @@ | ||
/* | ||
* 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.action.search; | ||
|
||
import org.opensearch.tasks.TaskResourceTrackingService; | ||
|
||
/** | ||
* SearchTaskRequestOperationsListener subscriber for operations on search tasks resource usages. | ||
* Listener ensures to refreshResourceStats on request end capturing the search task resource usage | ||
* upon request completion. | ||
* | ||
*/ | ||
public final class SearchTaskRequestOperationsListener extends SearchRequestOperationsListener { | ||
private final TaskResourceTrackingService taskResourceTrackingService; | ||
|
||
public SearchTaskRequestOperationsListener(TaskResourceTrackingService taskResourceTrackingService) { | ||
this.taskResourceTrackingService = taskResourceTrackingService; | ||
} | ||
|
||
@Override | ||
public void onRequestEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) { | ||
taskResourceTrackingService.refreshResourceStats(context.getTask()); | ||
} | ||
} |
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