use of com.netflix.titus.api.model.ApplicationSLA 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.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class BatchDifferenceResolver method createNewTaskAction.
private Optional<TitusChangeAction> createNewTaskAction(BatchJobView refJobView, int taskIndex, Optional<EntityHolder> previousTask, List<String> unassignedIpAllocations, List<String> ebsVolumeIds) {
// Safety check
long numberOfNotFinishedTasks = refJobView.getJobHolder().getChildren().stream().filter(holder -> TaskState.isRunning(((Task) holder.getEntity()).getStatus().getState())).count();
if (numberOfNotFinishedTasks >= refJobView.getRequiredSize()) {
titusRuntime.getCodeInvariants().inconsistent("Batch job reconciler attempts to create too many tasks: jobId=%s, requiredSize=%s, current=%s", refJobView.getJob().getId(), refJobView.getRequiredSize(), numberOfNotFinishedTasks);
return Optional.empty();
}
Map<String, String> taskContext = getTaskContext(previousTask, unassignedIpAllocations, ebsVolumeIds);
JobDescriptor jobDescriptor = refJobView.getJob().getJobDescriptor();
ApplicationSLA capacityGroupDescriptor = JobManagerUtil.getCapacityGroupDescriptor(jobDescriptor, capacityGroupService);
String resourcePool = capacityGroupDescriptor.getResourcePool();
taskContext = CollectionsExt.copyAndAdd(taskContext, ImmutableMap.of(TaskAttributes.TASK_ATTRIBUTES_RESOURCE_POOL, resourcePool, TaskAttributes.TASK_ATTRIBUTES_TIER, capacityGroupDescriptor.getTier().name()));
TitusChangeAction storeAction = storeWriteRetryInterceptor.apply(createOrReplaceTaskAction(runtime, jobStore, refJobView.getJobHolder(), taskIndex, versionSupplier, clock, taskContext));
return Optional.of(storeAction);
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class ServiceDifferenceResolver method createNewTaskAction.
private Optional<TitusChangeAction> createNewTaskAction(ServiceJobView refJobView, Optional<EntityHolder> previousTask, List<String> unassignedIpAllocations, List<String> unassignedEbsVolumeIds) {
// Safety check
long numberOfNotFinishedTasks = getNumberOfNotFinishedTasks(refJobView);
if (numberOfNotFinishedTasks >= refJobView.getRequiredSize()) {
titusRuntime.getCodeInvariants().inconsistent("Service job reconciler attempts to create too many tasks: jobId=%s, requiredSize=%s, current=%s", refJobView.getJob().getId(), refJobView.getRequiredSize(), numberOfNotFinishedTasks);
return Optional.empty();
}
Map<String, String> taskContext = getTaskContext(previousTask, unassignedIpAllocations, unassignedEbsVolumeIds);
JobDescriptor jobDescriptor = refJobView.getJob().getJobDescriptor();
ApplicationSLA capacityGroupDescriptor = JobManagerUtil.getCapacityGroupDescriptor(jobDescriptor, capacityGroupService);
String resourcePool = capacityGroupDescriptor.getResourcePool();
taskContext = CollectionsExt.copyAndAdd(taskContext, ImmutableMap.of(TaskAttributes.TASK_ATTRIBUTES_RESOURCE_POOL, resourcePool, TaskAttributes.TASK_ATTRIBUTES_TIER, capacityGroupDescriptor.getTier().name()));
TitusChangeAction storeAction = storeWriteRetryInterceptor.apply(createOrReplaceTaskAction(runtime, jobStore, versionSupplier, refJobView.getJobHolder(), previousTask, clock, taskContext));
return Optional.of(storeAction);
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class InMemoryApplicationSlaStore method create.
@Override
public Observable<Void> create(ApplicationSLA applicationSLA) {
return Observable.create(subscriber -> {
synchronized (lock) {
ApplicationSLA previous = applicationSLAs.put(applicationSLA.getAppName(), applicationSLA);
if (previous != null) {
applicationSLAsBySchedulerName.remove(previous.getSchedulerName(), previous);
}
applicationSLAsBySchedulerName.put(applicationSLA.getSchedulerName(), applicationSLA);
subscriber.onCompleted();
}
});
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class DefaultApplicationSlaManagementServiceTest method testGetApplicationBySchedulerNameFailure.
@Test
public void testGetApplicationBySchedulerNameFailure() {
ApplicationSLA myApp = ApplicationSlaSample.CriticalSmallKubeScheduler.build();
Observable observable = Observable.error(new RuntimeException("generic failure"));
when(storage.findBySchedulerName(myApp.getSchedulerName())).thenReturn(observable);
assertThatThrownBy(() -> slaManagementService.getApplicationSLAsForScheduler(myApp.getSchedulerName())).isInstanceOf(RuntimeException.class).hasMessage("generic failure");
}
Aggregations