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.
create per request listener to refresh task resource usage
Signed-off-by: Chenyang Ji <cyji@amazon.com>
- Loading branch information
Showing
6 changed files
with
48 additions
and
27 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
43 changes: 43 additions & 0 deletions
43
server/src/main/java/org/opensearch/tasks/SearchTaskResourceOperationsListener.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,43 @@ | ||
/* | ||
* 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.tasks; | ||
|
||
import org.opensearch.action.search.SearchPhaseContext; | ||
import org.opensearch.action.search.SearchRequestContext; | ||
import org.opensearch.action.search.SearchRequestOperationsListener; | ||
|
||
/** | ||
* SearchTaskResourceOperationsListener subscriber for operations on search tasks resource usages | ||
* | ||
* @opensearch.internal | ||
*/ | ||
public final class SearchTaskResourceOperationsListener extends SearchRequestOperationsListener { | ||
private final TaskResourceTrackingService taskResourceTrackingService; | ||
|
||
public SearchTaskResourceOperationsListener(TaskResourceTrackingService taskResourceTrackingService) { | ||
this.taskResourceTrackingService = taskResourceTrackingService; | ||
} | ||
|
||
@Override | ||
protected void onPhaseStart(SearchPhaseContext context) {} | ||
|
||
@Override | ||
protected void onPhaseEnd(SearchPhaseContext context, SearchRequestContext searchRequestContext) {} | ||
|
||
@Override | ||
protected void onPhaseFailure(SearchPhaseContext context, Throwable cause) {} | ||
|
||
@Override | ||
public void onRequestStart(SearchRequestContext searchRequestContext) {} | ||
|
||
@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