Class ProduceRequestResult
java.lang.Object
org.apache.kafka.clients.producer.internals.ProduceRequestResult
A class that models the future completion of a produce request for a single partition. There is one of these per
partition in a produce request and it is shared by all the
RecordMetadata instances that are batched together
for the same partition in the request.-
Constructor Summary
ConstructorsConstructorDescriptionProduceRequestResult(org.apache.kafka.common.TopicPartition topicPartition) Create an instance of this class. -
Method Summary
Modifier and TypeMethodDescriptionvoidawait()Await the completion of this requestbooleanAwait the completion of this request (up to the given time interval)longThe base offset for the request (the first offset in the record set)booleanHas the request completed?voiddone()Mark this request as complete and unblock any threads waiting on its completion.error(int batchIndex) The error thrown (generally on the server) while processing this requestbooleanReturn true if log append time is being used for this topiclongThe log append time or -1 if CreateTime is being usedvoidset(long baseOffset, long logAppendTime, Function<Integer, RuntimeException> errorsByIndex) Set the result of the produce request.org.apache.kafka.common.TopicPartitionThe topic and partition to which the record was appended
-
Constructor Details
-
ProduceRequestResult
public ProduceRequestResult(org.apache.kafka.common.TopicPartition topicPartition) Create an instance of this class.- Parameters:
topicPartition- The topic and partition to which this record set was sent was sent
-
-
Method Details
-
set
public void set(long baseOffset, long logAppendTime, Function<Integer, RuntimeException> errorsByIndex) Set the result of the produce request.- Parameters:
baseOffset- The base offset assigned to the recordlogAppendTime- The log append time or -1 if CreateTime is being usederrorsByIndex- Function mapping the batch index to the exception, or null if the response was successful
-
done
public void done()Mark this request as complete and unblock any threads waiting on its completion. -
await
Await the completion of this request- Throws:
InterruptedException
-
await
Await the completion of this request (up to the given time interval)- Parameters:
timeout- The maximum time to waitunit- The unit for the max time- Returns:
- true if the request completed, false if we timed out
- Throws:
InterruptedException
-
baseOffset
public long baseOffset()The base offset for the request (the first offset in the record set) -
hasLogAppendTime
public boolean hasLogAppendTime()Return true if log append time is being used for this topic -
logAppendTime
public long logAppendTime()The log append time or -1 if CreateTime is being used -
error
The error thrown (generally on the server) while processing this request -
topicPartition
public org.apache.kafka.common.TopicPartition topicPartition()The topic and partition to which the record was appended -
completed
public boolean completed()Has the request completed?
-