public final class BufferingAppendRecordsBuilder extends Object
Used to consume incoming PushReplicationEvent
s 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
BufferingPartitionDataBuilder
s 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.
BufferingPartitionDataBuilder
Constructor and Description |
---|
BufferingAppendRecordsBuilder(int destinationBrokerId,
long destinationBrokerEpoch,
ReplicationConfig config,
RefCountingMemoryTracker<org.apache.kafka.common.record.MemoryRecords> tracker,
org.apache.kafka.common.utils.Time time) |
Modifier and Type | Method and Description |
---|---|
org.apache.kafka.common.message.AppendRecordsRequestData |
build()
Creates an
AppendRecordsRequestData from all the buffered data in the builder. |
void |
clear()
Clears all data buffered in the partitions builders of this request builder, including
untracking all buffered
MemoryRecords . |
long |
destinationBrokerEpoch() |
int |
destinationBrokerId()
The ID of the destination broker for which this builder creates AppendRecords requests.
|
boolean |
isRequestReady()
Return whether the request is ready to send.
|
boolean |
processEvent(PushReplicationEvent<?> event,
PushSession pushSession)
Processes the given push replication event indicating whether it was successfully consumed
in the returned boolean result.
|
public BufferingAppendRecordsBuilder(int destinationBrokerId, long destinationBrokerEpoch, ReplicationConfig config, RefCountingMemoryTracker<org.apache.kafka.common.record.MemoryRecords> tracker, org.apache.kafka.common.utils.Time time)
public boolean processEvent(PushReplicationEvent<?> event, PushSession pushSession)
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.
public void clear()
MemoryRecords
.public long destinationBrokerEpoch()
public int destinationBrokerId()
public boolean isRequestReady()
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.