use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class TpcdsConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
int splitsPerNode = getSplitsPerNode(config);
NodeManager nodeManager = context.getNodeManager();
return new Connector() {
@Override
public ConnectorTransactionHandle beginTransaction(IsolationLevel isolationLevel, boolean readOnly) {
return TpcdsTransactionHandle.INSTANCE;
}
@Override
public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle) {
return new TpcdsMetadata();
}
@Override
public ConnectorSplitManager getSplitManager() {
return new TpcdsSplitManager(nodeManager, splitsPerNode, isWithNoSexism(config));
}
@Override
public ConnectorRecordSetProvider getRecordSetProvider() {
return new TpcdsRecordSetProvider();
}
@Override
public ConnectorNodePartitioningProvider getNodePartitioningProvider() {
return new TpcdsNodePartitioningProvider(nodeManager, splitsPerNode);
}
};
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class TestThriftPlugin method testPlugin.
@Test
public void testPlugin() {
ThriftPlugin plugin = loadPlugin(ThriftPlugin.class);
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);
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class TestAccessControlManager method registerBogusConnector.
private static ConnectorId registerBogusConnector(CatalogManager catalogManager, TransactionManager transactionManager, AccessControl accessControl, String catalogName) {
ConnectorId connectorId = new ConnectorId(catalogName);
Connector connector = new TpchConnectorFactory().create(catalogName, ImmutableMap.of(), new TestingConnectorContext());
InMemoryNodeManager nodeManager = new InMemoryNodeManager();
MetadataManager metadata = MetadataManager.createTestMetadataManager(catalogManager);
ConnectorId systemId = createSystemTablesConnectorId(connectorId);
catalogManager.registerCatalog(new Catalog(catalogName, connectorId, connector, createInformationSchemaConnectorId(connectorId), new InformationSchemaConnector(catalogName, nodeManager, metadata, accessControl, ImmutableList.of()), systemId, new SystemConnector(systemId, nodeManager, connector.getSystemTables(), transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId))));
return connectorId;
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class AtopConnectorFactory method create.
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context) {
requireNonNull(requiredConfig, "requiredConfig is null");
try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
Bootstrap app = new Bootstrap(new AtopModule(atopFactoryClass, context.getTypeManager(), context.getNodeManager(), context.getNodeManager().getEnvironment(), catalogName), installModuleIf(AtopConnectorConfig.class, config -> config.getSecurity().equalsIgnoreCase(SECURITY_NONE), new AllowAllAccessControlModule()), installModuleIf(AtopConnectorConfig.class, config -> config.getSecurity().equalsIgnoreCase(SECURITY_FILE), binder -> {
binder.install(new FileBasedAccessControlModule());
binder.install(new JsonModule());
}));
Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
return injector.getInstance(AtopConnector.class);
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
use of com.facebook.presto.spi.connector.Connector in project presto by prestodb.
the class ConnectorManager method addCatalogConnector.
private synchronized void addCatalogConnector(String catalogName, ConnectorId connectorId, ConnectorFactory factory, Map<String, String> properties) {
// create all connectors before adding, so a broken connector does not leave the system half updated
MaterializedConnector connector = new MaterializedConnector(connectorId, createConnector(connectorId, factory, properties));
MaterializedConnector informationSchemaConnector = new MaterializedConnector(createInformationSchemaConnectorId(connectorId), new InformationSchemaConnector(catalogName, nodeManager, metadataManager, accessControlManager, connector.getSessionProperties()));
ConnectorId systemId = createSystemTablesConnectorId(connectorId);
SystemTablesProvider systemTablesProvider;
if (nodeManager.getCurrentNode().isCoordinator()) {
systemTablesProvider = new DelegatingSystemTablesProvider(new StaticSystemTablesProvider(connector.getSystemTables()), new MetadataBasedSystemTablesProvider(metadataManager, catalogName));
} else {
systemTablesProvider = new StaticSystemTablesProvider(connector.getSystemTables());
}
MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector(systemId, nodeManager, systemTablesProvider, transactionId -> transactionManager.getConnectorTransaction(transactionId, connectorId), connector.getSessionProperties()));
Catalog catalog = new Catalog(catalogName, connector.getConnectorId(), connector.getConnector(), informationSchemaConnector.getConnectorId(), informationSchemaConnector.getConnector(), systemConnector.getConnectorId(), systemConnector.getConnector());
try {
addConnectorInternal(connector);
addConnectorInternal(informationSchemaConnector);
addConnectorInternal(systemConnector);
catalogManager.registerCatalog(catalog);
} catch (Throwable e) {
catalogManager.removeCatalog(catalog.getCatalogName());
removeConnectorInternal(systemConnector.getConnectorId());
removeConnectorInternal(informationSchemaConnector.getConnectorId());
removeConnectorInternal(connector.getConnectorId());
throw e;
}
}
Aggregations