@InterfaceStability.Evolving public interface ProcessorContext
Modifier and Type | Method and Description |
---|---|
Map<String,Object> |
appConfigs()
Returns all the application config properties as key/value pairs.
|
Map<String,Object> |
appConfigsWithPrefix(String prefix)
Returns all the application config properties with the given key prefix, as key/value pairs
stripping the prefix.
|
String |
applicationId()
Returns the application id
|
void |
commit()
Requests a commit
|
<K,V> void |
forward(K key,
V value)
Forwards a key/value pair to the downstream processors
|
<K,V> void |
forward(K key,
V value,
int childIndex)
Forwards a key/value pair to one of the downstream processors designated by childIndex
|
<K,V> void |
forward(K key,
V value,
String childName)
Forwards a key/value pair to one of the downstream processors designated by the downstream processor name
|
StateStore |
getStateStore(String name)
Get the state store given the store name.
|
Serde<?> |
keySerde()
Returns the default key serde
|
StreamsMetrics |
metrics()
Returns Metrics instance
|
long |
offset()
Returns the offset of the current input record; could be -1 if it is not
available (for example, if this method is invoked from the punctuate call)
|
int |
partition()
Returns the partition id of the current input record; could be -1 if it is not
available (for example, if this method is invoked from the punctuate call)
|
void |
register(StateStore store,
boolean loggingEnabled,
StateRestoreCallback stateRestoreCallback)
Registers and possibly restores the specified storage engine.
|
void |
schedule(long interval)
Deprecated.
Please use
schedule(long, PunctuationType, Punctuator) instead. |
Cancellable |
schedule(long interval,
PunctuationType type,
Punctuator callback)
Schedules a periodic operation for processors.
|
File |
stateDir()
Returns the state directory for the partition.
|
TaskId |
taskId()
Returns the task id
|
long |
timestamp()
Returns the current timestamp.
|
String |
topic()
Returns the topic name of the current input record; could be null if it is not
available (for example, if this method is invoked from the punctuate call)
|
Serde<?> |
valueSerde()
Returns the default value serde
|
String applicationId()
TaskId taskId()
Serde<?> keySerde()
Serde<?> valueSerde()
File stateDir()
StreamsMetrics metrics()
void register(StateStore store, boolean loggingEnabled, StateRestoreCallback stateRestoreCallback)
store
- the storage engineStateStore getStateStore(String name)
name
- The store nameCancellable schedule(long interval, PunctuationType type, Punctuator callback)
initialization
or
processing
to
schedule a periodic callback - called a punctuation - to Punctuator.punctuate(long)
.
The type parameter controls what notion of time is used for punctuation:
PunctuationType.STREAM_TIME
- uses "stream time", which is advanced by the processing of messages
in accordance with the timestamp as extracted by the TimestampExtractor
in use.
NOTE: Only advanced if messages arrivePunctuationType.SYSTEM_TIME
- uses system time (the wall-clock time),
which is advanced at the polling interval (StreamsConfig.POLL_MS_CONFIG
)
independent of whether new messages arrive. NOTE: This is best effort only as its granularity is limited
by how long an iteration of the processing loop takes to completeinterval
- the time interval between punctuationstype
- one of: PunctuationType.STREAM_TIME
, PunctuationType.SYSTEM_TIME
callback
- a function consuming timestamps representing the current stream or system time@Deprecated void schedule(long interval)
schedule(long, PunctuationType, Punctuator)
instead.initialization
to
schedule a periodic call - called a punctuation - to Processor.punctuate(long)
.interval
- the time interval between punctuations<K,V> void forward(K key, V value)
key
- keyvalue
- value<K,V> void forward(K key, V value, int childIndex)
key
- keyvalue
- valuechildIndex
- index in list of children of this node<K,V> void forward(K key, V value, String childName)
key
- keyvalue
- valuechildName
- name of downstream processorvoid commit()
String topic()
int partition()
long offset()
long timestamp()
ConsumerRecord
by TimestampExtractor
.
If it is triggered while processing a record generated not from the source processor (for example,
if this method is invoked from the punctuate call), timestamp is defined as the current
task's stream time, which is defined as the smallest among all its input stream partition timestamps.Map<String,Object> appConfigs()
StreamsConfig
object and associated to the ProcessorContext.Map<String,Object> appConfigsWithPrefix(String prefix)
StreamsConfig
object and associated to the ProcessorContext.prefix
- the properties prefix