Class StreamingQueryManager

Object
org.apache.spark.sql.streaming.StreamingQueryManager
All Implemented Interfaces:
org.apache.spark.internal.Logging

public class StreamingQueryManager extends Object implements org.apache.spark.internal.Logging
A class to manage all the StreamingQuery active in a SparkSession.

Since:
2.0.0
  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.apache.spark.internal.Logging

    org.apache.spark.internal.Logging.LogStringContext, org.apache.spark.internal.Logging.SparkShellLoggingFilter
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns a list of active queries associated with this SQLContext
    void
    Register a StreamingQueryListener to receive up-calls for life cycle events of StreamingQuery.
    void
    Wait until any of the queries on the associated SQLContext has terminated since the creation of the context, or since resetTerminated() was called.
    boolean
    awaitAnyTermination(long timeoutMs)
    Wait until any of the queries on the associated SQLContext has terminated since the creation of the context, or since resetTerminated() was called.
    get(String id)
    Returns the query if there is an active query with the given id, or null.
    get(UUID id)
    Returns the query if there is an active query with the given id, or null.
    List all StreamingQueryListeners attached to this StreamingQueryManager.
    void
    void
    Forget about past terminated queries so that awaitAnyTermination() can be used again to wait for new terminations.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.apache.spark.internal.Logging

    initializeForcefully, initializeLogIfNecessary, initializeLogIfNecessary, initializeLogIfNecessary$default$2, isTraceEnabled, log, logDebug, logDebug, logDebug, logDebug, logError, logError, logError, logError, logInfo, logInfo, logInfo, logInfo, logName, LogStringContext, logTrace, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, logWarning, org$apache$spark$internal$Logging$$log_, org$apache$spark$internal$Logging$$log__$eq, withLogContext
  • Method Details

    • active

      public StreamingQuery[] active()
      Returns a list of active queries associated with this SQLContext

      Returns:
      (undocumented)
      Since:
      2.0.0
    • addListener

      public void addListener(StreamingQueryListener listener)
      Register a StreamingQueryListener to receive up-calls for life cycle events of StreamingQuery.

      Parameters:
      listener - (undocumented)
      Since:
      2.0.0
    • awaitAnyTermination

      public void awaitAnyTermination() throws StreamingQueryException
      Wait until any of the queries on the associated SQLContext has terminated since the creation of the context, or since resetTerminated() was called. If any query was terminated with an exception, then the exception will be thrown.

      If a query has terminated, then subsequent calls to awaitAnyTermination() will either return immediately (if the query was terminated by query.stop()), or throw the exception immediately (if the query was terminated with exception). Use resetTerminated() to clear past terminations and wait for new terminations.

      In the case where multiple queries have terminated since resetTermination() was called, if any query has terminated with exception, then awaitAnyTermination() will throw any of the exception. For correctly documenting exceptions across multiple queries, users need to stop all of them after any of them terminates with exception, and then check the query.exception() for each query.

      Throws:
      StreamingQueryException - if any query has terminated with an exception

      Since:
      2.0.0
    • awaitAnyTermination

      public boolean awaitAnyTermination(long timeoutMs) throws StreamingQueryException
      Wait until any of the queries on the associated SQLContext has terminated since the creation of the context, or since resetTerminated() was called. Returns whether any query has terminated or not (multiple may have terminated). If any query has terminated with an exception, then the exception will be thrown.

      If a query has terminated, then subsequent calls to awaitAnyTermination() will either return true immediately (if the query was terminated by query.stop()), or throw the exception immediately (if the query was terminated with exception). Use resetTerminated() to clear past terminations and wait for new terminations.

      In the case where multiple queries have terminated since resetTermination() was called, if any query has terminated with exception, then awaitAnyTermination() will throw any of the exception. For correctly documenting exceptions across multiple queries, users need to stop all of them after any of them terminates with exception, and then check the query.exception() for each query.

      Parameters:
      timeoutMs - (undocumented)
      Returns:
      (undocumented)
      Throws:
      StreamingQueryException - if any query has terminated with an exception

      Since:
      2.0.0
    • get

      public StreamingQuery get(UUID id)
      Returns the query if there is an active query with the given id, or null.

      Parameters:
      id - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.1.0
    • get

      public StreamingQuery get(String id)
      Returns the query if there is an active query with the given id, or null.

      Parameters:
      id - (undocumented)
      Returns:
      (undocumented)
      Since:
      2.1.0
    • listListeners

      public StreamingQueryListener[] listListeners()
      List all StreamingQueryListeners attached to this StreamingQueryManager.

      Returns:
      (undocumented)
      Since:
      3.0.0
    • removeListener

      public void removeListener(StreamingQueryListener listener)
      Deregister a StreamingQueryListener.

      Parameters:
      listener - (undocumented)
      Since:
      2.0.0
    • resetTerminated

      public void resetTerminated()
      Forget about past terminated queries so that awaitAnyTermination() can be used again to wait for new terminations.

      Since:
      2.0.0