Class BufferingAppendRecordsBuilder

java.lang.Object
io.confluent.kafka.replication.push.buffer.BufferingAppendRecordsBuilder

public final class BufferingAppendRecordsBuilder extends Object

Used to consume incoming PushReplicationEvents for a given destination broker and (eventually) to build an AppendRecords out of them. When an incoming event can not be consumed, the builder is expected to be used to build a new request to be sent, after which a new builder should be created for the subsequent events for that destination broker.

The builder consumes events by mostly delegating their processing to BufferingPartitionDataBuilders that it maintains for the partition replicas for which there are updates. Like the main PusherThread implementation and BufferingPartitionDataBuilder, it indicates whether a processed event has actually been consumed by returning a boolean flag, and like BufferingPartitionDataBuilder it expects the entity it builds to be built when no further events can be consumed.

This class is not thread-safe. It expects that the same thread will be initializing it, sending push replication events to it, and building requests out of it.

See Also:
  • Constructor Details

  • Method Details

    • processEvent

      public boolean processEvent(PushReplicationEvent<?> event, PushSession pushSession)
      Processes the given push replication event indicating whether it was successfully consumed in the returned boolean result. If an event has not been consumed, the internal state of the builder should not be changed in any way.
    • build

      public org.apache.kafka.common.message.AppendRecordsRequestData build()

      Creates an AppendRecordsRequestData from all the buffered data in the builder. The data can then be used to create a new AppendRecords request to the builder's destination broker.

    • clear

      public void clear()
      Clears all data buffered in the partitions builders of this request builder, including untracking all buffered MemoryRecords.
    • destinationBrokerEpoch

      public long destinationBrokerEpoch()
    • destinationBrokerId

      public int destinationBrokerId()
      The ID of the destination broker for which this builder creates AppendRecords requests.
    • isRequestReady

      public boolean isRequestReady()
      Return whether the request is ready to send. We wait for ReplicationConfig.lingerMs() if there are records buffered in the builder. Otherwise, we wait for ReplicationConfig.maxWaitMs() if there is any non-record data to send.