Search in sources :

Example 6 with StartTransaction

use of io.prestosql.sql.tree.StartTransaction in project hetu-core by openlookeng.

the class TestStartTransactionTask method testNestedTransaction.

@Test
public void testNestedTransaction() {
    TransactionManager transactionManager = createTestTransactionManager();
    Session session = sessionBuilder().setTransactionId(TransactionId.create()).setClientTransactionSupport().build();
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    assertPrestoExceptionThrownBy(() -> getFutureValue((Future<?>) new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(NOT_SUPPORTED);
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
}
Also used : TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager(io.prestosql.transaction.InMemoryTransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) StartTransaction(io.prestosql.sql.tree.StartTransaction) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 7 with StartTransaction

use of io.prestosql.sql.tree.StartTransaction in project hetu-core by openlookeng.

the class TestStartTransactionTask method testNonTransactionalClient.

@Test
public void testNonTransactionalClient() {
    Session session = sessionBuilder().build();
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    assertFalse(stateMachine.getSession().getTransactionId().isPresent());
    assertPrestoExceptionThrownBy(() -> getFutureValue((Future<?>) new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(INCOMPATIBLE_CLIENT);
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
}
Also used : TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager(io.prestosql.transaction.InMemoryTransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) StartTransaction(io.prestosql.sql.tree.StartTransaction) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 8 with StartTransaction

use of io.prestosql.sql.tree.StartTransaction in project hetu-core by openlookeng.

the class TestStartTransactionTask method testStartTransactionTooManyAccessModes.

@Test
public void testStartTransactionTooManyAccessModes() {
    Session session = sessionBuilder().setClientTransactionSupport().build();
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    assertFalse(stateMachine.getSession().getTransactionId().isPresent());
    assertSemanticExceptionThrownBy(() -> getFutureValue(new StartTransactionTask().execute(new StartTransaction(ImmutableList.of(new TransactionAccessMode(true), new TransactionAccessMode(true))), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(INVALID_TRANSACTION_MODE);
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
}
Also used : TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager(io.prestosql.transaction.InMemoryTransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) TransactionAccessMode(io.prestosql.sql.tree.TransactionAccessMode) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) StartTransaction(io.prestosql.sql.tree.StartTransaction) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Aggregations

StartTransaction (io.prestosql.sql.tree.StartTransaction)8 Test (org.testng.annotations.Test)8 Session (io.prestosql.Session)7 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)7 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)7 HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)7 AllowAllAccessControl (io.prestosql.security.AllowAllAccessControl)7 InMemoryTransactionManager (io.prestosql.transaction.InMemoryTransactionManager)7 InMemoryTransactionManager.createTestTransactionManager (io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager)7 TransactionManager (io.prestosql.transaction.TransactionManager)7 Isolation (io.prestosql.sql.tree.Isolation)3 TransactionAccessMode (io.prestosql.sql.tree.TransactionAccessMode)3 TransactionInfo (io.prestosql.transaction.TransactionInfo)2 Duration (io.airlift.units.Duration)1 CatalogManager (io.prestosql.metadata.CatalogManager)1 TransactionManagerConfig (io.prestosql.transaction.TransactionManagerConfig)1