Search in sources :

Example 1 with TraceTokenModule

use of com.facebook.airlift.tracetoken.TraceTokenModule 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)

Example 2 with TraceTokenModule

use of com.facebook.airlift.tracetoken.TraceTokenModule in project presto by prestodb.

the class TestHeartbeatFailureDetector method testExcludesCurrentNode.

@Test
public void testExcludesCurrentNode() throws Exception {
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingJmxModule(), new TestingDiscoveryModule(), new TestingHttpServerModule(), new TraceTokenModule(), new JsonModule(), new JaxrsModule(true), new FailureDetectorModule(), new Module() {

        @Override
        public void configure(Binder binder) {
            configBinder(binder).bindConfig(InternalCommunicationConfig.class);
            configBinder(binder).bindConfig(QueryManagerConfig.class);
            discoveryBinder(binder).bindSelector("presto");
            discoveryBinder(binder).bindHttpAnnouncement("presto");
            // Jersey with jetty 9 requires at least one resource
            // todo add a dummy resource to airlift jaxrs in this case
            jaxrsBinder(binder).bind(FooResource.class);
        }
    });
    Injector injector = app.doNotInitializeLogging().quiet().initialize();
    ServiceSelector selector = injector.getInstance(Key.get(ServiceSelector.class, serviceType("presto")));
    assertEquals(selector.selectAllServices().size(), 1);
    HeartbeatFailureDetector detector = injector.getInstance(HeartbeatFailureDetector.class);
    detector.updateMonitoredServices();
    assertEquals(detector.getTotalCount(), 0);
    assertEquals(detector.getActiveCount(), 0);
    assertEquals(detector.getFailedCount(), 0);
    assertTrue(detector.getFailed().isEmpty());
}
Also used : TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) ServiceSelector(com.facebook.airlift.discovery.client.ServiceSelector) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) JsonModule(com.facebook.airlift.json.JsonModule) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) TestingJmxModule(com.facebook.airlift.jmx.testing.TestingJmxModule) JaxrsBinder.jaxrsBinder(com.facebook.airlift.jaxrs.JaxrsBinder.jaxrsBinder) Binder(com.google.inject.Binder) ConfigBinder.configBinder(com.facebook.airlift.configuration.ConfigBinder.configBinder) DiscoveryBinder.discoveryBinder(com.facebook.airlift.discovery.client.DiscoveryBinder.discoveryBinder) TestingDiscoveryModule(com.facebook.airlift.discovery.client.testing.TestingDiscoveryModule) InternalCommunicationConfig(com.facebook.presto.server.InternalCommunicationConfig) Injector(com.google.inject.Injector) Bootstrap(com.facebook.airlift.bootstrap.Bootstrap) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) TestingHttpServerModule(com.facebook.airlift.http.server.testing.TestingHttpServerModule) Module(com.google.inject.Module) JaxrsModule(com.facebook.airlift.jaxrs.JaxrsModule) TraceTokenModule(com.facebook.airlift.tracetoken.TraceTokenModule) JsonModule(com.facebook.airlift.json.JsonModule) TestingDiscoveryModule(com.facebook.airlift.discovery.client.testing.TestingDiscoveryModule) TestingJmxModule(com.facebook.airlift.jmx.testing.TestingJmxModule) TestingNodeModule(com.facebook.airlift.node.testing.TestingNodeModule) Test(org.testng.annotations.Test)

Example 3 with TraceTokenModule

use of com.facebook.airlift.tracetoken.TraceTokenModule 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)

Aggregations

Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)3 JaxrsModule (com.facebook.airlift.jaxrs.JaxrsModule)3 JsonModule (com.facebook.airlift.json.JsonModule)3 TraceTokenModule (com.facebook.airlift.tracetoken.TraceTokenModule)3 HttpServerModule (com.facebook.airlift.http.server.HttpServerModule)2 JmxModule (com.facebook.airlift.jmx.JmxModule)2 LogJmxModule (com.facebook.airlift.log.LogJmxModule)2 Logger (com.facebook.airlift.log.Logger)2 NodeModule (com.facebook.airlift.node.NodeModule)2 Injector (com.google.inject.Injector)2 Module (com.google.inject.Module)2 MBeanModule (org.weakref.jmx.guice.MBeanModule)2 ConditionalModule.installModuleIf (com.facebook.airlift.configuration.ConditionalModule.installModuleIf)1 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)1 Announcer (com.facebook.airlift.discovery.client.Announcer)1 DiscoveryBinder.discoveryBinder (com.facebook.airlift.discovery.client.DiscoveryBinder.discoveryBinder)1 DiscoveryModule (com.facebook.airlift.discovery.client.DiscoveryModule)1 ServiceAnnouncement (com.facebook.airlift.discovery.client.ServiceAnnouncement)1 ServiceAnnouncementBuilder (com.facebook.airlift.discovery.client.ServiceAnnouncement.ServiceAnnouncementBuilder)1 ServiceAnnouncement.serviceAnnouncement (com.facebook.airlift.discovery.client.ServiceAnnouncement.serviceAnnouncement)1