com.netflix.runtime.health.api.HealthCheckAggregator Java Examples
The following examples show how to use
com.netflix.runtime.health.api.HealthCheckAggregator.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HealthServiceImplTest.java From conductor with Apache License 2.0 | 6 votes |
@Test public void healthServing() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); HealthCheckStatus hcs = mock(HealthCheckStatus.class); when(hcs.isHealthy()).thenReturn(true); when(hcsf.get()).thenReturn(hcs); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build()); assertEquals(HealthCheckResponse.ServingStatus.SERVING, reply.getStatus()); }
Example #2
Source File: HealthServiceImplTest.java From conductor with Apache License 2.0 | 6 votes |
@Test public void healthNotServing() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); HealthCheckStatus hcs = mock(HealthCheckStatus.class); when(hcs.isHealthy()).thenReturn(false); when(hcsf.get()).thenReturn(hcs); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); HealthCheckResponse reply = blockingStub.check(HealthCheckRequest.newBuilder().build()); assertEquals(HealthCheckResponse.ServingStatus.NOT_SERVING, reply.getStatus()); }
Example #3
Source File: HealthServiceImplTest.java From conductor with Apache License 2.0 | 6 votes |
@Test public void healthException() throws Exception { // Generate a unique in-process server name. String serverName = InProcessServerBuilder.generateName(); HealthCheckAggregator hca = mock(HealthCheckAggregator.class); CompletableFuture<HealthCheckStatus> hcsf = mock(CompletableFuture.class); when(hcsf.get()).thenThrow(InterruptedException.class); when(hca.check()).thenReturn(hcsf); HealthServiceImpl healthyService = new HealthServiceImpl(hca); addService(serverName, healthyService); HealthGrpc.HealthBlockingStub blockingStub = HealthGrpc.newBlockingStub( // Create a client channel and register for automatic graceful shutdown. grpcCleanup.register(InProcessChannelBuilder.forName(serverName).directExecutor().build())); thrown.expect(StatusRuntimeException.class); thrown.expect(hasProperty("status", is(Status.INTERNAL))); blockingStub.check(HealthCheckRequest.newBuilder().build()); }
Example #4
Source File: HealthModuleTest.java From runtime-health with Apache License 2.0 | 6 votes |
@Test public void testMultipleInstancesOfHealthModuleInstalled() throws InterruptedException, ExecutionException { LifecycleInjector injector = InjectorBuilder.fromModules(new HealthModule() { @Override protected void configureHealth() { bindAdditionalHealthIndicator().toInstance(healthy); } }, new HealthModule() { @Override protected void configureHealth() { bindAdditionalHealthIndicator().toInstance(unhealthy); } }, new ArchaiusModule()).createInjector(); HealthCheckAggregator aggregator = injector.getInstance(HealthCheckAggregator.class); assertNotNull(aggregator); HealthCheckStatus healthCheckStatus = aggregator.check().get(); assertFalse(healthCheckStatus.isHealthy()); assertEquals(2, healthCheckStatus.getHealthResults().size()); }
Example #5
Source File: HealthLocalMasterReadinessResolver.java From titus-control-plane with Apache License 2.0 | 5 votes |
public HealthLocalMasterReadinessResolver(HealthCheckAggregator healthCheckAggregator, ScheduleDescriptor scheduleDescriptor, TitusRuntime titusRuntime, Scheduler scheduler) { this.healthCheckAggregator = healthCheckAggregator; this.clock = titusRuntime.getClock(); this.poller = PollingLocalMasterReadinessResolver.newPollingResolver( refresh(), scheduleDescriptor, titusRuntime, scheduler ); }
Example #6
Source File: HealthModule.java From runtime-health with Apache License 2.0 | 5 votes |
@Override public HealthCheckAggregator get() { if (indicators == null) { indicators = Collections.emptySet(); } if (config.cacheHealthIndicators()) { return new DefaultCachingHealthCheckAggregator(new ArrayList<HealthIndicator>(indicators), config.getCacheIntervalInMillis(), TimeUnit.MILLISECONDS, config.getAggregatorWaitIntervalInMillis(), TimeUnit.MILLISECONDS, dispatcher); } else { return new SimpleHealthCheckAggregator(new ArrayList<HealthIndicator>(indicators), config.getAggregatorWaitIntervalInMillis(), TimeUnit.MILLISECONDS, dispatcher); } }
Example #7
Source File: HealthModuleTest.java From runtime-health with Apache License 2.0 | 5 votes |
@Test public void testNoIndicators() throws InterruptedException, ExecutionException { LifecycleInjector injector = InjectorBuilder.fromModules(new HealthModule(), new ArchaiusModule()).createInjector(); HealthCheckAggregator aggregator = injector.getInstance(HealthCheckAggregator.class); assertNotNull(aggregator); HealthCheckStatus healthCheckStatus = aggregator.check().get(); assertTrue(healthCheckStatus.isHealthy()); assertEquals(0, healthCheckStatus.getHealthResults().size()); }
Example #8
Source File: HealthModuleTest.java From runtime-health with Apache License 2.0 | 5 votes |
@Test public void testConfiguringIndicatorsByExtendingHealthModule() throws InterruptedException, ExecutionException { LifecycleInjector injector = InjectorBuilder.fromModules(new HealthModule() { @Override protected void configureHealth() { bindAdditionalHealthIndicator().toInstance(healthy); } }, new ArchaiusModule()).createInjector(); HealthCheckAggregator aggregator = injector.getInstance(HealthCheckAggregator.class); assertNotNull(aggregator); HealthCheckStatus healthCheckStatus = aggregator.check().get(); assertTrue(healthCheckStatus.isHealthy()); assertEquals(1, healthCheckStatus.getHealthResults().size()); }
Example #9
Source File: EurekaHealthStatusBridgeModuleTest.java From runtime-health with Apache License 2.0 | 5 votes |
@Test public void testHealthCheckHandlerRegistered() { InjectorBuilder.fromModules(new EurekaHealthStatusBridgeModule(), new AbstractModule() { @Override protected void configure() { bind(ApplicationInfoManager.class).toInstance(infoManager); bind(EurekaClient.class).toInstance(eurekaClient); bind(HealthCheckAggregator.class).toInstance(healthCheckAggregator); } }).createInjector(); Mockito.verify(eurekaClient, Mockito.times(1)).registerHealthCheck(Mockito.any(HealthCheckHandler.class)); }
Example #10
Source File: HealthLocalMasterReadinessResolver.java From titus-control-plane with Apache License 2.0 | 4 votes |
@Inject public HealthLocalMasterReadinessResolver(HealthCheckAggregator healthCheckAggregator, TitusRuntime titusRuntime) { this(healthCheckAggregator, REFRESH_SCHEDULER_DESCRIPTOR, titusRuntime, Schedulers.parallel()); }
Example #11
Source File: HealthCheckResource.java From titus-control-plane with Apache License 2.0 | 4 votes |
@Inject public HealthCheckResource(HealthCheckAggregator healthCheck) { this.healthCheck = healthCheck; }
Example #12
Source File: HealthServiceImpl.java From conductor with Apache License 2.0 | 4 votes |
@Inject public HealthServiceImpl(HealthCheckAggregator healthCheck) { this.healthCheck = healthCheck; }
Example #13
Source File: HealthCheckResource.java From conductor with Apache License 2.0 | 4 votes |
@Inject public HealthCheckResource(HealthCheckAggregator healthCheck) { this.healthCheck = healthCheck; }
Example #14
Source File: HealthModule.java From runtime-health with Apache License 2.0 | 4 votes |
@Override protected void configure() { install(new GuavaApplicationEventModule()); requireBinding(Key.get(ConfigProxyFactory.class)); bind(HealthCheckAggregator.class).toProvider(HealthProvider.class).asEagerSingleton(); }
Example #15
Source File: HealthAggregatorEurekaHealthCheckHandler.java From runtime-health with Apache License 2.0 | 4 votes |
public HealthAggregatorEurekaHealthCheckHandler(HealthCheckAggregator healthCheckAggregator, IndicatorMatcher matcher) { this.healthCheckAggregator = healthCheckAggregator; this.matcher = matcher; }