com.facebook.presto.spi.connector.ConnectorFactory Java Examples

The following examples show how to use com.facebook.presto.spi.connector.ConnectorFactory. 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-kinesis with Apache License 2.0 6 votes vote down vote up
@Test
public ConnectorFactory testConnectorExists()
{
    KinesisPlugin plugin = TestUtils.createPluginInstance();

    // Create factory manually to double check everything is done right
    Iterable<ConnectorFactory> iter = plugin.getConnectorFactories();

    List<ConnectorFactory> factories = new ArrayList<>();
    for (ConnectorFactory cf : iter) {
        factories.add(cf);
    }
    assertNotNull(factories);
    assertEquals(factories.size(), 1);
    ConnectorFactory factory = factories.get(0);
    assertNotNull(factory);
    return factory;
}
 
Example #2
Source File: TestUtils.java    From presto-kinesis with Apache License 2.0 6 votes vote down vote up
/**
 * Build a connector instance from the plug in, supplying the given properties.
 *
 * This can build a connector with the mock client which is normally done in testing.
 * The plug in is created first with createPluginInstance.
 *
 * @param plugin
 * @param properties
 * @param withMockClient
 * @return
 */
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)");

    if (withMockClient) {
        plugin.setAltProviderClass(KinesisTestClientManager.class);
    }

    ConnectorFactory factory = plugin.getConnectorFactories().iterator().next();
    assertNotNull(factory);

    Connector connector = factory.create("kinesis", properties, new TestingConnectorContext() {});
    assertTrue(connector instanceof KinesisConnector);
    return (KinesisConnector) connector;
}
 
Example #3
Source File: TestKuduPlugin.java    From presto-kudu with Apache License 2.0 5 votes vote down vote up
@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:8050"), new TestingConnectorContext());
}
 
Example #4
Source File: KinesisPlugin.java    From presto-kinesis with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized Iterable<ConnectorFactory> getConnectorFactories()
{
    if(factory == null) {
        this.factory = new KinesisConnectorFactory(getClassLoader(), tableDescriptionSupplier, optionalConfig, altProviderClass);
    }
    return ImmutableList.of(this.factory);
}
 
Example #5
Source File: TestKinesisPlugin.java    From presto-kinesis with Apache License 2.0 5 votes vote down vote up
@Parameters({
        "kinesis.awsAccessKey",
        "kinesis.awsSecretKey"
})
@Test
public void testSpinUp(String awsAccessKey, String awsSecretKey)
{
    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(awsAccessKey))
            .put("kinesis.secret-key", TestUtils.noneToBlank(awsSecretKey))
            .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 != null && handle instanceof KinesisTransactionHandle);
}
 
Example #6
Source File: KubePlugin.java    From kubesql with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new KubeConnectorFactory());
}
 
Example #7
Source File: ElasticsearchPlugin.java    From presto-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new ElasticsearchConnectorFactory(name, module, getClassLoader()));
}
 
Example #8
Source File: HbasePlugin.java    From presto-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new HbaseConnectorFactory("hbase"));
}
 
Example #9
Source File: ParaflowPlugin.java    From paraflow with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new ParaflowConnectorFactory());
}
 
Example #10
Source File: EthereumPlugin.java    From presto-ethereum with Apache License 2.0 4 votes vote down vote up
@Override
public Iterable<ConnectorFactory> getConnectorFactories() {
    return ImmutableList.of(new EthereumConnectorFactory());
}
 
Example #11
Source File: KuduPlugin.java    From presto-kudu with Apache License 2.0 4 votes vote down vote up
@Override public Iterable<ConnectorFactory> getConnectorFactories() {
  return ImmutableList.of(new KuduConnectorFactory("kudu"));
}