Search in sources :

Example 26 with Bootstrap

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

the class PrestoServer method run.

@Override
public void run() {
    verifyJvmRequirements();
    verifySystemTimeIsReasonable();
    Logger log = Logger.get(PrestoServer.class);
    ImmutableList.Builder<Module> modules = ImmutableList.builder();
    modules.add(new NodeModule(), new DiscoveryModule(), new HttpServerModule(), new JsonModule(), installModuleIf(FeaturesConfig.class, FeaturesConfig::isJsonSerdeCodeGenerationEnabled, binder -> jsonBinder(binder).addModuleBinding().to(AfterburnerModule.class)), new SmileModule(), new JaxrsModule(true), new MBeanModule(), new JmxModule(), new JmxHttpModule(), new LogJmxModule(), new TraceTokenModule(), new JsonEventModule(), new HttpEventModule(), new ServerSecurityModule(), new AccessControlModule(), new EventListenerModule(), new ServerMainModule(sqlParserOptions), new GracefulShutdownModule(), new WarningCollectorModule(), new TempStorageModule(), new QueryPrerequisitesManagerModule(), new NodeTtlFetcherManagerModule(), new ClusterTtlProviderManagerModule());
    modules.addAll(getAdditionalModules());
    Bootstrap app = new Bootstrap(modules.build());
    try {
        Injector injector = app.initialize();
        injector.getInstance(PluginManager.class).loadPlugins();
        ServerConfig serverConfig = injector.getInstance(ServerConfig.class);
        if (!serverConfig.isResourceManager()) {
            injector.getInstance(StaticCatalogStore.class).loadCatalogs();
        }
        // TODO: remove this huge hack
        updateConnectorIds(injector.getInstance(Announcer.class), injector.getInstance(CatalogManager.class), injector.getInstance(ServerConfig.class), injector.getInstance(NodeSchedulerConfig.class));
        // TODO: thrift server port should be announced by discovery server similar to http/https ports
        updateThriftServerPort(injector.getInstance(Announcer.class), injector.getInstance(DriftServer.class));
        injector.getInstance(StaticFunctionNamespaceStore.class).loadFunctionNamespaceManagers();
        injector.getInstance(SessionPropertyDefaults.class).loadConfigurationManager();
        injector.getInstance(ResourceGroupManager.class).loadConfigurationManager();
        if (!serverConfig.isResourceManager()) {
            injector.getInstance(AccessControlManager.class).loadSystemAccessControl();
        }
        injector.getInstance(PasswordAuthenticatorManager.class).loadPasswordAuthenticator();
        injector.getInstance(EventListenerManager.class).loadConfiguredEventListener();
        injector.getInstance(TempStorageManager.class).loadTempStorages();
        injector.getInstance(QueryPrerequisitesManager.class).loadQueryPrerequisites();
        injector.getInstance(NodeTtlFetcherManager.class).loadNodeTtlFetcher();
        injector.getInstance(ClusterTtlProviderManager.class).loadClusterTtlProvider();
        injector.getInstance(Announcer.class).start();
        log.info("======== SERVER STARTED ========");
    } catch (Throwable e) {
        log.error(e);
        System.exit(1);
    }
}
Also used : Module(com.google.inject.Module) SqlParserOptions(com.facebook.presto.sql.parser.SqlParserOptions) DriftServer(com.facebook.drift.server.DriftServer) MBeanModule(org.weakref.jmx.guice.MBeanModule) ClusterTtlProviderManagerModule(com.facebook.presto.ttl.clusterttlprovidermanagers.ClusterTtlProviderManagerModule) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JmxHttpModule(com.facebook.airlift.jmx.JmxHttpModule) EventListenerManager(com.facebook.presto.eventlistener.EventListenerManager) DriftNettyServerTransport(com.facebook.drift.transport.netty.server.DriftNettyServerTransport) WarningCollectorModule(com.facebook.presto.execution.warnings.WarningCollectorModule) PrestoSystemRequirements.verifySystemTimeIsReasonable(com.facebook.presto.server.PrestoSystemRequirements.verifySystemTimeIsReasonable) Map(java.util.Map) QueryPrerequisitesManagerModule(com.facebook.presto.dispatcher.QueryPrerequisitesManagerModule) Splitter(com.google.common.base.Splitter) ServiceAnnouncement(com.facebook.airlift.discovery.client.ServiceAnnouncement) ClusterTtlProviderManager(com.facebook.presto.ttl.clusterttlprovidermanagers.ClusterTtlProviderManager) ServiceAnnouncement.serviceAnnouncement(com.facebook.airlift.discovery.client.ServiceAnnouncement.serviceAnnouncement) JsonModule(com.facebook.airlift.json.JsonModule) ConditionalModule.installModuleIf(com.facebook.airlift.configuration.ConditionalModule.installModuleIf) SmileModule(com.facebook.airlift.json.smile.SmileModule) Set(java.util.Set) JsonBinder.jsonBinder(com.facebook.airlift.json.JsonBinder.jsonBinder) ServiceAnnouncementBuilder(com.facebook.airlift.discovery.client.ServiceAnnouncement.ServiceAnnouncementBuilder) TempStorageModule(com.facebook.presto.storage.TempStorageModule) AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) HttpEventModule(com.facebook.airlift.event.client.HttpEventModule) List(java.util.List) Catalog(com.facebook.presto.metadata.Catalog) PasswordAuthenticatorManager(com.facebook.presto.server.security.PasswordAuthenticatorManager) NodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.NodeTtlFetcherManager) JsonEventModule(com.facebook.airlift.event.client.JsonEventModule) JmxModule(com.facebook.airlift.jmx.JmxModule) Joiner(com.google.common.base.Joiner) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) Logger(com.facebook.airlift.log.Logger) Strings.nullToEmpty(com.google.common.base.Strings.nullToEmpty) QueryPrerequisitesManager(com.facebook.presto.dispatcher.QueryPrerequisitesManager) AccessControlManager(com.facebook.presto.security.AccessControlManager) TempStorageManager(com.facebook.presto.storage.TempStorageManager) Announcer(com.facebook.airlift.discovery.client.Announcer) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) LinkedHashMap(java.util.LinkedHashMap) StaticCatalogStore(com.facebook.presto.metadata.StaticCatalogStore) ImmutableList(com.google.common.collect.ImmutableList) Objects.requireNonNull(java.util.Objects.requireNonNull) AccessControlModule(com.facebook.presto.security.AccessControlModule) PrestoSystemRequirements.verifyJvmRequirements(com.facebook.presto.server.PrestoSystemRequirements.verifyJvmRequirements) LogJmxModule(com.facebook.airlift.log.LogJmxModule) ResourceGroupManager(com.facebook.presto.execution.resourceGroups.ResourceGroupManager) LinkedHashSet(java.util.LinkedHashSet) EventListenerModule(com.facebook.presto.eventlistener.EventListenerModule) ServerSecurityModule(com.facebook.presto.server.security.ServerSecurityModule) HttpServerModule(com.facebook.airlift.http.server.HttpServerModule) CatalogManager(com.facebook.presto.metadata.CatalogManager) Injector(com.google.inject.Injector) NodeTtlFetcherManagerModule(com.facebook.presto.ttl.nodettlfetchermanagers.NodeTtlFetcherManagerModule) DiscoveryModule(com.facebook.airlift.discovery.client.DiscoveryModule) StaticFunctionNamespaceStore(com.facebook.presto.metadata.StaticFunctionNamespaceStore) NodeModule(com.facebook.airlift.node.NodeModule) AccessControlManager(com.facebook.presto.security.AccessControlManager) JmxModule(com.facebook.airlift.jmx.JmxModule) LogJmxModule(com.facebook.airlift.log.LogJmxModule) DiscoveryModule(com.facebook.airlift.discovery.client.DiscoveryModule) ClusterTtlProviderManagerModule(com.facebook.presto.ttl.clusterttlprovidermanagers.ClusterTtlProviderManagerModule) JsonEventModule(com.facebook.airlift.event.client.JsonEventModule) PasswordAuthenticatorManager(com.facebook.presto.server.security.PasswordAuthenticatorManager) TempStorageModule(com.facebook.presto.storage.TempStorageModule) TempStorageManager(com.facebook.presto.storage.TempStorageManager) Announcer(com.facebook.airlift.discovery.client.Announcer) Injector(com.google.inject.Injector) QueryPrerequisitesManager(com.facebook.presto.dispatcher.QueryPrerequisitesManager) StaticCatalogStore(com.facebook.presto.metadata.StaticCatalogStore) NodeModule(com.facebook.airlift.node.NodeModule) StaticFunctionNamespaceStore(com.facebook.presto.metadata.StaticFunctionNamespaceStore) ResourceGroupManager(com.facebook.presto.execution.resourceGroups.ResourceGroupManager) LogJmxModule(com.facebook.airlift.log.LogJmxModule) JsonModule(com.facebook.airlift.json.JsonModule) EventListenerManager(com.facebook.presto.eventlistener.EventListenerManager) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) HttpServerModule(com.facebook.airlift.http.server.HttpServerModule) Module(com.google.inject.Module) MBeanModule(org.weakref.jmx.guice.MBeanModule) ClusterTtlProviderManagerModule(com.facebook.presto.ttl.clusterttlprovidermanagers.ClusterTtlProviderManagerModule) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JmxHttpModule(com.facebook.airlift.jmx.JmxHttpModule) WarningCollectorModule(com.facebook.presto.execution.warnings.WarningCollectorModule) QueryPrerequisitesManagerModule(com.facebook.presto.dispatcher.QueryPrerequisitesManagerModule) JsonModule(com.facebook.airlift.json.JsonModule) SmileModule(com.facebook.airlift.json.smile.SmileModule) TempStorageModule(com.facebook.presto.storage.TempStorageModule) AfterburnerModule(com.fasterxml.jackson.module.afterburner.AfterburnerModule) HttpEventModule(com.facebook.airlift.event.client.HttpEventModule) JsonEventModule(com.facebook.airlift.event.client.JsonEventModule) JmxModule(com.facebook.airlift.jmx.JmxModule) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) AccessControlModule(com.facebook.presto.security.AccessControlModule) LogJmxModule(com.facebook.airlift.log.LogJmxModule) EventListenerModule(com.facebook.presto.eventlistener.EventListenerModule) ServerSecurityModule(com.facebook.presto.server.security.ServerSecurityModule) HttpServerModule(com.facebook.airlift.http.server.HttpServerModule) NodeTtlFetcherManagerModule(com.facebook.presto.ttl.nodettlfetchermanagers.NodeTtlFetcherManagerModule) DiscoveryModule(com.facebook.airlift.discovery.client.DiscoveryModule) NodeModule(com.facebook.airlift.node.NodeModule) JmxHttpModule(com.facebook.airlift.jmx.JmxHttpModule) MBeanModule(org.weakref.jmx.guice.MBeanModule) WarningCollectorModule(com.facebook.presto.execution.warnings.WarningCollectorModule) ImmutableList(com.google.common.collect.ImmutableList) FeaturesConfig(com.facebook.presto.sql.analyzer.FeaturesConfig) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) Logger(com.facebook.airlift.log.Logger) NodeTtlFetcherManagerModule(com.facebook.presto.ttl.nodettlfetchermanagers.NodeTtlFetcherManagerModule) HttpEventModule(com.facebook.airlift.event.client.HttpEventModule) ClusterTtlProviderManager(com.facebook.presto.ttl.clusterttlprovidermanagers.ClusterTtlProviderManager) ServerSecurityModule(com.facebook.presto.server.security.ServerSecurityModule) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) DriftServer(com.facebook.drift.server.DriftServer) QueryPrerequisitesManagerModule(com.facebook.presto.dispatcher.QueryPrerequisitesManagerModule) EventListenerModule(com.facebook.presto.eventlistener.EventListenerModule) AccessControlModule(com.facebook.presto.security.AccessControlModule) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) CatalogManager(com.facebook.presto.metadata.CatalogManager) SmileModule(com.facebook.airlift.json.smile.SmileModule) NodeTtlFetcherManager(com.facebook.presto.ttl.nodettlfetchermanagers.NodeTtlFetcherManager)

Example 27 with Bootstrap

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

the class TestThriftTaskIntegration method setup.

@BeforeClass
public void setup() throws Exception {
    Bootstrap app = new Bootstrap(new DriftNettyServerModule(), new TestingTaskThriftModule());
    Injector injector = app.doNotInitializeLogging().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    thriftServerPort = driftServerPort(injector.getInstance(DriftServer.class));
}
Also used : DriftNettyServerModule(com.facebook.drift.transport.netty.server.DriftNettyServerModule) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) BeforeClass(org.testng.annotations.BeforeClass)

Example 28 with Bootstrap

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

the class TestThriftServerInfoIntegration method setup.

@BeforeClass
public void setup() throws Exception {
    Bootstrap app = new Bootstrap(new DriftNettyServerModule(), new TestingThriftServerInfoModule());
    app.setRequiredConfigurationProperties(ImmutableMap.of("presto.version", "test.0", "coordinator", "false"));
    Injector injector = app.doNotInitializeLogging().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    thriftServerPort = driftServerPort(injector.getInstance(DriftServer.class));
}
Also used : DriftNettyServerModule(com.facebook.drift.transport.netty.server.DriftNettyServerModule) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) BeforeClass(org.testng.annotations.BeforeClass)

Example 29 with Bootstrap

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

the class InternalIcebergConnectorFactory method createConnector.

public static Connector createConnector(String catalogName, Map<String, String> config, ConnectorContext context, Optional<ExtendedHiveMetastore> metastore) {
    ClassLoader classLoader = InternalIcebergConnectorFactory.class.getClassLoader();
    try (ThreadContextClassLoader ignored = new ThreadContextClassLoader(classLoader)) {
        Bootstrap app = new Bootstrap(new EventModule(), new MBeanModule(), new JsonModule(), new IcebergModule(catalogName), new IcebergMetastoreModule(), new HiveS3Module(catalogName), new HiveAuthenticationModule(), new HiveMetastoreModule(catalogName, metastore), new CachingModule(), binder -> {
            binder.bind(NodeVersion.class).toInstance(new NodeVersion(context.getNodeManager().getCurrentNode().getVersion()));
            binder.bind(NodeManager.class).toInstance(context.getNodeManager());
            binder.bind(TypeManager.class).toInstance(context.getTypeManager());
            binder.bind(PageIndexerFactory.class).toInstance(context.getPageIndexerFactory());
            binder.bind(StandardFunctionResolution.class).toInstance(context.getStandardFunctionResolution());
            binder.bind(RowExpressionService.class).toInstance(context.getRowExpressionService());
        });
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        LifeCycleManager lifeCycleManager = injector.getInstance(LifeCycleManager.class);
        IcebergTransactionManager transactionManager = injector.getInstance(IcebergTransactionManager.class);
        IcebergMetadataFactory metadataFactory = injector.getInstance(IcebergMetadataFactory.class);
        ConnectorSplitManager splitManager = injector.getInstance(ConnectorSplitManager.class);
        ConnectorPageSourceProvider connectorPageSource = injector.getInstance(ConnectorPageSourceProvider.class);
        ConnectorPageSinkProvider pageSinkProvider = injector.getInstance(ConnectorPageSinkProvider.class);
        ConnectorNodePartitioningProvider connectorDistributionProvider = injector.getInstance(ConnectorNodePartitioningProvider.class);
        IcebergSessionProperties icebergSessionProperties = injector.getInstance(IcebergSessionProperties.class);
        IcebergTableProperties icebergTableProperties = injector.getInstance(IcebergTableProperties.class);
        Set<Procedure> procedures = injector.getInstance((Key<Set<Procedure>>) Key.get(Types.setOf(Procedure.class)));
        ConnectorPlanOptimizer planOptimizer = injector.getInstance(IcebergPlanOptimizer.class);
        return new IcebergConnector(lifeCycleManager, transactionManager, metadataFactory, new ClassLoaderSafeConnectorSplitManager(splitManager, classLoader), new ClassLoaderSafeConnectorPageSourceProvider(connectorPageSource, classLoader), new ClassLoaderSafeConnectorPageSinkProvider(pageSinkProvider, classLoader), new ClassLoaderSafeNodePartitioningProvider(connectorDistributionProvider, classLoader), ImmutableSet.of(), icebergSessionProperties.getSessionProperties(), IcebergSchemaProperties.SCHEMA_PROPERTIES, icebergTableProperties.getTableProperties(), new AllowAllAccessControl(), procedures, planOptimizer);
    }
}
Also used : MBeanModule(org.weakref.jmx.guice.MBeanModule) ImmutableSet(com.google.common.collect.ImmutableSet) Set(java.util.Set) EventModule(com.facebook.airlift.event.client.EventModule) NodeVersion(com.facebook.presto.hive.NodeVersion) ClassLoaderSafeConnectorPageSourceProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider) RowExpressionService(com.facebook.presto.spi.relation.RowExpressionService) Injector(com.google.inject.Injector) AllowAllAccessControl(com.facebook.presto.plugin.base.security.AllowAllAccessControl) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) Procedure(com.facebook.presto.spi.procedure.Procedure) HiveMetastoreModule(com.facebook.presto.hive.metastore.HiveMetastoreModule) ThreadContextClassLoader(com.facebook.presto.spi.classloader.ThreadContextClassLoader) ClassLoaderSafeNodePartitioningProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeNodePartitioningProvider) ConnectorPlanOptimizer(com.facebook.presto.spi.ConnectorPlanOptimizer) HiveAuthenticationModule(com.facebook.presto.hive.authentication.HiveAuthenticationModule) ClassLoaderSafeConnectorPageSinkProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSinkProvider) JsonModule(com.facebook.airlift.json.JsonModule) CachingModule(com.facebook.presto.cache.CachingModule) PageIndexerFactory(com.facebook.presto.spi.PageIndexerFactory) HiveS3Module(com.facebook.presto.hive.s3.HiveS3Module) NodeManager(com.facebook.presto.spi.NodeManager) LifeCycleManager(com.facebook.airlift.bootstrap.LifeCycleManager) ConnectorPageSinkProvider(com.facebook.presto.spi.connector.ConnectorPageSinkProvider) ClassLoaderSafeConnectorPageSinkProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSinkProvider) ClassLoaderSafeConnectorSplitManager(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager) ConnectorSplitManager(com.facebook.presto.spi.connector.ConnectorSplitManager) ConnectorPageSourceProvider(com.facebook.presto.spi.connector.ConnectorPageSourceProvider) ClassLoaderSafeConnectorPageSourceProvider(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorPageSourceProvider) ConnectorNodePartitioningProvider(com.facebook.presto.spi.connector.ConnectorNodePartitioningProvider) ClassLoaderSafeConnectorSplitManager(com.facebook.presto.spi.connector.classloader.ClassLoaderSafeConnectorSplitManager) TypeManager(com.facebook.presto.common.type.TypeManager) StandardFunctionResolution(com.facebook.presto.spi.function.StandardFunctionResolution)

Example 30 with Bootstrap

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

the class CassandraConnectorFactory method create.

@Override
public Connector create(String catalogName, Map<String, String> config, ConnectorContext context) {
    requireNonNull(config, "config is null");
    try {
        Bootstrap app = new Bootstrap(new MBeanModule(), new JsonModule(), new CassandraClientModule(catalogName), new Module() {

            @Override
            public void configure(Binder binder) {
                MBeanServer platformMBeanServer = ManagementFactory.getPlatformMBeanServer();
                binder.bind(MBeanServer.class).toInstance(new RebindSafeMBeanServer(platformMBeanServer));
            }
        });
        Injector injector = app.doNotInitializeLogging().setRequiredConfigurationProperties(config).initialize();
        return injector.getInstance(CassandraConnector.class);
    } catch (Exception e) {
        throwIfUnchecked(e);
        throw new RuntimeException(e);
    }
}
Also used : MBeanModule(org.weakref.jmx.guice.MBeanModule) Binder(com.google.inject.Binder) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) Module(com.google.inject.Module) MBeanModule(org.weakref.jmx.guice.MBeanModule) JsonModule(com.facebook.airlift.json.JsonModule) JsonModule(com.facebook.airlift.json.JsonModule) MBeanServer(javax.management.MBeanServer)

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