Search in sources :

Example 81 with KafkaException

use of org.apache.kafka.common.KafkaException in project kafka by apache.

the class TransactionManagerTest method testFailIfNotReadyForSendAfterFatalError.

@Test
public void testFailIfNotReadyForSendAfterFatalError() {
    doInitTransactions();
    transactionManager.transitionToFatalError(new KafkaException());
    assertThrows(KafkaException.class, () -> transactionManager.maybeAddPartition(tp0));
}
Also used : KafkaException(org.apache.kafka.common.KafkaException) Test(org.junit.jupiter.api.Test)

Example 82 with KafkaException

use of org.apache.kafka.common.KafkaException in project kafka by apache.

the class TransactionManagerTest method testFindCoordinatorAllowedInAbortableErrorState.

@Test
public void testFindCoordinatorAllowedInAbortableErrorState() throws InterruptedException {
    doInitTransactions();
    transactionManager.beginTransaction();
    transactionManager.maybeAddPartition(tp0);
    Future<RecordMetadata> responseFuture = appendToAccumulator(tp0);
    assertFalse(responseFuture.isDone());
    runUntil(transactionManager::hasInFlightRequest);
    transactionManager.transitionToAbortableError(new KafkaException());
    sendAddPartitionsToTxnResponse(Errors.NOT_COORDINATOR, tp0, epoch, producerId);
    runUntil(() -> transactionManager.coordinator(CoordinatorType.TRANSACTION) == null);
    prepareFindCoordinatorResponse(Errors.NONE, false, CoordinatorType.TRANSACTION, transactionalId);
    runUntil(() -> transactionManager.coordinator(CoordinatorType.TRANSACTION) != null);
    assertEquals(brokerNode, transactionManager.coordinator(CoordinatorType.TRANSACTION));
    assertTrue(transactionManager.hasAbortableError());
}
Also used : RecordMetadata(org.apache.kafka.clients.producer.RecordMetadata) KafkaException(org.apache.kafka.common.KafkaException) Test(org.junit.jupiter.api.Test)

Example 83 with KafkaException

use of org.apache.kafka.common.KafkaException in project kafka by apache.

the class TransactionManagerTest method testIsSendToPartitionAllowedWithAddedPartitionAfterFatalError.

@Test
public void testIsSendToPartitionAllowedWithAddedPartitionAfterFatalError() {
    doInitTransactions();
    transactionManager.beginTransaction();
    transactionManager.maybeAddPartition(tp0);
    prepareAddPartitionsToTxnResponse(Errors.NONE, tp0, epoch, producerId);
    runUntil(() -> !transactionManager.hasPartitionsToAdd());
    transactionManager.transitionToFatalError(new KafkaException());
    assertFalse(transactionManager.isSendToPartitionAllowed(tp0));
    assertTrue(transactionManager.hasFatalError());
}
Also used : KafkaException(org.apache.kafka.common.KafkaException) Test(org.junit.jupiter.api.Test)

Example 84 with KafkaException

use of org.apache.kafka.common.KafkaException in project kafka by apache.

the class TransactionManagerTest method testFailIfNotReadyForSendIdempotentProducerFatalError.

@Test
public void testFailIfNotReadyForSendIdempotentProducerFatalError() {
    initializeTransactionManager(Optional.empty());
    transactionManager.transitionToFatalError(new KafkaException());
    assertThrows(KafkaException.class, () -> transactionManager.maybeAddPartition(tp0));
}
Also used : KafkaException(org.apache.kafka.common.KafkaException) Test(org.junit.jupiter.api.Test)

Example 85 with KafkaException

use of org.apache.kafka.common.KafkaException in project kafka by apache.

the class TransactionManagerTest method testIsSendToPartitionAllowedWithPendingPartitionAfterAbortableError.

@Test
public void testIsSendToPartitionAllowedWithPendingPartitionAfterAbortableError() {
    doInitTransactions();
    transactionManager.beginTransaction();
    transactionManager.maybeAddPartition(tp0);
    transactionManager.transitionToAbortableError(new KafkaException());
    assertFalse(transactionManager.isSendToPartitionAllowed(tp0));
    assertTrue(transactionManager.hasAbortableError());
}
Also used : KafkaException(org.apache.kafka.common.KafkaException) Test(org.junit.jupiter.api.Test)

Aggregations

KafkaException (org.apache.kafka.common.KafkaException)262 Test (org.junit.Test)69 TopicPartition (org.apache.kafka.common.TopicPartition)56 Test (org.junit.jupiter.api.Test)47 HashMap (java.util.HashMap)40 IOException (java.io.IOException)39 StreamsException (org.apache.kafka.streams.errors.StreamsException)34 Map (java.util.Map)32 TimeoutException (org.apache.kafka.common.errors.TimeoutException)28 ArrayList (java.util.ArrayList)27 List (java.util.List)21 ByteBuffer (java.nio.ByteBuffer)19 ExecutionException (java.util.concurrent.ExecutionException)19 ConfigException (org.apache.kafka.common.config.ConfigException)16 TopicAuthorizationException (org.apache.kafka.common.errors.TopicAuthorizationException)14 HashSet (java.util.HashSet)13 Properties (java.util.Properties)13 Set (java.util.Set)11 Collectors (java.util.stream.Collectors)11 RecordMetadata (org.apache.kafka.clients.producer.RecordMetadata)11