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.
Signed-off-by: Bharathwaj G <[email protected]>
- Loading branch information
1 parent
327b1dc
commit a891884
Showing
5 changed files
with
233 additions
and
66 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
45 changes: 45 additions & 0 deletions
45
server/src/main/java/org/opensearch/tasks/ResourceUsageStatsTCPropagator.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,45 @@ | ||
/* | ||
* 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 java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.opensearch.common.util.concurrent.ThreadContextStatePropagator; | ||
|
||
import static org.opensearch.tasks.TaskResourceTrackingService.TASK_ID; | ||
|
||
|
||
public class ResourceUsageStatsTCPropagator implements ThreadContextStatePropagator { | ||
public static final String NODE_RESOURCE_STATS = "PERF_STATS"; | ||
@Override | ||
public Map<String, Object> transients(Map<String, Object> source) { | ||
final Map<String, Object> transients = new HashMap<>(); | ||
for(Map.Entry<String, Object> entry : source.entrySet()) { | ||
if(entry.getKey().startsWith(NODE_RESOURCE_STATS)) { | ||
// key starts with prefix | ||
transients.put(entry.getKey(), entry.getValue()); | ||
} | ||
} | ||
return transients; | ||
} | ||
|
||
@Override | ||
public Map<String, String> headers(Map<String, Object> source) { | ||
final Map<String, String> transients = new HashMap<>(); | ||
for(Map.Entry<String, Object> entry : source.entrySet()) { | ||
if(entry.getKey().startsWith(NODE_RESOURCE_STATS)) { | ||
// key starts with prefix | ||
transients.put(entry.getKey(), entry.getValue().toString()); | ||
} | ||
} | ||
return transients; | ||
//return Collections.emptyMap(); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
server/src/main/java/org/opensearch/transport/ResourceUsageStatsReference.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,2 @@ | ||
package org.opensearch.transport;public class ResourceUsageStatsReference { | ||
} |
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