org.apache.spark.sql.execution.streaming

CompactibleFileStreamLog

abstract class CompactibleFileStreamLog[T] extends HDFSMetadataLog[Array[T]]

An abstract class for compactible metadata logs. It will write one log file for each batch. The first line of the log file is the version number, and there are multiple serialized metadata lines following.

As reading from many small files is usually pretty slow, also too many small files in one folder will mess the FS, CompactibleFileStreamLog will compact log files every 10 batches by default into a big file. When doing a compaction, it will read all old log files and merge them with the new batch.

Linear Supertypes
HDFSMetadataLog[Array[T]], Logging, MetadataLog[Array[T]], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. CompactibleFileStreamLog
  2. HDFSMetadataLog
  3. Logging
  4. MetadataLog
  5. AnyRef
  6. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new CompactibleFileStreamLog(metadataLogVersion: String, sparkSession: SparkSession, path: String)(implicit arg0: ClassTag[T])

Abstract Value Members

  1. abstract def compactInterval: Int

    Attributes
    protected
  2. abstract def compactLogs(logs: Seq[T]): Seq[T]

    Filter out the obsolete logs.

  3. abstract def deserializeData(encodedString: String): T

    Deserialize the string into data object.

    Deserialize the string into data object.

    Attributes
    protected
  4. abstract def fileCleanupDelayMs: Long

    If we delete the old files after compaction at once, there is a race condition in S3: other processes may see the old files are deleted but still cannot see the compaction file using "list".

    If we delete the old files after compaction at once, there is a race condition in S3: other processes may see the old files are deleted but still cannot see the compaction file using "list". The allFiles handles this by looking for the next compaction file directly, however, a live lock may happen if the compaction happens too frequently: one processing keeps deleting old files while another one keeps retrying. Setting a reasonable cleanup delay could avoid it.

    Attributes
    protected
  5. abstract def isDeletingExpiredLog: Boolean

    Attributes
    protected
  6. abstract def serializeData(t: T): String

    Serialize the data into encoded string.

    Serialize the data into encoded string.

    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def add(batchId: Long, logs: Array[T]): Boolean

    Store the metadata for the specified batchId and return true if successful.

    Store the metadata for the specified batchId and return true if successful. If the batchId's metadata has already been stored, this method will return false.

    Note that this method must be called on a org.apache.spark.util.UninterruptibleThread so that interrupts can be disabled while writing the batch file. This is because there is a potential dead-lock in Hadoop "Shell.runCommand" before 2.5.0 (HADOOP-10622). If the thread running "Shell.runCommand" is interrupted, then the thread can get deadlocked. In our case, writeBatch creates a file using HDFS API and calls "Shell.runCommand" to set the file permissions, and can get deadlocked if the stream execution thread is stopped by interrupt. Hence, we make sure that this method is called on UninterruptibleThread which allows us to disable interrupts here. Also see SPARK-14131.

    Definition Classes
    CompactibleFileStreamLogHDFSMetadataLogMetadataLog
  7. def allFiles(): Array[T]

    Returns all files except the deleted ones.

  8. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  9. def batchIdToPath(batchId: Long): Path

  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  11. def deserialize(in: InputStream): Array[T]

  12. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  13. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  14. val fileManager: FileManager

    Attributes
    protected
    Definition Classes
    HDFSMetadataLog
  15. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  16. def get(startId: Option[Long], endId: Option[Long]): Array[(Long, Array[T])]

    Return metadata for batches between startId (inclusive) and endId (inclusive).

    Return metadata for batches between startId (inclusive) and endId (inclusive). If startId is None, just return all batches before endId (inclusive).

    Definition Classes
    HDFSMetadataLogMetadataLog
  17. def get(batchId: Long): Option[Array[T]]

    Return the metadata for the specified batchId if it's stored.

    Return the metadata for the specified batchId if it's stored. Otherwise, return None.

    Definition Classes
    HDFSMetadataLogMetadataLog
  18. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
  19. def getLatest(): Option[(Long, Array[T])]

    Return the latest batch Id and its metadata if exist.

    Return the latest batch Id and its metadata if exist.

    Definition Classes
    HDFSMetadataLogMetadataLog
  20. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  21. def initializeLogIfNecessary(isInterpreter: Boolean): Unit

    Attributes
    protected
    Definition Classes
    Logging
  22. def isBatchFile(path: Path): Boolean

  23. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  24. def isTraceEnabled(): Boolean

    Attributes
    protected
    Definition Classes
    Logging
  25. def log: Logger

    Attributes
    protected
    Definition Classes
    Logging
  26. def logDebug(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  27. def logDebug(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  28. def logError(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  29. def logError(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  30. def logInfo(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  31. def logInfo(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  32. def logName: String

    Attributes
    protected
    Definition Classes
    Logging
  33. def logTrace(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  34. def logTrace(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  35. def logWarning(msg: ⇒ String, throwable: Throwable): Unit

    Attributes
    protected
    Definition Classes
    Logging
  36. def logWarning(msg: ⇒ String): Unit

    Attributes
    protected
    Definition Classes
    Logging
  37. val metadataPath: Path

    Definition Classes
    HDFSMetadataLog
  38. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  39. final def notify(): Unit

    Definition Classes
    AnyRef
  40. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  41. def pathToBatchId(path: Path): Long

  42. def purge(thresholdBatchId: Long): Unit

    Removes all the log entry earlier than thresholdBatchId (exclusive).

    Removes all the log entry earlier than thresholdBatchId (exclusive).

    Definition Classes
    HDFSMetadataLogMetadataLog
  43. def serialize(logData: Array[T], out: OutputStream): Unit

  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  45. def toString(): String

    Definition Classes
    AnyRef → Any
  46. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  47. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  48. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from HDFSMetadataLog[Array[T]]

Inherited from Logging

Inherited from MetadataLog[Array[T]]

Inherited from AnyRef

Inherited from Any

Ungrouped