Packages

abstract class CompactibleFileStreamLog[T <: AnyRef] 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
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
Visibility
  1. Public
  2. Protected

Instance Constructors

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

Abstract Value Members

  1. abstract def defaultCompactInterval: Int
    Attributes
    protected
  2. 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
  3. abstract def isDeletingExpiredLog: Boolean
    Attributes
    protected

Concrete Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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.

    Definition Classes
    CompactibleFileStreamLogHDFSMetadataLogMetadataLog
  5. def addNewBatchByStream(batchId: Long)(fn: (OutputStream) => Unit): 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. This method fills the content of metadata via executing function. If the function throws an exception, writing will be automatically cancelled and this method will propagate the exception.

    If the batchId's metadata has already been stored, this method will return false.

    Writing the metadata is done by writing a batch to a temp file then rename it to the batch file.

    There may be multiple HDFSMetadataLog using the same metadata path. Although it is not a valid behavior, we still need to prevent it from destroying the files.

    Definition Classes
    HDFSMetadataLog
  6. def allFiles(): Array[T]

    Returns all files except the deleted ones.

  7. def applyFnToBatchByStream[RET](batchId: Long, skipExistingCheck: Boolean = false)(fn: (InputStream) => RET): RET

    Apply provided function to each entry in the specific batch metadata log.

    Apply provided function to each entry in the specific batch metadata log.

    Unlike get which will materialize all entries into memory, this method streamlines the process via READ-AND-PROCESS. This helps to avoid the memory issue on huge metadata log file.

    NOTE: This no longer fails early on corruption. The caller should handle the exception properly and make sure the logic is not affected by failing in the middle.

    Definition Classes
    HDFSMetadataLog
  8. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  9. val batchCache: Map[Long, Array[T]]

    Cache the latest two batches.

    Cache the latest two batches. StreamExecution usually just accesses the latest two batches when committing offsets, this cache will save some file system operations.

    Attributes
    protected[sql]
    Definition Classes
    HDFSMetadataLog
  10. val batchFilesFilter: PathFilter

    A PathFilter to filter only batch files

    A PathFilter to filter only batch files

    Attributes
    protected
    Definition Classes
    HDFSMetadataLog
  11. def batchIdToPath(batchId: Long): Path
  12. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  13. final lazy val compactInterval: Int
    Attributes
    protected
  14. def deserialize(in: InputStream): Array[T]

    Read and deserialize the metadata from input stream.

    Read and deserialize the metadata from input stream. If this method is overridden in a subclass, the overriding method should not close the given input stream, as it will be closed in the caller.

    Definition Classes
    CompactibleFileStreamLogHDFSMetadataLog
  15. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  17. val fileManager: CheckpointFileManager
    Attributes
    protected
    Definition Classes
    HDFSMetadataLog
  18. def filterInBatch(batchId: Long)(predicate: (T) => Boolean): Option[Array[T]]

    Apply filter on all entries in the specific batch.

  19. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable])
  20. def foreachInBatch(batchId: Long)(fn: (T) => Unit): Unit

    Apply function on all entries in the specific batch.

    Apply function on all entries in the specific batch. The method will throw FileNotFoundException if the metadata log file doesn't exist.

    NOTE: This doesn't fail early on corruption. The caller should handle the exception properly and make sure the logic is not affected by failing in the middle.

  21. 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
  22. 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
  23. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  24. 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
  25. def getLatestBatchId(): Option[Long]

    Return the latest batch id without reading the file.

    Return the latest batch id without reading the file.

    Definition Classes
    HDFSMetadataLog
  26. def getOrderedBatchFiles(): Array[FileStatus]

    Get an array of [FileStatus] referencing batch files.

    Get an array of [FileStatus] referencing batch files. The array is sorted by most recent batch file first to oldest batch file.

    Definition Classes
    HDFSMetadataLog
  27. def getPrevBatchFromStorage(batchId: Long): Option[Long]

    Get the id of the previous batch from storage

    Get the id of the previous batch from storage

    batchId

    get the previous batch id of this batch with batchId

    Definition Classes
    HDFSMetadataLog
  28. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  29. def initializeLogIfNecessary(isInterpreter: Boolean, silent: Boolean): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  30. def initializeLogIfNecessary(isInterpreter: Boolean): Unit
    Attributes
    protected
    Definition Classes
    Logging
  31. def isBatchFile(path: Path): Boolean
  32. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  33. def isTraceEnabled(): Boolean
    Attributes
    protected
    Definition Classes
    Logging
  34. def listBatches: Array[Long]

    List the available batches on file system.

    List the available batches on file system.

    Attributes
    protected
    Definition Classes
    HDFSMetadataLog
  35. def listBatchesOnDisk: Array[Long]

    List the batches persisted to storage

    List the batches persisted to storage

    returns

    array of batches ids

    Definition Classes
    HDFSMetadataLog
  36. def log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  37. def logDebug(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  38. def logDebug(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  39. def logError(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  40. def logError(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  41. def logInfo(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  42. def logInfo(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  43. def logName: String
    Attributes
    protected
    Definition Classes
    Logging
  44. def logTrace(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  45. def logTrace(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  46. def logWarning(msg: => String, throwable: Throwable): Unit
    Attributes
    protected
    Definition Classes
    Logging
  47. def logWarning(msg: => String): Unit
    Attributes
    protected
    Definition Classes
    Logging
  48. val metadataCacheEnabled: Boolean
    Attributes
    protected
    Definition Classes
    HDFSMetadataLog
  49. val metadataPath: Path
    Definition Classes
    HDFSMetadataLog
  50. val minBatchesToRetain: Int
    Attributes
    protected
  51. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  52. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  53. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  54. def pathToBatchId(path: Path): Long
  55. def purge(thresholdBatchId: Long): Unit

    CompactibleFileStreamLog maintains logs by itself, and manual purging might break internal state, specifically which latest compaction batch is purged.

    CompactibleFileStreamLog maintains logs by itself, and manual purging might break internal state, specifically which latest compaction batch is purged.

    To simplify the situation, this method just throws UnsupportedOperationException regardless of given parameter, and let CompactibleFileStreamLog handles purging by itself.

    Definition Classes
    CompactibleFileStreamLogHDFSMetadataLogMetadataLog
  56. def purgeAfter(thresholdBatchId: Long): Unit

    Removes all log entries later than thresholdBatchId (exclusive).

    Removes all log entries later than thresholdBatchId (exclusive).

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

    Serialize the metadata and write to the output stream.

    Serialize the metadata and write to the output stream. If this method is overridden in a subclass, the overriding method should not close the given output stream, as it will be closed in the caller.

    Definition Classes
    CompactibleFileStreamLogHDFSMetadataLog
  58. def shouldRetain(log: T, currentTime: Long): Boolean

    Determine whether the log should be retained or not.

    Determine whether the log should be retained or not.

    Default implementation retains all log entries. Implementations should override the method to change the behavior.

  59. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  60. def toString(): String
    Definition Classes
    AnyRef → Any
  61. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  62. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  63. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  64. def write(batchMetadataFile: Path, fn: (OutputStream) => Unit): Unit
    Attributes
    protected
    Definition Classes
    HDFSMetadataLog

Inherited from HDFSMetadataLog[Array[T]]

Inherited from Logging

Inherited from MetadataLog[Array[T]]

Inherited from AnyRef

Inherited from Any

Ungrouped