-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Optimize overlord GET /tasks memory usage #12404
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
abhishekagarwal87
merged 22 commits into
apache:master
from
AmatyaAvadhanula:feature-optimize_memory_getTasks_overlord
Jun 16, 2022
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
40e479e
Optimize overlord GET /tasks memory usage
AmatyaAvadhanula 98fca66
Use extra columns for better perf
AmatyaAvadhanula bf8e8c5
Migration in thread, determining strategy for sql fetch
AmatyaAvadhanula c784c3a
Fix existing unit tests
AmatyaAvadhanula d0d7f12
Merge remote-tracking branch 'upstream/master' into feature-optimize_…
AmatyaAvadhanula 74fac09
SQLMetadataConnector migration fix and tests
AmatyaAvadhanula c436ba5
Refactoring
AmatyaAvadhanula 71b2a4a
Add test
AmatyaAvadhanula 843a32d
Fix bug, refactor etc
AmatyaAvadhanula 4807b13
trivial tests for coverage
AmatyaAvadhanula 07ead45
Merge remote-tracking branch 'upstream/master' into feature-optimize_…
AmatyaAvadhanula 082d0c3
Possible fix for integration tests
AmatyaAvadhanula 3a91ce8
Merge remote-tracking branch 'upstream/master' into feature-optimize_…
AmatyaAvadhanula 731caab
Merge remote-tracking branch 'upstream/master' into feature-optimize_…
AmatyaAvadhanula a5bafe7
Cleanup OverlordResourceTest
kfaraz e2b9e93
Address review
AmatyaAvadhanula cb919a3
Merge remote-tracking branch 'origin/feature-optimize_memory_getTasks…
AmatyaAvadhanula 48e8a89
Address review
AmatyaAvadhanula 127fc88
Merge remote-tracking branch 'upstream/master' into feature-optimize_…
AmatyaAvadhanula 402dd12
Incorporate feedback
AmatyaAvadhanula aa82787
Refactor for cleaner API
AmatyaAvadhanula f1c1151
migration at startup and fix checkstyle
AmatyaAvadhanula 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
110 changes: 110 additions & 0 deletions
110
core/src/main/java/org/apache/druid/indexer/TaskIdentifier.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,110 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
|
|
||
| package org.apache.druid.indexer; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonCreator; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.google.common.base.Preconditions; | ||
|
|
||
| import javax.annotation.Nullable; | ||
| import java.util.Objects; | ||
|
|
||
| /** | ||
| * Model class containing the id, type and groupId of a task | ||
| * These fields are extracted from the task payload for the new schema and this model can be used for migration as well. | ||
| */ | ||
| public class TaskIdentifier | ||
| { | ||
|
|
||
| private final String id; | ||
|
|
||
| @Nullable | ||
| private final String type; | ||
|
|
||
| @Nullable | ||
| private final String groupId; | ||
|
|
||
| @JsonCreator | ||
| public TaskIdentifier( | ||
| @JsonProperty("id") String id, | ||
| @JsonProperty("groupId") @Nullable String groupId, | ||
| @JsonProperty("type") @Nullable String type // nullable for backward compatibility | ||
| ) | ||
| { | ||
| this.id = Preconditions.checkNotNull(id, "id"); | ||
| this.groupId = groupId; | ||
| this.type = type; | ||
| } | ||
|
|
||
| @JsonProperty | ||
| public String getId() | ||
| { | ||
| return id; | ||
| } | ||
|
|
||
| @Nullable | ||
| @JsonProperty | ||
| public String getGroupId() | ||
| { | ||
| return groupId; | ||
| } | ||
|
|
||
| @Nullable | ||
| @JsonProperty | ||
| public String getType() | ||
| { | ||
| return type; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) | ||
| { | ||
| if (this == o) { | ||
| return true; | ||
| } | ||
| if (o == null || getClass() != o.getClass()) { | ||
| return false; | ||
| } | ||
| TaskIdentifier that = (TaskIdentifier) o; | ||
| return Objects.equals(getId(), that.getId()) && | ||
| Objects.equals(getGroupId(), that.getGroupId()) && | ||
| Objects.equals(getType(), that.getType()); | ||
| } | ||
|
|
||
| @Override | ||
| public int hashCode() | ||
| { | ||
| return Objects.hash( | ||
| getId(), | ||
| getGroupId(), | ||
| getType() | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() | ||
| { | ||
| return "TaskIdentifier{" + | ||
| "id='" + id + '\'' + | ||
| ", groupId='" + groupId + '\'' + | ||
| ", type='" + type + '\'' + | ||
| '}'; | ||
| } | ||
| } |
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,8 @@ | |
| import com.fasterxml.jackson.annotation.JsonSubTypes; | ||
| import com.fasterxml.jackson.annotation.JsonSubTypes.Type; | ||
| import com.fasterxml.jackson.annotation.JsonTypeInfo; | ||
| import org.apache.druid.indexer.TaskIdentifier; | ||
| import org.apache.druid.indexer.TaskInfo; | ||
| import org.apache.druid.indexer.TaskStatus; | ||
| import org.apache.druid.indexing.common.TaskToolbox; | ||
| import org.apache.druid.indexing.common.actions.TaskActionClient; | ||
|
|
@@ -241,4 +243,20 @@ default <ContextValueType> ContextValueType getContextValue(String key, ContextV | |
| final ContextValueType value = getContextValue(key); | ||
| return value == null ? defaultValue : value; | ||
| } | ||
|
|
||
| default TaskIdentifier getMetadata() | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Rename to |
||
| { | ||
| return new TaskIdentifier(this.getId(), this.getGroupId(), this.getType()); | ||
| } | ||
|
|
||
| static TaskInfo<TaskIdentifier, TaskStatus> toTaskIdentifierInfo(TaskInfo<Task, TaskStatus> taskInfo) | ||
| { | ||
| return new TaskInfo<>( | ||
| taskInfo.getId(), | ||
| taskInfo.getCreatedTime(), | ||
| taskInfo.getStatus(), | ||
| taskInfo.getDataSource(), | ||
| taskInfo.getTask().getMetadata() | ||
| ); | ||
| } | ||
| } | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: These arguments should probably come earlier, maybe right after
id.