in priam/src/main/java/com/netflix/priam/resources/BackupServlet.java [243:284]
private JSONObject constructJsonResponse(
JSONObject object, Iterator<AbstractBackupPath> it, String filter) throws Exception {
int fileCnt = 0;
filter = filter.contains("?") ? filter.substring(0, filter.indexOf("?")) : filter;
try {
JSONArray jArray = new JSONArray();
while (it.hasNext()) {
AbstractBackupPath p = it.next();
if (!filter.isEmpty() && BackupFileType.valueOf(filter) != p.getType()) continue;
JSONObject backupJSON = new JSONObject();
backupJSON.put("bucket", config.getBackupPrefix());
backupJSON.put("filename", p.getRemotePath());
backupJSON.put("app", p.getClusterName());
backupJSON.put("region", p.getRegion());
backupJSON.put("token", p.getToken());
backupJSON.put("ts", DateUtil.formatyyyyMMddHHmm(p.getTime()));
backupJSON.put(
"instance_id", p.getInstanceIdentity().getInstance().getInstanceId());
backupJSON.put("uploaded_ts", DateUtil.formatyyyyMMddHHmm(p.getUploadedTs()));
if ("meta".equalsIgnoreCase(filter)) { // only check for existence of meta file
p.setFileName(
"meta.json"); // ignore incremental meta files, we are only interested
// in daily snapshot
if (metaData.doesExist(p)) {
// if here, snapshot completed.
fileCnt++;
jArray.put(backupJSON);
backupJSON.put("num_files", "1");
}
} else { // account for every file (data, and meta) .
fileCnt++;
jArray.put(backupJSON);
}
}
object.put("files", jArray);
object.put("num_files", fileCnt);
} catch (JSONException jse) {
logger.info("Caught JSON Exception --> {}", jse.getMessage());
}
return object;
}