use of com.netflix.titus.grpc.protogen.ServiceActivation 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.ServiceActivation in project titus-control-plane by Netflix.
the class ServerStatusResource method getServerStatus.
@GET
public ServerStatusRepresentation getServerStatus() {
Details details = healthService.getServerStatus();
if (details.getStatus() != ServingStatus.SERVING) {
return new ServerStatusRepresentation(false, false, DateTimeExt.toTimeUnitString(details.getUptime()), NOT_APPLICABLE, NOT_APPLICABLE, NOT_APPLICABLE, Collections.emptyList(), Collections.emptyList());
}
List<ServerStatusRepresentation.ServiceActivation> sortedByActivationTime = details.getServiceActivationTimesList().stream().sorted(Comparator.comparing(ServiceActivation::getActivationTime, Durations.comparator())).map(s -> new ServerStatusRepresentation.ServiceActivation(s.getName(), DateTimeExt.toTimeUnitString(s.getActivationTime()))).collect(Collectors.toList());
List<String> namesSortedByActivationTimestamp = details.getServiceActivationTimesList().stream().map(ServiceActivation::getName).collect(Collectors.toList());
return new ServerStatusRepresentation(details.getLeader(), details.getActive(), DateTimeExt.toTimeUnitString(details.getUptime()), Timestamps.toString(details.getElectionTimestamp()), Timestamps.toString(details.getActivationTimestamp()), details.getActive() ? DateTimeExt.toTimeUnitString(details.getActivationTime()) : NOT_APPLICABLE, sortedByActivationTime, namesSortedByActivationTimestamp);
}
Aggregations