io.prestosql.spi.connector.Connector Java Examples
The following examples show how to use
io.prestosql.spi.connector.Connector.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestKinesisPlugin.java From presto with Apache License 2.0 | 6 votes |
@Test public void testSpinUp() { String accessKey = "kinesis.accessKey"; String secretKey = "kinesis.secretKey"; ConnectorFactory factory = testConnectorExists(); // Important: this has to be created before we setup the injector in the factory: assertNotNull(factory.getHandleResolver()); Connector c = factory.create("kinesis.test-connector", ImmutableMap.<String, String>builder() .put("kinesis.hide-internal-columns", "false") .put("kinesis.access-key", TestUtils.noneToBlank(accessKey)) .put("kinesis.secret-key", TestUtils.noneToBlank(secretKey)) .build(), new TestingConnectorContext()); assertNotNull(c); // Verify that the key objects have been created on the connector assertNotNull(c.getRecordSetProvider()); assertNotNull(c.getSplitManager()); ConnectorMetadata md = c.getMetadata(KinesisTransactionHandle.INSTANCE); assertNotNull(md); ConnectorTransactionHandle handle = c.beginTransaction(READ_COMMITTED, true); assertTrue(handle instanceof KinesisTransactionHandle); }
Example #2
Source File: PhoenixConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) { requireNonNull(requiredConfig, "requiredConfig is null"); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) { Bootstrap app = new Bootstrap( new JsonModule(), new MBeanServerModule(), new MBeanModule(), new PhoenixClientModule(catalogName), binder -> { binder.bind(ClassLoader.class).toInstance(PhoenixConnectorFactory.class.getClassLoader()); binder.bind(TypeManager.class).toInstance(context.getTypeManager()); }); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(requiredConfig) .initialize(); return injector.getInstance(PhoenixConnector.class); } }
Example #3
Source File: PrometheusConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) { requireNonNull(requiredConfig, "requiredConfig is null"); try { // A plugin is not required to use Guice; it is just very convenient Bootstrap app = new Bootstrap( new JsonModule(), new PrometheusModule(context.getTypeManager())); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(requiredConfig) .initialize(); return injector.getInstance(PrometheusConnector.class); } catch (Exception e) { throwIfUnchecked(e); throw new RuntimeException(e); } }
Example #4
Source File: SheetsConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new SheetsModule(context.getTypeManager())); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(SheetsConnector.class); }
Example #5
Source File: ExampleConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) { requireNonNull(requiredConfig, "requiredConfig is null"); // A plugin is not required to use Guice; it is just very convenient Bootstrap app = new Bootstrap( new JsonModule(), new ExampleModule(context.getTypeManager())); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(requiredConfig) .initialize(); return injector.getInstance(ExampleConnector.class); }
Example #6
Source File: TestRedisPlugin.java From presto with Apache License 2.0 | 6 votes |
@Test public void testStartup() { RedisPlugin plugin = new RedisPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); assertInstanceOf(factory, RedisConnectorFactory.class); Connector c = factory.create( "test-connector", ImmutableMap.<String, String>builder() .put("redis.table-names", "test") .put("redis.nodes", "localhost:6379") .build(), new TestingConnectorContext()); assertNotNull(c); }
Example #7
Source File: JdbcConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) { requireNonNull(requiredConfig, "requiredConfig is null"); Bootstrap app = new Bootstrap( binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager()), binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()), binder -> binder.bind(VersionEmbedder.class).toInstance(context.getVersionEmbedder()), new JdbcModule(catalogName), moduleProvider.getModule(catalogName)); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(requiredConfig) .initialize(); return injector.getInstance(JdbcConnector.class); }
Example #8
Source File: AccumuloConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "catalogName is null"); requireNonNull(config, "requiredConfig is null"); requireNonNull(context, "context is null"); Bootstrap app = new Bootstrap( new JsonModule(), new AccumuloModule(context.getTypeManager())); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(AccumuloConnector.class); }
Example #9
Source File: JmxConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { Bootstrap app = new Bootstrap( new MBeanServerModule(), binder -> { configBinder(binder).bindConfig(JmxConnectorConfig.class); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); binder.bind(JmxConnector.class).in(Scopes.SINGLETON); binder.bind(JmxHistoricalData.class).in(Scopes.SINGLETON); binder.bind(JmxMetadata.class).in(Scopes.SINGLETON); binder.bind(JmxSplitManager.class).in(Scopes.SINGLETON); binder.bind(JmxPeriodicSampler.class).in(Scopes.SINGLETON); binder.bind(JmxRecordSetProvider.class).in(Scopes.SINGLETON); }); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(JmxConnector.class); }
Example #10
Source File: TestBeginQuery.java From presto with Apache License 2.0 | 6 votes |
@Override public Iterable<ConnectorFactory> getConnectorFactories() { return ImmutableList.of(new ConnectorFactory() { @Override public String getName() { return "test"; } @Override public ConnectorHandleResolver getHandleResolver() { return new TestingHandleResolver(); } @Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { return new TestConnector(metadata); } }); }
Example #11
Source File: TestCoordinatorDynamicFiltering.java From presto with Apache License 2.0 | 6 votes |
@Override public Iterable<ConnectorFactory> getConnectorFactories() { return ImmutableList.of(new ConnectorFactory() { private final ConnectorMetadata metadata = new TestingMetadata(); @Override public String getName() { return "test"; } @Override public ConnectorHandleResolver getHandleResolver() { return new TestingHandleResolver(); } @Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { return new TestConnector(metadata, Duration.valueOf("10s"), expectedDynamicFilter); } }); }
Example #12
Source File: PinotConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "connectorId is null"); requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new MBeanModule(), new PinotModule(catalogName, context.getTypeManager(), context.getNodeManager())); Injector injector = app.strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(PinotConnector.class); }
Example #13
Source File: KafkaConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "catalogName is null"); requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new KafkaConnectorModule(), extension, binder -> { binder.bind(ClassLoader.class).toInstance(KafkaConnectorFactory.class.getClassLoader()); binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); }); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(KafkaConnector.class); }
Example #14
Source File: ConnectorManager.java From presto with Apache License 2.0 | 6 votes |
@PreDestroy public synchronized void stop() { if (stopped.getAndSet(true)) { return; } for (Map.Entry<CatalogName, MaterializedConnector> entry : connectors.entrySet()) { Connector connector = entry.getValue().getConnector(); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(connector.getClass().getClassLoader())) { connector.shutdown(); } catch (Throwable t) { log.error(t, "Error shutting down connector: %s", entry.getKey()); } } }
Example #15
Source File: ConnectorManager.java From presto with Apache License 2.0 | 6 votes |
private synchronized void removeConnectorInternal(CatalogName catalogName) { splitManager.removeConnectorSplitManager(catalogName); pageSourceManager.removeConnectorPageSourceProvider(catalogName); pageSinkManager.removeConnectorPageSinkProvider(catalogName); indexManager.removeIndexProvider(catalogName); nodePartitioningManager.removePartitioningProvider(catalogName); metadataManager.getProcedureRegistry().removeProcedures(catalogName); accessControlManager.removeCatalogAccessControl(catalogName); metadataManager.getTablePropertyManager().removeProperties(catalogName); metadataManager.getColumnPropertyManager().removeProperties(catalogName); metadataManager.getSchemaPropertyManager().removeProperties(catalogName); metadataManager.getAnalyzePropertyManager().removeProperties(catalogName); metadataManager.getSessionPropertyManager().removeConnectorSessionProperties(catalogName); MaterializedConnector materializedConnector = connectors.remove(catalogName); 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", catalogName); } } }
Example #16
Source File: TestKafkaPlugin.java From presto with Apache License 2.0 | 6 votes |
@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); }
Example #17
Source File: KuduConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new KuduModule(context.getTypeManager())); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(KuduConnector.class); }
Example #18
Source File: Catalog.java From presto with Apache License 2.0 | 6 votes |
public Catalog( String catalogName, CatalogName connectorCatalogName, Connector connector, CatalogName informationSchemaId, Connector informationSchema, CatalogName systemTablesId, Connector systemTables) { this.catalogName = checkCatalogName(catalogName); this.connectorCatalogName = requireNonNull(connectorCatalogName, "connectorConnectorId is null"); this.connector = requireNonNull(connector, "connector is null"); this.informationSchemaId = requireNonNull(informationSchemaId, "informationSchemaId is null"); this.informationSchema = requireNonNull(informationSchema, "informationSchema is null"); this.systemTablesId = requireNonNull(systemTablesId, "systemTablesId is null"); this.systemTables = requireNonNull(systemTables, "systemTables is null"); }
Example #19
Source File: TestingSession.java From presto with Apache License 2.0 | 6 votes |
private static Connector createTestSessionConnector() { return new Connector() { @Override public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) { return new ConnectorTransactionHandle() {}; } @Override public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) { return new SystemTablesMetadata(new StaticSystemTablesProvider(ImmutableSet.of())); } }; }
Example #20
Source File: TestAccessControlManager.java From presto with Apache License 2.0 | 6 votes |
private static CatalogName registerBogusConnector(CatalogManager catalogManager, TransactionManager transactionManager, AccessControl accessControl, String catalogName) { CatalogName catalog = new CatalogName(catalogName); Connector connector = new TpchConnectorFactory().create(catalogName, ImmutableMap.of(), new TestingConnectorContext()); InMemoryNodeManager nodeManager = new InMemoryNodeManager(); Metadata metadata = createTestMetadataManager(catalogManager); CatalogName systemId = createSystemTablesCatalogName(catalog); catalogManager.registerCatalog(new Catalog( catalogName, catalog, connector, createInformationSchemaCatalogName(catalog), new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl), systemId, new SystemConnector( nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog)))); return catalog; }
Example #21
Source File: CassandraConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new MBeanModule(), new JsonModule(), new CassandraClientModule(), new MBeanServerModule()); Injector injector = app.strictConfig().doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(CassandraConnector.class); }
Example #22
Source File: LocalFileConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()), new LocalFileModule()); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(LocalFileConnector.class); }
Example #23
Source File: BigQueryConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "catalogName is null"); requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new BigQueryConnectorModule(context.getNodeManager()), binder -> { binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); }); Injector injector = app.strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(BigQueryConnector.class); }
Example #24
Source File: TestTransactionManager.java From presto with Apache License 2.0 | 6 votes |
private static void registerConnector( CatalogManager catalogManager, TransactionManager transactionManager, String catalogName, CatalogName catalog, Connector connector) { CatalogName systemId = createSystemTablesCatalogName(catalog); InternalNodeManager nodeManager = new InMemoryNodeManager(); Metadata metadata = createTestMetadataManager(catalogManager); catalogManager.registerCatalog(new Catalog( catalogName, catalog, connector, createInformationSchemaCatalogName(catalog), new InformationSchemaConnector(catalogName, nodeManager, metadata, new AllowAllAccessControl()), systemId, new SystemConnector( nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog)))); }
Example #25
Source File: ThriftConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { Bootstrap app = new Bootstrap( new MBeanModule(), new MBeanServerModule(), new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.plugin.thrift", "presto.plugin.thrift"), new DriftNettyClientModule(), binder -> { binder.bind(TypeManager.class).toInstance(context.getTypeManager()); }, locationModule, new ThriftModule()); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(ThriftConnector.class); }
Example #26
Source File: TestAnalyzer.java From presto with Apache License 2.0 | 6 votes |
private Catalog createTestingCatalog(String catalogName, CatalogName catalog) { CatalogName systemId = createSystemTablesCatalogName(catalog); Connector connector = createTestingConnector(); InternalNodeManager nodeManager = new InMemoryNodeManager(); return new Catalog( catalogName, catalog, connector, createInformationSchemaCatalogName(catalog), new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl), systemId, new SystemConnector( nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, catalog))); }
Example #27
Source File: TestingElasticsearchConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "catalogName is null"); requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new ElasticsearchConnectorModule(), binder -> { binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); }); Injector injector = app.strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(ElasticsearchConnector.class); }
Example #28
Source File: MongoConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new JsonModule(), new MongoClientModule(), binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager())); Injector injector = app.strictConfig().doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(MongoConnector.class); }
Example #29
Source File: ElasticsearchConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) { requireNonNull(catalogName, "catalogName is null"); requireNonNull(config, "config is null"); Bootstrap app = new Bootstrap( new MBeanModule(), new MBeanServerModule(), new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.elasticsearch", "presto.plugin.elasticsearch"), new JsonModule(), new ElasticsearchConnectorModule(), binder -> { binder.bind(TypeManager.class).toInstance(context.getTypeManager()); binder.bind(NodeManager.class).toInstance(context.getNodeManager()); }); Injector injector = app.strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(config) .initialize(); return injector.getInstance(ElasticsearchConnector.class); }
Example #30
Source File: MemoryConnectorFactory.java From presto with Apache License 2.0 | 6 votes |
@Override public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) { requireNonNull(requiredConfig, "requiredConfig is null"); // A plugin is not required to use Guice; it is just very convenient Bootstrap app = new Bootstrap( new JsonModule(), new MemoryModule(context.getTypeManager(), context.getNodeManager())); Injector injector = app .strictConfig() .doNotInitializeLogging() .setRequiredConfigurationProperties(requiredConfig) .initialize(); return injector.getInstance(MemoryConnector.class); }