Search in sources :

Example 1 with TransactionManagerConfig

use of io.prestosql.transaction.TransactionManagerConfig in project hetu-core by openlookeng.

the class TestStartTransactionTask method testStartTransactionIdleExpiration.

@Test
public void testStartTransactionIdleExpiration() throws Exception {
    Session session = sessionBuilder().setClientTransactionSupport().build();
    TransactionManager transactionManager = InMemoryTransactionManager.create(new TransactionManagerConfig().setIdleTimeout(// Fast idle timeout
    new Duration(1, TimeUnit.MICROSECONDS)).setIdleCheckInterval(new Duration(10, TimeUnit.MILLISECONDS)), scheduledExecutor, new CatalogManager(), executor);
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    assertFalse(stateMachine.getSession().getTransactionId().isPresent());
    getFutureValue(new StartTransactionTask().execute(new StartTransaction(ImmutableList.of()), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    long start = System.nanoTime();
    while (!transactionManager.getAllTransactionInfos().isEmpty()) {
        if (Duration.nanosSince(start).toMillis() > 10_000) {
            fail("Transaction did not expire in the allotted time");
        }
        TimeUnit.MILLISECONDS.sleep(10);
    }
}
Also used : HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) Duration(io.airlift.units.Duration) CatalogManager(io.prestosql.metadata.CatalogManager) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) TransactionManagerConfig(io.prestosql.transaction.TransactionManagerConfig) TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager(io.prestosql.transaction.InMemoryTransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) StartTransaction(io.prestosql.sql.tree.StartTransaction) Session(io.prestosql.Session) Test(org.testng.annotations.Test)

Aggregations

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