Search in sources :

Example 6 with DeleteRecordsResult

use of org.apache.kafka.clients.admin.DeleteRecordsResult in project kafka by apache.

the class TaskManagerTest method shouldIgnorePurgeDataErrors.

@Test
public void shouldIgnorePurgeDataErrors() {
    final StateMachineTask task00 = new StateMachineTask(taskId00, taskId00Partitions, true);
    expectRestoreToBeCompleted(consumer, changeLogReader);
    expect(activeTaskCreator.createTasks(anyObject(), eq(taskId00Assignment))).andStubReturn(singletonList(task00));
    final KafkaFutureImpl<DeletedRecords> futureDeletedRecords = new KafkaFutureImpl<>();
    final DeleteRecordsResult deleteRecordsResult = new DeleteRecordsResult(singletonMap(t1p1, futureDeletedRecords));
    futureDeletedRecords.completeExceptionally(new Exception("KABOOM!"));
    expect(adminClient.deleteRecords(anyObject())).andReturn(deleteRecordsResult).times(2);
    replay(activeTaskCreator, adminClient, consumer, changeLogReader);
    taskManager.handleAssignment(taskId00Assignment, emptyMap());
    assertThat(taskManager.tryToCompleteRestoration(time.milliseconds(), null), is(true));
    assertThat(task00.state(), is(Task.State.RUNNING));
    task00.setPurgeableOffsets(singletonMap(t1p1, 5L));
    taskManager.maybePurgeCommittedRecords();
    taskManager.maybePurgeCommittedRecords();
    verify(adminClient);
}
Also used : DeletedRecords(org.apache.kafka.clients.admin.DeletedRecords) KafkaFutureImpl(org.apache.kafka.common.internals.KafkaFutureImpl) DeleteRecordsResult(org.apache.kafka.clients.admin.DeleteRecordsResult) KafkaException(org.apache.kafka.common.KafkaException) StreamsException(org.apache.kafka.streams.errors.StreamsException) LockException(org.apache.kafka.streams.errors.LockException) TaskMigratedException(org.apache.kafka.streams.errors.TaskMigratedException) TaskCorruptedException(org.apache.kafka.streams.errors.TaskCorruptedException) TimeoutException(org.apache.kafka.common.errors.TimeoutException) CommitFailedException(org.apache.kafka.clients.consumer.CommitFailedException) Test(org.junit.Test)

Aggregations

DeleteRecordsResult (org.apache.kafka.clients.admin.DeleteRecordsResult)6 Test (org.junit.Test)6 DeletedRecords (org.apache.kafka.clients.admin.DeletedRecords)5 TopicPartition (org.apache.kafka.common.TopicPartition)5 KafkaFutureImpl (org.apache.kafka.common.internals.KafkaFutureImpl)5 RecordsToDelete (org.apache.kafka.clients.admin.RecordsToDelete)3 HashMap (java.util.HashMap)2 KafkaFuture (org.apache.kafka.common.KafkaFuture)2 StreamsException (org.apache.kafka.streams.errors.StreamsException)2 IOException (java.io.IOException)1 CommitFailedException (org.apache.kafka.clients.consumer.CommitFailedException)1 KafkaException (org.apache.kafka.common.KafkaException)1 TimeoutException (org.apache.kafka.common.errors.TimeoutException)1 LockException (org.apache.kafka.streams.errors.LockException)1 TaskCorruptedException (org.apache.kafka.streams.errors.TaskCorruptedException)1 TaskMigratedException (org.apache.kafka.streams.errors.TaskMigratedException)1