use of com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.NOT_SERVING in project titus-control-plane by Netflix.
the class DefaultHealthService method getServerStatus.
public Details getServerStatus() {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
Duration uptime = Durations.fromMillis(rb.getUptime());
if (!leaderActivator.isLeader()) {
return Details.newBuilder().setStatus(NOT_SERVING).setLeader(false).setActive(false).setUptime(uptime).build();
}
boolean active = leaderActivator.isActivated();
List<ServiceActivation> serviceActivations = activationLifecycle.getServiceActionTimesMs().stream().sorted(Comparator.comparing(Pair::getRight)).map(pair -> ServiceActivation.newBuilder().setName(pair.getLeft()).setActivationTime(Durations.fromMillis(pair.getRight())).build()).collect(Collectors.toList());
Details.Builder details = Details.newBuilder().setStatus(SERVING).setCell(cellInfoResolver.getCellName()).setLeader(true).setActive(active).setUptime(uptime).setElectionTimestamp(Timestamps.fromMillis(leaderActivator.getElectionTimestamp())).setActivationTimestamp(Timestamps.fromMillis(leaderActivator.getActivationEndTimestamp())).addAllServiceActivationTimes(serviceActivations);
if (active) {
details.setActivationTime(Durations.fromMillis(leaderActivator.getActivationTime()));
}
return details.build();
}
use of com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.NOT_SERVING in project titus-control-plane by Netflix.
the class AggregatingHealthServiceTest method allCellsFailing.
@Test
public void allCellsFailing() {
cellOne.getServiceRegistry().addService(new CellWithHealthStatus(failing("one")));
cellTwo.getServiceRegistry().addService(new CellWithHealthStatus(failing("two")));
AssertableSubscriber<HealthCheckResponse> subscriber = service.check(HealthCheckRequest.newBuilder().build()).test();
subscriber.awaitTerminalEvent(10, TimeUnit.SECONDS);
subscriber.assertNoErrors();
subscriber.assertValueCount(1);
HealthCheckResponse response = subscriber.getOnNextEvents().get(0);
assertThat(response.getStatus()).isEqualTo(NOT_SERVING);
assertThat(response.getDetailsCount()).isEqualTo(2);
assertThat(response.getDetails(0).hasDetails()).isTrue();
assertThat(response.getDetails(1).hasDetails()).isTrue();
Set<String> cellsSeen = response.getDetailsList().stream().map(s -> s.getDetails().getCell()).collect(Collectors.toSet());
assertThat(cellsSeen).contains("one", "two");
}
use of com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.NOT_SERVING in project titus-control-plane by Netflix.
the class AggregatingHealthServiceTest method oneCellFailing.
@Test
public void oneCellFailing() {
cellOne.getServiceRegistry().addService(new CellWithHealthStatus(ok("one")));
cellTwo.getServiceRegistry().addService(new CellWithHealthStatus(failing("two")));
AssertableSubscriber<HealthCheckResponse> subscriber = service.check(HealthCheckRequest.newBuilder().build()).test();
subscriber.awaitTerminalEvent(10, TimeUnit.SECONDS);
subscriber.assertNoErrors();
subscriber.assertValueCount(1);
HealthCheckResponse response = subscriber.getOnNextEvents().get(0);
assertThat(response.getStatus()).isEqualTo(NOT_SERVING);
assertThat(response.getDetailsCount()).isEqualTo(2);
assertThat(response.getDetails(0).hasDetails()).isTrue();
assertThat(response.getDetails(1).hasDetails()).isTrue();
Set<String> cellsSeen = response.getDetailsList().stream().map(s -> s.getDetails().getCell()).collect(Collectors.toSet());
assertThat(cellsSeen).contains("one", "two");
}
Aggregations