Enum StreamThread.State

  • All Implemented Interfaces:
    Serializable, Comparable<StreamThread.State>, ThreadStateTransitionValidator
    Enclosing class:
    StreamThread

    public static enum StreamThread.State
    extends Enum<StreamThread.State>
    implements ThreadStateTransitionValidator
    Stream thread states are the possible states that a stream thread can be in. A thread must only be in one state at a time The expected state transitions with the following defined states is:
                     +-------------+
              +<---- | Created (0) |
              |      +-----+-------+
              |            |
              |            v
              |      +-----+-------+
              +<---- | Starting (1)|----->+
              |      +-----+-------+      |
              |            |              |
              |            |              |
              |            v              |
              |      +-----+-------+      |
              +<---- | Partitions  |      |
              |      | Revoked (2) | <----+
              |      +-----+-------+      |
              |           |  ^            |
              |           |  |            |
              |           v  |            |
              |      +-----+-------+      |
              +<---- | Partitions  |      |
              |      | Assigned (3)| <----+
              |      +-----+-------+      |
              |            |              |
              |            |--------------+
              |            v              |
              |      +-----+-------+      |
              |      | Running (4) | ---->+
              |      +-----+-------+
              |            |
              |            |
              |            v
              |      +-----+-------+
              +----> | Pending     |
                     | Shutdown (5)|
                     +-----+-------+
                           |
                           v
                     +-----+-------+
                     | Dead (6)    |
                     +-------------+
     
    Note the following:
    • Any state can go to PENDING_SHUTDOWN. That is because streams can be closed at any time.
    • State PENDING_SHUTDOWN may want to transit to some other states other than DEAD, in the corner case when the shutdown is triggered while the thread is still in the rebalance loop. In this case we will forbid the transition but will not treat as an error.
    • State PARTITIONS_REVOKED may want transit to itself indefinitely, in the corner case when the coordinator repeatedly fails in-between revoking partitions and assigning new partitions. Also during streams instance start up PARTITIONS_REVOKED may want to transit to itself as well. In this case we will allow the transition but it will be a no-op as the set of revoked partitions should be empty.
    • Method Detail

      • values

        public static StreamThread.State[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (StreamThread.State c : StreamThread.State.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static StreamThread.State valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • isAlive

        public boolean isAlive()