use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class TestAnalyzer method createTestingCatalog.
private Catalog createTestingCatalog(String catalogName, ConnectorId connectorId) {
ConnectorId systemId = createSystemTablesConnectorId(connectorId);
Connector connector = createTestingConnector();
InternalNodeManager nodeManager = new InMemoryNodeManager();
return new Catalog(catalogName, connectorId, connector, createInformationSchemaConnectorId(connectorId), new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl), systemId, new SystemConnector(systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId)));
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class TestTransactionManager method testTransactionWorkflow.
@Test
public void testTransactionWorkflow() {
try (IdleCheckExecutor executor = new IdleCheckExecutor()) {
CatalogManager catalogManager = new CatalogManager();
TransactionManager transactionManager = InMemoryTransactionManager.create(new TransactionManagerConfig(), executor.getExecutor(), catalogManager, finishingExecutor);
Connector c1 = new TpchConnectorFactory().create(CATALOG_NAME, ImmutableMap.of(), new TestingConnectorContext());
registerConnector(catalogManager, transactionManager, CATALOG_NAME, CONNECTOR_ID, c1);
TransactionId transactionId = transactionManager.beginTransaction(false);
assertEquals(transactionManager.getAllTransactionInfos().size(), 1);
TransactionInfo transactionInfo = transactionManager.getTransactionInfo(transactionId);
assertFalse(transactionInfo.isAutoCommitContext());
assertTrue(transactionInfo.getConnectorIds().isEmpty());
assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
ConnectorMetadata metadata = transactionManager.getOptionalCatalogMetadata(transactionId, CATALOG_NAME).get().getMetadata();
metadata.listSchemaNames(TEST_SESSION.toConnectorSession(CONNECTOR_ID));
transactionInfo = transactionManager.getTransactionInfo(transactionId);
assertEquals(transactionInfo.getConnectorIds(), ImmutableList.of(CONNECTOR_ID, INFORMATION_SCHEMA_ID, SYSTEM_TABLES_ID));
assertFalse(transactionInfo.getWrittenConnectorId().isPresent());
getFutureValue(transactionManager.asyncCommit(transactionId));
assertTrue(transactionManager.getAllTransactionInfos().isEmpty());
}
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class TestRedisPlugin method testStartup.
@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);
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
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(catalogName, indexSpec);
NodeManager nodeManager = context.getNodeManager();
return new Connector() {
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
return TpchTransactionHandle.INSTANCE;
}
@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) {
return new TpchIndexMetadata(catalogName, indexedData);
}
@Override
public ConnectorSplitManager getSplitManager() {
return new TpchSplitManager(nodeManager, splitsPerNode);
}
@Override
public ConnectorRecordSetProvider getRecordSetProvider() {
return new TpchRecordSetProvider();
}
@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);
}
};
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class TpchConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> properties, ConnectorContext context) {
int splitsPerNode = getSplitsPerNode(properties);
ColumnNaming columnNaming = ColumnNaming.valueOf(properties.getOrDefault(TPCH_COLUMN_NAMING_PROPERTY, ColumnNaming.SIMPLIFIED.name()).toUpperCase());
NodeManager nodeManager = context.getNodeManager();
return new Connector() {
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
return TpchTransactionHandle.INSTANCE;
}
@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transaction) {
return new TpchMetadata(catalogName, columnNaming, predicatePushdownEnabled, isPartitioningEnabled(properties));
}
@Override
public ConnectorSplitManager getSplitManager() {
return new TpchSplitManager(nodeManager, splitsPerNode);
}
@Override
public ConnectorRecordSetProvider getRecordSetProvider() {
return new TpchRecordSetProvider();
}
@Override
public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
return new TpchNodePartitioningProvider(nodeManager, splitsPerNode);
}
};
}
Aggregations