public abstract class BackgroundTask extends Object
| Constructor and Description |
|---|
BackgroundTask() |
| Modifier and Type | Method and Description |
|---|---|
void |
addTask(TaskState taskState,
TaskConfiguration configuration)
Submit a new task for execution
|
TaskConfiguration |
configuration()
Get the configuration needed to execute the task
|
GraknEngineConfig |
engineConfiguration() |
EngineGraknGraphFactory |
factory() |
void |
initialize(java.util.function.Consumer<TaskCheckpoint> saveCheckpoint,
TaskConfiguration configuration,
TaskSubmitter taskSubmitter,
GraknEngineConfig engineConfig,
RedisConnection redis,
EngineGraknGraphFactory factory)
Initialize the
BackgroundTask. |
void |
pause()
Called to suspend the execution of a currently running task.
|
RedisConnection |
redis() |
boolean |
resume(TaskCheckpoint lastCheckpoint)
This method may be called when resuming from a paused state or recovering from a crash or failure of any kind.
|
void |
saveCheckpoint(TaskCheckpoint checkpoint) |
abstract boolean |
start()
Called to start execution of the task, may be called on a newly scheduled or previously stopped task.
|
boolean |
stop()
Called to stop execution of the task, may be called on a running or paused task.
|
public final void initialize(java.util.function.Consumer<TaskCheckpoint> saveCheckpoint, TaskConfiguration configuration, TaskSubmitter taskSubmitter, GraknEngineConfig engineConfig, RedisConnection redis, EngineGraknGraphFactory factory)
BackgroundTask. This must be called prior to any other call to BackgroundTask.saveCheckpoint - Consumerconfiguration - The configuration needed to execute the tasktaskSubmitter - Allows followup tasks to be submitted for processingpublic abstract boolean start()
public boolean stop()
This implementation always throws UnsupportedOperationException.
UnsupportedOperationException - if stopping the task is not supported
TODO: Should we allow start() to be called after stop()?public void pause()
This implementation always throws UnsupportedOperationException.
UnsupportedOperationException - if pausing the task is not supported
TODO: stop runningpublic boolean resume(TaskCheckpoint lastCheckpoint)
This implementation always throws UnsupportedOperationException.
lastCheckpoint - The last checkpoint as sent to saveCheckpoint.UnsupportedOperationException - if resuming the task is not supportedpublic final void saveCheckpoint(TaskCheckpoint checkpoint)
public final void addTask(TaskState taskState, TaskConfiguration configuration)
taskState - state describing the taskpublic final TaskConfiguration configuration()
public final GraknEngineConfig engineConfiguration()
public final RedisConnection redis()
public final EngineGraknGraphFactory factory()
Copyright © 2017 Grakn Labs Ltd. All rights reserved.