Java Code Examples for io.prestosql.spi.connector.ConnectorFactory#create()

The following examples show how to use io.prestosql.spi.connector.ConnectorFactory#create() . 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: TestRedisPlugin.java    From presto with Apache License 2.0 6 votes vote down vote up
@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 2
Source File: TestKafkaPlugin.java    From presto with Apache License 2.0 6 votes vote down vote up
@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 3
Source File: TestJmxStats.java    From presto with Apache License 2.0 6 votes vote down vote up
@Test
public void testJmxStatsExposure()
        throws Exception
{
    Plugin plugin = new JdbcPlugin("base-jdbc", new TestingH2JdbcModule());
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "jdbc"), new TestingConnectorContext());
    MBeanServer mbeanServer = getPlatformMBeanServer();
    Set<ObjectName> objectNames = mbeanServer.queryNames(new ObjectName("io.prestosql.plugin.jdbc:*"), null);

    assertTrue(objectNames.containsAll(
            ImmutableSet.of(
                    new ObjectName("io.prestosql.plugin.jdbc:type=ConnectionFactory,name=test"),
                    new ObjectName("io.prestosql.plugin.jdbc:type=JdbcClient,name=test"))));

    for (ObjectName objectName : objectNames) {
        MBeanInfo mbeanInfo = mbeanServer.getMBeanInfo(objectName);
        assertNotEquals(mbeanInfo.getAttributes().length, 0, format("Object %s doesn't expose JMX stats", objectName.getCanonicalName()));
    }
}
 
Example 4
Source File: TestKinesisPlugin.java    From presto with Apache License 2.0 6 votes vote down vote up
@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 5
Source File: TestRaptorPlugin.java    From presto with Apache License 2.0 6 votes vote down vote up
@Test
public void testPlugin()
        throws Exception
{
    Plugin plugin = new RaptorPlugin();
    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);
    }
}
 
Example 6
Source File: TestSheetsPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
        throws Exception
{
    Plugin plugin = new SheetsPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    Builder<String, String> propertiesMap = new Builder<String, String>().put("credentials-path", getTestCredentialsPath()).put("metadata-sheet-id", TEST_METADATA_SHEET_ID);
    Connector c = factory.create(GOOGLE_SHEETS, propertiesMap.build(), new TestingConnectorContext());
    assertNotNull(c);
}
 
Example 7
Source File: TestOraclePlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
{
    Plugin plugin = new OraclePlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "jdbc:oracle:thin//test"), new TestingConnectorContext());
}
 
Example 8
Source File: TestRedshiftPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
{
    Plugin plugin = new RedshiftPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
 
Example 9
Source File: TestUtils.java    From presto with Apache License 2.0 5 votes vote down vote up
public static KinesisConnector createConnector(KinesisPlugin plugin, Map<String, String> properties, boolean withMockClient)
{
    requireNonNull(plugin, "Plugin instance should not be null");
    requireNonNull(properties, "Properties map should not be null (can be empty)");
    ConnectorFactory factory = plugin.getConnectorFactories().iterator().next();
    assertNotNull(factory);

    Connector connector = factory.create("kinesis", properties, new TestingConnectorContext());
    return (KinesisConnector) connector;
}
 
Example 10
Source File: TestKuduPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
{
    Plugin plugin = new KuduPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("kudu.client.master-addresses", "localhost:7051"), new TestingConnectorContext());
}
 
Example 11
Source File: TestMemSqlPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
{
    Plugin plugin = new MemSqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "jdbc:mariadb://test"), new TestingConnectorContext());
}
 
Example 12
Source File: TestThriftPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testPlugin()
{
    Plugin plugin = new ThriftPlugin();
    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);
}
 
Example 13
Source File: TestMongoPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@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();
}
 
Example 14
Source File: TestJdbcConnectorFactory.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void test()
{
    ConnectorFactory connectorFactory = new JdbcConnectorFactory("test", new TestingH2JdbcModule());

    connectorFactory.create("test", TestingH2JdbcModule.createProperties(), new TestingConnectorContext());
}
 
Example 15
Source File: TestPostgreSqlPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
{
    Plugin plugin = new PostgreSqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
 
Example 16
Source File: TestSqlServerPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
{
    Plugin plugin = new SqlServerPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
 
Example 17
Source File: TestDruidJdbcPlugin.java    From presto with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateConnector()
{
    Plugin plugin = new DruidJdbcPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", "test"), new TestingConnectorContext());
}
 
Example 18
Source File: TestMySqlPlugin.java    From presto with Apache License 2.0 4 votes vote down vote up
private static void createMySqlPlugin(String url)
{
    Plugin plugin = new MySqlPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    factory.create("test", ImmutableMap.of("connection-url", url), new TestingConnectorContext());
}