Search in sources :

Example 1 with SingularityTaskRequestWithPriority

use of com.hubspot.singularity.SingularityTaskRequestWithPriority in project Singularity by HubSpot.

the class SingularityMesosTaskPrioritizer method getSortedDueTasks.

public List<SingularityTaskRequest> getSortedDueTasks(List<SingularityTaskRequest> dueTasks) {
    long now = System.currentTimeMillis();
    List<SingularityTaskRequestWithPriority> taskRequestWithPriorities = new ArrayList<>();
    for (SingularityTaskRequest taskRequest : dueTasks) {
        taskRequestWithPriorities.add(new SingularityTaskRequestWithPriority(taskRequest, getWeightedPriority(taskRequest, now)));
    }
    Collections.sort(taskRequestWithPriorities, SingularityTaskRequestWithPriority.weightedPriorityComparator());
    List<SingularityTaskRequest> taskRequests = new ArrayList<>();
    for (SingularityTaskRequestWithPriority taskRequestWithPriority : taskRequestWithPriorities) {
        taskRequests.add(taskRequestWithPriority.getTaskRequest());
    }
    return taskRequests;
}
Also used : ArrayList(java.util.ArrayList) SingularityTaskRequestWithPriority(com.hubspot.singularity.SingularityTaskRequestWithPriority) SingularityTaskRequest(com.hubspot.singularity.SingularityTaskRequest)

Aggregations

SingularityTaskRequest (com.hubspot.singularity.SingularityTaskRequest)1 SingularityTaskRequestWithPriority (com.hubspot.singularity.SingularityTaskRequestWithPriority)1 ArrayList (java.util.ArrayList)1