Search in sources :

Example 1 with ConnectorContext

use of com.facebook.presto.spi.connector.ConnectorContext in project presto by prestodb.

the class AtopConnectorFactory method create.

@Override
public Connector create(String connectorId, 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(), connectorId), 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.strictConfig().doNotInitializeLogging().setRequiredConfigurationProperties(requiredConfig).initialize();
        return injector.getInstance(AtopConnector.class);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : Connector(com.facebook.presto.spi.connector.Connector) SECURITY_FILE(com.facebook.presto.atop.AtopConnectorConfig.SECURITY_FILE) ConditionalModule.installModuleIf(io.airlift.configuration.ConditionalModule.installModuleIf) ConnectorHandleResolver(com.facebook.presto.spi.ConnectorHandleResolver) Throwables(com.google.common.base.Throwables) SECURITY_NONE(com.facebook.presto.atop.AtopConnectorConfig.SECURITY_NONE) AllowAllAccessControlModule(com.facebook.presto.plugin.base.security.AllowAllAccessControlModule) ConnectorFactory(com.facebook.presto.spi.connector.ConnectorFactory) Injector(com.google.inject.Injector) FileBasedAccessControlModule(com.facebook.presto.plugin.base.security.FileBasedAccessControlModule) Bootstrap(io.airlift.bootstrap.Bootstrap) Map(java.util.Map) Objects.requireNonNull(java.util.Objects.requireNonNull) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) ConnectorContext(com.facebook.presto.spi.connector.ConnectorContext) JsonModule(io.airlift.json.JsonModule) Injector(com.google.inject.Injector) AllowAllAccessControlModule(com.facebook.presto.plugin.base.security.AllowAllAccessControlModule) Bootstrap(io.airlift.bootstrap.Bootstrap) FileBasedAccessControlModule(com.facebook.presto.plugin.base.security.FileBasedAccessControlModule) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(io.airlift.json.JsonModule)

Aggregations

SECURITY_FILE (com.facebook.presto.atop.AtopConnectorConfig.SECURITY_FILE)1 SECURITY_NONE (com.facebook.presto.atop.AtopConnectorConfig.SECURITY_NONE)1 AllowAllAccessControlModule (com.facebook.presto.plugin.base.security.AllowAllAccessControlModule)1 FileBasedAccessControlModule (com.facebook.presto.plugin.base.security.FileBasedAccessControlModule)1 ConnectorHandleResolver (com.facebook.presto.spi.ConnectorHandleResolver)1 ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)1 Connector (com.facebook.presto.spi.connector.Connector)1 ConnectorContext (com.facebook.presto.spi.connector.ConnectorContext)1 ConnectorFactory (com.facebook.presto.spi.connector.ConnectorFactory)1 Throwables (com.google.common.base.Throwables)1 Injector (com.google.inject.Injector)1 Bootstrap (io.airlift.bootstrap.Bootstrap)1 ConditionalModule.installModuleIf (io.airlift.configuration.ConditionalModule.installModuleIf)1 JsonModule (io.airlift.json.JsonModule)1 Map (java.util.Map)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1