Search in sources :

Example 16 with HetuMetaStoreManager

use of io.prestosql.metastore.HetuMetaStoreManager in project hetu-core by openlookeng.

the class TestResetSessionTask method test.

@Test
public void test() {
    Session session = testSessionBuilder(metadata.getSessionPropertyManager()).setSystemProperty("foo", "bar").setCatalogSessionProperty(CATALOG_NAME, "baz", "blah").build();
    QueryStateMachine stateMachine = QueryStateMachine.begin("reset foo", Optional.empty(), session, URI.create("fake://uri"), new ResourceGroupId("test"), new NoOpResourceGroupManager(), false, transactionManager, accessControl, executor, metadata, WarningCollector.NOOP);
    getFutureValue(new ResetSessionTask().execute(new ResetSession(QualifiedName.of(CATALOG_NAME, "baz")), transactionManager, metadata, accessControl, stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    Set<String> sessionProperties = stateMachine.getResetSessionProperties();
    assertEquals(sessionProperties, ImmutableSet.of("catalog.baz"));
}
Also used : ResourceGroupId(io.prestosql.spi.resourcegroups.ResourceGroupId) ResetSession(io.prestosql.sql.tree.ResetSession) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) NoOpResourceGroupManager(io.prestosql.execution.resourcegroups.NoOpResourceGroupManager) ResetSession(io.prestosql.sql.tree.ResetSession) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 17 with HetuMetaStoreManager

use of io.prestosql.metastore.HetuMetaStoreManager in project hetu-core by openlookeng.

the class TestRollbackTask method testRollback.

@Test
public void testRollback() {
    TransactionManager transactionManager = createTestTransactionManager();
    Session session = sessionBuilder().setTransactionId(transactionManager.beginTransaction(false)).build();
    QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, transactionManager);
    assertTrue(stateMachine.getSession().getTransactionId().isPresent());
    assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
    getFutureValue(new RollbackTask().execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
Also used : TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) Rollback(io.prestosql.sql.tree.Rollback) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 18 with HetuMetaStoreManager

use of io.prestosql.metastore.HetuMetaStoreManager in project hetu-core by openlookeng.

the class TestSetSessionTask method testSetSessionWithParameters.

private void testSetSessionWithParameters(String property, Expression expression, String expectedValue, List<Expression> parameters) {
    QualifiedName qualifiedPropName = QualifiedName.of(CATALOG_NAME, property);
    QueryStateMachine stateMachine = QueryStateMachine.begin(format("set %s = 'old_value'", qualifiedPropName), Optional.empty(), TEST_SESSION, URI.create("fake://uri"), new ResourceGroupId("test"), new NoOpResourceGroupManager(), false, transactionManager, accessControl, executor, metadata, WarningCollector.NOOP);
    getFutureValue(new SetSessionTask().execute(new SetSession(qualifiedPropName, expression), transactionManager, metadata, accessControl, stateMachine, parameters, new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    Map<String, String> sessionProperties = stateMachine.getSetSessionProperties();
    assertEquals(sessionProperties, ImmutableMap.of(qualifiedPropName.toString(), expectedValue));
}
Also used : ResourceGroupId(io.prestosql.spi.resourcegroups.ResourceGroupId) SetSession(io.prestosql.sql.tree.SetSession) QualifiedName(io.prestosql.sql.tree.QualifiedName) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) NoOpResourceGroupManager(io.prestosql.execution.resourcegroups.NoOpResourceGroupManager) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager)

Example 19 with HetuMetaStoreManager

use of io.prestosql.metastore.HetuMetaStoreManager in project hetu-core by openlookeng.

the class TestStartTransactionTask method testStartTransaction.

@Test
public void testStartTransaction() {
    Session session = sessionBuilder().setClientTransactionSupport().build();
    TransactionManager transactionManager = createTestTransactionManager();
    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());
    assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
    TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
    assertFalse(transactionInfo.isAutoCommitContext());
}
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) TransactionInfo(io.prestosql.transaction.TransactionInfo) 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 20 with HetuMetaStoreManager

use of io.prestosql.metastore.HetuMetaStoreManager in project hetu-core by openlookeng.

the class TestStartTransactionTask method testStartTransactionExplicitModes.

@Test
public void testStartTransactionExplicitModes() {
    Session session = sessionBuilder().setClientTransactionSupport().build();
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    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(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertTrue(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
    TransactionInfo transactionInfo = transactionManager.getTransactionInfo(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().get());
    assertEquals(transactionInfo.getIsolationLevel(), IsolationLevel.SERIALIZABLE);
    assertTrue(transactionInfo.isReadOnly());
    assertFalse(transactionInfo.isAutoCommitContext());
}
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) Isolation(io.prestosql.sql.tree.Isolation) TransactionInfo(io.prestosql.transaction.TransactionInfo) 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

HetuMetaStoreManager (io.prestosql.metastore.HetuMetaStoreManager)25 FileSystemClientManager (io.prestosql.filesystem.FileSystemClientManager)24 HeuristicIndexerManager (io.prestosql.heuristicindex.HeuristicIndexerManager)24 AllowAllAccessControl (io.prestosql.security.AllowAllAccessControl)18 Test (org.testng.annotations.Test)18 Session (io.prestosql.Session)15 InMemoryTransactionManager.createTestTransactionManager (io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager)15 TransactionManager (io.prestosql.transaction.TransactionManager)15 StartTransaction (io.prestosql.sql.tree.StartTransaction)6 InMemoryTransactionManager (io.prestosql.transaction.InMemoryTransactionManager)6 NoOpResourceGroupManager (io.prestosql.execution.resourcegroups.NoOpResourceGroupManager)5 ResourceGroupId (io.prestosql.spi.resourcegroups.ResourceGroupId)5 Commit (io.prestosql.sql.tree.Commit)3 Duration (io.airlift.units.Duration)2 CubeManager (io.prestosql.cube.CubeManager)2 Metadata (io.prestosql.metadata.Metadata)2 Split (io.prestosql.metadata.Split)2 CatalogName (io.prestosql.spi.connector.CatalogName)2 PlanNodeId (io.prestosql.spi.plan.PlanNodeId)2 SplitSource (io.prestosql.split.SplitSource)2