use of com.hubspot.singularity.RequestUtilization in project Singularity by HubSpot.
the class SingularityUsagePoller method runActionOnPoll.
@Override
public void runActionOnPoll() {
Map<String, RequestUtilization> utilizationPerRequestId = new ConcurrentHashMap<>();
final long now = System.currentTimeMillis();
AtomicLong totalMemBytesUsed = new AtomicLong(0);
AtomicLong totalMemBytesAvailable = new AtomicLong(0);
AtomicDouble totalCpuUsed = new AtomicDouble(0.00);
AtomicDouble totalCpuAvailable = new AtomicDouble(0.00);
AtomicLong totalDiskBytesUsed = new AtomicLong(0);
AtomicLong totalDiskBytesAvailable = new AtomicLong(0);
Map<SingularitySlaveUsage, List<TaskIdWithUsage>> overLoadedHosts = new ConcurrentHashMap<>();
List<CompletableFuture<Void>> usageFutures = new ArrayList<>();
usageHelper.getSlavesToTrackUsageFor().forEach((slave) -> {
usageFutures.add(usageCollectionSemaphore.call(() -> CompletableFuture.runAsync(() -> {
collectSlaveUage(slave, now, utilizationPerRequestId, overLoadedHosts, totalMemBytesUsed, totalMemBytesAvailable, totalCpuUsed, totalCpuAvailable, totalDiskBytesUsed, totalDiskBytesAvailable);
})));
});
CompletableFutures.allOf(usageFutures).join();
usageManager.saveClusterUtilization(getClusterUtilization(utilizationPerRequestId, totalMemBytesUsed.get(), totalMemBytesAvailable.get(), totalCpuUsed.get(), totalCpuAvailable.get(), totalDiskBytesUsed.get(), totalDiskBytesAvailable.get(), now));
if (configuration.isShuffleTasksForOverloadedSlaves()) {
shuffleTasksOnOverloadedHosts(overLoadedHosts);
}
}
Aggregations