in src/main/java/org/apache/rocketmq/dashboard/task/DashboardCollectTask.java [220:245]
private void writeFile(LoadingCache<String, List<String>> map, Map<String, List<String>> fileMap,
File file) throws IOException {
Map<String, List<String>> newMap = map.asMap();
Map<String, List<String>> resultMap = Maps.newHashMap();
if (fileMap.size() == 0) {
resultMap = newMap;
}
else {
for (Map.Entry<String, List<String>> entry : fileMap.entrySet()) {
List<String> oldList = entry.getValue();
List<String> newList = newMap.get(entry.getKey());
resultMap.put(entry.getKey(), appendData(newList, oldList));
if (newList == null || newList.size() == 0) {
map.put(entry.getKey(), appendData(newList, oldList));
}
}
for (Map.Entry<String, List<String>> entry : newMap.entrySet()) {
List<String> oldList = fileMap.get(entry.getKey());
if (oldList == null || oldList.size() == 0) {
resultMap.put(entry.getKey(), entry.getValue());
}
}
}
Files.write(JsonUtil.obj2String(resultMap).getBytes(), file);
}