public abstract class AbstractProcessorContext extends java.lang.Object implements InternalProcessorContext
Modifier and Type | Field and Description |
---|---|
protected ProcessorNode |
currentNode |
static java.lang.String |
NONEXIST_TOPIC |
protected ProcessorRecordContext |
recordContext |
Constructor and Description |
---|
AbstractProcessorContext(TaskId taskId,
StreamsConfig config,
StreamsMetricsImpl metrics,
org.apache.kafka.streams.processor.internals.StateManager stateManager,
ThreadCache cache) |
Modifier and Type | Method and Description |
---|---|
java.util.Map<java.lang.String,java.lang.Object> |
appConfigs()
Returns all the application config properties as key/value pairs.
|
java.util.Map<java.lang.String,java.lang.Object> |
appConfigsWithPrefix(java.lang.String prefix)
Returns all the application config properties with the given key prefix, as key/value pairs
stripping the prefix.
|
java.lang.String |
applicationId()
Returns the application id
|
java.lang.String |
applicationInternalStream()
Returns the application internal stream name
|
ProcessorNode |
currentNode() |
ThreadCache |
getCache()
Get the thread-global cache
|
org.apache.kafka.common.header.Headers |
headers()
Returns the headers of the current input record; could be null if it is not available
|
void |
initialize()
Mark this context as being initialized
|
org.apache.kafka.common.serialization.Serde<?> |
keySerde()
Returns the default key serde
|
StreamsMetricsImpl |
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)
|
ProcessorRecordContext |
recordContext()
Returns the current
RecordContext |
void |
register(StateStore store,
StateRestoreCallback stateRestoreCallback)
Registers and possibly restores the specified storage engine.
|
void |
setCurrentNode(ProcessorNode currentNode) |
void |
setRecordContext(ProcessorRecordContext recordContext) |
java.io.File |
stateDir()
Returns the state directory for the partition.
|
TaskId |
taskId()
Returns the task id
|
long |
timestamp()
Returns the current timestamp.
|
java.lang.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)
|
void |
uninitialize()
Mark this context as being uninitialized
|
org.apache.kafka.common.serialization.Serde<?> |
valueSerde()
Returns the default value serde
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
streamTime
commit, forward, forward, forward, forward, getStateStore, schedule, schedule
public static final java.lang.String NONEXIST_TOPIC
protected ProcessorRecordContext recordContext
protected ProcessorNode currentNode
public AbstractProcessorContext(TaskId taskId, StreamsConfig config, StreamsMetricsImpl metrics, org.apache.kafka.streams.processor.internals.StateManager stateManager, ThreadCache cache)
public java.lang.String applicationId()
ProcessorContext
applicationId
in interface ProcessorContext
public java.lang.String applicationInternalStream()
ProcessorContext
applicationInternalStream
in interface ProcessorContext
public TaskId taskId()
ProcessorContext
taskId
in interface ProcessorContext
public org.apache.kafka.common.serialization.Serde<?> keySerde()
ProcessorContext
keySerde
in interface ProcessorContext
public org.apache.kafka.common.serialization.Serde<?> valueSerde()
ProcessorContext
valueSerde
in interface ProcessorContext
public java.io.File stateDir()
ProcessorContext
stateDir
in interface ProcessorContext
public StreamsMetricsImpl metrics()
ProcessorContext
metrics
in interface InternalProcessorContext
metrics
in interface ProcessorContext
public void register(StateStore store, StateRestoreCallback stateRestoreCallback)
ProcessorContext
register
in interface ProcessorContext
store
- the storage enginestateRestoreCallback
- the restoration callback logic for log-backed state stores upon restartpublic java.lang.String topic()
ProcessorContext
topic
in interface ProcessorContext
java.lang.IllegalStateException
- if the task's record is nullpublic int partition()
ProcessorContext
partition
in interface ProcessorContext
java.lang.IllegalStateException
- if partition is nullpublic long offset()
ProcessorContext
offset
in interface ProcessorContext
java.lang.IllegalStateException
- if offset is nullpublic org.apache.kafka.common.header.Headers headers()
ProcessorContext
headers
in interface ProcessorContext
public long timestamp()
ProcessorContext
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.timestamp
in interface ProcessorContext
java.lang.IllegalStateException
- if timestamp is nullpublic java.util.Map<java.lang.String,java.lang.Object> appConfigs()
ProcessorContext
StreamsConfig
object and associated to the ProcessorContext.
The type of the values is dependent on the type
of the property
(e.g. the value of DEFAULT_KEY_SERDE_CLASS_CONFIG
will be of type Class
, even if it was specified as a String to
StreamsConfig(Map)
).
appConfigs
in interface ProcessorContext
public java.util.Map<java.lang.String,java.lang.Object> appConfigsWithPrefix(java.lang.String prefix)
ProcessorContext
StreamsConfig
object and associated to the ProcessorContext.appConfigsWithPrefix
in interface ProcessorContext
prefix
- the properties prefixpublic void setRecordContext(ProcessorRecordContext recordContext)
setRecordContext
in interface InternalProcessorContext
recordContext
- the ProcessorRecordContext
for the record about to be processespublic ProcessorRecordContext recordContext()
InternalProcessorContext
RecordContext
recordContext
in interface InternalProcessorContext
RecordContext
public void setCurrentNode(ProcessorNode currentNode)
setCurrentNode
in interface InternalProcessorContext
currentNode
- the current ProcessorNode
public ProcessorNode currentNode()
currentNode
in interface InternalProcessorContext
public ThreadCache getCache()
InternalProcessorContext
getCache
in interface InternalProcessorContext
public void initialize()
InternalProcessorContext
initialize
in interface InternalProcessorContext
public void uninitialize()
InternalProcessorContext
uninitialize
in interface InternalProcessorContext