use of com.facebook.presto.spi.QueryId in project presto by prestodb.
the class TestCommitTask method testNoTransactionCommit.
@Test
public void testNoTransactionCommit() throws Exception {
TransactionManager transactionManager = createTestTransactionManager();
AccessControl accessControl = new AccessControlManager(transactionManager);
Session session = sessionBuilder().build();
QueryStateMachine stateMachine = QueryStateMachine.begin(new QueryId("query"), "COMMIT", session, URI.create("fake://uri"), true, transactionManager, accessControl, executor, metadata);
try {
try {
getFutureValue(new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
fail();
} catch (CompletionException e) {
throw Throwables.propagate(e.getCause());
}
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), NOT_IN_TRANSACTION.toErrorCode());
}
assertFalse(stateMachine.getQueryInfoWithoutDetails().isClearTransactionId());
assertFalse(stateMachine.getQueryInfoWithoutDetails().getStartedTransactionId().isPresent());
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
use of com.facebook.presto.spi.QueryId in project presto by prestodb.
the class TestDeallocateTask method executeDeallocate.
private Set<String> executeDeallocate(String statementName, String sqlString, Session session) {
TransactionManager transactionManager = createTestTransactionManager();
AccessControl accessControl = new AccessControlManager(transactionManager);
QueryStateMachine stateMachine = QueryStateMachine.begin(new QueryId("query"), sqlString, session, URI.create("fake://uri"), false, transactionManager, accessControl, executor, metadata);
Deallocate deallocate = new Deallocate(statementName);
new DeallocateTask().execute(deallocate, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList());
return stateMachine.getDeallocatedPreparedStatements();
}
use of com.facebook.presto.spi.QueryId in project presto by prestodb.
the class TestStartTransactionTask method testStartTransactionExplicitModes.
@Test
public void testStartTransactionExplicitModes() throws Exception {
Session session = sessionBuilder().setClientTransactionSupport().build();
TransactionManager transactionManager = createTestTransactionManager();
AccessControl accessControl = new AccessControlManager(transactionManager);
QueryStateMachine stateMachine = QueryStateMachine.begin(new QueryId("query"), "START TRANSACTION", session, URI.create("fake://uri"), true, transactionManager, accessControl, executor, metadata);
assertFalse(stateMachine.getSession().getTransactionId().isPresent());
getFutureValue(new StartTransactionTask().execute(new StartTransaction(ImmutableList.of(new Isolation(Isolation.Level.SERIALIZABLE), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
assertFalse(stateMachine.getQueryInfoWithoutDetails().isClearTransactionId());
assertTrue(stateMachine.getQueryInfoWithoutDetails().getStartedTransactionId().isPresent());
assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfoWithoutDetails().getStartedTransactionId().get());
assertEquals(transactionInfo.getIsolationLevel(), IsolationLevel.SERIALIZABLE);
assertTrue(transactionInfo.isReadOnly());
assertFalse(transactionInfo.isAutoCommitContext());
}
use of com.facebook.presto.spi.QueryId in project presto by prestodb.
the class TestStartTransactionTask method testNonTransactionalClient.
@Test
public void testNonTransactionalClient() throws Exception {
Session session = sessionBuilder().build();
TransactionManager transactionManager = createTestTransactionManager();
AccessControl accessControl = new AccessControlManager(transactionManager);
QueryStateMachine stateMachine = QueryStateMachine.begin(new QueryId("query"), "START TRANSACTION", session, URI.create("fake://uri"), true, transactionManager, accessControl, executor, metadata);
assertFalse(stateMachine.getSession().getTransactionId().isPresent());
try {
try {
getFutureValue(new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
fail();
} catch (CompletionException e) {
throw Throwables.propagate(e.getCause());
}
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), INCOMPATIBLE_CLIENT.toErrorCode());
}
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
assertFalse(stateMachine.getQueryInfoWithoutDetails().isClearTransactionId());
assertFalse(stateMachine.getQueryInfoWithoutDetails().getStartedTransactionId().isPresent());
}
use of com.facebook.presto.spi.QueryId in project presto by prestodb.
the class TestStartTransactionTask method testNestedTransaction.
@Test
public void testNestedTransaction() throws Exception {
TransactionManager transactionManager = createTestTransactionManager();
AccessControl accessControl = new AccessControlManager(transactionManager);
Session session = sessionBuilder().setTransactionId(TransactionId.create()).setClientTransactionSupport().build();
QueryStateMachine stateMachine = QueryStateMachine.begin(new QueryId("query"), "START TRANSACTION", session, URI.create("fake://uri"), true, transactionManager, accessControl, executor, metadata);
try {
try {
getFutureValue(new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList()));
fail();
} catch (CompletionException e) {
throw Throwables.propagate(e.getCause());
}
} catch (PrestoException e) {
assertEquals(e.getErrorCode(), NOT_SUPPORTED.toErrorCode());
}
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
assertFalse(stateMachine.getQueryInfoWithoutDetails().isClearTransactionId());
assertFalse(stateMachine.getQueryInfoWithoutDetails().getStartedTransactionId().isPresent());
}
Aggregations