Search in sources :

Example 16 with Connector

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

the class TestCassandraConnector method setup.

@BeforeClass
public void setup() throws Exception {
    EmbeddedCassandra.start();
    String keyspace = "test_connector";
    createTestTables(EmbeddedCassandra.getSession(), keyspace, DATE);
    String connectorId = "cassandra-test";
    CassandraConnectorFactory connectorFactory = new CassandraConnectorFactory(connectorId);
    Connector connector = connectorFactory.create(connectorId, ImmutableMap.of("cassandra.contact-points", EmbeddedCassandra.getHost(), "cassandra.native-protocol-port", Integer.toString(EmbeddedCassandra.getPort())), new TestingConnectorContext());
    metadata = connector.getMetadata(CassandraTransactionHandle.INSTANCE);
    assertInstanceOf(metadata, CassandraMetadata.class);
    splitManager = connector.getSplitManager();
    assertInstanceOf(splitManager, CassandraSplitManager.class);
    recordSetProvider = connector.getRecordSetProvider();
    assertInstanceOf(recordSetProvider, CassandraRecordSetProvider.class);
    database = keyspace;
    table = new SchemaTableName(database, TABLE_ALL_TYPES.toLowerCase(ENGLISH));
    tableUnpartitioned = new SchemaTableName(database, "presto_test_unpartitioned");
    invalidTable = new SchemaTableName(database, "totally_invalid_table_name");
}
Also used : Connector(com.facebook.presto.spi.connector.Connector) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext) SchemaTableName(com.facebook.presto.spi.SchemaTableName) BeforeClass(org.testng.annotations.BeforeClass)

Example 17 with Connector

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

the class TestKafkaPlugin method testSpinup.

@Test
public void testSpinup() {
    KafkaPlugin plugin = new KafkaPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    assertInstanceOf(factory, KafkaConnectorFactory.class);
    Connector c = factory.create("test-connector", ImmutableMap.<String, String>builder().put("kafka.table-names", "test").put("kafka.nodes", "localhost:9092").build(), new TestingConnectorContext());
    assertNotNull(c);
}
Also used : Connector(com.facebook.presto.spi.connector.Connector) ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 18 with Connector

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

the class TestHiveConnectorFactory method assertCreateConnector.

private static void assertCreateConnector(String metastoreUri) {
    HiveConnectorFactory connectorFactory = new HiveConnectorFactory("hive-test", HiveConnector.class.getClassLoader(), Optional.empty());
    Map<String, String> config = ImmutableMap.<String, String>builder().put("hive.metastore.uri", metastoreUri).build();
    Connector connector = connectorFactory.create("hive-test", config, new TestingConnectorContext());
    ConnectorTransactionHandle transaction = connector.beginTransaction(READ_UNCOMMITTED, true);
    assertInstanceOf(connector.getMetadata(transaction), ClassLoaderSafeConnectorMetadata.class);
    assertInstanceOf(connector.getSplitManager(), ClassLoaderSafeConnectorSplitManager.class);
    assertInstanceOf(connector.getPageSourceProvider(), ConnectorPageSourceProvider.class);
    connector.commit(transaction);
}
Also used : Connector(com.facebook.presto.spi.connector.Connector) ConnectorTransactionHandle(com.facebook.presto.spi.connector.ConnectorTransactionHandle) TestingConnectorContext(com.facebook.presto.testing.TestingConnectorContext)

Example 19 with Connector

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

the class ConnectorManager method removeConnectorInternal.

private synchronized void removeConnectorInternal(ConnectorId connectorId) {
    splitManager.removeConnectorSplitManager(connectorId);
    pageSourceManager.removeConnectorPageSourceProvider(connectorId);
    pageSinkManager.removeConnectorPageSinkProvider(connectorId);
    indexManager.removeIndexProvider(connectorId);
    partitioningProviderManager.removePartitioningProvider(connectorId);
    metadataManager.getProcedureRegistry().removeProcedures(connectorId);
    accessControlManager.removeCatalogAccessControl(connectorId);
    metadataManager.getTablePropertyManager().removeProperties(connectorId);
    metadataManager.getColumnPropertyManager().removeProperties(connectorId);
    metadataManager.getSchemaPropertyManager().removeProperties(connectorId);
    metadataManager.getAnalyzePropertyManager().removeProperties(connectorId);
    metadataManager.getSessionPropertyManager().removeConnectorSessionProperties(connectorId);
    connectorPlanOptimizerManager.removePlanOptimizerProvider(connectorId);
    connectorMetadataUpdaterManager.removeMetadataUpdaterProvider(connectorId);
    MaterializedConnector materializedConnector = connectors.remove(connectorId);
    if (materializedConnector != null) {
        Connector connector = materializedConnector.getConnector();
        try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(connector.getClass().getClassLoader())) {
            connector.shutdown();
        } catch (Throwable t) {
            log.error(t, "Error shutting down connector: %s", connectorId);
        }
    }
}
Also used : SystemConnector(com.facebook.presto.connector.system.SystemConnector) InformationSchemaConnector(com.facebook.presto.connector.informationSchema.InformationSchemaConnector) Connector(com.facebook.presto.spi.connector.Connector) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader)

Aggregations

Connector (com.facebook.presto.spi.connector.Connector)19 TestingConnectorContext (com.facebook.presto.testing.TestingConnectorContext)11 Test (org.testng.annotations.Test)9 InformationSchemaConnector (com.facebook.presto.connector.informationSchema.InformationSchemaConnector)8 SystemConnector (com.facebook.presto.connector.system.SystemConnector)8 ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)7 CatalogManager (com.facebook.presto.metadata.CatalogManager)6 ConnectorTransactionHandle (com.facebook.presto.spi.connector.ConnectorTransactionHandle)6 ConnectorMetadata (com.facebook.presto.spi.connector.ConnectorMetadata)5 Catalog (com.facebook.presto.metadata.Catalog)4 IsolationLevel (com.facebook.presto.spi.transaction.IsolationLevel)4 TpchConnectorFactory (com.facebook.presto.tpch.TpchConnectorFactory)4 InMemoryNodeManager (com.facebook.presto.metadata.InMemoryNodeManager)3 InternalNodeManager (com.facebook.presto.metadata.InternalNodeManager)3 MetadataManager (com.facebook.presto.metadata.MetadataManager)3 AccessControlManager (com.facebook.presto.security.AccessControlManager)3 NodeManager (com.facebook.presto.spi.NodeManager)3 Session (com.facebook.presto.Session)2 ConnectorId (com.facebook.presto.spi.ConnectorId)2 ConnectorId.createInformationSchemaConnectorId (com.facebook.presto.spi.ConnectorId.createInformationSchemaConnectorId)2