use of org.ow2.proactive.resourcemanager.common.event.RMNodeHistory in project scheduling by ow2-proactive.
the class RMRest method getNodesHistory.
@Override
public Map<String, Map<String, Map<String, List<RMNodeHistory>>>> getNodesHistory(String sessionId, long windowStart, long windowEnd) throws NotConnectedException {
ResourceManager rm = checkAccess(sessionId);
List<RMNodeHistory> rawDataFromRM = rm.getNodesHistory(windowStart, windowEnd);
// grouped by node source name, host name, and node name
Map<String, Map<String, Map<String, List<RMNodeHistory>>>> grouped = rawDataFromRM.stream().collect(Collectors.groupingBy(RMNodeHistory::getNodeSource, Collectors.groupingBy(RMNodeHistory::getHost, Collectors.groupingBy(this::getNodeName))));
grouped.values().forEach(a -> a.values().forEach(b -> {
b.values().forEach(c -> {
// sorting by startTime
c.sort(Comparator.comparing(RMNodeHistory::getStartTime));
c.forEach(nh -> {
// if startTime before window
if (nh.getStartTime() < windowStart) {
nh.setStartTime(windowStart);
}
// if endTime after window
if (windowEnd < nh.getEndTime()) {
nh.setEndTime(windowEnd);
}
if (nh.getEndTime() == 0) {
nh.setEndTime(windowEnd);
}
});
});
}));
return grouped;
}
Aggregations