Packages

c

com.adform.streamloader.sink.batch.storage

TwoPhaseCommitBatchStorage

abstract class TwoPhaseCommitBatchStorage[-B <: RecordBatch, S] extends RecordBatchStorage[B] with Logging with Metrics

An abstract batch storage that stores batches and commits offsets to Kafka in a two phase transaction. Committed stream positions are looked up in Kafka. The batch commit algorithm proceeds in phases as follows:

  1. stage the batch to storage (e.g. upload file to a temporary path),
  2. stage offsets to Kafka by performing an offset commit without modifying the actual offset, instead saving the new offset and the staged batch information (e.g. file path of the temporary uploaded file) serialized as compressed and base64 encoded JSON to the offset commit metadata field,
  3. store the staged batch (e.g. move the temporary file to the final destination)
  4. commit new offsets to Kafka and clear the staging information from the offset metadata.

If committing fails in the first two stages the recovery will revert it, if it fails afterwards, recovery will complete the transaction.

Implementers need to define the batch staging and storing.

B

Type of record batches.

S

Type of the batch staging information, must be JSON serializable.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TwoPhaseCommitBatchStorage
  2. Metrics
  3. Logging
  4. RecordBatchStorage
  5. AnyRef
  6. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new TwoPhaseCommitBatchStorage()(implicit arg0: JsonSerializer[S])

Abstract Value Members

  1. abstract def isBatchStored(staging: S): Boolean

    Checks whether a staged batch is actually stored, used during recovery.

    Checks whether a staged batch is actually stored, used during recovery.

    staging

    Batch staging information.

    returns

    Whether the batch is fully stored.

    Attributes
    protected
  2. abstract def stageBatch(batch: B): S

    Stages a record batch to storage.

    Stages a record batch to storage.

    batch

    Record batch to store.

    returns

    Information about the staging.

    Attributes
    protected
  3. abstract def storeBatch(staging: S): Unit

    Finalizes storage of a staged record batch.

    Finalizes storage of a staged record batch.

    staging

    Batch staging information.

    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. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @native()
  6. final def commitBatch(batch: B): Unit

    Commits a given batch to storage.

    Commits a given batch to storage.

    Definition Classes
    TwoPhaseCommitBatchStorageRecordBatchStorage
  7. final def committedPositions(topicPartitions: Set[TopicPartition]): Map[TopicPartition, Option[StreamPosition]]

    Gets the latest committed stream positions for the given partitions.

    Gets the latest committed stream positions for the given partitions.

    Definition Classes
    TwoPhaseCommitBatchStorageRecordBatchStorage
  8. def createCounter(name: String, tags: Seq[MetricTag] = Seq()): Counter
    Attributes
    protected
    Definition Classes
    Metrics
  9. def createDistribution(name: String, tags: Seq[MetricTag] = Seq()): DistributionSummary
    Attributes
    protected
    Definition Classes
    Metrics
  10. def createGauge[T <: AnyRef](name: String, metric: T, tdf: ToDoubleFunction[T], tags: Seq[MetricTag] = Seq()): Gauge
    Attributes
    protected
    Definition Classes
    Metrics
  11. def createTimer(name: String, tags: Seq[MetricTag] = Seq(), maxDuration: Duration = null): Timer
    Attributes
    protected
    Definition Classes
    Metrics
  12. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  14. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  15. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native()
  16. def initialize(context: KafkaContext): Unit

    Initializes the storage with a Kafka context, which can be used to lookup/commit offsets, if needed.

    Initializes the storage with a Kafka context, which can be used to lookup/commit offsets, if needed.

    Definition Classes
    RecordBatchStorage
  17. def isBatchCommitted(batch: B): Boolean

    Checks whether a given batch was successfully committed to storage by comparing committed positions with the record ranges in the batch.

    Checks whether a given batch was successfully committed to storage by comparing committed positions with the record ranges in the batch.

    batch

    Batch to check.

    returns

    Whether the batch is successfully stored.

    Definition Classes
    RecordBatchStorage
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. val kafkaContext: KafkaContext
    Attributes
    protected
    Definition Classes
    RecordBatchStorage
  20. val log: Logger
    Attributes
    protected
    Definition Classes
    Logging
  21. def metricsRoot: String

    A common prefix for all created metrics.

    A common prefix for all created metrics.

    Attributes
    protected
    Definition Classes
    TwoPhaseCommitBatchStorageMetrics
  22. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  23. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  24. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native()
  25. final def recover(topicPartitions: Set[TopicPartition]): Unit

    Performs any needed recovery upon startup, e.g.

    Performs any needed recovery upon startup, e.g. rolling back or completing transactions. Can fail, users should handle any possible exceptions.

    Definition Classes
    TwoPhaseCommitBatchStorageRecordBatchStorage
  26. def removeMeters(meters: Meter*): Unit
    Attributes
    protected
    Definition Classes
    Metrics
  27. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  28. def toString(): String
    Definition Classes
    AnyRef → Any
  29. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  30. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  31. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from Metrics

Inherited from Logging

Inherited from RecordBatchStorage[B]

Inherited from AnyRef

Inherited from Any

Ungrouped