Search in sources :

Example 1 with JaxrsModule

use of io.airlift.jaxrs.JaxrsModule 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(), new JaxrsModule(true), new MBeanModule(), new JmxModule(), new JmxHttpModule(), new LogJmxModule(), new TraceTokenModule(), new JsonEventModule(), new HttpEventModule(), new EmbeddedDiscoveryModule(), new ServerSecurityModule(), new AccessControlModule(), new EventListenerModule(), new ServerMainModule(sqlParserOptions), new GracefulShutdownModule());
    modules.addAll(getAdditionalModules());
    Bootstrap app = new Bootstrap(modules.build());
    try {
        Injector injector = app.strictConfig().initialize();
        injector.getInstance(PluginManager.class).loadPlugins();
        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));
        injector.getInstance(ResourceGroupManager.class).loadConfigurationManager();
        injector.getInstance(AccessControlManager.class).loadSystemAccessControl();
        injector.getInstance(EventListenerManager.class).loadConfiguredEventListener();
        injector.getInstance(Announcer.class).start();
        log.info("======== SERVER STARTED ========");
    } catch (Throwable e) {
        log.error(e);
        System.exit(1);
    }
}
Also used : AccessControlManager(com.facebook.presto.security.AccessControlManager) MBeanModule(org.weakref.jmx.guice.MBeanModule) JmxModule(io.airlift.jmx.JmxModule) LogJmxModule(io.airlift.log.LogJmxModule) ImmutableList(com.google.common.collect.ImmutableList) EmbeddedDiscoveryModule(com.facebook.presto.discovery.EmbeddedDiscoveryModule) DiscoveryModule(io.airlift.discovery.client.DiscoveryModule) NodeSchedulerConfig(com.facebook.presto.execution.scheduler.NodeSchedulerConfig) JsonEventModule(io.airlift.event.client.JsonEventModule) Logger(io.airlift.log.Logger) HttpEventModule(io.airlift.event.client.HttpEventModule) Announcer(io.airlift.discovery.client.Announcer) ServerSecurityModule(com.facebook.presto.server.security.ServerSecurityModule) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) EventListenerModule(com.facebook.presto.eventlistener.EventListenerModule) AccessControlModule(com.facebook.presto.security.AccessControlModule) StaticCatalogStore(com.facebook.presto.metadata.StaticCatalogStore) NodeModule(io.airlift.node.NodeModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) EmbeddedDiscoveryModule(com.facebook.presto.discovery.EmbeddedDiscoveryModule) ResourceGroupManager(com.facebook.presto.execution.resourceGroups.ResourceGroupManager) LogJmxModule(io.airlift.log.LogJmxModule) JsonModule(io.airlift.json.JsonModule) EventListenerManager(com.facebook.presto.eventlistener.EventListenerManager) CatalogManager(com.facebook.presto.metadata.CatalogManager) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) HttpServerModule(io.airlift.http.server.HttpServerModule) Module(com.google.inject.Module) MBeanModule(org.weakref.jmx.guice.MBeanModule) JmxModule(io.airlift.jmx.JmxModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) JmxHttpModule(io.airlift.jmx.JmxHttpModule) JsonEventModule(io.airlift.event.client.JsonEventModule) NodeModule(io.airlift.node.NodeModule) HttpServerModule(io.airlift.http.server.HttpServerModule) AccessControlModule(com.facebook.presto.security.AccessControlModule) EmbeddedDiscoveryModule(com.facebook.presto.discovery.EmbeddedDiscoveryModule) EventListenerModule(com.facebook.presto.eventlistener.EventListenerModule) ServerSecurityModule(com.facebook.presto.server.security.ServerSecurityModule) HttpEventModule(io.airlift.event.client.HttpEventModule) DiscoveryModule(io.airlift.discovery.client.DiscoveryModule) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) LogJmxModule(io.airlift.log.LogJmxModule) JsonModule(io.airlift.json.JsonModule) JmxHttpModule(io.airlift.jmx.JmxHttpModule)

Example 2 with JaxrsModule

use of io.airlift.jaxrs.JaxrsModule 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(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.strictConfig().doNotInitializeLogging().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(io.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) ServiceSelector(io.airlift.discovery.client.ServiceSelector) JaxrsModule(io.airlift.jaxrs.JaxrsModule) JsonModule(io.airlift.json.JsonModule) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) TestingJmxModule(io.airlift.jmx.testing.TestingJmxModule) Binder(com.google.inject.Binder) DiscoveryBinder.discoveryBinder(io.airlift.discovery.client.DiscoveryBinder.discoveryBinder) JaxrsBinder.jaxrsBinder(io.airlift.jaxrs.JaxrsBinder.jaxrsBinder) ConfigBinder.configBinder(io.airlift.configuration.ConfigBinder.configBinder) TestingDiscoveryModule(io.airlift.discovery.client.testing.TestingDiscoveryModule) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) QueryManagerConfig(com.facebook.presto.execution.QueryManagerConfig) Module(com.google.inject.Module) TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) TraceTokenModule(io.airlift.tracetoken.TraceTokenModule) TestingJmxModule(io.airlift.jmx.testing.TestingJmxModule) TestingDiscoveryModule(io.airlift.discovery.client.testing.TestingDiscoveryModule) JsonModule(io.airlift.json.JsonModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) Test(org.testng.annotations.Test)

Example 3 with JaxrsModule

use of io.airlift.jaxrs.JaxrsModule in project presto by prestodb.

the class TestHttpBackupStore method setup.

@BeforeMethod
public void setup() throws Exception {
    temporary = createTempDir();
    Map<String, String> properties = ImmutableMap.<String, String>builder().put("backup.http.uri", "http://localhost:8080").build();
    Bootstrap app = new Bootstrap(new TestingNodeModule(), new TestingHttpServerModule(), new JsonModule(), new JaxrsModule(true), binder -> jaxrsBinder(binder).bind(TestingHttpBackupResource.class), override(new HttpBackupModule()).with(new TestingModule()));
    Injector injector = app.strictConfig().setRequiredConfigurationProperties(properties).doNotInitializeLogging().initialize();
    lifeCycleManager = injector.getInstance(LifeCycleManager.class);
    store = injector.getInstance(BackupStore.class);
}
Also used : TestingHttpServerModule(io.airlift.http.server.testing.TestingHttpServerModule) TestingNodeModule(io.airlift.node.testing.TestingNodeModule) JaxrsModule(io.airlift.jaxrs.JaxrsModule) JsonModule(io.airlift.json.JsonModule) LifeCycleManager(io.airlift.bootstrap.LifeCycleManager) Injector(com.google.inject.Injector) Bootstrap(io.airlift.bootstrap.Bootstrap) BeforeMethod(org.testng.annotations.BeforeMethod)

Aggregations

Injector (com.google.inject.Injector)3 Bootstrap (io.airlift.bootstrap.Bootstrap)3 JaxrsModule (io.airlift.jaxrs.JaxrsModule)3 JsonModule (io.airlift.json.JsonModule)3 Module (com.google.inject.Module)2 TestingHttpServerModule (io.airlift.http.server.testing.TestingHttpServerModule)2 TestingNodeModule (io.airlift.node.testing.TestingNodeModule)2 TraceTokenModule (io.airlift.tracetoken.TraceTokenModule)2 EmbeddedDiscoveryModule (com.facebook.presto.discovery.EmbeddedDiscoveryModule)1 EventListenerManager (com.facebook.presto.eventlistener.EventListenerManager)1 EventListenerModule (com.facebook.presto.eventlistener.EventListenerModule)1 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)1 ResourceGroupManager (com.facebook.presto.execution.resourceGroups.ResourceGroupManager)1 NodeSchedulerConfig (com.facebook.presto.execution.scheduler.NodeSchedulerConfig)1 CatalogManager (com.facebook.presto.metadata.CatalogManager)1 StaticCatalogStore (com.facebook.presto.metadata.StaticCatalogStore)1 AccessControlManager (com.facebook.presto.security.AccessControlManager)1 AccessControlModule (com.facebook.presto.security.AccessControlModule)1 ServerSecurityModule (com.facebook.presto.server.security.ServerSecurityModule)1 ImmutableList (com.google.common.collect.ImmutableList)1