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));
}
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());
}
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());
}
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));
}
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());
}
Aggregations