use of com.dtstack.taier.common.enums.EJobCacheStage in project Taier by DTStack.
the class ConsoleService method dealGroupResult.
private Collection<Map<String, Object>> dealGroupResult(List<Map<String, Object>> groupResult) {
// {jobResource, Map<String, Object> overviewRecord}
Map<String, Map<String, Object>> overview = new HashMap<>(16);
List<Map<String, Object>> finalResult = new ArrayList<>(groupResult.size());
// 处理 DB 返回结果
for (Map<String, Object> record : groupResult) {
long generateTime = MapUtils.getLong(record, "generateTime");
String waitTime = com.dtstack.taier.common.util.DateUtil.getTimeDifference(System.currentTimeMillis() - (generateTime * 1000));
record.put("waitTime", waitTime);
finalResult.add(record);
}
for (Map<String, Object> record : finalResult) {
String jobResource = MapUtils.getString(record, "jobResource");
int stage = MapUtils.getInteger(record, "stage");
String waitTime = MapUtils.getString(record, "waitTime");
long jobSize = MapUtils.getLong(record, "jobSize");
EJobCacheStage eJobCacheStage = EJobCacheStage.getStage(stage);
Map<String, Object> overviewRecord = overview.computeIfAbsent(jobResource, k -> {
Map<String, Object> overviewEle = new HashMap<>(16);
overviewEle.put("jobResource", jobResource);
return overviewEle;
});
String stageName = eJobCacheStage.name().toLowerCase();
overviewRecord.put(stageName, stage);
overviewRecord.put(stageName + "JobSize", jobSize);
overviewRecord.put(stageName + "WaitTime", waitTime);
}
Collection<Map<String, Object>> overviewValues = overview.values();
for (Map<String, Object> record : overviewValues) {
// 针对单个 jobResource,归集所有 stage
for (EJobCacheStage checkStage : EJobCacheStage.values()) {
String checkStageName = checkStage.name().toLowerCase();
if (record.containsKey(checkStageName)) {
continue;
}
record.put(checkStageName, checkStage.getStage());
record.put(checkStageName + "JobSize", 0);
record.put(checkStageName + "WaitTime", "");
}
}
return overviewValues;
}
Aggregations