use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class ApplicationSlaStoreCacheTest method testRemove.
@Test
public void testRemove() throws Exception {
when(delegate.remove(anyString())).thenReturn(Observable.empty());
ApplicationSLA applicationSLA = initSet.get(0);
store.remove(applicationSLA.getAppName()).toBlocking().firstOrDefault(null);
try {
store.findByName(applicationSLA.getAppName()).toBlocking().first();
fail("Expected to fail as the entity has been removed");
} catch (NotFoundException ignore) {
}
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class JobManagerUtil method getCapacityGroupDescriptor.
public static ApplicationSLA getCapacityGroupDescriptor(JobDescriptor<?> jobDescriptor, ApplicationSlaManagementService capacityGroupService) {
String capacityGroup = jobDescriptor.getCapacityGroup();
ApplicationSLA applicationSLA = capacityGroupService.getApplicationSLA(capacityGroup);
return applicationSLA == null ? capacityGroupService.getApplicationSLA(ApplicationSlaManagementService.DEFAULT_APPLICATION) : applicationSLA;
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class JobManagerUtil method getTierAssignment.
public static Pair<Tier, String> getTierAssignment(JobDescriptor<?> jobDescriptor, ApplicationSlaManagementService capacityGroupService) {
String capacityGroup = jobDescriptor.getCapacityGroup();
ApplicationSLA applicationSLA = capacityGroupService.getApplicationSLA(capacityGroup);
if (applicationSLA == null) {
capacityGroup = ApplicationSlaManagementService.DEFAULT_APPLICATION;
applicationSLA = capacityGroupService.getApplicationSLA(capacityGroup);
}
return Pair.of(applicationSLA.getTier(), capacityGroup);
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class ManagementSubsystemInitializer method enterActiveMode.
@Activator
public Observable<Void> enterActiveMode() {
logger.info("Entering active mode");
try {
ApplicationSLA defaultSLA = applicationSlaStore.findByName(ApplicationSlaManagementService.DEFAULT_APPLICATION).toBlocking().first();
logger.info("Default application SLA configured as: {}", defaultSLA);
} catch (NotFoundException e) {
ApplicationSLA defaultSLA = buildDefaultApplicationSLA(configuration);
applicationSlaStore.create(defaultSLA).toBlocking().firstOrDefault(null);
logger.info("Default application SLA not defined; creating it according to the provided configuration: {}", defaultSLA);
}
return Observable.empty();
}
use of com.netflix.titus.api.model.ApplicationSLA in project titus-control-plane by Netflix.
the class ResourceConsumptionEvaluator method buildSystemConsumption.
private CompositeResourceConsumption buildSystemConsumption(Map<String, Map<String, ResourceConsumption>> capacityGroupConsumptionMap) {
// Capacity group level
Map<Tier, List<CompositeResourceConsumption>> tierConsumptions = new HashMap<>();
capacityGroupConsumptionMap.forEach((capacityGroup, appConsumptions) -> {
ApplicationSLA sla = applicationSlaMap.get(capacityGroup);
ResourceDimension allowedConsumption = ResourceDimensions.multiply(sla.getResourceDimension(), sla.getInstanceCount());
ResourceDimension maxConsumption = ResourceConsumptions.addMaxConsumptions(appConsumptions.values());
List<Map<String, Object>> attrsList = appConsumptions.values().stream().map(ResourceConsumption::getAttributes).collect(Collectors.toList());
CompositeResourceConsumption capacityGroupConsumption = new CompositeResourceConsumption(capacityGroup, ConsumptionLevel.CapacityGroup, ResourceConsumptions.addCurrentConsumptions(appConsumptions.values()), maxConsumption, allowedConsumption, ResourceConsumptions.mergeAttributes(attrsList), appConsumptions, !ResourceDimensions.isBigger(allowedConsumption, maxConsumption));
tierConsumptions.computeIfAbsent(sla.getTier(), t -> new ArrayList<>()).add(capacityGroupConsumption);
});
// Tier level
List<CompositeResourceConsumption> aggregatedTierConsumptions = new ArrayList<>();
tierConsumptions.forEach((tier, consumptions) -> aggregatedTierConsumptions.add(ResourceConsumptions.aggregate(tier.name(), ConsumptionLevel.Tier, consumptions)));
// System level
return ResourceConsumptions.aggregate(SYSTEM_CONSUMER, ConsumptionLevel.System, aggregatedTierConsumptions);
}
Aggregations