use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class ConnectorManager method addConnectorFactory.
public synchronized void addConnectorFactory(ConnectorFactory connectorFactory) {
checkState(!stopped.get(), "ConnectorManager is stopped");
ConnectorFactory existingConnectorFactory = connectorFactories.putIfAbsent(connectorFactory.getName(), connectorFactory);
checkArgument(existingConnectorFactory == null, "Connector %s is already registered", connectorFactory.getName());
handleResolver.addConnectorName(connectorFactory.getName(), connectorFactory.getHandleResolver());
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class TestPostgreSqlPlugin method testCreateConnector.
@Test
public void testCreateConnector() {
Plugin plugin = new PostgreSqlPlugin();
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class TestMetadataManager method setUp.
@BeforeClass
public void setUp() throws Exception {
queryRunner = TpchQueryRunnerBuilder.builder().build();
queryRunner.installPlugin(new Plugin() {
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
MockConnectorFactory connectorFactory = MockConnectorFactory.builder().withListSchemaNames(session -> ImmutableList.of("UPPER_CASE_SCHEMA")).withListTables((session, schemaNameOrNull) -> {
throw new UnsupportedOperationException();
}).withGetViews((session, prefix) -> ImmutableMap.of()).withGetColumnHandles((session, tableHandle) -> {
throw new UnsupportedOperationException();
}).withGetTableStatistics(() -> {
throw new UnsupportedOperationException();
}).build();
return ImmutableList.of(connectorFactory);
}
});
queryRunner.createCatalog("upper_case_schema_catalog", "mock");
metadataManager = (MetadataManager) queryRunner.getMetadata();
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class TestRaptorPlugin method testPlugin.
@Test
public void testPlugin() throws Exception {
RaptorPlugin plugin = loadPlugin(RaptorPlugin.class);
ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
assertInstanceOf(factory, RaptorConnectorFactory.class);
File tmpDir = Files.createTempDir();
try {
Map<String, String> config = ImmutableMap.<String, String>builder().put("metadata.db.type", "h2").put("metadata.db.filename", tmpDir.getAbsolutePath()).put("storage.data-directory", tmpDir.toURI().toString()).build();
factory.create("test", config, new TestingConnectorContext());
} finally {
deleteRecursively(tmpDir.toPath(), ALLOW_INSECURE);
}
}
use of com.facebook.presto.spi.connector.ConnectorFactory in project presto by prestodb.
the class RaptorBenchmarkQueryRunner method createLocalQueryRunner.
public static LocalQueryRunner createLocalQueryRunner() {
Session session = testSessionBuilder().setCatalog("raptor").setSchema("benchmark").build();
LocalQueryRunner localQueryRunner = new LocalQueryRunner(session);
// add tpch
localQueryRunner.createCatalog("tpch", new TpchConnectorFactory(1), ImmutableMap.of());
// add raptor
ConnectorFactory raptorConnectorFactory = getOnlyElement(new RaptorPlugin().getConnectorFactories());
Map<String, String> config = createRaptorConfig(TPCH_CACHE_DIR);
localQueryRunner.createCatalog("raptor", raptorConnectorFactory, config);
if (!localQueryRunner.tableExists(session, "orders")) {
localQueryRunner.execute("CREATE TABLE orders AS SELECT * FROM tpch.sf1.orders");
}
if (!localQueryRunner.tableExists(session, "lineitem")) {
localQueryRunner.execute("CREATE TABLE lineitem AS SELECT * FROM tpch.sf1.lineitem");
}
return localQueryRunner;
}
Aggregations