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();
}
Aggregations