Search in sources :

Example 1 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class AccumuloConnector method getMetadata.

@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) {
    ConnectorMetadata metadata = transactions.get(transactionHandle);
    checkArgument(metadata != null, "no such transaction: %s", transactionHandle);
    return metadata;
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata)

Example 2 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class HiveConnector method getMetadata.

@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) {
    ConnectorMetadata metadata = transactionManager.get(transaction);
    checkArgument(metadata != null, "no such transaction: %s", transaction);
    return new ClassLoaderSafeConnectorMetadata(metadata, classLoader);
}
Also used : ClassLoaderSafeConnectorMetadata(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ClassLoaderSafeConnectorMetadata(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorMetadata)

Example 3 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class HiveTransactionManager method put.

public void put(ConnectorTransactionHandle transactionHandle, ConnectorMetadata metadata) {
    ConnectorMetadata previousValue = transactions.putIfAbsent(transactionHandle, metadata);
    checkState(previousValue == null);
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata)

Example 4 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class TestTransactionManager method testTransactionWorkflow.

@Test
public void testTransactionWorkflow() throws Exception {
    try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
        CatalogManager catalogManager = new CatalogManager();
        TransactionManager transactionManager = TransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), catalogManager, finishingExecutor);
        Connector c1 = new TpchConnectorFactory().create(CATALOG_NAME, ImmutableMap.of(), new TestingConnectorContext());
        registerConnector(catalogManager, transactionManager, CATALOG_NAME, CONNECTOR_ID, c1);
        TransactionId transactionId = transactionManager.beginTransaction(false);
        assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
        TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertFalse(transactionInfo.isAutoCommitContext());
        assertTrue(transactionInfo.getConnectorIds().isEmpty());
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        ConnectorMetadata metadata = transactionManager.getOptionalCatalogMetadata(transactionId, CATALOG_NAME).get().getMetadata();
        metadata.listSchemaNames(TEST_SESSION.toConnectorSession(CONNECTOR_ID));
        transactionInfo = transactionManager.getTransactionInfo(transactionId);
        assertEquals(transactionInfo.getConnectorIds(), ImmutableList.of(CONNECTOR_ID, INFORMATION_SCHEMA_ID, SYSTEM_TABLES_ID));
        assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
        getFutureValue(transactionManager.asyncCommit(transactionId));
        assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
    }
}
Also used : InformationSchemaConnector(com.facebook.presto.connector.informationSchema.InformationSchemaConnector) Connector(com.facebook.presto.spi.connector.Connector) SystemConnector(com.facebook.presto.connector.system.SystemConnector) TpchConnectorFactory(com.facebook.presto.tpch.TpchConnectorFactory) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext) ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) CatalogManager(com.facebook.presto.metadata.CatalogManager) Test(org.testng.annotations.Test)

Example 5 with ConnectorMetadata

use of com.facebook.presto.spi.connector.ConnectorMetadata in project presto by prestodb.

the class MetadataManager method createView.

@Override
public void createView(Session session, QualifiedObjectName viewName, String viewData, boolean replace) {
    CatalogMetadata catalogMetadata = getCatalogMetadataForWrite(session, viewName.getCatalogName());
    ConnectorId connectorId = catalogMetadata.getConnectorId();
    ConnectorMetadata metadata = catalogMetadata.getMetadata();
    metadata.createView(session.toConnectorSession(connectorId), viewName.asSchemaTableName(), viewData, replace);
}
Also used : ConnectorMetadata(com.facebook.presto.spi.connector.ConnectorMetadata) ConnectorId(com.facebook.presto.connector.ConnectorId)

Aggregations

ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)100 ConnectorSession (com.facebook.presto.spi.ConnectorSession)49 Test (org.testng.annotations.Test)48 ConnectorTableHandle (com.facebook.presto.spi.ConnectorTableHandle)42 TestingConnectorSession (com.facebook.presto.testing.TestingConnectorSession)39 ConnectorId (com.facebook.presto.connector.ConnectorId)38 ColumnHandle (com.facebook.presto.spi.ColumnHandle)33 ConnectorTableMetadata (com.facebook.presto.spi.ConnectorTableMetadata)33 SchemaTableName (com.facebook.presto.spi.SchemaTableName)31 MaterializedResult (com.facebook.presto.testing.MaterializedResult)28 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)26 ConnectorOutputTableHandle (com.facebook.presto.spi.ConnectorOutputTableHandle)25 ConnectorInsertTableHandle (com.facebook.presto.spi.ConnectorInsertTableHandle)24 ConnectorPageSink (com.facebook.presto.spi.ConnectorPageSink)24 ConnectorPageSource (com.facebook.presto.spi.ConnectorPageSource)24 PrestoException (com.facebook.presto.spi.PrestoException)24 Path (org.apache.hadoop.fs.Path)24 Constraint (com.facebook.presto.spi.Constraint)23 SchemaTablePrefix (com.facebook.presto.spi.SchemaTablePrefix)23 MaterializedRow (com.facebook.presto.testing.MaterializedRow)23