use of com.facebook.presto.transaction.DelegatingTransactionManager in project presto by prestodb.
the class TestQueryStateMachine method testTransitionToCanceledAfterTransitionToFinishing.
@Test
public void testTransitionToCanceledAfterTransitionToFinishing() {
SettableFuture<?> commitFuture = SettableFuture.create();
TransactionManager transactionManager = new DelegatingTransactionManager(createTestTransactionManager()) {
@Override
public ListenableFuture<?> asyncCommit(TransactionId transactionId) {
return allAsList(commitFuture, super.asyncCommit(transactionId));
}
};
QueryStateMachine stateMachine = createQueryStateMachine(transactionManager);
stateMachine.transitionToFinishing();
assertEquals(stateMachine.getQueryState(), FINISHING);
assertTrue(stateMachine.transitionToCanceled());
assertEquals(stateMachine.getQueryState(), FAILED);
commitFuture.set(null);
assertEquals(stateMachine.getQueryState(), FAILED);
assertEquals(stateMachine.getFailureInfo().get().getMessage(), "Query was canceled");
}
use of com.facebook.presto.transaction.DelegatingTransactionManager in project presto by prestodb.
the class TestQueryStateMachine method testCommitFailure.
@Test
public void testCommitFailure() {
SettableFuture<?> commitFuture = SettableFuture.create();
TransactionManager transactionManager = new DelegatingTransactionManager(createTestTransactionManager()) {
@Override
public ListenableFuture<?> asyncCommit(TransactionId transactionId) {
return allAsList(commitFuture, super.asyncCommit(transactionId));
}
};
QueryStateMachine stateMachine = createQueryStateMachine(transactionManager);
stateMachine.transitionToFinishing();
// after transitioning to finishing, the transaction is gone
assertEquals(stateMachine.getQueryState(), FINISHING);
assertFalse(stateMachine.transitionToFailed(new RuntimeException("failed")));
assertEquals(stateMachine.getQueryState(), FINISHING);
commitFuture.setException(new RuntimeException("transaction failed"));
tryGetFutureValue(stateMachine.getStateChange(FAILED), 2, SECONDS);
assertEquals(stateMachine.getQueryState(), FAILED);
assertEquals(stateMachine.getFailureInfo().get().getMessage(), "transaction failed");
}
use of com.facebook.presto.transaction.DelegatingTransactionManager in project presto by prestodb.
the class TestQueryStateMachine method testTransitionToFailedAfterTransitionToFinishing.
@Test
public void testTransitionToFailedAfterTransitionToFinishing() {
SettableFuture<?> commitFuture = SettableFuture.create();
TransactionManager transactionManager = new DelegatingTransactionManager(createTestTransactionManager()) {
@Override
public ListenableFuture<?> asyncCommit(TransactionId transactionId) {
return allAsList(commitFuture, super.asyncCommit(transactionId));
}
};
QueryStateMachine stateMachine = createQueryStateMachine(transactionManager);
stateMachine.transitionToFinishing();
assertEquals(stateMachine.getQueryState(), FINISHING);
assertFalse(stateMachine.transitionToFailed(new RuntimeException("failed")));
assertEquals(stateMachine.getQueryState(), FINISHING);
commitFuture.set(null);
tryGetFutureValue(stateMachine.getStateChange(FINISHED), 2, SECONDS);
assertEquals(stateMachine.getQueryState(), FINISHED);
}
Aggregations