Class StreamThread
- java.lang.Object
-
- java.lang.Thread
-
- org.apache.kafka.streams.processor.internals.StreamThread
-
- All Implemented Interfaces:
java.lang.Runnable
public class StreamThread extends java.lang.Thread
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description 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
-
Constructor Summary
Constructors Constructor Description StreamThread(org.apache.kafka.common.utils.Time time, StreamsConfig config, org.apache.kafka.clients.producer.Producer<byte[],byte[]> producer, org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> restoreConsumer, org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> consumer, java.lang.String originalReset, TaskManager taskManager, org.apache.kafka.streams.processor.internals.StreamThread.StreamsMetricsThreadImpl streamsMetrics, InternalTopologyBuilder builder, java.lang.String threadClientId, org.apache.kafka.common.utils.LogContext logContext, java.util.concurrent.atomic.AtomicInteger assignmentErrorCode)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Map<org.apache.kafka.common.MetricName,org.apache.kafka.common.Metric>
adminClientMetrics()
java.util.Map<org.apache.kafka.common.MetricName,org.apache.kafka.common.Metric>
consumerMetrics()
static StreamThread
create(InternalTopologyBuilder builder, StreamsConfig config, KafkaClientSupplier clientSupplier, org.apache.kafka.clients.admin.AdminClient adminClient, java.util.UUID processId, java.lang.String clientId, org.apache.kafka.common.metrics.Metrics metrics, org.apache.kafka.common.utils.Time time, StreamsMetadataState streamsMetadataState, long cacheSizeBytes, StateDirectory stateDirectory, StateRestoreListener userStateRestoreListener)
boolean
isRunning()
boolean
isRunningAndNotRebalancing()
java.util.Map<org.apache.kafka.common.MetricName,org.apache.kafka.common.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()
java.util.Map<TaskId,StreamTask>
tasks()
ThreadMetadata
threadMetadata()
Return information about the currentStreamThread
.java.lang.String
toString()
Produces a string representation containing useful information about a StreamThread.java.lang.String
toString(java.lang.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, org.apache.kafka.clients.producer.Producer<byte[],byte[]> producer, org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> restoreConsumer, org.apache.kafka.clients.consumer.Consumer<byte[],byte[]> consumer, java.lang.String originalReset, TaskManager taskManager, org.apache.kafka.streams.processor.internals.StreamThread.StreamsMetricsThreadImpl streamsMetrics, InternalTopologyBuilder builder, java.lang.String threadClientId, org.apache.kafka.common.utils.LogContext logContext, java.util.concurrent.atomic.AtomicInteger assignmentErrorCode)
-
-
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
-
isRunningAndNotRebalancing
public boolean isRunningAndNotRebalancing()
-
isRunning
public boolean isRunning()
-
create
public static StreamThread create(InternalTopologyBuilder builder, StreamsConfig config, KafkaClientSupplier clientSupplier, org.apache.kafka.clients.admin.AdminClient adminClient, java.util.UUID processId, java.lang.String clientId, org.apache.kafka.common.metrics.Metrics metrics, org.apache.kafka.common.utils.Time time, StreamsMetadataState streamsMetadataState, long cacheSizeBytes, StateDirectory stateDirectory, StateRestoreListener userStateRestoreListener)
-
run
public void run()
Execute the stream processors- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
- Throws:
org.apache.kafka.common.KafkaException
- for any Kafka-related exceptionsjava.lang.RuntimeException
- 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
.
-
tasks
public java.util.Map<TaskId,StreamTask> tasks()
-
toString
public java.lang.String toString()
Produces a string representation containing useful information about a StreamThread. This is useful in debugging scenarios.- Overrides:
toString
in classjava.lang.Thread
- Returns:
- A string representation of the StreamThread instance.
-
toString
public java.lang.String toString(java.lang.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 java.util.Map<org.apache.kafka.common.MetricName,org.apache.kafka.common.Metric> producerMetrics()
-
consumerMetrics
public java.util.Map<org.apache.kafka.common.MetricName,org.apache.kafka.common.Metric> consumerMetrics()
-
adminClientMetrics
public java.util.Map<org.apache.kafka.common.MetricName,org.apache.kafka.common.Metric> adminClientMetrics()
-
-