io.airlift.bootstrap.Bootstrap Java Examples

The following examples show how to use io.airlift.bootstrap.Bootstrap. 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: KuduConnectorFactory.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(config, "config is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new KuduModule(context.getTypeManager()));

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

    return injector.getInstance(KuduConnector.class);
}
 
Example #2
Source File: ElasticsearchConnectorFactory.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 MBeanModule(),
            new MBeanServerModule(),
            new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.elasticsearch", "presto.plugin.elasticsearch"),
            new JsonModule(),
            new ElasticsearchConnectorModule(),
            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(ElasticsearchConnector.class);
}
 
Example #3
Source File: TestingElasticsearchConnectorFactory.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 ElasticsearchConnectorModule(),
            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(ElasticsearchConnector.class);
}
 
Example #4
Source File: DbSessionPropertyManagerFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public SessionPropertyConfigurationManager create(Map<String, String> config, SessionPropertyConfigurationManagerContext context)
{
    try {
        Bootstrap app = new Bootstrap(
                new MBeanModule(),
                new MBeanServerModule(),
                new JsonModule(),
                new DbSessionPropertyManagerModule());

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

        return injector.getInstance(DbSessionPropertyManager.class);
    }
    catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
 
Example #5
Source File: FileAuthenticatorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public PasswordAuthenticator create(Map<String, String> config)
{
    Bootstrap app = new Bootstrap(
            binder -> {
                configBinder(binder).bindConfig(FileConfig.class);
                binder.bind(FileAuthenticator.class).in(Scopes.SINGLETON);
            });

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

    return injector.getInstance(FileAuthenticator.class);
}
 
Example #6
Source File: LdapAuthenticatorFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public PasswordAuthenticator create(Map<String, String> config)
{
    Bootstrap app = new Bootstrap(
            binder -> {
                configBinder(binder).bindConfig(LdapConfig.class);
                binder.bind(LdapAuthenticator.class).in(Scopes.SINGLETON);
            });

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

    return injector.getInstance(LdapAuthenticator.class);
}
 
Example #7
Source File: ThriftConnectorFactory.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)
{
    Bootstrap app = new Bootstrap(
            new MBeanModule(),
            new MBeanServerModule(),
            new ConnectorObjectNameGeneratorModule(catalogName, "io.prestosql.plugin.thrift", "presto.plugin.thrift"),
            new DriftNettyClientModule(),
            binder -> {
                binder.bind(TypeManager.class).toInstance(context.getTypeManager());
            },
            locationModule,
            new ThriftModule());

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

    return injector.getInstance(ThriftConnector.class);
}
 
Example #8
Source File: KafkaConnectorFactory.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 KafkaConnectorModule(),
            extension,
            binder -> {
                binder.bind(ClassLoader.class).toInstance(KafkaConnectorFactory.class.getClassLoader());
                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(KafkaConnector.class);
}
 
Example #9
Source File: LocalFileConnectorFactory.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(config, "config is null");

    Bootstrap app = new Bootstrap(
            binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()),
            new LocalFileModule());

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

    return injector.getInstance(LocalFileConnector.class);
}
 
Example #10
Source File: CassandraConnectorFactory.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(config, "config is null");

    Bootstrap app = new Bootstrap(
            new MBeanModule(),
            new JsonModule(),
            new CassandraClientModule(),
            new MBeanServerModule());

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

    return injector.getInstance(CassandraConnector.class);
}
 
Example #11
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 #12
Source File: FileResourceGroupConfigurationManagerFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public ResourceGroupConfigurationManager<?> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context)
{
    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new FileResourceGroupsModule(),
            binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));

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

    return injector.getInstance(FileResourceGroupConfigurationManager.class);
}
 
Example #13
Source File: DbResourceGroupConfigurationManagerFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public ResourceGroupConfigurationManager<?> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context)
{
    Bootstrap app = new Bootstrap(
            new MBeanModule(),
            new MBeanServerModule(),
            new JsonModule(),
            new DbResourceGroupsModule(),
            new PrefixObjectNameGeneratorModule("io.prestosql.plugin.resourcegroups.db", "presto.plugin.resourcegroups.db"),
            binder -> binder.bind(String.class).annotatedWith(ForEnvironment.class).toInstance(context.getEnvironment()),
            binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));

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

    return injector.getInstance(DbResourceGroupConfigurationManager.class);
}
 
Example #14
Source File: SheetsConnectorFactory.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(config, "config is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new SheetsModule(context.getTypeManager()));

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

    return injector.getInstance(SheetsConnector.class);
}
 
Example #15
Source File: PrestoProxy.java    From presto with Apache License 2.0 6 votes vote down vote up
public static void start(Module... extraModules)
{
    Bootstrap app = new Bootstrap(ImmutableList.<Module>builder()
            .add(new NodeModule())
            .add(new HttpServerModule())
            .add(new JsonModule())
            .add(new JaxrsModule())
            .add(new MBeanModule())
            .add(new JmxModule())
            .add(new LogJmxModule())
            .add(new TraceTokenModule())
            .add(new EventModule())
            .add(new ProxyModule())
            .add(extraModules)
            .build());

    Logger log = Logger.get(PrestoProxy.class);
    try {
        app.strictConfig().initialize();
        log.info("======== SERVER STARTED ========");
    }
    catch (Throwable t) {
        log.error(t);
        System.exit(1);
    }
}
 
Example #16
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 #17
Source File: TestDriftNettyClientModule.java    From drift with Apache License 2.0 6 votes vote down vote up
@Test
public void test()
        throws Exception
{
    Annotation clientAnnotation = named("test");
    Bootstrap bootstrap = new Bootstrap(
            new DriftNettyClientModule(),
            binder -> configBinder(binder).bindConfig(DriftClientConfig.class, clientAnnotation, "prefix"));

    Injector injector = bootstrap
            .doNotInitializeLogging()
            .strictConfig()
            .initialize();

    assertNotNull(injector.getInstance(Key.get(new TypeLiteral<MethodInvokerFactory<Annotation>>() {})));
    assertNotNull(injector.getInstance(Key.get(DriftClientConfig.class, clientAnnotation)));
    assertNotNull(injector.getInstance(Key.get(DriftNettyClientConfig.class, clientAnnotation)));
}
 
Example #18
Source File: ParaflowConnectorFactory.java    From paraflow with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String connectorId, Map<String, String> config, ConnectorContext context)
{
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new ParaflowModule(connectorId, context.getTypeManager())
        );

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

        return injector.getInstance(ParaflowConnector.class);
    }
    catch (Exception e) {
        throw new PrestoException(CONNECTOR_INIT_ERROR, e);
    }
}
 
Example #19
Source File: KuduConnectorFactory.java    From presto-kudu with Apache License 2.0 6 votes vote down vote up
@Override
public Connector create(String connectorId, Map<String, String> config,
                        ConnectorContext context) {
    requireNonNull(config, "config is null");

    try {
        Bootstrap app = new Bootstrap(new JsonModule(),
                new KuduModule(connectorId, context.getTypeManager()));

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

        return injector.getInstance(KuduConnector.class);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example #20
Source File: RangerSystemAccessControlFactory.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public SystemAccessControl create(Map<String, String> config) {
  requireNonNull(config, "config is null");

  try {
    Bootstrap app = new Bootstrap(
      binder -> {
        configBinder(binder).bindConfig(RangerConfig.class);
        binder.bind(RangerSystemAccessControl.class).in(Scopes.SINGLETON);
      }
    );

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

    return injector.getInstance(RangerSystemAccessControl.class);
  } catch (Exception e) {
    throwIfUnchecked(e);
    throw new RuntimeException(e);
  }
}
 
Example #21
Source File: PhoenixConnectorFactory.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");

    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new MBeanServerModule(),
                new MBeanModule(),
                new PhoenixClientModule(catalogName),
                binder -> {
                    binder.bind(ClassLoader.class).toInstance(PhoenixConnectorFactory.class.getClassLoader());
                    binder.bind(TypeManager.class).toInstance(context.getTypeManager());
                });

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

        return injector.getInstance(PhoenixConnector.class);
    }
}
 
Example #22
Source File: H2ResourceGroupConfigurationManagerFactory.java    From presto with Apache License 2.0 6 votes vote down vote up
@Override
public ResourceGroupConfigurationManager<?> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context)
{
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new H2ResourceGroupsModule(),
                new NodeModule(),
                binder -> binder.bind(ResourceGroupConfigurationManagerContext.class).toInstance(context),
                binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));

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

        return injector.getInstance(DbResourceGroupConfigurationManager.class);
    }
}
 
Example #23
Source File: JmxConnectorFactory.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)
{
    Bootstrap app = new Bootstrap(
            new MBeanServerModule(),
            binder -> {
                configBinder(binder).bindConfig(JmxConnectorConfig.class);
                binder.bind(NodeManager.class).toInstance(context.getNodeManager());
                binder.bind(JmxConnector.class).in(Scopes.SINGLETON);
                binder.bind(JmxHistoricalData.class).in(Scopes.SINGLETON);
                binder.bind(JmxMetadata.class).in(Scopes.SINGLETON);
                binder.bind(JmxSplitManager.class).in(Scopes.SINGLETON);
                binder.bind(JmxPeriodicSampler.class).in(Scopes.SINGLETON);
                binder.bind(JmxRecordSetProvider.class).in(Scopes.SINGLETON);
            });

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

    return injector.getInstance(JmxConnector.class);
}
 
Example #24
Source File: AccumuloConnectorFactory.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, "requiredConfig is null");
    requireNonNull(context, "context is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new AccumuloModule(context.getTypeManager()));

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

    return injector.getInstance(AccumuloConnector.class);
}
 
Example #25
Source File: JdbcConnectorFactory.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");

    Bootstrap app = new Bootstrap(
            binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager()),
            binder -> binder.bind(NodeManager.class).toInstance(context.getNodeManager()),
            binder -> binder.bind(VersionEmbedder.class).toInstance(context.getVersionEmbedder()),
            new JdbcModule(catalogName),
            moduleProvider.getModule(catalogName));

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

    return injector.getInstance(JdbcConnector.class);
}
 
Example #26
Source File: ExampleConnectorFactory.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 ExampleModule(context.getTypeManager()));

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

    return injector.getInstance(ExampleConnector.class);
}
 
Example #27
Source File: PrometheusHttpServer.java    From presto with Apache License 2.0 6 votes vote down vote up
public PrometheusHttpServer()
        throws Exception
{
    Bootstrap app = new Bootstrap(
            new TestingNodeModule(),
            new TestingHttpServerModule(),
            new PrometheusHttpServerModule());

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

    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    baseUri = injector.getInstance(TestingHttpServer.class).getBaseUrl();
}
 
Example #28
Source File: MongoConnectorFactory.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(config, "config is null");

    Bootstrap app = new Bootstrap(
            new JsonModule(),
            new MongoClientModule(),
            binder -> binder.bind(TypeManager.class).toInstance(context.getTypeManager()));

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

    return injector.getInstance(MongoConnector.class);
}
 
Example #29
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 #30
Source File: PrometheusConnectorFactory.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");
    try {
        // A plugin is not required to use Guice; it is just very convenient
        Bootstrap app = new Bootstrap(
                new JsonModule(),
                new PrometheusModule(context.getTypeManager()));

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

        return injector.getInstance(PrometheusConnector.class);
    }
    catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}