Class ProcessorContextImpl
- java.lang.Object
-
- org.apache.kafka.streams.processor.internals.AbstractProcessorContext
-
- org.apache.kafka.streams.processor.internals.ProcessorContextImpl
-
- All Implemented Interfaces:
InternalProcessorContext
,RecordCollector.Supplier
,ProcessorContext
public class ProcessorContextImpl extends AbstractProcessorContext implements RecordCollector.Supplier
-
-
Field Summary
-
Fields inherited from class org.apache.kafka.streams.processor.internals.AbstractProcessorContext
currentNode, NONEXIST_TOPIC, recordContext
-
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
commit()
Requests a commit<K,V>
voidforward(K key, V value)
Forwards a key/value pair to all downstream processors.<K,V>
voidforward(K key, V value, int childIndex)
Forwards a key/value pair to one of the downstream processors designated by childIndex<K,V>
voidforward(K key, V value, java.lang.String childName)
Forwards a key/value pair to one of the downstream processors designated by the downstream processor name<K,V>
voidforward(K key, V value, To to)
Forwards a key/value pair to the specified downstream processors.ProcessorStateManager
getStateMgr()
StateStore
getStateStore(java.lang.String name)
Get the state store given the store name.RecordCollector
recordCollector()
Get the record collector.Cancellable
schedule(long interval, PunctuationType type, Punctuator callback)
Deprecated.Cancellable
schedule(java.time.Duration interval, PunctuationType type, Punctuator callback)
Schedules a periodic operation for processors.long
streamTime()
-
Methods inherited from class org.apache.kafka.streams.processor.internals.AbstractProcessorContext
appConfigs, appConfigsWithPrefix, applicationId, applicationInternalStream, currentNode, getCache, headers, initialize, keySerde, metrics, offset, partition, recordContext, register, setCurrentNode, setRecordContext, stateDir, taskId, timestamp, topic, uninitialize, valueSerde
-
-
-
-
Method Detail
-
getStateMgr
public ProcessorStateManager getStateMgr()
-
recordCollector
public RecordCollector recordCollector()
Description copied from interface:RecordCollector.Supplier
Get the record collector.- Specified by:
recordCollector
in interfaceRecordCollector.Supplier
- Returns:
- the record collector
-
getStateStore
public StateStore getStateStore(java.lang.String name)
Description copied from interface:ProcessorContext
Get the state store given the store name.- Specified by:
getStateStore
in interfaceProcessorContext
- Parameters:
name
- The store name- Returns:
- The state store instance
- Throws:
StreamsException
- if an attempt is made to access this state store from an unknown node
-
forward
public <K,V> void forward(K key, V value)
Description copied from interface:ProcessorContext
Forwards a key/value pair to all downstream processors. Used the input record's timestamp as timestamp for the output record.- Specified by:
forward
in interfaceProcessorContext
- Parameters:
key
- keyvalue
- value
-
forward
public <K,V> void forward(K key, V value, int childIndex)
Description copied from interface:ProcessorContext
Forwards a key/value pair to one of the downstream processors designated by childIndex- Specified by:
forward
in interfaceProcessorContext
- Parameters:
key
- keyvalue
- valuechildIndex
- index in list of children of this node
-
forward
public <K,V> void forward(K key, V value, java.lang.String childName)
Description copied from interface:ProcessorContext
Forwards a key/value pair to one of the downstream processors designated by the downstream processor name- Specified by:
forward
in interfaceProcessorContext
- Parameters:
key
- keyvalue
- valuechildName
- name of downstream processor
-
forward
public <K,V> void forward(K key, V value, To to)
Description copied from interface:ProcessorContext
Forwards a key/value pair to the specified downstream processors. Can be used to set the timestamp of the output record.- Specified by:
forward
in interfaceProcessorContext
- Parameters:
key
- keyvalue
- valueto
- the options to use when forwarding
-
commit
public void commit()
Description copied from interface:ProcessorContext
Requests a commit- Specified by:
commit
in interfaceProcessorContext
-
schedule
@Deprecated public Cancellable schedule(long interval, PunctuationType type, Punctuator callback)
Deprecated.Description copied from interface:ProcessorContext
Schedules a periodic operation for processors. A processor may call this method duringinitialization
orprocessing
to schedule a periodic callback — called a punctuation — toPunctuator.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 theTimestampExtractor
in use. The first punctuation will be triggered by the first record that is processed. NOTE: Only advanced if messages arrivePunctuationType.WALL_CLOCK_TIME
— uses system time (the wall-clock time), which is advanced independent of whether new messages arrive. The first punctuation will be triggered after interval has elapsed. NOTE: This is best effort only as its granularity is limited by how long an iteration of the processing loop takes to complete
- with
PunctuationType.STREAM_TIME
, when stream time advances more than interval - with
PunctuationType.WALL_CLOCK_TIME
, on GC pause, too short interval, ...
- Specified by:
schedule
in interfaceProcessorContext
- Parameters:
interval
- the time interval between punctuations in millisecondstype
- one of:PunctuationType.STREAM_TIME
,PunctuationType.WALL_CLOCK_TIME
callback
- a function consuming timestamps representing the current stream or system time- Returns:
- a handle allowing cancellation of the punctuation schedule established by this method
-
schedule
public Cancellable schedule(java.time.Duration interval, PunctuationType type, Punctuator callback) throws java.lang.IllegalArgumentException
Description copied from interface:ProcessorContext
Schedules a periodic operation for processors. A processor may call this method duringinitialization
orprocessing
to schedule a periodic callback — called a punctuation — toPunctuator.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 theTimestampExtractor
in use. The first punctuation will be triggered by the first record that is processed. NOTE: Only advanced if messages arrivePunctuationType.WALL_CLOCK_TIME
— uses system time (the wall-clock time), which is advanced independent of whether new messages arrive. The first punctuation will be triggered after interval has elapsed. NOTE: This is best effort only as its granularity is limited by how long an iteration of the processing loop takes to complete
- with
PunctuationType.STREAM_TIME
, when stream time advances more than interval - with
PunctuationType.WALL_CLOCK_TIME
, on GC pause, too short interval, ...
- Specified by:
schedule
in interfaceProcessorContext
- Parameters:
interval
- the time interval between punctuationstype
- one of:PunctuationType.STREAM_TIME
,PunctuationType.WALL_CLOCK_TIME
callback
- a function consuming timestamps representing the current stream or system time- Returns:
- a handle allowing cancellation of the punctuation schedule established by this method
- Throws:
java.lang.IllegalArgumentException
-
streamTime
public long streamTime()
- Specified by:
streamTime
in interfaceInternalProcessorContext
-
-