-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Add changes to propagate queryGroupId across child requests and nodes #14614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mch2
merged 22 commits into
opensearch-project:main
from
kaushalmahi12:feature/sandbox-qgHdrPropagatino
Jul 16, 2024
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
58303c6
add query group header propagator
kaushalmahi12 5efa3e3
apply spotless check
kaushalmahi12 ede0efa
add new propagator in ThreadContext
kaushalmahi12 51c5222
spotlessApply
kaushalmahi12 dfa53b1
address comments
kaushalmahi12 153134d
Bump com.microsoft.azure:msal4j from 1.15.1 to 1.16.0 in /plugins/rep…
dependabot[bot] ec9d435
[Bugfix] Fix ICacheKeySerializerTests flakiness (#14564)
peteralfonsi bda1bfa
Correct typo in method name (#14621)
imvtsl 6abdba2
Refactoring FilterPath.parse by using an iterative approach instead o…
deshsidd 38c9f82
Removing String format in RemoteStoreMigrationAllocationDecider to op…
RS146BIJAY a5b991e
Clear templates before Adding; Use NamedWriteableAwareStreamInput for…
soosinha b1b5f87
add changelog
kaushalmahi12 9a1c7b9
add PR link changelog
kaushalmahi12 cbcbb0e
Improve reroute performance by optimising List.removeAll in LocalShar…
RS146BIJAY 1abe6b1
Fix assertion failure while deleting remote backed index (#14601)
sachinpkale 1d20abe
Allow system index warning in OpenSearchRestTestCase.refreshAllIndice…
cwperks fe1983e
Star tree codec changes (#14514)
bharath-techie ba851fb
Bump com.github.spullara.mustache.java:compiler from 0.9.13 to 0.9.14…
dependabot[bot] 3925aac
Bump net.minidev:accessors-smart from 2.5.0 to 2.5.1 in /plugins/repo…
dependabot[bot] aa7c560
Merge branch 'main' into feature/sandbox-qgHdrPropagatino
kaushalmahi12 eea2a2c
rebase with upstream
kaushalmahi12 7b21688
move query group thread context propagator out of ThreadContext
kaushalmahi12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
53 changes: 53 additions & 0 deletions
53
server/src/main/java/org/opensearch/wlm/QueryGroupThreadContextStatePropagator.java
This file contains hidden or 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,53 @@ | ||
| /* | ||
| * 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; | ||
|
|
||
| import org.opensearch.common.util.concurrent.ThreadContextStatePropagator; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
|
|
||
| /** | ||
| * This class is used to propagate QueryGroup related headers to request and nodes | ||
| */ | ||
| public class QueryGroupThreadContextStatePropagator implements ThreadContextStatePropagator { | ||
| // TODO: move this constant to QueryGroupService class once the QueryGroup monitoring framework PR is ready | ||
| public static List<String> PROPAGATED_HEADERS = List.of("queryGroupId"); | ||
|
|
||
| /** | ||
| * @param source current context transient headers | ||
| * @return the map of header and their values to be propagated across request threadContexts | ||
| */ | ||
| @Override | ||
| @SuppressWarnings("removal") | ||
| public Map<String, Object> transients(Map<String, Object> source) { | ||
| final Map<String, Object> transientHeaders = new HashMap<>(); | ||
|
|
||
| for (String headerName : PROPAGATED_HEADERS) { | ||
| transientHeaders.compute(headerName, (k, v) -> source.get(headerName)); | ||
| } | ||
| return transientHeaders; | ||
| } | ||
|
|
||
| /** | ||
| * @param source current context headers | ||
| * @return map of header and their values to be propagated across nodes | ||
| */ | ||
| @Override | ||
| @SuppressWarnings("removal") | ||
| public Map<String, String> headers(Map<String, Object> source) { | ||
| final Map<String, String> propagatedHeaders = new HashMap<>(); | ||
|
|
||
| for (String headerName : PROPAGATED_HEADERS) { | ||
| propagatedHeaders.compute(headerName, (k, v) -> (String) source.get(headerName)); | ||
| } | ||
| return propagatedHeaders; | ||
| } | ||
| } |
This file contains hidden or 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,13 @@ | ||
| /* | ||
| * 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. | ||
| */ | ||
|
|
||
| /** | ||
| * This package contains workload management constructs | ||
| */ | ||
|
|
||
| package org.opensearch.wlm; | ||
30 changes: 30 additions & 0 deletions
30
server/src/test/java/org/opensearch/wlm/QueryGroupThreadContextStatePropagatorTests.java
This file contains hidden or 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.wlm; | ||
|
|
||
| import org.opensearch.test.OpenSearchTestCase; | ||
|
|
||
| import java.util.Map; | ||
|
|
||
| public class QueryGroupThreadContextStatePropagatorTests extends OpenSearchTestCase { | ||
|
|
||
| public void testTransients() { | ||
| QueryGroupThreadContextStatePropagator sut = new QueryGroupThreadContextStatePropagator(); | ||
| Map<String, Object> source = Map.of("queryGroupId", "adgarja0r235te"); | ||
| Map<String, Object> transients = sut.transients(source); | ||
| assertEquals("adgarja0r235te", transients.get("queryGroupId")); | ||
| } | ||
|
|
||
| public void testHeaders() { | ||
| QueryGroupThreadContextStatePropagator sut = new QueryGroupThreadContextStatePropagator(); | ||
| Map<String, Object> source = Map.of("queryGroupId", "adgarja0r235te"); | ||
| Map<String, String> headers = sut.headers(source); | ||
| assertEquals("adgarja0r235te", headers.get("queryGroupId")); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.