private Connector createConnector(ConnectorId connectorId, ConnectorFactory factory, Map<String, String> properties) { ConnectorContext context = new ConnectorContextInstance( new ConnectorAwareNodeManager(nodeManager, nodeInfo.getEnvironment(), connectorId), typeManager, pageSorter, pageIndexerFactory); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) { return factory.create(connectorId.getCatalogName(), properties, context); } }
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()); }
public void createCatalog(String catalogName, ConnectorFactory connectorFactory, Map<String, String> properties) { nodeManager.addCurrentNodeConnector(new ConnectorId(catalogName)); connectorManager.addConnectorFactory(connectorFactory); connectorManager.createConnection(catalogName, connectorFactory.getName(), properties); }
public void createCatalog(String catalogName, ConnectorFactory connectorFactory, Map<String, String> properties) { nodeManager.addCurrentNodeConnector(new ConnectorId(catalogName)); connectorManager.addConnectorFactory(connectorFactory); connectorManager.createConnection(catalogName, connectorFactory.getName(), properties); }
private Connector createConnector(ConnectorId connectorId, ConnectorFactory factory, Map<String, String> properties) { ConnectorContext context = new ConnectorContextInstance( new ConnectorAwareNodeManager(nodeManager, nodeInfo.getEnvironment(), connectorId), typeManager, pageSorter, pageIndexerFactory); try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(factory.getClass().getClassLoader())) { return factory.create(connectorId.getCatalogName(), properties, context); } }
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()); }
log.info("Registering connector %s", connectorFactory.getName()); connectorManager.addConnectorFactory(connectorFactory);
@Test public void testCreateConnector() { Plugin plugin = new MySqlPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); factory.create("test", ImmutableMap.of("connection-url", "jdbc:mysql://test"), new TestingConnectorContext()); } }
log.info("Registering connector %s", connectorFactory.getName()); connectorManager.addConnectorFactory(connectorFactory);
@Test public void testCreateConnector() { Plugin plugin = new SqlServerPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext()); } }
@Test public void testCreateConnector() { Plugin plugin = new RedshiftPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext()); } }
@Test public void testCreateConnector() { Plugin plugin = new PostgreSqlPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext()); } }
@Test public void testCreateConnector() throws Exception { Plugin plugin = new KuduPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); factory.create("test", ImmutableMap.of("kudu.client.master-addresses", "localhost:7051"), new TestingConnectorContext()); } }
@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); } }
@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); } }
@Test public void testCreateConnector() { MongoPlugin plugin = new MongoPlugin(); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); Connector connector = factory.create("test", ImmutableMap.of("mongodb.seeds", seed), new TestingConnectorContext()); Type type = getOnlyElement(plugin.getTypes()); assertEquals(type, OBJECT_ID); connector.shutdown(); }
@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.getAbsolutePath()) .build(); factory.create("test", config, new TestingConnectorContext()); } finally { deleteRecursively(tmpDir.toPath(), ALLOW_INSECURE); } }
@Test public void testPlugin() { ThriftPlugin plugin = loadPlugin(ThriftPlugin.class); ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories()); assertInstanceOf(factory, ThriftConnectorFactory.class); Map<String, String> config = ImmutableMap.of("presto.thrift.client.addresses", "localhost:7779"); Connector connector = factory.create("test", config, new TestingConnectorContext()); assertNotNull(connector); assertInstanceOf(connector, ThriftConnector.class); }