org.apache.kafka.clients.producer.internals
Class RecordBatch

java.lang.Object
  extended by org.apache.kafka.clients.producer.internals.RecordBatch

public final class RecordBatch
extends java.lang.Object

A batch of records that is or will be sent. This class is not thread safe and external synchronization must be used when modifying it


Field Summary
 int attempts
           
 long createdMs
           
 long drainedMs
           
 long lastAttemptMs
           
 int maxRecordSize
           
 int recordCount
           
 MemoryRecords records
           
 TopicPartition topicPartition
           
 
Constructor Summary
RecordBatch(TopicPartition tp, MemoryRecords records, long now)
           
 
Method Summary
 void done(long baseOffset, java.lang.RuntimeException exception)
          Complete the request
 java.lang.String toString()
           
 FutureRecordMetadata tryAppend(byte[] key, byte[] value, Callback callback)
          Append the record to the current record set and return the relative offset within that record set
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

recordCount

public int recordCount

maxRecordSize

public int maxRecordSize

attempts

public volatile int attempts

createdMs

public final long createdMs

drainedMs

public long drainedMs

lastAttemptMs

public long lastAttemptMs

records

public final MemoryRecords records

topicPartition

public final TopicPartition topicPartition
Constructor Detail

RecordBatch

public RecordBatch(TopicPartition tp,
                   MemoryRecords records,
                   long now)
Method Detail

tryAppend

public FutureRecordMetadata tryAppend(byte[] key,
                                      byte[] value,
                                      Callback callback)
Append the record to the current record set and return the relative offset within that record set

Returns:
The RecordSend corresponding to this record or null if there isn't sufficient room.

done

public void done(long baseOffset,
                 java.lang.RuntimeException exception)
Complete the request

Parameters:
baseOffset - The base offset of the messages assigned by the server
exception - The exception that occurred (or null if the request was successful)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object