Class 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
      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.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, 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 processors
      void setStateListener​(StreamThread.StateListener listener)
      Set the StreamThread.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 current StreamThread.
      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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 the StreamThread.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.
      • isRunningAndNotRebalancing

        public boolean isRunningAndNotRebalancing()
      • isRunning

        public boolean isRunning()
      • run

        public void run()
        Execute the stream processors
        Specified by:
        run in interface java.lang.Runnable
        Overrides:
        run in class java.lang.Thread
        Throws:
        org.apache.kafka.common.KafkaException - for any Kafka-related exceptions
        java.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

      • 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 class java.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()