use of org.apache.kafka.clients.admin.RecordsToDelete in project apache-kafka-on-k8s by banzaicloud.
the class TaskManagerTest method shouldSendPurgeData.
@Test
public void shouldSendPurgeData() {
final KafkaFutureImpl<DeletedRecords> futureDeletedRecords = new KafkaFutureImpl<>();
final Map<TopicPartition, RecordsToDelete> recordsToDelete = Collections.singletonMap(t1p1, RecordsToDelete.beforeOffset(5L));
final DeleteRecordsResult deleteRecordsResult = new DeleteRecordsResult(Collections.singletonMap(t1p1, (KafkaFuture<DeletedRecords>) futureDeletedRecords));
futureDeletedRecords.complete(null);
EasyMock.expect(active.recordsToDelete()).andReturn(Collections.singletonMap(t1p1, 5L)).times(2);
EasyMock.expect(adminClient.deleteRecords(recordsToDelete)).andReturn(deleteRecordsResult).times(2);
replay();
taskManager.maybePurgeCommitedRecords();
taskManager.maybePurgeCommitedRecords();
verify(active, adminClient);
}
use of org.apache.kafka.clients.admin.RecordsToDelete in project apache-kafka-on-k8s by banzaicloud.
the class TaskManagerTest method shouldIgnorePurgeDataErrors.
@Test
public void shouldIgnorePurgeDataErrors() {
final KafkaFutureImpl<DeletedRecords> futureDeletedRecords = new KafkaFutureImpl<>();
final Map<TopicPartition, RecordsToDelete> recordsToDelete = Collections.singletonMap(t1p1, RecordsToDelete.beforeOffset(5L));
final DeleteRecordsResult deleteRecordsResult = new DeleteRecordsResult(Collections.singletonMap(t1p1, (KafkaFuture<DeletedRecords>) futureDeletedRecords));
futureDeletedRecords.completeExceptionally(new Exception("KABOOM!"));
EasyMock.expect(active.recordsToDelete()).andReturn(Collections.singletonMap(t1p1, 5L)).times(2);
EasyMock.expect(adminClient.deleteRecords(recordsToDelete)).andReturn(deleteRecordsResult).times(2);
replay();
taskManager.maybePurgeCommitedRecords();
taskManager.maybePurgeCommitedRecords();
verify(active, adminClient);
}
use of org.apache.kafka.clients.admin.RecordsToDelete in project apache-kafka-on-k8s by banzaicloud.
the class TaskManagerTest method shouldNotSendPurgeDataIfPreviousNotDone.
@Test
public void shouldNotSendPurgeDataIfPreviousNotDone() {
final KafkaFuture<DeletedRecords> futureDeletedRecords = new KafkaFutureImpl<>();
final Map<TopicPartition, RecordsToDelete> recordsToDelete = Collections.singletonMap(t1p1, RecordsToDelete.beforeOffset(5L));
final DeleteRecordsResult deleteRecordsResult = new DeleteRecordsResult(Collections.singletonMap(t1p1, futureDeletedRecords));
EasyMock.expect(active.recordsToDelete()).andReturn(Collections.singletonMap(t1p1, 5L)).once();
EasyMock.expect(adminClient.deleteRecords(recordsToDelete)).andReturn(deleteRecordsResult).once();
replay();
taskManager.maybePurgeCommitedRecords();
// second call should be no-op as the previous one is not done yet
taskManager.maybePurgeCommitedRecords();
verify(active, adminClient);
}
Aggregations