public interface TaskCoordinator
StreamTask
implementations
to allow the user code to request actions from the Samza framework, including committing the current checkpoints
to configured org.apache.samza.checkpoint.CheckpointManager or shutting down the task or all tasks within
a container.
This interface may evolve over time.
Modifier and Type | Interface and Description |
---|---|
static class |
TaskCoordinator.RequestScope
A task can make requests to the Samza framework while processing messages, such as
commit(RequestScope) and
shutdown(RequestScope) . |
Modifier and Type | Method and Description |
---|---|
void |
commit(TaskCoordinator.RequestScope scope)
Requests that Samza should write out a checkpoint, from which a task can restart
after failure.
|
void |
shutdown(TaskCoordinator.RequestScope scope)
Requests that the container should be shut down.
|
void commit(TaskCoordinator.RequestScope scope)
If CURRENT_TASK
is given, a checkpoint is only written for the
current task. If ALL_TASKS_IN_CONTAINER
is given, a checkpoint is
written for all tasks in the current container.
Note that if you also have also configured your job to commit in regular
intervals (using the task.commit.ms
property), those time-based
commits are not affected by calling this method. Any commits you request explicitly
are in addition to timer-based commits. You can set task.commit.ms=-1
if you don't want commits to happen automatically.
scope
- Which tasks are being asked to commit.void shutdown(TaskCoordinator.RequestScope scope)
If CURRENT_TASK
is given, that indicates a willingness of the current
task to shut down. All tasks in the container (including the one that requested
shutdown) will continue processing messages. Only when every task in the container
has called shutdown(CURRENT_TASK)
, the container is shut down. Once a
task has called shutdown(CURRENT_TASK)
, it cannot change its mind
(i.e. it cannot revoke its willingness to shut down).
If ALL_TASKS_IN_CONTAINER
is given, the container will shut down
immediately after it has finished processing the current message. Any buffers of
pending writes are flushed, but no further messages will be processed in this
container.
scope
- The approach we should use for shutting down the container.