Interface StateStoreContext


public interface StateStoreContext
State store context interface.
  • Method Details

    • applicationId

      String applicationId()
      Returns the application id.
      Returns:
      the application id
    • taskId

      TaskId taskId()
      Returns the task id.
      Returns:
      the task id
    • recordMetadata

      Optional<RecordMetadata> recordMetadata()
      Return the metadata of the current topic/partition/offset if available. This is defined as the metadata of the record that is currently being processed (or was last processed) by the StreamTask that holds the store.

      Note that the metadata is not defined during all store interactions, for example, while the StreamTask is running a punctuation.

      Returns:
      metadata of the current record
    • keySerde

      Serde<?> keySerde()
      Returns the default key serde.
      Returns:
      the key serializer
    • valueSerde

      Serde<?> valueSerde()
      Returns the default value serde.
      Returns:
      the value serializer
    • stateDir

      File stateDir()
      Returns the state directory for the partition.
      Returns:
      the state directory
    • metrics

      StreamsMetrics metrics()
      Returns Metrics instance.
      Returns:
      StreamsMetrics
    • register

      void register(StateStore store, StateRestoreCallback stateRestoreCallback)
      Registers and possibly restores the specified storage engine.
      Parameters:
      store - the storage engine
      stateRestoreCallback - the restoration callback logic for log-backed state stores upon restart
      Throws:
      IllegalStateException - If store gets registered after initialized is already finished
      StreamsException - if the store's change log does not contain the partition
    • register

      @Evolving void register(StateStore store, StateRestoreCallback stateRestoreCallback, CommitCallback commitCallback)
      Registers and possibly restores the specified storage engine.
      Parameters:
      store - the storage engine
      stateRestoreCallback - the restoration callback logic for log-backed state stores upon restart
      commitCallback - a callback to be invoked upon successful task commit, in case the store needs to perform any state tracking when the task is known to be in a consistent state. If the store has no such state to track, it may use register(StateStore, StateRestoreCallback) instead. Persistent stores provided by Kafka Streams use this method to save their Position information to local disk, for example.
      Throws:
      IllegalStateException - If store gets registered after initialized is already finished
      StreamsException - if the store's change log does not contain the partition
    • appConfigs

      Map<String,Object> appConfigs()
      Returns all the application config properties as key/value pairs.

      The config properties are defined in the StreamsConfig object and associated to the StateStoreContext.

      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)).

      Returns:
      all the key/values from the StreamsConfig properties
    • appConfigsWithPrefix

      Map<String,Object> appConfigsWithPrefix(String prefix)
      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 StateStoreContext.

      Parameters:
      prefix - the properties prefix
      Returns:
      the key/values matching the given prefix from the StreamsConfig properties.