Class StateDirectory


  • public class StateDirectory
    extends java.lang.Object
    Manages the directories where the state of Tasks owned by a StreamThread are stored. Handles creation/locking/unlocking/cleaning of the Task Directories. This class is not thread-safe.
    • Constructor Summary

      Constructors 
      Constructor Description
      StateDirectory​(StreamsConfig config, org.apache.kafka.common.utils.Time time)
      Ensures that the state base directory as well as the application's sub-directory are created.
    • Constructor Detail

      • StateDirectory

        public StateDirectory​(StreamsConfig config,
                              org.apache.kafka.common.utils.Time time)
        Ensures that the state base directory as well as the application's sub-directory are created.
        Throws:
        ProcessorStateException - if the base state directory or application state directory does not exist and could not be created
    • Method Detail

      • directoryForTask

        public java.io.File directoryForTask​(TaskId taskId)
        Get or create the directory for the provided TaskId.
        Returns:
        directory for the TaskId
        Throws:
        ProcessorStateException - if the task directory does not exists and could not be created
      • clean

        public void clean()
      • cleanRemovedTasks

        public void cleanRemovedTasks​(long cleanupDelayMs)
        Remove the directories for any TaskIds that are no-longer owned by this StreamThread and aren't locked by either another process or another StreamThread
        Parameters:
        cleanupDelayMs - only remove directories if they haven't been modified for at least this amount of time (milliseconds)