public interface TaskContext
Use ApplicationTaskContext
for the application-defined context for the current task.
Modifier and Type | Method and Description |
---|---|
CallbackScheduler |
getCallbackScheduler()
Gets the
CallbackScheduler for this task, which can be used to schedule a callback to be executed
at a future time. |
KeyValueStore<?,?> |
getStore(java.lang.String storeName)
Gets the
KeyValueStore associated with storeName for this task. |
<K,V> ReadWriteTable<K,V> |
getTable(java.lang.String tableId)
Gets the
ReadWriteTable corresponding to the tableId for this task. |
MetricsRegistry |
getTaskMetricsRegistry()
Gets the
MetricsRegistry for this task, which can be used to register metrics that are reported per task. |
TaskModel |
getTaskModel()
Gets the
TaskModel for this task, which contains this task's name and its SystemStreamPartition s. |
<K,V,U> ReadWriteUpdateTable<K,V,U> |
getUpdatableTable(java.lang.String tableId)
Gets the
ReadWriteUpdateTable corresponding to the tableId for this task. |
void |
setStartingOffset(SystemStreamPartition systemStreamPartition,
java.lang.String offset)
Sets the starting offset for the given
SystemStreamPartition . |
TaskModel getTaskModel()
TaskModel
for this task, which contains this task's name and its SystemStreamPartition
s.TaskModel
for this taskMetricsRegistry getTaskMetricsRegistry()
MetricsRegistry
for this task, which can be used to register metrics that are reported per task.MetricsRegistry
for this taskKeyValueStore<?,?> getStore(java.lang.String storeName)
KeyValueStore
associated with storeName
for this task.
The returned store should be cast with the concrete type parameters based on the configured store serdes.
E.g., if using string key and integer value serde, it should be cast to a KeyValueStore<String, Integer>
.
storeName
- name of the KeyValueStore
to get for this taskKeyValueStore
associated with storeName
for this taskjava.lang.IllegalArgumentException
- if there is no store associated with storeName
<K,V,U> ReadWriteUpdateTable<K,V,U> getUpdatableTable(java.lang.String tableId)
ReadWriteUpdateTable
corresponding to the tableId
for this task.K
- the type of the key in this tableV
- the type of the value in this tableU
- the type of the update applied to records in this tabletableId
- id of the ReadWriteUpdateTable
to getReadWriteUpdateTable
associated with tableId
for this taskjava.lang.IllegalArgumentException
- if there is no table associated with tableId
<K,V> ReadWriteTable<K,V> getTable(java.lang.String tableId)
ReadWriteTable
corresponding to the tableId
for this task.
This is retained for backward compatibility of the API. Please prefer the use of getUpdatableTable(String)
instead as it provides the ability to do updates as well.K
- the type of the key in this tableV
- the type of the value in this tabletableId
- id of the ReadWriteTable
to getReadWriteTable
associated with tableId
for this taskjava.lang.IllegalArgumentException
- if there is no table associated with tableId
CallbackScheduler getCallbackScheduler()
CallbackScheduler
for this task, which can be used to schedule a callback to be executed
at a future time.CallbackScheduler
for this task@InterfaceStability.Evolving void setStartingOffset(SystemStreamPartition systemStreamPartition, java.lang.String offset)
SystemStreamPartition
.
Offsets can only be set for a SystemStreamPartition
assigned to this task.
The SystemStreamPartition
s assigned to this task can be accessed through
TaskModel.getSystemStreamPartitions()
for the TaskModel
obtained by calling
getTaskModel()
. Trying to set the offset for any other partition will have no effect.
NOTE: this feature is experimental, and the API may change in a future release.
systemStreamPartition
- SystemStreamPartition
whose offset should be setoffset
- to set for the given SystemStreamPartition