Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Status

Current state"Under DiscussionAccepted"

Discussion thread: here 

JIRA: KAFKA-5925 

...

Code Block
languagejava
deleteRecords(Map<TopicPartition, RecordsToDelete> partitionsAndOffsetsrecordsToDelete)

Proposed Changes

AdminClient : deleteRecords()

Code Block
languagejava
public DeleteRecordsResult deleteRecords(Map<TopicPartition, RecordsToDelete> partitionsAndOffsetsrecordsToDelete)
public DeleteRecordsResult deleteRecords(Map<TopicPartition, RecordsToDelete> partitionsAndOffsetsrecordsToDelete, DeleteRecordsOptions options)

...

Code Block
languagejava
/**
 * Options for {@link AdminClient#deleteRecords(Map, DeleteRecordsOptions)}.
 */
public class DeleteRecordsOptions extends AbstractOptions<DeleteRecordsOptions> {

}
 
/**
 * Describe records to delete in a call to {@link AdminClient#deleteRecords(Map)}
 */
public class RecordsToDelete {
	private long offset;
	
	/** 
	 * Delete all the records before the given {@code offset}
	 *
	 * @param offset    the offset before which all records will be deleted
	 */
	public static RecordsToDelete beforeOffset(long offset) { ... }
}

/**
 * The result of the {@link AdminClient#deleteRecords(Map)} call.
 */ 
public class DeleteRecordsResult {
    // package access constructor
    Map<TopicPartition, KafkaFuture<Long>>KafkaFuture<DeleteRecords>> values() { ... }
    KafkaFuture<Long>KafkaFuture<DeleteRecords> all() { ... }
}
 
/**
 * Represents information about deleted records
 */
public class DeletedRecords {
	private final long lowWatermark;
 
	/**
 	 * Create an instance of this class with the provided parameters.
 	 *
	 * @param lowWatermark  "low watermark" for the topic partition on which the deletion was executed
	 */
	public DeletedRecords(long lowWatermark) {
    	this.lowWatermark = lowWatermark;
	}

	/**
	 * Return the "low watermark" for the topic partition on which the deletion was executed
	 */
	public long lowWatermark() {
    	return lowWatermark;
	}
}

In the DeleteRecordsResult, the Long value accessed by values() and all() method specifies the low watermark as described in the KIP-107.

...