Search in sources :

Example 16 with Connector

use of io.trino.spi.connector.Connector in project trino by trinodb.

the class TestKinesisPlugin method testCreateConnector.

@Test
public void testCreateConnector() {
    KinesisPlugin plugin = new KinesisPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    String accessKey = "kinesis.accessKey";
    String secretKey = "kinesis.secretKey";
    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)).buildOrThrow(), 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(SESSION, KinesisTransactionHandle.INSTANCE);
    assertNotNull(md);
    ConnectorTransactionHandle handle = c.beginTransaction(READ_COMMITTED, true, true);
    assertTrue(handle instanceof KinesisTransactionHandle);
    c.shutdown();
}
Also used : Connector(io.trino.spi.connector.Connector) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) ConnectorTransactionHandle(io.trino.spi.connector.ConnectorTransactionHandle) TestingConnectorContext(io.trino.testing.TestingConnectorContext) ConnectorMetadata(io.trino.spi.connector.ConnectorMetadata) Test(org.testng.annotations.Test)

Example 17 with Connector

use of io.trino.spi.connector.Connector in project trino by trinodb.

the class TestRedisPlugin method testStartup.

@Test
public void testStartup() {
    RedisPlugin plugin = new RedisPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    assertInstanceOf(factory, RedisConnectorFactory.class);
    Connector connector = factory.create("test-connector", ImmutableMap.<String, String>builder().put("redis.table-names", "test").put("redis.nodes", "localhost:6379").buildOrThrow(), new TestingConnectorContext());
    assertNotNull(connector);
    connector.shutdown();
}
Also used : Connector(io.trino.spi.connector.Connector) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 18 with Connector

use of io.trino.spi.connector.Connector in project trino by trinodb.

the class TestKafkaPlugin method testSpinup.

@Test
public void testSpinup() {
    KafkaPlugin plugin = new KafkaPlugin();
    ConnectorFactory factory = getOnlyElement(plugin.getConnectorFactories());
    assertInstanceOf(factory, KafkaConnectorFactory.class);
    Connector connector = factory.create("test-connector", ImmutableMap.<String, String>builder().put("kafka.table-names", "test").put("kafka.nodes", "localhost:9092").buildOrThrow(), new TestingConnectorContext());
    assertNotNull(connector);
    connector.shutdown();
}
Also used : Connector(io.trino.spi.connector.Connector) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) TestingConnectorContext(io.trino.testing.TestingConnectorContext) Test(org.testng.annotations.Test)

Example 19 with Connector

use of io.trino.spi.connector.Connector in project trino by trinodb.

the class TestUtils method createConnector.

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;
}
Also used : KinesisConnector(io.trino.plugin.kinesis.KinesisConnector) Connector(io.trino.spi.connector.Connector) TestingKinesisConnectorFactory(io.trino.plugin.kinesis.TestingKinesisConnectorFactory) KinesisConnectorFactory(io.trino.plugin.kinesis.KinesisConnectorFactory) ConnectorFactory(io.trino.spi.connector.ConnectorFactory) KinesisConnector(io.trino.plugin.kinesis.KinesisConnector) TestingConnectorContext(io.trino.testing.TestingConnectorContext)

Example 20 with Connector

use of io.trino.spi.connector.Connector in project trino by trinodb.

the class IndexedTpchConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> properties, ConnectorContext context) {
    int splitsPerNode = getSplitsPerNode(properties);
    TpchIndexedData indexedData = new TpchIndexedData(indexSpec);
    NodeManager nodeManager = context.getNodeManager();
    return new Connector() {

        @Override
        public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly, boolean autoCommit) {
            return TpchTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorSession session, ConnectorTransactionHandle transactionHandle) {
            return new TpchIndexMetadata(indexedData);
        }

        @Override
        public ConnectorSplitManager getSplitManager() {
            return new TpchSplitManager(nodeManager, splitsPerNode);
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider() {
            return new TpchRecordSetProvider(DecimalTypeMapping.DOUBLE);
        }

        @Override
        public ConnectorIndexProvider getIndexProvider() {
            return new TpchIndexProvider(indexedData);
        }

        @Override
        public Set<SystemTable> getSystemTables() {
            return ImmutableSet.of(new ExampleSystemTable());
        }

        @Override
        public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
            return new TpchNodePartitioningProvider(nodeManager, splitsPerNode);
        }
    };
}
Also used : Connector(io.trino.spi.connector.Connector) IsolationLevel(io.trino.spi.transaction.IsolationLevel) ConnectorTransactionHandle(io.trino.spi.connector.ConnectorTransactionHandle) TpchSplitManager(io.trino.plugin.tpch.TpchSplitManager) NodeManager(io.trino.spi.NodeManager) TpchNodePartitioningProvider(io.trino.plugin.tpch.TpchNodePartitioningProvider) ConnectorSession(io.trino.spi.connector.ConnectorSession) SystemTable(io.trino.spi.connector.SystemTable) TpchRecordSetProvider(io.trino.plugin.tpch.TpchRecordSetProvider)

Aggregations

Connector (io.trino.spi.connector.Connector)23 ConnectorFactory (io.trino.spi.connector.ConnectorFactory)15 TestingConnectorContext (io.trino.testing.TestingConnectorContext)14 Test (org.testng.annotations.Test)12 NodeManager (io.trino.spi.NodeManager)6 ThreadContextClassLoader (io.trino.spi.classloader.ThreadContextClassLoader)5 ConnectorContext (io.trino.spi.connector.ConnectorContext)5 ConnectorTransactionHandle (io.trino.spi.connector.ConnectorTransactionHandle)5 Map (java.util.Map)5 Injector (com.google.inject.Injector)4 Bootstrap (io.airlift.bootstrap.Bootstrap)4 JsonModule (io.airlift.json.JsonModule)4 PageIndexerFactory (io.trino.spi.PageIndexerFactory)4 ConnectorNodePartitioningProvider (io.trino.spi.connector.ConnectorNodePartitioningProvider)4 ConnectorPageSinkProvider (io.trino.spi.connector.ConnectorPageSinkProvider)4 ConnectorPageSourceProvider (io.trino.spi.connector.ConnectorPageSourceProvider)4 ConnectorSplitManager (io.trino.spi.connector.ConnectorSplitManager)4 TableProcedureMetadata (io.trino.spi.connector.TableProcedureMetadata)4 Procedure (io.trino.spi.procedure.Procedure)4 Optional (java.util.Optional)4