Java Code Examples for io.prestosql.spi.connector.ConnectorContext#getNodeManager()

The following examples show how to use io.prestosql.spi.connector.ConnectorContext#getNodeManager() . 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 File: MemoryConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context)
{
    requireNonNull(requiredConfig, "requiredConfig is null");

    // A plugin is not required to use Guice; it is just very convenient
    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new MemoryModule(context.getTypeManager(), context.getNodeManager()));

    Injector injector = app
            .strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(requiredConfig)
            .initialize();

    return injector.getInstance(MemoryConnector.class);
}
 
Example 2
Source File: BigQueryConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(catalogName, "catalogName is null");
    requireNonNull(config, "config is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new BigQueryConnectorModule(context.getNodeManager()),
            binder -> {
                binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                binder.bind(NodeManager.class).toInstance(context.getNodeManager());
            });

    Injector injector = app.strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();

    return injector.getInstance(BigQueryConnector.class);
}
 
Example 3
Source File: PinotConnectorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(catalogName, "connectorId is null");
    requireNonNull(config, "config is null");
    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new MBeanModule(),
            new PinotModule(catalogName, context.getTypeManager(), context.getNodeManager()));

    Injector injector = app.strictConfig()
            .doNotInitializeLogging()
            .setRequiredConfigurationProperties(config)
            .initialize();

    return injector.getInstance(PinotConnector.class);
}
 
Example 4
Source File: BlackHoleConnectorFactory.java    From presto with Apache License 2.0 5 votes vote down vote up
@Override
public Connector create(String catalogName, Map<String, String> requiredConfig, ConnectorContext context)
{
    ListeningScheduledExecutorService executorService = listeningDecorator(newSingleThreadScheduledExecutor(daemonThreadsNamed("blackhole")));
    return new BlackHoleConnector(
            new BlackHoleMetadata(),
            new BlackHoleSplitManager(),
            new BlackHolePageSourceProvider(executorService),
            new BlackHolePageSinkProvider(executorService),
            new BlackHoleNodePartitioningProvider(context.getNodeManager()),
            context.getTypeManager(),
            executorService);
}
 
Example 5
Source File: TpcdsConnectorFactory.java    From presto with Apache License 2.0 5 votes vote down vote up
@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);
        }
    };
}
 
Example 6
Source File: AtopConnectorFactory.java    From presto with Apache License 2.0 5 votes vote down vote up
@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() == AtopSecurity.NONE,
                        new AllowAllAccessControlModule()),
                installModuleIf(
                        AtopConnectorConfig.class,
                        config -> config.getSecurity() == AtopSecurity.FILE,
                        binder -> {
                            binder.install(new FileBasedAccessControlModule(catalogName));
                            binder.install(new JsonModule());
                        }));

        Injector injector = app
                .strictConfig()
                .doNotInitializeLogging()
                .setRequiredConfigurationProperties(requiredConfig)
                .initialize();

        return injector.getInstance(AtopConnector.class);
    }
}
 
Example 7
Source File: IndexedTpchConnectorFactory.java    From presto with Apache License 2.0 4 votes vote down vote up
@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)
        {
            return TpchTransactionHandle.INSTANCE;
        }

        @Override
        public ConnectorMetadata getMetadata(ConnectorTransactionHandle transactionHandle)
        {
            return new TpchIndexMetadata(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);
        }
    };
}
 
Example 8
Source File: TpchConnectorFactory.java    From presto with Apache License 2.0 4 votes vote down vote up
@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(columnNaming, predicatePushdownEnabled, partitioningEnabled);
        }

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

        @Override
        public ConnectorPageSourceProvider getPageSourceProvider()
        {
            if (isProducePages(properties)) {
                return new TpchPageSourceProvider(getMaxRowsPerPage(properties));
            }

            throw new UnsupportedOperationException();
        }

        @Override
        public ConnectorRecordSetProvider getRecordSetProvider()
        {
            if (!isProducePages(properties)) {
                return new TpchRecordSetProvider();
            }

            throw new UnsupportedOperationException();
        }

        @Override
        public ConnectorNodePartitioningProvider getNodePartitioningProvider()
        {
            return new TpchNodePartitioningProvider(nodeManager, splitsPerNode);
        }
    };
}