Enum StreamThread.State
- java.lang.Object
-
- java.lang.Enum<StreamThread.State>
-
- org.apache.kafka.streams.processor.internals.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.
-
-
Enum Constant Summary
Enum Constants Enum Constant Description CREATED
DEAD
PARTITIONS_ASSIGNED
PARTITIONS_REVOKED
PENDING_SHUTDOWN
RUNNING
STARTING
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
isAlive()
boolean
isValidTransition(ThreadStateTransitionValidator newState)
static StreamThread.State
valueOf(String name)
Returns the enum constant of this type with the specified name.static StreamThread.State[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
CREATED
public static final StreamThread.State CREATED
-
STARTING
public static final StreamThread.State STARTING
-
PARTITIONS_REVOKED
public static final StreamThread.State PARTITIONS_REVOKED
-
PARTITIONS_ASSIGNED
public static final StreamThread.State PARTITIONS_ASSIGNED
-
RUNNING
public static final StreamThread.State RUNNING
-
PENDING_SHUTDOWN
public static final StreamThread.State PENDING_SHUTDOWN
-
DEAD
public static final StreamThread.State DEAD
-
-
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 nameNullPointerException
- if the argument is null
-
isAlive
public boolean isAlive()
-
isValidTransition
public boolean isValidTransition(ThreadStateTransitionValidator newState)
- Specified by:
isValidTransition
in interfaceThreadStateTransitionValidator
-
-