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");
}
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);
}
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);
}
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);
}
}
}
Aggregations