use of com.netflix.titus.common.util.tuple.Pair in project titus-control-plane by Netflix.
the class ReservationUsageCalculator method buildCapacityGroupUsage.
public ReservationUsage buildCapacityGroupUsage(String capacityGroupName) {
ApplicationSLA capacityGroup = capacityManagementService.getApplicationSLA(capacityGroupName);
if (capacityGroup == null) {
return ReservationUsage.none();
}
List<Pair<Job, List<Task>>> jobsAndTasks = jobOperations.getJobsAndTasks();
ResourceAccumulator accumulator = new ResourceAccumulator();
for (Pair<Job, List<Task>> jobAndTasks : jobsAndTasks) {
Job job = jobAndTasks.getLeft();
if (capacityGroupName.equals(job.getJobDescriptor().getCapacityGroup())) {
processJob(accumulator, jobAndTasks);
}
}
return accumulator.toReservationUsage();
}
use of com.netflix.titus.common.util.tuple.Pair 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.common.util.tuple.Pair in project titus-control-plane by Netflix.
the class ResourceConsumptionServiceMetrics method update.
public void update(DefaultResourceConsumptionService.ConsumptionEvaluationResult evaluationResult) {
CompositeResourceConsumption systemConsumption = evaluationResult.getSystemConsumption();
Set<Pair<String, String>> touchedApps = new HashSet<>();
Set<String> touchedGroups = new HashSet<>();
systemConsumption.getContributors().values().forEach(tierConsumption -> updateTier((CompositeResourceConsumption) tierConsumption, touchedApps, touchedGroups));
// Remove no longer referenced items
copyAndRemove(metricsByCapacityGroupAndApp.keySet(), touchedApps).forEach(removed -> metricsByCapacityGroupAndApp.remove(removed).reset());
copyAndRemove(capacityGroupLimits.keySet(), touchedGroups).forEach(removed -> capacityGroupLimits.remove(removed).reset());
updateTimestamp = registry.clock().wallTime();
}
use of com.netflix.titus.common.util.tuple.Pair in project titus-control-plane by Netflix.
the class TaskTerminationExecutorTest method testTerminateTaskWithNoQuota.
@Test
public void testTerminateTaskWithNoQuota() {
Pair<Job, List<Task>> jobAndTask = createAndStartJobWithTasks(1);
Job<?> job = jobAndTask.getLeft();
Task task = jobAndTask.getRight().get(0);
when(quotasManager.tryConsumeQuota(job, task)).thenReturn(ConsumptionResult.rejected("no quota"));
StepVerifier.withVirtualTime(() -> newTerminationExecutor().terminateTask(task.getId(), EVICTION_REASON, "callerContext")).consumeErrorWith(e -> expectEvictionError(e, ErrorCode.NoQuota)).verify();
expectTaskTerminationEvent(task, false);
verify(quotasManager, times(1)).tryConsumeQuota(job, task);
}
use of com.netflix.titus.common.util.tuple.Pair in project titus-control-plane by Netflix.
the class RetryActionInterceptorTest method expectAboveExecutionLimits.
private EntityHolder expectAboveExecutionLimits(ModelAction updateAction, EntityHolder model) {
Optional<Pair<EntityHolder, EntityHolder>> pair = updateAction.apply(model);
assertThat(pair).isPresent();
EntityHolder modelWithTag = pair.get().getRight();
assertThat(retryInterceptor.executionLimits(modelWithTag)).isFalse();
return modelWithTag;
}
Aggregations