Class ProduceRequestResult

java.lang.Object
org.apache.kafka.clients.producer.internals.ProduceRequestResult

public class ProduceRequestResult extends Object
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

    Constructors
    Constructor
    Description
    ProduceRequestResult(org.apache.kafka.common.TopicPartition topicPartition)
    Create an instance of this class.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Await the completion of this request
    boolean
    await(long timeout, TimeUnit unit)
    Await the completion of this request (up to the given time interval)
    long
    The base offset for the request (the first offset in the record set)
    boolean
    Has the request completed?
    void
    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 request
    boolean
    Return true if log append time is being used for this topic
    long
    The log append time or -1 if CreateTime is being used
    void
    set(long baseOffset, long logAppendTime, Function<Integer,RuntimeException> errorsByIndex)
    Set the result of the produce request.
    org.apache.kafka.common.TopicPartition
    The topic and partition to which the record was appended

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 record
      logAppendTime - The log append time or -1 if CreateTime is being used
      errorsByIndex - 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

      public void await() throws InterruptedException
      Await the completion of this request
      Throws:
      InterruptedException
    • await

      public boolean await(long timeout, TimeUnit unit) throws InterruptedException
      Await the completion of this request (up to the given time interval)
      Parameters:
      timeout - The maximum time to wait
      unit - 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

      public RuntimeException error(int batchIndex)
      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?