Class ForwardingDisabledProcessorContext

  • All Implemented Interfaces:
    ProcessorContext

    public final class ForwardingDisabledProcessorContext
    extends java.lang.Object
    implements ProcessorContext
    ProcessorContext implementation that will throw on any forward call.
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method 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
      void commit()
      Requests a commit
      <K,​V>
      void
      forward​(K key, V value)
      Forwards a key/value pair to all 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, java.lang.String childName)
      Forwards a key/value pair to one of the downstream processors designated by the downstream processor name
      <K,​V>
      void
      forward​(K key, V value, To to)
      Forwards a key/value pair to the specified downstream processors.
      StateStore getStateStore​(java.lang.String name)
      Get the state store given the store name.
      org.apache.kafka.common.header.Headers headers()
      Returns the headers of the current input record; could be null if it is not available
      org.apache.kafka.common.serialization.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, StateRestoreCallback stateRestoreCallback)
      Registers and possibly restores the specified storage engine.
      Cancellable schedule​(long intervalMs, PunctuationType type, Punctuator callback)
      Deprecated.
      Cancellable schedule​(java.time.Duration interval, PunctuationType type, Punctuator callback)
      Schedules a periodic operation for processors.
      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)
      org.apache.kafka.common.serialization.Serde<?> valueSerde()
      Returns the default value serde
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ForwardingDisabledProcessorContext

        public ForwardingDisabledProcessorContext​(ProcessorContext delegate)
    • Method Detail

      • applicationId

        public java.lang.String applicationId()
        Description copied from interface: ProcessorContext
        Returns the application id
        Specified by:
        applicationId in interface ProcessorContext
        Returns:
        the application id
      • applicationInternalStream

        public java.lang.String applicationInternalStream()
        Description copied from interface: ProcessorContext
        Returns the application internal stream name
        Specified by:
        applicationInternalStream in interface ProcessorContext
        Returns:
        the application internal stream
      • keySerde

        public org.apache.kafka.common.serialization.Serde<?> keySerde()
        Description copied from interface: ProcessorContext
        Returns the default key serde
        Specified by:
        keySerde in interface ProcessorContext
        Returns:
        the key serializer
      • valueSerde

        public org.apache.kafka.common.serialization.Serde<?> valueSerde()
        Description copied from interface: ProcessorContext
        Returns the default value serde
        Specified by:
        valueSerde in interface ProcessorContext
        Returns:
        the value serializer
      • stateDir

        public java.io.File stateDir()
        Description copied from interface: ProcessorContext
        Returns the state directory for the partition.
        Specified by:
        stateDir in interface ProcessorContext
        Returns:
        the state directory
      • register

        public void register​(StateStore store,
                             StateRestoreCallback stateRestoreCallback)
        Description copied from interface: ProcessorContext
        Registers and possibly restores the specified storage engine.
        Specified by:
        register in interface ProcessorContext
        Parameters:
        store - the storage engine
        stateRestoreCallback - the restoration callback logic for log-backed state stores upon restart
      • 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 interface ProcessorContext
        Parameters:
        name - The store name
        Returns:
        The state store instance
      • schedule

        @Deprecated
        public Cancellable schedule​(long intervalMs,
                                    PunctuationType type,
                                    Punctuator callback)
        Deprecated.
        Description copied from interface: ProcessorContext
        Schedules a periodic operation for processors. A processor may call this method during 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. The first punctuation will be triggered by the first record that is processed. NOTE: Only advanced if messages arrive
        • PunctuationType.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
        Skipping punctuations: Punctuations will not be triggered more than once at any given timestamp. This means that "missed" punctuation will be skipped. It's possible to "miss" a punctuation if:
        Specified by:
        schedule in interface ProcessorContext
        Parameters:
        intervalMs - the time interval between punctuations in milliseconds
        type - 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 during 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. The first punctuation will be triggered by the first record that is processed. NOTE: Only advanced if messages arrive
        • PunctuationType.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
        Skipping punctuations: Punctuations will not be triggered more than once at any given timestamp. This means that "missed" punctuation will be skipped. It's possible to "miss" a punctuation if:
        Specified by:
        schedule in interface ProcessorContext
        Parameters:
        interval - the time interval between punctuations
        type - 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
      • 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 interface ProcessorContext
        Parameters:
        key - key
        value - value
      • 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 interface ProcessorContext
        Parameters:
        key - key
        value - value
        to - the options to use when forwarding
      • 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 interface ProcessorContext
        Parameters:
        key - key
        value - value
        childIndex - 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 interface ProcessorContext
        Parameters:
        key - key
        value - value
        childName - name of downstream processor
      • topic

        public java.lang.String topic()
        Description copied from interface: ProcessorContext
        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)
        Specified by:
        topic in interface ProcessorContext
        Returns:
        the topic name
      • partition

        public int partition()
        Description copied from interface: ProcessorContext
        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)
        Specified by:
        partition in interface ProcessorContext
        Returns:
        the partition id
      • offset

        public long offset()
        Description copied from interface: ProcessorContext
        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)
        Specified by:
        offset in interface ProcessorContext
        Returns:
        the offset
      • headers

        public org.apache.kafka.common.header.Headers headers()
        Description copied from interface: ProcessorContext
        Returns the headers of the current input record; could be null if it is not available
        Specified by:
        headers in interface ProcessorContext
        Returns:
        the headers
      • timestamp

        public long timestamp()
        Description copied from interface: ProcessorContext
        Returns the current timestamp. If it is triggered while processing a record streamed from the source processor, timestamp is defined as the timestamp of the current input record; the timestamp is extracted from 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.
        Specified by:
        timestamp in interface ProcessorContext
        Returns:
        the timestamp
      • appConfigs

        public java.util.Map<java.lang.String,​java.lang.Object> appConfigs()
        Description copied from interface: ProcessorContext
        Returns all the application config properties as key/value pairs. The config properties are defined in the 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)).

        Specified by:
        appConfigs in interface ProcessorContext
        Returns:
        all the key/values from the StreamsConfig properties
      • appConfigsWithPrefix

        public java.util.Map<java.lang.String,​java.lang.Object> appConfigsWithPrefix​(java.lang.String prefix)
        Description copied from interface: ProcessorContext
        Returns all the application config properties with the given key prefix, as key/value pairs stripping the prefix. The config properties are defined in the StreamsConfig object and associated to the ProcessorContext.
        Specified by:
        appConfigsWithPrefix in interface ProcessorContext
        Parameters:
        prefix - the properties prefix
        Returns:
        the key/values matching the given prefix from the StreamsConfig properties.