Class BufferingAppendRecordsBuilder
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 Summary
ConstructorsConstructorDescriptionBufferingAppendRecordsBuilder(int destinationBrokerId, long destinationBrokerEpoch, ReplicationConfig config, RefCountingMemoryTracker<org.apache.kafka.common.record.MemoryRecords> tracker, org.apache.kafka.common.utils.Time time, PushReplicationManagerMetrics pushReplicationManagerMetrics) -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.kafka.common.message.AppendRecordsRequestDatabuild()Creates anAppendRecordsRequestDatafrom all the buffered data in the builder.voidclear()Clears all data buffered in the partitions builders of this request builder, including untracking all bufferedMemoryRecords.longintThe ID of the destination broker for which this builder creates AppendRecords requests.booleanReturn whether the request is ready to send.booleanprocessEvent(PushReplicationEvent<?> event, PushSession pushSession) Processes the given push replication event indicating whether it was successfully consumed in the returned boolean result.
-
Constructor Details
-
BufferingAppendRecordsBuilder
public BufferingAppendRecordsBuilder(int destinationBrokerId, long destinationBrokerEpoch, ReplicationConfig config, RefCountingMemoryTracker<org.apache.kafka.common.record.MemoryRecords> tracker, org.apache.kafka.common.utils.Time time, PushReplicationManagerMetrics pushReplicationManagerMetrics)
-
-
Method Details
-
processEvent
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
AppendRecordsRequestDatafrom 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 bufferedMemoryRecords. -
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 forReplicationConfig.lingerMs()if there are records buffered in the builder. Otherwise, we wait forReplicationConfig.maxWaitMs()if there is any non-record data to send.
-