public class SingleQueueTaskRunner extends Object implements Runnable, AutoCloseable
SingleQueueTaskRunner is used by the SingleQueueTaskManager to execute tasks from a Kafka queue.| Constructor and Description |
|---|
SingleQueueTaskRunner(SingleQueueTaskManager manager,
EngineID engineID,
GraknEngineConfig config,
RedisConnection redis,
EngineGraknGraphFactory factory,
ExternalOffsetStorage offsetStorage,
org.apache.kafka.clients.consumer.Consumer<TaskState,TaskConfiguration> consumer)
Create a
SingleQueueTaskRunner which retrieves tasks from the given and uses the given
to store and retrieve information about tasks. |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close connection to Kafka and thread pool.
|
void |
run()
Poll Kafka for any new tasks.
|
boolean |
stopTask(TaskId taskId)
Stop the task if it is executing on this machine
|
public SingleQueueTaskRunner(SingleQueueTaskManager manager, EngineID engineID, GraknEngineConfig config, RedisConnection redis, EngineGraknGraphFactory factory, ExternalOffsetStorage offsetStorage, org.apache.kafka.clients.consumer.Consumer<TaskState,TaskConfiguration> consumer)
SingleQueueTaskRunner which retrieves tasks from the given and uses the given
to store and retrieve information about tasks.engineID - identifier of the engine this task runner is onmanager - a place to control the lifecycle of tasksoffsetStorage - a place to externally store kafka offsetspublic void run()
close() is called.
After receiving tasks, accept as many as possible, up to the maximum allowed number of tasks.
For each task, follow the workflow based on its type:
- If not created or not in storage:
- Record that this engine is running this task
Record that this task is running
- Send to thread pool for execution:
- Use reflection to retrieve task
- Start from checkpoint if necessary, or from beginning (TODO)
- Record that this engine is no longer running this task
Mark as completed or failed
- Acknowledge message in queuepublic void close()
throws Exception
run() method to stop and block until it returns.close in interface AutoCloseableExceptionpublic boolean stopTask(TaskId taskId)
taskId - Identifier of the task to stopCopyright © 2017 Grakn Labs Ltd. All rights reserved.