in timestamp-storage/src/main/java/org/apache/omid/timestamp/storage/ZKTimestampStorage.java [51:72]
public void updateMaxTimestamp(long previousMaxTimestamp, long newMaxTimestamp) throws IOException {
if (newMaxTimestamp < 0) {
LOG.error("Negative value received for maxTimestamp: {}", newMaxTimestamp);
throw new IllegalArgumentException();
}
if (newMaxTimestamp <= previousMaxTimestamp) {
LOG.error("maxTimestamp {} <= previousMaxTimesamp: {}", newMaxTimestamp, previousMaxTimestamp);
throw new IllegalArgumentException();
}
AtomicValue<Long> compareAndSet;
try {
compareAndSet = timestamp.compareAndSet(previousMaxTimestamp, newMaxTimestamp);
} catch (Exception e) {
throw new IOException("Problem setting timestamp in ZK", e);
}
if (!compareAndSet.succeeded()) { // We have to explicitly check for success (See Curator doc)
throw new IOException("GetAndSet operation for storing timestamp in ZK did not succeed "
+ compareAndSet.preValue() + " " + compareAndSet.postValue());
}
}