-
Couldn't load subscription status.
- Fork 2.3k
Add queryGroupId to search workload tasks at co-ordinator and data node level #14708
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 94 commits into
opensearch-project:main
from
kaushalmahi12:feature/sandbox-qgTaskHeaders
Jul 30, 2024
Merged
Changes from all commits
Commits
Show all changes
94 commits
Select commit
Hold shift + click to select a range
a6ea59c
add logic to add headers to Task
kaushalmahi12 bc30528
add logic to add queryGroupId to task headers
kaushalmahi12 f0768b0
remove redundant code
kaushalmahi12 668a167
add changelog entry
kaushalmahi12 b31388e
address comments
kaushalmahi12 ea02672
fix precommit
kaushalmahi12 4920301
Add UTs for RemoteIndexMetadataManager (#14660)
shiv0408 f4d7983
Fix match_phrase_prefix_query not working on text field with multiple…
gaobinlong fa284e3
Offline calculation of total shard per node and caching it for weight…
RS146BIJAY 8f5ef47
[bug fix] validate lower bound for top n size (#14587)
ansjcy b6d4c40
Create SystemIndexRegistry with helper method matchesSystemIndex (#14…
cwperks bb8e8c9
Refactor Grok validate pattern to iterative approach (#14206)
sandeshkr419 bddfa89
Bump opentelemetry from 1.39.0 to 1.40.0 (#14674)
reta 4f02eb4
Bump jackson from 2.17.1 to 2.17.2 (#14687)
reta 7574c48
Add release notes for release 1.3.18 (#14699)
zelinh 241c00a
Bump reactor from 3.5.19 to 3.5.20 (#14697)
reta 56c989f
Add unit tests for read flow of RemoteClusterStateService and bug fix…
shiv0408 4bc621f
Update version check for the bug fix of match_phrase_prefix_query not…
gaobinlong c9b075b
Remove unnecessary cast to int from test (#14696)
lukas-vlcek 69dc9e2
print reason why parent task was cancelled (#14604)
kkewwei f21eb0a
Use set of shard routing for shard in unassigned shard batch check. (…
SwethaGuptha e1fbbe5
Add versioning for UploadedIndexMetadata (#14677)
soosinha 0a40af0
Fix: update help output for _cat (#14722)
ahmedsobeh 0afb641
Fix hdfs-fixture kerb-admin & hadoop-minicluster dependencies are not…
reta ead19ab
Update to Gradle 8.9 (#14574)
reta 7c86cec
Fix hdfs-fixture hadoop-minicluster dependencies are not being update…
reta 04f9ea1
Add `strict_allow_templates` dynamic mapping option (#14555)
gaobinlong e8da561
Bump net.minidev:json-smart from 2.5.0 to 2.5.1 in /plugins/repositor…
dependabot[bot] 0205d9b
remove query insights plugin from core (#14743)
ansjcy c49659b
Add `strict_allow_templates` dynamic mapping option (#14555) (#14737)…
reta 4127725
Fix create or update alias API doesn't throw exception for unsupporte…
gaobinlong 8682859
Remove query categorization from core (#14759)
deshsidd 0d70e36
Add changes to propagate queryGroupId across child requests and nodes…
kaushalmahi12 4b56657
Add consumers to remote store based index settings (#14764)
shourya035 10b187e
Add matchesPluginSystemIndexPattern to SystemIndexRegistry (#14750)
cwperks ef49713
SPI for loading ABC templates (#14659)
mgodwan 2eb7a92
Fix bulk upsert ignores the default_pipeline and final_pipeline when …
gaobinlong 09aa997
Fix flaky test due to node being used across all tests (#14787)
mgodwan 763354c
Star Tree Implementation [OnHeap] (#14512)
sarthakaggarwal97 94aa7c0
Add Gao Binlong as maintainer (#14796)
reta 28e516a
Clear ehcache disk cache files during initialization (#14738)
sgup432 1bf20c5
Refactor remote-routing-table service inline with remote state interf…
alchemist51 2332fe3
Set version to 2.15 for determining metadata during migration to remo…
skumawat2025 e1bd0ad
Fix bulk upsert ignores the default_pipeline and final_pipeline when …
reta c4317f8
Fix create or update alias API doesn't throw exception for unsupporte…
reta acd5b51
Change RCSS info logs to debug (#14814)
shiv0408 eff7595
[Bugfix] Fix NPE in ReplicaShardAllocator (#13993) (#14385)
DaniilRoman 8b97cd5
Run performance benchmark on pull requests (#14760)
rishabh6788 2caebaf
fix constant_keyword field type (#14807)
kkewwei ecb65cf
[Remote Store Migration] Reconcile remote store based index settings …
shourya035 2e31c78
Add prefix mode verification setting for repository verification (#14…
ashking94 9d69875
add length check on comment body for benchmark workflow (#14834)
rishabh6788 0267660
Add restore-from-snapshot test procedure for snapshot run benchmark c…
rishabh6788 c4164c5
Fix env variable name typo (#14843)
rishabh6788 9acd749
Use circuit breaker in InternalHistogram when adding empty buckets (#…
bowenlan-amzn 23eac8d
[Remote State] Create interface RemoteEntitiesManager (#14671)
shiv0408 cb51734
Optimise TransportNodesAction to not send DiscoveryNodes for NodeStat…
Pranshu-S 6165336
Enabling term version check on local state for all ClusterManager Rea…
rajiv-kv a6c97b6
Reduce logging in DEBUG for MasterService:run (#14795)
sumitasr f21de7d
Add SplitResponseProcessor to Search Pipelines (#14800)
dbwiddis d8a47ec
Add integration tests for RemoteRoutingTable Service. (#14631)
shailendra0811 566de75
Add SortResponseProcessor to Search Pipelines (#14785)
dbwiddis a49fc8c
Fix allowUnmappedFields, mapUnmappedFieldAsString settings to be appl…
imyp92 7829554
Bump com.microsoft.azure:msal4j from 1.16.0 to 1.16.1 in /plugins/rep…
dependabot[bot] 071c265
Bump com.gradle.develocity from 3.17.5 to 3.17.6 (#14856)
dependabot[bot] 0080832
Bump org.jline:jline in /test/fixtures/hdfs-fixture (#14859)
dependabot[bot] 920f86a
Use Lucene provided Persian stem (#14847)
ebraminio 824fab2
Bump actions/checkout from 2 to 4 (#14858)
dependabot[bot] a293d52
Deprecate batch_size parameter on bulk API (#14725)
chishui 2e13b79
Add perms for remote snapshot cache eviction on scripted query (#14411)
finnegancarroll c926996
add transport interceptor to populate queryGroupId in task headers
kaushalmahi12 61b0032
Add rest, transport layer changes for Hot to warm tiering - dedicated…
neetikasinghal f188e91
Create listener to refresh search thread resource usage (#14832)
deshsidd f1235e0
Caching avg total bytes and avg free bytes inside ClusterInfo (#14851)
RS146BIJAY 57f1cbc
Use default value when index.number_of_replicas is null (#14812)
chishui 69bf700
[Remote Routing Table] Implement write and read flow for shard diff f…
shailendra0811 8369771
Optimized ClusterStatsIndices to precomute shard stats (#14426)
Pranshu-S ffc885e
Fix constraint bug which allows more primary shards than average prim…
gbbafna 90ad0ab
Optmising AwarenessAllocationDecider for hashmap.get call (#14761)
RS146BIJAY 1b00b5d
update comment
kaushalmahi12 2d52a2d
Fix IngestServiceTests.testBulkRequestExecutionWithFailures (#14918)
andrross b3fd0f8
Merge branch 'main' into feature/sandbox-qgTaskHeaders
kaushalmahi12 fe66e9d
add queryGroupTask
kaushalmahi12 d5d26e9
remove unnecessary imports
kaushalmahi12 3eb07e7
add QueryGroupTask tests
kaushalmahi12 c77c06e
rename WLM transport request handler
kaushalmahi12 9d12a95
Merge branch 'main' into feature/sandbox-qgTaskHeaders
kaushalmahi12 f5415b5
add CHANGELOG entry
kaushalmahi12 c108a50
fix ut
kaushalmahi12 2605a35
Merge branch 'main' into feature/sandbox-qgTaskHeaders
kaushalmahi12 31ca5cc
Merge branch 'main' into feature/sandbox-qgTaskHeaders
kaushalmahi12 4940dcf
address comments
kaushalmahi12 191a860
fix UT to remove the verify for final method
kaushalmahi12 cdd61bf
apply spotless
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
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
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
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
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
76 changes: 76 additions & 0 deletions
76
server/src/main/java/org/opensearch/wlm/QueryGroupTask.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,76 @@ | ||
| /* | ||
| * 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.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
| import org.opensearch.common.unit.TimeValue; | ||
| import org.opensearch.common.util.concurrent.ThreadContext; | ||
| import org.opensearch.core.tasks.TaskId; | ||
| import org.opensearch.tasks.CancellableTask; | ||
|
|
||
| import java.util.Map; | ||
| import java.util.Optional; | ||
| import java.util.function.Supplier; | ||
|
|
||
| import static org.opensearch.search.SearchService.NO_TIMEOUT; | ||
|
|
||
| /** | ||
| * Base class to define QueryGroup tasks | ||
| */ | ||
| public class QueryGroupTask extends CancellableTask { | ||
kaushalmahi12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| private static final Logger logger = LogManager.getLogger(QueryGroupTask.class); | ||
| public static final String QUERY_GROUP_ID_HEADER = "queryGroupId"; | ||
| public static final Supplier<String> DEFAULT_QUERY_GROUP_ID_SUPPLIER = () -> "DEFAULT_QUERY_GROUP"; | ||
| private String queryGroupId; | ||
|
|
||
| public QueryGroupTask(long id, String type, String action, String description, TaskId parentTaskId, Map<String, String> headers) { | ||
| this(id, type, action, description, parentTaskId, headers, NO_TIMEOUT); | ||
| } | ||
|
|
||
| public QueryGroupTask( | ||
| long id, | ||
| String type, | ||
| String action, | ||
| String description, | ||
| TaskId parentTaskId, | ||
| Map<String, String> headers, | ||
| TimeValue cancelAfterTimeInterval | ||
| ) { | ||
| super(id, type, action, description, parentTaskId, headers, cancelAfterTimeInterval); | ||
| } | ||
|
|
||
| /** | ||
| * This method should always be called after calling setQueryGroupId at least once on this object | ||
| * @return task queryGroupId | ||
| */ | ||
| public final String getQueryGroupId() { | ||
| if (queryGroupId == null) { | ||
| logger.warn("QueryGroup _id can't be null, It should be set before accessing it. This is abnormal behaviour "); | ||
kaushalmahi12 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| return queryGroupId; | ||
| } | ||
|
|
||
| /** | ||
| * sets the queryGroupId from threadContext into the task itself, | ||
| * This method was defined since the queryGroupId can only be evaluated after task creation | ||
| * @param threadContext current threadContext | ||
| */ | ||
| public final void setQueryGroupId(final ThreadContext threadContext) { | ||
| this.queryGroupId = Optional.ofNullable(threadContext) | ||
| .map(threadContext1 -> threadContext1.getHeader(QUERY_GROUP_ID_HEADER)) | ||
| .orElse(DEFAULT_QUERY_GROUP_ID_SUPPLIER.get()); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean shouldCancelChildrenOnCancellation() { | ||
| return false; | ||
| } | ||
| } | ||
64 changes: 64 additions & 0 deletions
64
server/src/main/java/org/opensearch/wlm/WorkloadManagementTransportInterceptor.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,64 @@ | ||
| /* | ||
| * 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.tasks.Task; | ||
| import org.opensearch.threadpool.ThreadPool; | ||
| import org.opensearch.transport.TransportChannel; | ||
| import org.opensearch.transport.TransportInterceptor; | ||
| import org.opensearch.transport.TransportRequest; | ||
| import org.opensearch.transport.TransportRequestHandler; | ||
|
|
||
| /** | ||
| * This class is used to intercept search traffic requests and populate the queryGroupId header in task headers | ||
| */ | ||
| public class WorkloadManagementTransportInterceptor implements TransportInterceptor { | ||
| private final ThreadPool threadPool; | ||
|
|
||
| public WorkloadManagementTransportInterceptor(ThreadPool threadPool) { | ||
| this.threadPool = threadPool; | ||
| } | ||
|
|
||
| @Override | ||
| public <T extends TransportRequest> TransportRequestHandler<T> interceptHandler( | ||
| String action, | ||
| String executor, | ||
| boolean forceExecution, | ||
| TransportRequestHandler<T> actualHandler | ||
| ) { | ||
| return new RequestHandler<T>(threadPool, actualHandler); | ||
| } | ||
|
|
||
| /** | ||
| * This class is mainly used to populate the queryGroupId header | ||
| * @param <T> T is Search related request | ||
| */ | ||
| public static class RequestHandler<T extends TransportRequest> implements TransportRequestHandler<T> { | ||
|
|
||
| private final ThreadPool threadPool; | ||
| TransportRequestHandler<T> actualHandler; | ||
|
|
||
| public RequestHandler(ThreadPool threadPool, TransportRequestHandler<T> actualHandler) { | ||
| this.threadPool = threadPool; | ||
| this.actualHandler = actualHandler; | ||
| } | ||
|
|
||
| @Override | ||
| public void messageReceived(T request, TransportChannel channel, Task task) throws Exception { | ||
| if (isSearchWorkloadRequest(task)) { | ||
| ((QueryGroupTask) task).setQueryGroupId(threadPool.getThreadContext()); | ||
| } | ||
| actualHandler.messageReceived(request, channel, task); | ||
| } | ||
|
|
||
| boolean isSearchWorkloadRequest(Task task) { | ||
| return task instanceof QueryGroupTask; | ||
| } | ||
| } | ||
| } |
44 changes: 44 additions & 0 deletions
44
server/src/test/java/org/opensearch/wlm/QueryGroupTaskTests.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,44 @@ | ||
| /* | ||
| * 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 org.opensearch.threadpool.TestThreadPool; | ||
| import org.opensearch.threadpool.ThreadPool; | ||
|
|
||
| import java.util.Collections; | ||
|
|
||
| import static org.opensearch.wlm.QueryGroupTask.DEFAULT_QUERY_GROUP_ID_SUPPLIER; | ||
| import static org.opensearch.wlm.QueryGroupTask.QUERY_GROUP_ID_HEADER; | ||
|
|
||
| public class QueryGroupTaskTests extends OpenSearchTestCase { | ||
| private ThreadPool threadPool; | ||
| private QueryGroupTask sut; | ||
|
|
||
| public void setUp() throws Exception { | ||
| super.setUp(); | ||
| threadPool = new TestThreadPool(getTestName()); | ||
| sut = new QueryGroupTask(123, "transport", "Search", "test task", null, Collections.emptyMap()); | ||
| } | ||
|
|
||
| public void tearDown() throws Exception { | ||
| super.tearDown(); | ||
| threadPool.shutdown(); | ||
| } | ||
|
|
||
| public void testSuccessfulSetQueryGroupId() { | ||
| sut.setQueryGroupId(threadPool.getThreadContext()); | ||
| assertEquals(DEFAULT_QUERY_GROUP_ID_SUPPLIER.get(), sut.getQueryGroupId()); | ||
|
|
||
| threadPool.getThreadContext().putHeader(QUERY_GROUP_ID_HEADER, "akfanglkaglknag2332"); | ||
|
|
||
| sut.setQueryGroupId(threadPool.getThreadContext()); | ||
| assertEquals("akfanglkaglknag2332", sut.getQueryGroupId()); | ||
| } | ||
| } |
40 changes: 40 additions & 0 deletions
40
server/src/test/java/org/opensearch/wlm/WorkloadManagementTransportInterceptorTests.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,40 @@ | ||
| /* | ||
| * 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 org.opensearch.threadpool.TestThreadPool; | ||
| import org.opensearch.threadpool.ThreadPool; | ||
| import org.opensearch.transport.TransportRequest; | ||
| import org.opensearch.transport.TransportRequestHandler; | ||
| import org.opensearch.wlm.WorkloadManagementTransportInterceptor.RequestHandler; | ||
|
|
||
| import static org.opensearch.threadpool.ThreadPool.Names.SAME; | ||
|
|
||
| public class WorkloadManagementTransportInterceptorTests extends OpenSearchTestCase { | ||
|
|
||
| private ThreadPool threadPool; | ||
| private WorkloadManagementTransportInterceptor sut; | ||
|
|
||
| public void setUp() throws Exception { | ||
| super.setUp(); | ||
| threadPool = new TestThreadPool(getTestName()); | ||
| sut = new WorkloadManagementTransportInterceptor(threadPool); | ||
| } | ||
|
|
||
| public void tearDown() throws Exception { | ||
| super.tearDown(); | ||
| threadPool.shutdown(); | ||
| } | ||
|
|
||
| public void testInterceptHandler() { | ||
| TransportRequestHandler<TransportRequest> requestHandler = sut.interceptHandler("Search", SAME, false, null); | ||
| assertTrue(requestHandler instanceof RequestHandler); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
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.