Search in sources :

Example 1 with ServiceSelector

use of com.facebook.airlift.discovery.client.ServiceSelector 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)

Aggregations

Bootstrap (com.facebook.airlift.bootstrap.Bootstrap)1 ConfigBinder.configBinder (com.facebook.airlift.configuration.ConfigBinder.configBinder)1 DiscoveryBinder.discoveryBinder (com.facebook.airlift.discovery.client.DiscoveryBinder.discoveryBinder)1 ServiceSelector (com.facebook.airlift.discovery.client.ServiceSelector)1 TestingDiscoveryModule (com.facebook.airlift.discovery.client.testing.TestingDiscoveryModule)1 TestingHttpServerModule (com.facebook.airlift.http.server.testing.TestingHttpServerModule)1 JaxrsBinder.jaxrsBinder (com.facebook.airlift.jaxrs.JaxrsBinder.jaxrsBinder)1 JaxrsModule (com.facebook.airlift.jaxrs.JaxrsModule)1 TestingJmxModule (com.facebook.airlift.jmx.testing.TestingJmxModule)1 JsonModule (com.facebook.airlift.json.JsonModule)1 TestingNodeModule (com.facebook.airlift.node.testing.TestingNodeModule)1 TraceTokenModule (com.facebook.airlift.tracetoken.TraceTokenModule)1 QueryManagerConfig (com.facebook.presto.execution.QueryManagerConfig)1 InternalCommunicationConfig (com.facebook.presto.server.InternalCommunicationConfig)1 Binder (com.google.inject.Binder)1 Injector (com.google.inject.Injector)1 Module (com.google.inject.Module)1 Test (org.testng.annotations.Test)1