Search in sources :

Example 1 with CounterMap

use of com.hubspot.mesos.CounterMap in project Singularity by HubSpot.

the class StateManager method getNumTasks.

private Map<String, Long> getNumTasks(List<SingularityRequestWithState> requests) {
    final CounterMap<String> numTasks = new CounterMap<>(requests.size());
    for (SingularityTaskId taskId : taskManager.getActiveTaskIds()) {
        numTasks.incr(taskId.getRequestId());
    }
    for (SingularityPendingTaskId pendingTaskId : taskManager.getPendingTaskIds()) {
        numTasks.incr(pendingTaskId.getRequestId());
    }
    for (SingularityTaskId cleaningTaskId : taskManager.getCleanupTaskIds()) {
        Optional<SingularityRequestWithState> request = requestManager.getRequest(cleaningTaskId.getRequestId());
        if (request.isPresent() && request.get().getRequest().isScheduled()) {
            continue;
        }
        numTasks.decr(cleaningTaskId.getRequestId());
    }
    return numTasks.toCountMap();
}
Also used : CounterMap(com.hubspot.mesos.CounterMap) SingularityPendingTaskId(com.hubspot.singularity.SingularityPendingTaskId) SingularityRequestWithState(com.hubspot.singularity.SingularityRequestWithState) SingularityTaskId(com.hubspot.singularity.SingularityTaskId)

Aggregations

CounterMap (com.hubspot.mesos.CounterMap)1 SingularityPendingTaskId (com.hubspot.singularity.SingularityPendingTaskId)1 SingularityRequestWithState (com.hubspot.singularity.SingularityRequestWithState)1 SingularityTaskId (com.hubspot.singularity.SingularityTaskId)1