Search in sources :

Example 6 with HetuMetaStoreManager

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

the class TestCommitTask method testUnknownTransactionCommit.

@Test
public void testUnknownTransactionCommit() {
    TransactionManager transactionManager = createTestTransactionManager();
    Session session = sessionBuilder().setTransactionId(// Use a random transaction ID that is unknown to the system
    TransactionId.create()).build();
    QueryStateMachine stateMachine = createQueryStateMachine("COMMIT", session, transactionManager);
    Future<?> future = new CommitTask().execute(new Commit(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager()));
    assertPrestoExceptionThrownBy(() -> getFutureValue(future)).hasErrorCode(UNKNOWN_TRANSACTION);
    // Still issue clear signal
    assertTrue(stateMachine.getQueryInfo(Optional.empty()).isClearTransactionId());
    assertFalse(stateMachine.getQueryInfo(Optional.empty()).getStartedTransactionId().isPresent());
    assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
Also used : Commit(io.prestosql.sql.tree.Commit) TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 7 with HetuMetaStoreManager

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

the class TestDropCacheTask method testDropWithNonQualifiedName.

@Test
public void testDropWithNonQualifiedName() {
    QualifiedName tableName = QualifiedName.of(table3);
    QualifiedName fullName = QualifiedName.of(CATALOG_NAME, schema, table3);
    DropCache statement = new DropCache(tableName, true);
    Session session = testSessionBuilder().setTransactionId(transactionManager.beginTransaction(false)).setCatalog(CATALOG_NAME).setSchema(schema).build();
    QueryStateMachine queryStateMachine = createQueryStateMachine("START TRANSACTION", session, transactionManager);
    getFutureValue(new DropCacheTask().execute(statement, createTestTransactionManager(), metadata, new AllowAllAccessControl(), queryStateMachine, Collections.emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())));
    assertFalse(SplitCacheMap.getInstance().cacheExists(fullName));
}
Also used : DropCache(io.prestosql.sql.tree.DropCache) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) QualifiedName(io.prestosql.sql.tree.QualifiedName) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) Session(io.prestosql.Session) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager) Test(org.testng.annotations.Test)

Example 8 with HetuMetaStoreManager

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

the class TestRollbackTask method testNoTransactionRollback.

@Test
public void testNoTransactionRollback() {
    TransactionManager transactionManager = createTestTransactionManager();
    Session session = sessionBuilder().build();
    QueryStateMachine stateMachine = createQueryStateMachine("ROLLBACK", session, transactionManager);
    assertPrestoExceptionThrownBy(() -> getFutureValue((Future<?>) new RollbackTask().execute(new Rollback(), transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager())))).hasErrorCode(NOT_IN_TRANSACTION);
    assertFalse(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 9 with HetuMetaStoreManager

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

the class TestSetRoleTask method assertSetRole.

private void assertSetRole(String statement, Map<String, SelectedRole> expected) {
    SetRole setRole = (SetRole) parser.createStatement(statement);
    QueryStateMachine stateMachine = QueryStateMachine.begin(statement, Optional.empty(), testSessionBuilder().setCatalog(CATALOG_NAME).build(), URI.create("fake://uri"), new ResourceGroupId("test"), new NoOpResourceGroupManager(), false, transactionManager, accessControl, executor, metadata, WarningCollector.NOOP);
    new SetRoleTask().execute(setRole, transactionManager, metadata, accessControl, stateMachine, ImmutableList.of(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager()));
    QueryInfo queryInfo = stateMachine.getQueryInfo(Optional.empty());
    assertEquals(queryInfo.getSetRoles(), expected);
}
Also used : SetRole(io.prestosql.sql.tree.SetRole) ResourceGroupId(io.prestosql.spi.resourcegroups.ResourceGroupId) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) NoOpResourceGroupManager(io.prestosql.execution.resourcegroups.NoOpResourceGroupManager) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager)

Example 10 with HetuMetaStoreManager

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

the class TestPrepareTask method executePrepare.

private Map<String, String> executePrepare(String statementName, Statement statement, String sqlString, Session session) {
    TransactionManager transactionManager = createTestTransactionManager();
    QueryStateMachine stateMachine = QueryStateMachine.begin(sqlString, Optional.empty(), session, URI.create("fake://uri"), new ResourceGroupId("test"), new NoOpResourceGroupManager(), false, transactionManager, new AccessControlManager(transactionManager), executor, metadata, WarningCollector.NOOP);
    Prepare prepare = new Prepare(identifier(statementName), statement);
    new PrepareTask(new SqlParser()).execute(prepare, transactionManager, metadata, new AllowAllAccessControl(), stateMachine, emptyList(), new HeuristicIndexerManager(new FileSystemClientManager(), new HetuMetaStoreManager()));
    return stateMachine.getAddedPreparedStatements();
}
Also used : AccessControlManager(io.prestosql.security.AccessControlManager) ResourceGroupId(io.prestosql.spi.resourcegroups.ResourceGroupId) TransactionManager(io.prestosql.transaction.TransactionManager) InMemoryTransactionManager.createTestTransactionManager(io.prestosql.transaction.InMemoryTransactionManager.createTestTransactionManager) AllowAllAccessControl(io.prestosql.security.AllowAllAccessControl) HeuristicIndexerManager(io.prestosql.heuristicindex.HeuristicIndexerManager) SqlParser(io.prestosql.sql.parser.SqlParser) Prepare(io.prestosql.sql.tree.Prepare) HetuMetaStoreManager(io.prestosql.metastore.HetuMetaStoreManager) NoOpResourceGroupManager(io.prestosql.execution.resourcegroups.NoOpResourceGroupManager) FileSystemClientManager(io.prestosql.filesystem.FileSystemClientManager)

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