Java Code Examples for io.prestosql.spi.connector.ConnectorHandleResolver

The following examples show how to use io.prestosql.spi.connector.ConnectorHandleResolver. These examples are extracted from open source projects. 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 Project: presto   Source File: TestCoordinatorDynamicFiltering.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new ConnectorFactory()
    {
        private final ConnectorMetadata metadata = new TestingMetadata();

        @Override
        public String getName()
        {
            return "test";
        }

        @Override
        public ConnectorHandleResolver getHandleResolver()
        {
            return new TestingHandleResolver();
        }

        @Override
        public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
        {
            return new TestConnector(metadata, Duration.valueOf("10s"), expectedDynamicFilter);
        }
    });
}
 
Example 2
Source Project: presto   Source File: TestBeginQuery.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public Iterable<ConnectorFactory> getConnectorFactories()
{
    return ImmutableList.of(new ConnectorFactory()
    {
        @Override
        public String getName()
        {
            return "test";
        }

        @Override
        public ConnectorHandleResolver getHandleResolver()
        {
            return new TestingHandleResolver();
        }

        @Override
        public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
        {
            return new TestConnector(metadata);
        }
    });
}
 
Example 3
Source Project: presto   Source File: HandleResolver.java    License: Apache License 2.0 5 votes vote down vote up
public void addCatalogHandleResolver(String catalogName, ConnectorHandleResolver resolver)
{
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(resolver, "resolver is null");
    MaterializedHandleResolver existingResolver = handleResolvers.putIfAbsent(catalogName, new MaterializedHandleResolver(resolver));
    checkState(existingResolver == null, "Catalog '%s' is already assigned to resolver: %s", catalogName, existingResolver);
}
 
Example 4
Source Project: presto   Source File: HandleResolver.java    License: Apache License 2.0 5 votes vote down vote up
public MaterializedHandleResolver(ConnectorHandleResolver resolver)
{
    tableHandle = getHandleClass(resolver::getTableHandleClass);
    layoutHandle = getHandleClass(resolver::getTableLayoutHandleClass);
    columnHandle = getHandleClass(resolver::getColumnHandleClass);
    split = getHandleClass(resolver::getSplitClass);
    indexHandle = getHandleClass(resolver::getIndexHandleClass);
    outputTableHandle = getHandleClass(resolver::getOutputTableHandleClass);
    insertTableHandle = getHandleClass(resolver::getInsertTableHandleClass);
    partitioningHandle = getHandleClass(resolver::getPartitioningHandleClass);
    transactionHandle = getHandleClass(resolver::getTransactionHandleClass);
}
 
Example 5
Source Project: presto   Source File: KafkaConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new KafkaHandleResolver();
}
 
Example 6
Source Project: presto   Source File: PrometheusConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new PrometheusHandleResolver();
}
 
Example 7
Source Project: presto   Source File: ExampleConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new ExampleHandleResolver();
}
 
Example 8
Source Project: presto   Source File: RedisConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new RedisHandleResolver();
}
 
Example 9
Source Project: presto   Source File: BlackHoleConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new BlackHoleHandleResolver();
}
 
Example 10
Source Project: presto   Source File: JmxConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new JmxHandleResolver();
}
 
Example 11
Source Project: presto   Source File: AccumuloConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new AccumuloHandleResolver();
}
 
Example 12
Source Project: presto   Source File: JdbcConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new JdbcHandleResolver();
}
 
Example 13
Source Project: presto   Source File: TpcdsConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new TpcdsHandleResolver();
}
 
Example 14
Source Project: presto   Source File: IndexedTpchConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new TpchIndexHandleResolver();
}
 
Example 15
Source Project: presto   Source File: PhoenixConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new PhoenixHandleResolver();
}
 
Example 16
Source Project: presto   Source File: ConnectorManager.java    License: Apache License 2.0 4 votes vote down vote up
private synchronized void createCatalog(CatalogName catalogName, InternalConnectorFactory 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(catalogName, createConnector(catalogName, factory, properties));

    ConnectorHandleResolver connectorHandleResolver = connector.getConnector().getHandleResolver()
            .orElseGet(factory.getConnectorFactory()::getHandleResolver);
    checkArgument(connectorHandleResolver != null, "Connector %s does not have a handle resolver", factory);

    MaterializedConnector informationSchemaConnector = new MaterializedConnector(
            createInformationSchemaCatalogName(catalogName),
            new InformationSchemaConnector(catalogName.getCatalogName(), nodeManager, metadataManager, accessControlManager));

    CatalogName systemId = createSystemTablesCatalogName(catalogName);
    SystemTablesProvider systemTablesProvider;

    if (nodeManager.getCurrentNode().isCoordinator()) {
        systemTablesProvider = new DelegatingSystemTablesProvider(
                new StaticSystemTablesProvider(connector.getSystemTables()),
                new MetadataBasedSystemTablesProvider(metadataManager, catalogName.getCatalogName()));
    }
    else {
        systemTablesProvider = new StaticSystemTablesProvider(connector.getSystemTables());
    }

    MaterializedConnector systemConnector = new MaterializedConnector(systemId, new SystemConnector(
            nodeManager,
            systemTablesProvider,
            transactionId -> transactionManager.getConnectorTransaction(transactionId, catalogName)));

    Catalog catalog = new Catalog(
            catalogName.getCatalogName(),
            connector.getCatalogName(),
            connector.getConnector(),
            informationSchemaConnector.getCatalogName(),
            informationSchemaConnector.getConnector(),
            systemConnector.getCatalogName(),
            systemConnector.getConnector());

    try {
        addConnectorInternal(connector);
        addConnectorInternal(informationSchemaConnector);
        addConnectorInternal(systemConnector);
        catalogManager.registerCatalog(catalog);
        handleResolver.addCatalogHandleResolver(catalogName.getCatalogName(), connectorHandleResolver);
    }
    catch (Throwable e) {
        handleResolver.removeCatalogHandleResolver(catalogName.getCatalogName());
        catalogManager.removeCatalog(catalog.getCatalogName());
        removeConnectorInternal(systemConnector.getCatalogName());
        removeConnectorInternal(informationSchemaConnector.getCatalogName());
        removeConnectorInternal(connector.getCatalogName());
        throw e;
    }

    connector.getEventListeners()
            .forEach(eventListenerManager::addEventListener);
}
 
Example 17
Source Project: presto   Source File: GlobalSystemConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new GlobalSystemHandleResolver();
}
 
Example 18
Source Project: presto   Source File: MockConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new TpchHandleResolver();
}
 
Example 19
Source Project: presto   Source File: MongoConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new MongoHandleResolver();
}
 
Example 20
Source Project: presto   Source File: MemoryConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new MemoryHandleResolver();
}
 
Example 21
Source Project: presto   Source File: TpchConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new TpchHandleResolver();
}
 
Example 22
Source Project: presto   Source File: RaptorConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new RaptorHandleResolver();
}
 
Example 23
Source Project: presto   Source File: ElasticsearchConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new ElasticsearchHandleResolver();
}
 
Example 24
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new ElasticsearchHandleResolver();
}
 
Example 25
Source Project: presto   Source File: IcebergConnector.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public Optional<ConnectorHandleResolver> getHandleResolver()
{
    return Optional.of(new IcebergHandleResolver());
}
 
Example 26
Source Project: presto   Source File: TestingIcebergConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new IcebergHandleResolver();
}
 
Example 27
Source Project: presto   Source File: ThriftConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new ThriftHandleResolver();
}
 
Example 28
Source Project: presto   Source File: BigQueryConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new BigQueryHandleResolver();
}
 
Example 29
Source Project: presto   Source File: LocalFileConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new LocalFileHandleResolver();
}
 
Example 30
Source Project: presto   Source File: CassandraConnectorFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public ConnectorHandleResolver getHandleResolver()
{
    return new CassandraHandleResolver();
}