Search in sources :

Example 1 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class ThriftConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    try {
        Bootstrap app = new Bootstrap(new MBeanModule(), new DriftNettyClientModule(), binder -> {
            binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(getPlatformMBeanServer()));
            binder.bind(TypeManager.class).toInstance(context.getTypeManager());
        }, locationModule, new ThriftModule(catalogName));
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(ThriftConnector.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : MBeanModule(org.weakref.jmx.guice.MBeanModule) RebindSafeMBeanServer(com.facebook.presto.connector.thrift.util.RebindSafeMBeanServer) DriftNettyClientModule(com.facebook.drift.transport.netty.client.DriftNettyClientModule) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) TypeManager(com.facebook.presto.common.type.TypeManager) RebindSafeMBeanServer(com.facebook.presto.connector.thrift.util.RebindSafeMBeanServer) ManagementFactory.getPlatformMBeanServer(java.lang.management.ManagementFactory.getPlatformMBeanServer) MBeanServer(javax.management.MBeanServer)

Example 2 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class InfiniteNodeTtlFetcherFactory method create.

@Override
public NodeTtlFetcher create(Map<String, String> config) {
    try {
        Bootstrap app = new Bootstrap(binder -> binder.bind(NodeTtlFetcher.class).to(InfiniteNodeTtlFetcher.class).in(Scopes.SINGLETON));
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(NodeTtlFetcher.class);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : NodeTtlFetcher(com.facebook.presto.spi.ttl.NodeTtlFetcher) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap)

Example 3 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class H2ResourceGroupConfigurationManagerFactory method create.

@Override
public ResourceGroupConfigurationManager<VariableMap> create(Map<String, String> config, ResourceGroupConfigurationManagerContext context) {
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new JsonModule(), new H2ResourceGroupsModule(), new NodeModule(), new ReloadingResourceGroupConfigurationManagerModule(), binder -> binder.bind(ResourceGroupConfigurationManagerContext.class).toInstance(context), binder -> binder.bind(ClusterMemoryPoolManager.class).toInstance(context.getMemoryPoolManager()));
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).quiet().initialize();
        return injector.getInstance(ReloadingResourceGroupConfigurationManager.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : ReloadingResourceGroupConfigurationManagerModule(com.facebook.presto.resourceGroups.reloading.ReloadingResourceGroupConfigurationManagerModule) NodeModule(com.facebook.airlift.node.NodeModule) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) JsonModule(com.facebook.airlift.json.JsonModule)

Example 4 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class TestProxyServer method setupServer.

@BeforeClass
public void setupServer() throws Exception {
    byte[] sharedSecret = Base64.getMimeEncoder().encode("test secret".getBytes(US_ASCII));
    sharedSecretFile = Files.createTempFile("secret", "txt");
    Files.write(sharedSecretFile, sharedSecret);
    Logging.initialize();
    server = new TestingPrestoServer();
    server.installPlugin(new TpchPlugin());
    server.createCatalog("tpch", "tpch");
    server.installPlugin(new BlackHolePlugin());
    server.createCatalog("blackhole", "blackhole");
    server.refreshNodes();
    Bootstrap app = new Bootstrap(new TestingNodeModule("test"), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(true), new TestingJmxModule(), new ProxyModule());
    Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperty("proxy.uri", server.getBaseUrl().toString()).setRequiredConfigurationProperty("proxy.shared-secret-file", sharedSecretFile.toString()).quiet().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    httpServerInfo = injector.getInstance(HttpServerInfo.class);
    executorService = newCachedThreadPool(daemonThreadsNamed("test-%s"));
    setupTestTable();
}
Also used : TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) TpchPlugin(com.facebook.presto.tpch.TpchPlugin) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) TestingPrestoServer(com.facebook.presto.server.testing.TestingPrestoServer) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JsonModule(com.facebook.airlift.json.JsonModule) TestingJmxModule(com.facebook.airlift.jmx.testing.TestingJmxModule) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) BlackHolePlugin(com.facebook.presto.plugin.blackhole.BlackHolePlugin) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) HttpServerInfo(com.facebook.airlift.http.server.HttpServerInfo) BeforeClass(org.testng.annotations.BeforeClass)

Example 5 with Bootstrap

use of com.facebook.airlift.bootstrap.Bootstrap in project presto by prestodb.

the class PrestoProxy method start.

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(true)).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.initialize();
        log.info("======== SERVER STARTED ========");
    } catch (Throwable t) {
        log.error(t);
        System.exit(1);
    }
}
Also used : MBeanModule(org.weakref.jmx.guice.MBeanModule) EventModule(com.facebook.airlift.event.client.EventModule) JmxModule(com.facebook.airlift.jmx.JmxModule) LogJmxModule(com.facebook.airlift.log.LogJmxModule) NodeModule(com.facebook.airlift.node.NodeModule) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) LogJmxModule(com.facebook.airlift.log.LogJmxModule) Logger(com.facebook.airlift.log.Logger) JsonModule(com.facebook.airlift.json.JsonModule) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) HttpServerModule(com.facebook.airlift.http.server.HttpServerModule) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap)

Aggregations

Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)61 Injector (com.google.inject.Injector)54 JsonModule (com.facebook.airlift.json.JsonModule)36 TypeManager (com.facebook.presto.common.type.TypeManager)16 Module (com.google.inject.Module)12 Test (org.testng.annotations.Test)12 LifeCycleManager (com.facebook.airlift.bootstrap.LifeCycleManager)11 NodeManager (com.facebook.presto.spi.NodeManager)10 JsonBinder.jsonBinder (com.facebook.airlift.json.JsonBinder.jsonBinder)7 FeaturesConfig (com.facebook.presto.sql.analyzer.FeaturesConfig)7 ImmutableList (com.google.common.collect.ImmutableList)7 MBeanModule (org.weakref.jmx.guice.MBeanModule)7 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)6 JsonCodecBinder.jsonCodecBinder (com.facebook.airlift.json.JsonCodecBinder.jsonCodecBinder)6 Type (com.facebook.presto.common.type.Type)6 FunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager)6 FunctionAndTypeManager.createTestFunctionAndTypeManager (com.facebook.presto.metadata.FunctionAndTypeManager.createTestFunctionAndTypeManager)6 HandleJsonModule (com.facebook.presto.metadata.HandleJsonModule)6 ThreadContextClassLoader (com.facebook.presto.spi.classloader.ThreadContextClassLoader)6 RowExpressionService (com.facebook.presto.spi.relation.RowExpressionService)6