-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Use Worker instead of ZkWorker whenever possible #2249
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
Merged
Changes from all commits
Commits
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
47 changes: 47 additions & 0 deletions
47
indexing-service/src/main/java/io/druid/indexing/overlord/WorkerTaskRunner.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,47 @@ | ||
| /* | ||
| * Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. Metamarkets 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 io.druid.indexing.overlord; | ||
|
|
||
| import com.google.common.base.Predicate; | ||
| import io.druid.indexing.worker.Worker; | ||
|
|
||
| import java.util.Collection; | ||
|
|
||
| public interface WorkerTaskRunner extends TaskRunner | ||
| { | ||
| /** | ||
| * List of known workers who can accept tasks | ||
| * @return A list of workers who can accept tasks for running | ||
| */ | ||
| Collection<Worker> getWorkers(); | ||
|
|
||
| /** | ||
| * Return a list of workers who can be reaped by autoscaling | ||
| * @return Workers which can be reaped by autoscaling | ||
| */ | ||
| Collection<Worker> getLazyWorkers(); | ||
|
|
||
| /** | ||
| * Check which workers can be marked as lazy | ||
| * @param isLazyWorker | ||
| * @param maxWorkers | ||
| * @return | ||
| */ | ||
| Collection<Worker> markWorkersLazy(Predicate<Worker> isLazyWorker, int maxWorkers); | ||
| } |
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 |
|---|---|---|
|
|
@@ -50,7 +50,6 @@ public class ZkWorker implements Closeable | |
| private final Function<ChildData, TaskAnnouncement> cacheConverter; | ||
|
|
||
| private AtomicReference<Worker> worker; | ||
| private AtomicReference<DateTime> lastCompletedTaskTime = new AtomicReference<DateTime>(new DateTime()); | ||
|
|
||
| public ZkWorker(Worker worker, PathChildrenCache statusCache, final ObjectMapper jsonMapper) | ||
| { | ||
|
|
@@ -129,7 +128,7 @@ public Set<String> getAvailabilityGroups() | |
| @JsonProperty | ||
| public DateTime getLastCompletedTaskTime() | ||
| { | ||
| return lastCompletedTaskTime.get(); | ||
| return worker.get().getLastCompletedTaskTime(); | ||
|
Member
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. can't see the variable lastCompletedTaskTime getting deleted ?
Contributor
Author
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. Class field was leftover value that was accidentally used in toString, removed |
||
| } | ||
|
|
||
| public boolean isRunningTask(String taskId) | ||
|
|
@@ -139,7 +138,7 @@ public boolean isRunningTask(String taskId) | |
|
|
||
| public boolean isValidVersion(String minVersion) | ||
| { | ||
| return worker.get().getVersion().compareTo(minVersion) >= 0; | ||
| return worker.get().isValidVersion(minVersion); | ||
| } | ||
|
|
||
| public void setWorker(Worker newWorker) | ||
|
|
@@ -153,7 +152,7 @@ public void setWorker(Worker newWorker) | |
|
|
||
| public void setLastCompletedTaskTime(DateTime completedTaskTime) | ||
| { | ||
| lastCompletedTaskTime.set(completedTaskTime); | ||
| worker.get().setLastCompletedTaskTime(completedTaskTime); | ||
| } | ||
|
|
||
| public ImmutableZkWorker toImmutable() | ||
|
|
@@ -172,7 +171,6 @@ public String toString() | |
| { | ||
| return "ZkWorker{" + | ||
| "worker=" + worker + | ||
| ", lastCompletedTaskTime=" + lastCompletedTaskTime + | ||
| '}'; | ||
| } | ||
| } | ||
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.
@drcrallen this change made the overlord
/druid/indexer/v1/workersAPI no longer return arunningTaskskey for each worker, which may confuse some folks' rolling update scripts and definitely makes the web UI less useful.how do you feel about having the OverlordResource specifically call
getZkWorkersif the runner is an RTR? or would it make more sense to add a list of running tasks to the Worker object?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.
((spoke in chat)) since io.druid.indexing.overlord.http.OverlordResource#getWorkers already special-cases the RTR, suggest making it get zk workers in that case until a more complete solution can be put in place.