// Calculate appropriate time, add it to the submap, then
// add
// that to the tempMap
subMap.put("snapshot_time", ((Long) mapTimeFix.get("times").get(
"snapshot_time") - (getSnapshotDuration() * skipCount)));
Format formatter = null;
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date((Long) subMap.get("snapshot_time"));
subMap.put("snapshot_date", formatter.format(date));
// Add the submap back to the tempmap
tempMap.put("times", new HashMap<String, Object>(subMap));
// Clear out the subMap for use again
subMap.clear();
// Run through the mbeans
// Run through the mbeans
for (Iterator<String> it = mapTimeFix.keySet().iterator(); it
.hasNext();) {
// get the mbean name
String mbeanName = it.next();
HashMap<String, Object> stats = null;
// Verify that it's not times
if (mbeanName.equals(new String("times"))) {
} else {
stats = mapTimeFix.get(mbeanName);
// Run through the stats elements for the particular
// mbean
for (Iterator<String> itt = stats.keySet().iterator(); itt
.hasNext();) {
String key = itt.next();
// Place faux data into the submap
subMap.put(key, new Long(0));
}
// Add the submap to the tempmap, and clear it
tempMap.put(mbeanName, new HashMap<String, Object>(subMap));
}
}
snapshotList.add(0, new HashMap<String, HashMap<String, Object>>(
tempMap));
}
/*
* This is where we will be inserting data to fill 'gaps' in the
* snapshots The initial for-loop will travel from the most recent
* snapshot to the oldest, checking that the snapshot_time along the way
* all align with what they should be
*/
for (int i = snapshotList.size() - 1; i > 0; i--) {
if (i > 0) {
HashMap<String, HashMap<String, Object>> mapTimeFix = snapshotList
.get(i);
HashMap<String, HashMap<String, Object>> mapTimeFix2 = snapshotList
.get(i - 1);
// here is where we will in missing data
while (((((Long) mapTimeFix.get("times").get("snapshot_time") / 1000) / 60)
- (((Long) mapTimeFix2.get("times")
.get("snapshot_time") / 1000) / 60) > (((getSnapshotDuration() / 1000) / 60) * skipCount))) {
HashMap<String, HashMap<String, Object>> tempMap = new HashMap<String, HashMap<String, Object>>();
HashMap<String, Object> subMap = new HashMap<String, Object>();
for (Iterator<String> it = mapTimeFix.keySet().iterator(); it
.hasNext();) {
// get the mbean name
String mbeanName = it.next();
HashMap<String, Object> stats = null;
// Verify that it's not times
if (!mbeanName.equals("times")) {
stats = mapTimeFix.get(mbeanName);
// Run through the stats elements for the
// particular
// mbean
for (Iterator<String> itt = stats.keySet()
.iterator(); itt.hasNext();) {
String key = itt.next();
// Place faux data into the submap
subMap.put(key, new Long(0));
}
// Add the submap to the tempmap, and clear it
tempMap.put(mbeanName, new HashMap<String, Object>(
subMap));
subMap.clear();
}
}
subMap.put("snapshot_time", new Long((Long) mapTimeFix.get(
"times").get("snapshot_time")
- (getSnapshotDuration() * skipCount)));
Format formatter = null;
formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date((Long) subMap.get("snapshot_time"));
subMap.put("snapshot_date", formatter.format(date));
tempMap.put("times", new HashMap<String, Object>(subMap));
subMap.clear();
snapshotList.add(i,
new HashMap<String, HashMap<String, Object>>(
tempMap));