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();
}
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();
}
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();
}
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;
}
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);
}
};
}
Aggregations