public class RemoteTaskRunner extends Object implements WorkerTaskRunner, TaskLogStreamer
The RemoteTaskRunner will assign tasks to a node until the node hits capacity. At that point, task assignment will fail. The RemoteTaskRunner depends on another component to create additional worker resources.
If a worker node becomes inexplicably disconnected from Zk, the RemoteTaskRunner will fail any tasks associated with the worker after waiting for RemoteTaskRunnerConfig.taskCleanupTimeout for the worker to show up.
The RemoteTaskRunner uses ZK for job management and assignment and http for IPC messages.
Constructor and Description |
---|
RemoteTaskRunner(com.fasterxml.jackson.databind.ObjectMapper jsonMapper,
RemoteTaskRunnerConfig config,
IndexerZkConfig indexerZkConfig,
org.apache.curator.framework.CuratorFramework cf,
PathChildrenCacheFactory.Builder pathChildrenCacheFactory,
com.metamx.http.client.HttpClient httpClient,
com.google.common.base.Supplier<WorkerBehaviorConfig> workerConfigRef,
ScheduledExecutorService cleanupExec,
ResourceManagementStrategy<WorkerTaskRunner> resourceManagement) |
Modifier and Type | Method and Description |
---|---|
void |
cleanBlackListedNode(ZkWorker zkWorker,
long currentTimeStamp) |
ZkWorker |
findWorkerRunningTask(String taskId) |
protected List<String> |
getAssignedTasks(Worker worker) |
Collection<ImmutableWorkerInfo> |
getBlackListedWorkers() |
RemoteTaskRunnerConfig |
getConfig() |
Collection<RemoteTaskRunnerWorkItem> |
getKnownTasks() |
Collection<Worker> |
getLazyWorkers()
Return a list of workers who can be reaped by autoscaling
|
Collection<Task> |
getPendingTaskPayloads() |
Collection<RemoteTaskRunnerWorkItem> |
getPendingTasks() |
Collection<RemoteTaskRunnerWorkItem> |
getRunningTasks() |
com.google.common.base.Optional<ScalingStats> |
getScalingStats()
Some runners are able to scale up and down their capacity in a dynamic manner.
|
static Collection<Worker> |
getWorkerFromZK(Collection<ZkWorker> workers) |
Collection<ImmutableWorkerInfo> |
getWorkers()
List of known workers who can accept tasks
|
boolean |
isWorkerRunningTask(Worker worker,
String taskId) |
Collection<Worker> |
markWorkersLazy(com.google.common.base.Predicate<ImmutableWorkerInfo> isLazyWorker,
int maxWorkers)
Check which workers can be marked as lazy
|
void |
registerListener(TaskRunnerListener listener,
Executor executor)
Register a listener with this task runner.
|
List<Pair<Task,com.google.common.util.concurrent.ListenableFuture<TaskStatus>>> |
restore()
Some task runners can restart previously-running tasks after being bounced.
|
com.google.common.util.concurrent.ListenableFuture<TaskStatus> |
run(Task task)
A task will be run only if there is no current knowledge in the RemoteTaskRunner of the task.
|
void |
shutdown(String taskId)
Finds the worker running the task and forwards the shutdown signal to the worker.
|
void |
start()
Start the state of the runner
|
void |
stop()
Stop this task runner.
|
com.google.common.base.Optional<com.google.common.io.ByteSource> |
streamTaskLog(String taskId,
long offset)
Stream log for a task.
|
void |
unregisterListener(String listenerId) |
public RemoteTaskRunner(com.fasterxml.jackson.databind.ObjectMapper jsonMapper, RemoteTaskRunnerConfig config, IndexerZkConfig indexerZkConfig, org.apache.curator.framework.CuratorFramework cf, PathChildrenCacheFactory.Builder pathChildrenCacheFactory, com.metamx.http.client.HttpClient httpClient, com.google.common.base.Supplier<WorkerBehaviorConfig> workerConfigRef, ScheduledExecutorService cleanupExec, ResourceManagementStrategy<WorkerTaskRunner> resourceManagement)
public void start()
TaskRunner
start
in interface TaskRunner
public void stop()
TaskRunner
stop
in interface TaskRunner
public List<Pair<Task,com.google.common.util.concurrent.ListenableFuture<TaskStatus>>> restore()
TaskRunner
restore
in interface TaskRunner
public void registerListener(TaskRunnerListener listener, Executor executor)
TaskRunner
registerListener
in interface TaskRunner
listener
- the listenerexecutor
- executor to run callbacks inpublic void unregisterListener(String listenerId)
unregisterListener
in interface TaskRunner
public Collection<ImmutableWorkerInfo> getWorkers()
WorkerTaskRunner
getWorkers
in interface WorkerTaskRunner
public Collection<RemoteTaskRunnerWorkItem> getRunningTasks()
getRunningTasks
in interface TaskRunner
public Collection<RemoteTaskRunnerWorkItem> getPendingTasks()
getPendingTasks
in interface TaskRunner
public Collection<Task> getPendingTaskPayloads()
getPendingTaskPayloads
in interface WorkerTaskRunner
public RemoteTaskRunnerConfig getConfig()
getConfig
in interface WorkerTaskRunner
public Collection<RemoteTaskRunnerWorkItem> getKnownTasks()
getKnownTasks
in interface TaskRunner
public com.google.common.base.Optional<ScalingStats> getScalingStats()
TaskRunner
getScalingStats
in interface TaskRunner
public com.google.common.util.concurrent.ListenableFuture<TaskStatus> run(Task task)
run
in interface TaskRunner
task
- task to runpublic void shutdown(String taskId)
shutdown
in interface TaskRunner
taskId
- - task id to shutdownpublic com.google.common.base.Optional<com.google.common.io.ByteSource> streamTaskLog(String taskId, long offset)
TaskLogStreamer
streamTaskLog
in interface TaskLogStreamer
offset
- If zero, stream the entire log. If positive, attempt to read from this position onwards. If
negative, attempt to read this many bytes from the end of the file (like tail -n).public void cleanBlackListedNode(ZkWorker zkWorker, long currentTimeStamp)
public Collection<Worker> markWorkersLazy(com.google.common.base.Predicate<ImmutableWorkerInfo> isLazyWorker, int maxWorkers)
WorkerTaskRunner
markWorkersLazy
in interface WorkerTaskRunner
protected List<String> getAssignedTasks(Worker worker) throws Exception
Exception
public Collection<Worker> getLazyWorkers()
WorkerTaskRunner
getLazyWorkers
in interface WorkerTaskRunner
public static Collection<Worker> getWorkerFromZK(Collection<ZkWorker> workers)
public Collection<ImmutableWorkerInfo> getBlackListedWorkers()
Copyright © 2011–2017. All rights reserved.