mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Local updates couldn't be late
This commit is contained in:
@@ -37,19 +37,21 @@ import java.io.Serializable;
|
||||
* @see ChronicleHashBuilder#timeProvider(TimeProvider)
|
||||
*/
|
||||
public abstract class TimeProvider implements Serializable {
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
/**
|
||||
* Delegates {@link #currentTime()} to {@link System#currentTime()}.
|
||||
*/
|
||||
public static final TimeProvider SYSTEM = new System();
|
||||
private static final long serialVersionUID = 0L;
|
||||
|
||||
public abstract long currentTime();
|
||||
|
||||
private static class System extends TimeProvider {
|
||||
private static final long serialVersionUID = 0L;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final long SCALE = 1000;
|
||||
|
||||
public long currentTime() {
|
||||
return java.lang.System.currentTimeMillis();
|
||||
return java.lang.System.currentTimeMillis() * SCALE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -541,22 +541,28 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
|
||||
closeReplicationUpdate();
|
||||
}
|
||||
|
||||
private boolean testTimeStampInSensibleRange() {
|
||||
if (rm().timeProvider == TimeProvider.SYSTEM) {
|
||||
long currentTime = TimeProvider.SYSTEM.currentTime();
|
||||
assert Math.abs(currentTime - timestamp) <= 100000000 :
|
||||
"unrealistic timestamp: " + timestamp;
|
||||
assert Math.abs(currentTime - newTimestamp) <= 100000000 :
|
||||
"unrealistic newTimestamp: " + newTimestamp;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
boolean shouldIgnore() {
|
||||
assert replicationStateInit() : "replication state not init";
|
||||
assert replicationUpdateInit() : "replication update not init";
|
||||
boolean shouldIgnore;
|
||||
if (timestamp < newTimestamp) {
|
||||
shouldIgnore = false;
|
||||
} else if (timestamp > newTimestamp) {
|
||||
shouldIgnore = true;
|
||||
} else {
|
||||
shouldIgnore = identifier > newIdentifier;
|
||||
assert testTimeStampInSensibleRange();
|
||||
if (!remoteUpdate()) {
|
||||
newTimestamp = timestamp + 1L;
|
||||
return false;
|
||||
}
|
||||
if (shouldIgnore && !remoteUpdate()) {
|
||||
assert newIdentifier == rm().identifier();
|
||||
throw new LateUpdateException(identifier, timestamp, newIdentifier, newTimestamp);
|
||||
}
|
||||
return shouldIgnore;
|
||||
return timestamp > newTimestamp ||
|
||||
(timestamp == newTimestamp && identifier > newIdentifier);
|
||||
}
|
||||
|
||||
public void dirtyEntries(final long dirtyFromTimeStamp,
|
||||
|
||||
Reference in New Issue
Block a user