use of com.netflix.titus.grpc.protogen.HealthCheckResponse.ServingStatus.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.SERVING in project titus-control-plane by Netflix.
the class AggregatingHealthServiceTest method allCellsOK.
@Test
public void allCellsOK() {
cellOne.getServiceRegistry().addService(new CellWithHealthStatus(ok("one")));
cellTwo.getServiceRegistry().addService(new CellWithHealthStatus(ok("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(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