Class StreamThread
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.kafka.streams.processor.internals.StreamThread
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
StreamThread.ProcessingMode
static class
StreamThread.State
Stream thread states are the possible states that a stream thread can be in.static interface
StreamThread.StateListener
Listen to state change events-
Nested classes/interfaces inherited from class java.lang.Thread
Thread.UncaughtExceptionHandler
-
-
Field Summary
-
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description StreamThread(org.apache.kafka.common.utils.Time time, StreamsConfig config, Admin adminClient, Consumer<byte[],byte[]> mainConsumer, Consumer<byte[],byte[]> restoreConsumer, ChangelogReader changelogReader, String originalReset, TaskManager taskManager, StreamsMetricsImpl streamsMetrics, InternalTopologyBuilder builder, String threadId, org.apache.kafka.common.utils.LogContext logContext, AtomicInteger assignmentErrorCode, AtomicLong nextProbingRebalanceMs)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<TaskId,Task>
activeTaskMap()
List<Task>
activeTasks()
Map<MetricName,Metric>
adminClientMetrics()
Map<TaskId,Task>
allTasks()
Map<MetricName,Metric>
consumerMetrics()
static StreamThread
create(InternalTopologyBuilder builder, StreamsConfig config, KafkaClientSupplier clientSupplier, Admin adminClient, UUID processId, String clientId, StreamsMetricsImpl streamsMetrics, org.apache.kafka.common.utils.Time time, StreamsMetadataState streamsMetadataState, long cacheSizeBytes, StateDirectory stateDirectory, StateRestoreListener userStateRestoreListener, int threadIdx)
static boolean
eosEnabled(StreamsConfig config)
boolean
isRunning()
static StreamThread.ProcessingMode
processingMode(StreamsConfig config)
Map<MetricName,Metric>
producerMetrics()
void
run()
Execute the stream processorsvoid
setStateListener(StreamThread.StateListener listener)
Set theStreamThread.StateListener
to be notified when state changes.void
shutdown()
Shutdown this stream thread.StreamThread.State
state()
ThreadMetadata
threadMetadata()
Return information about the currentStreamThread
.String
toString()
Produces a string representation containing useful information about a StreamThread.String
toString(String indent)
Produces a string representation containing useful information about a StreamThread, starting with the given indent.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, yield
-
-
-
-
Constructor Detail
-
StreamThread
public StreamThread(org.apache.kafka.common.utils.Time time, StreamsConfig config, Admin adminClient, Consumer<byte[],byte[]> mainConsumer, Consumer<byte[],byte[]> restoreConsumer, ChangelogReader changelogReader, String originalReset, TaskManager taskManager, StreamsMetricsImpl streamsMetrics, InternalTopologyBuilder builder, String threadId, org.apache.kafka.common.utils.LogContext logContext, AtomicInteger assignmentErrorCode, AtomicLong nextProbingRebalanceMs)
-
-
Method Detail
-
setStateListener
public void setStateListener(StreamThread.StateListener listener)
Set theStreamThread.StateListener
to be notified when state changes. Note this API is internal to Kafka Streams and is not intended to be used by an external application.
-
state
public StreamThread.State state()
- Returns:
- The state this instance is in
-
isRunning
public boolean isRunning()
-
create
public static StreamThread create(InternalTopologyBuilder builder, StreamsConfig config, KafkaClientSupplier clientSupplier, Admin adminClient, UUID processId, String clientId, StreamsMetricsImpl streamsMetrics, org.apache.kafka.common.utils.Time time, StreamsMetadataState streamsMetadataState, long cacheSizeBytes, StateDirectory stateDirectory, StateRestoreListener userStateRestoreListener, int threadIdx)
-
processingMode
public static StreamThread.ProcessingMode processingMode(StreamsConfig config)
-
eosEnabled
public static boolean eosEnabled(StreamsConfig config)
-
run
public void run()
Execute the stream processors- Specified by:
run
in interfaceRunnable
- Overrides:
run
in classThread
- Throws:
KafkaException
- for any Kafka-related exceptionsRuntimeException
- for any other non-Kafka exceptions
-
shutdown
public void shutdown()
Shutdown this stream thread.Note that there is nothing to prevent this function from being called multiple times (e.g., in testing), hence the state is set only the first time
-
threadMetadata
public final ThreadMetadata threadMetadata()
Return information about the currentStreamThread
.- Returns:
ThreadMetadata
.
-
toString
public String toString()
Produces a string representation containing useful information about a StreamThread. This is useful in debugging scenarios.
-
toString
public String toString(String indent)
Produces a string representation containing useful information about a StreamThread, starting with the given indent. This is useful in debugging scenarios.- Returns:
- A string representation of the StreamThread instance.
-
producerMetrics
public Map<MetricName,Metric> producerMetrics()
-
consumerMetrics
public Map<MetricName,Metric> consumerMetrics()
-
adminClientMetrics
public Map<MetricName,Metric> adminClientMetrics()
-
-