Skip to content

Commit

Permalink
Configuration Service: do not save the snapshot in the past. Adjust I…
Browse files Browse the repository at this point in the history
…D to latest ID + 1
  • Loading branch information
cdealti committed Jun 10, 2014
1 parent c94d30d commit 36bf0ef
Showing 1 changed file with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,20 @@ private synchronized long saveSnapshot(List<? extends ComponentConfiguration> co
//
// Write it to disk: marshall
long sid = (new Date()).getTime();

//
// Do not save the snapshot in the past
Set<Long> snapshotIDs = getSnapshots();
if (snapshotIDs != null && snapshotIDs.size() > 0) {
Long[] snapshots = snapshotIDs.toArray( new Long[]{});
Long lastestID = snapshots[snapshotIDs.size()-1];

if (lastestID != null && sid <= lastestID) {
s_logger.warn("Snapshot ID: {} is in the past. Adjusting ID to: {} + 1", sid, lastestID);
sid = lastestID + 1;
}
}

File fSnapshot = getSnapshotFile(sid);
s_logger.info("Writing snapshot - Saving {}...", fSnapshot.getAbsolutePath());
try {
Expand Down

0 comments on commit 36bf0ef

Please sign in to comment.