mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Late updates to ReplicatedChronicleMap throw LateUpdateException
This commit is contained in:
@@ -222,9 +222,8 @@ abstract class AbstractChronicleMap<K, V> extends AbstractMap<K, V>
|
||||
// 2. Always "try to read" the previous value (not via if (c.containsKey()) {...
|
||||
// because BytesChronicleMap relies on it to write null to the output stream
|
||||
V prevValue = c.getUsing(null);
|
||||
if (prevValue != null) {
|
||||
if (prevValue != null)
|
||||
c.put(value);
|
||||
}
|
||||
return prevValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
package net.openhft.chronicle.map;
|
||||
|
||||
import net.openhft.chronicle.hash.replication.AbstractReplication;
|
||||
import net.openhft.chronicle.hash.replication.LateUpdateException;
|
||||
import net.openhft.chronicle.hash.replication.TimeProvider;
|
||||
import net.openhft.chronicle.hash.serialization.BytesReader;
|
||||
import net.openhft.chronicle.hash.serialization.internal.BytesBytesInterop;
|
||||
@@ -515,11 +516,19 @@ final class ReplicatedChronicleMap<K, KI, MKI extends MetaBytesInterop<K, ? supe
|
||||
assert identifier != 0 && newIdentifier != 0 :
|
||||
"Own entry replication state or " +
|
||||
"update replication state is not initialized";
|
||||
if (timestamp < newTimestamp)
|
||||
return false;
|
||||
if (timestamp > newTimestamp)
|
||||
return true;
|
||||
return identifier > newIdentifier;
|
||||
boolean shouldIgnore;
|
||||
if (timestamp < newTimestamp) {
|
||||
shouldIgnore = false;
|
||||
} else if (timestamp > newTimestamp) {
|
||||
shouldIgnore = true;
|
||||
} else {
|
||||
shouldIgnore = identifier > newIdentifier;
|
||||
}
|
||||
if (shouldIgnore && !remoteUpdate()) {
|
||||
assert newIdentifier == m().identifier();
|
||||
throw new LateUpdateException(identifier, timestamp, newIdentifier, newTimestamp);
|
||||
}
|
||||
return shouldIgnore;
|
||||
}
|
||||
|
||||
public void dirtyEntries(final long dirtyFromTimeStamp,
|
||||
|
||||
Reference in New Issue
Block a user