use of com.hubspot.singularity.mesos.SingularitySlaveUsageWithCalculatedScores.MaxProbableUsage in project Singularity by HubSpot.
the class SingularityMesosOfferScheduler method getMaxProbableUsageForSlave.
private MaxProbableUsage getMaxProbableUsageForSlave(List<SingularityTaskId> activeTaskIds, Map<String, RequestUtilization> requestUtilizations, String sanitizedHostname) {
double cpu = 0;
double memBytes = 0;
double diskBytes = 0;
for (SingularityTaskId taskId : activeTaskIds) {
if (taskId.getSanitizedHost().equals(sanitizedHostname)) {
if (requestUtilizations.containsKey(taskId.getRequestId())) {
RequestUtilization utilization = requestUtilizations.get(taskId.getRequestId());
// To account for cpu bursts, tend towards max usage if the app is consistently over-utilizing cpu, tend towards avg if it is over-utilized in short bursts
cpu += (utilization.getMaxCpuUsed() - utilization.getAvgCpuUsed()) * utilization.getCpuBurstRating() + utilization.getAvgCpuUsed();
memBytes += utilization.getMaxMemBytesUsed();
diskBytes += utilization.getMaxDiskBytesUsed();
} else {
Optional<SingularityTask> maybeTask = taskManager.getTask(taskId);
if (maybeTask.isPresent()) {
Resources resources = maybeTask.get().getTaskRequest().getPendingTask().getResources().or(maybeTask.get().getTaskRequest().getDeploy().getResources()).or(defaultResources);
cpu += resources.getCpus();
memBytes += resources.getDiskMb() * SingularitySlaveUsage.BYTES_PER_MEGABYTE;
diskBytes += resources.getDiskMb() * SingularitySlaveUsage.BYTES_PER_MEGABYTE;
}
}
}
}
return new MaxProbableUsage(cpu, memBytes, diskBytes);
}
Aggregations