Search in sources :

Example 1 with MaxProbableUsage

use of com.hubspot.singularity.mesos.SingularityAgentUsageWithCalculatedScores.MaxProbableUsage in project Singularity by HubSpot.

the class SingularityMesosOfferSchedulerTest method getUsage.

private SingularityAgentUsageWithCalculatedScores getUsage(long memMbReserved, long memMbTotal, long memMbInUse, double cpusReserved, double cpusTotal, double cpuInUse, long diskMbReserved, long diskMbTotal, long diskMbInUse) {
    long totalMemBytes = memMbTotal * SingularityAgentUsage.BYTES_PER_MEGABYTE;
    long memBytesInUse = memMbInUse * SingularityAgentUsage.BYTES_PER_MEGABYTE;
    return new SingularityAgentUsageWithCalculatedScores(new SingularityAgentUsage(cpuInUse, cpusReserved, Optional.of(cpusTotal), memBytesInUse, memMbReserved, Optional.of(memMbTotal), diskMbInUse * SingularityAgentUsage.BYTES_PER_MEGABYTE, diskMbReserved, Optional.of(diskMbTotal), 1, 0L, totalMemBytes, totalMemBytes - memBytesInUse, cpusTotal, cpuInUse, cpuInUse, cpuInUse, diskMbInUse * SingularityAgentUsage.BYTES_PER_MEGABYTE, diskMbTotal * SingularityAgentUsage.BYTES_PER_MEGABYTE), MachineLoadMetric.LOAD_5, new MaxProbableUsage(0, 0, 0), 0, 0, System.currentTimeMillis());
}
Also used : SingularityAgentUsage(com.hubspot.singularity.SingularityAgentUsage) MaxProbableUsage(com.hubspot.singularity.mesos.SingularityAgentUsageWithCalculatedScores.MaxProbableUsage)

Example 2 with MaxProbableUsage

use of com.hubspot.singularity.mesos.SingularityAgentUsageWithCalculatedScores.MaxProbableUsage in project Singularity by HubSpot.

the class SingularityMesosOfferScheduler method getMaxProbableUsageForAgent.

private MaxProbableUsage getMaxProbableUsageForAgent(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());
                cpu += agentAndRackHelper.getEstimatedCpuUsageForRequest(utilization);
                memBytes += utilization.getMaxMemBytesUsed();
                diskBytes += utilization.getMaxDiskBytesUsed();
            } else {
                Optional<SingularityTask> maybeTask = taskManager.getTask(taskId);
                if (maybeTask.isPresent()) {
                    Resources resources = maybeTask.get().getTaskRequest().getPendingTask().getResources().orElse(maybeTask.get().getTaskRequest().getDeploy().getResources().orElse(defaultResources));
                    cpu += resources.getCpus();
                    memBytes += resources.getMemoryMb() * SingularityAgentUsage.BYTES_PER_MEGABYTE;
                    diskBytes += resources.getDiskMb() * SingularityAgentUsage.BYTES_PER_MEGABYTE;
                }
            }
        }
    }
    return new MaxProbableUsage(cpu, memBytes, diskBytes);
}
Also used : MaxProbableUsage(com.hubspot.singularity.mesos.SingularityAgentUsageWithCalculatedScores.MaxProbableUsage) SingularityTask(com.hubspot.singularity.SingularityTask) RequestUtilization(com.hubspot.singularity.RequestUtilization) Resources(com.hubspot.mesos.Resources) SingularityTaskId(com.hubspot.singularity.SingularityTaskId)

Aggregations

MaxProbableUsage (com.hubspot.singularity.mesos.SingularityAgentUsageWithCalculatedScores.MaxProbableUsage)2 Resources (com.hubspot.mesos.Resources)1 RequestUtilization (com.hubspot.singularity.RequestUtilization)1 SingularityAgentUsage (com.hubspot.singularity.SingularityAgentUsage)1 SingularityTask (com.hubspot.singularity.SingularityTask)1 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)1