mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Make TimeProvider non-extensible and non-configurable; Fix a bug in
ReplicatedQueryAlloc.CleanupAction
This commit is contained in:
+3
-2
@@ -25,6 +25,7 @@ import net.openhft.sg.Stage;
|
||||
import net.openhft.sg.StageRef;
|
||||
import net.openhft.sg.Staged;
|
||||
|
||||
import static net.openhft.chronicle.hash.replication.TimeProvider.currentTime;
|
||||
import static net.openhft.chronicle.map.ReplicatedChronicleMap.ADDITIONAL_ENTRY_BYTES;
|
||||
|
||||
@Staged
|
||||
@@ -128,7 +129,7 @@ public abstract class ReplicatedMapEntryStages<K, V> extends MapEntryStages<K, V
|
||||
public void updatedReplicationStateOnPresentEntry() {
|
||||
if (!ru.replicationUpdateInit()) {
|
||||
s.innerWriteLock.lock();
|
||||
long timestamp = Math.max(timestamp() + 1, mh.m().timeProvider.currentTime());
|
||||
long timestamp = Math.max(timestamp() + 1, currentTime());
|
||||
updateReplicationState(mh.m().identifier(), timestamp);
|
||||
}
|
||||
}
|
||||
@@ -136,7 +137,7 @@ public abstract class ReplicatedMapEntryStages<K, V> extends MapEntryStages<K, V
|
||||
public void updatedReplicationStateOnAbsentEntry() {
|
||||
if (!ru.replicationUpdateInit()) {
|
||||
s.innerWriteLock.lock();
|
||||
updateReplicationState(mh.m().identifier(), mh.m().timeProvider.currentTime());
|
||||
updateReplicationState(mh.m().identifier(), currentTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+14
-9
@@ -30,6 +30,9 @@ import net.openhft.sg.Staged;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.openhft.chronicle.hash.replication.TimeProvider.currentTime;
|
||||
import static net.openhft.chronicle.hash.replication.TimeProvider.systemTimeIntervalBetween;
|
||||
|
||||
@Staged
|
||||
public class ReplicatedQueryAlloc extends QueryAlloc {
|
||||
|
||||
@@ -64,15 +67,17 @@ public class ReplicatedQueryAlloc extends QueryAlloc {
|
||||
@Override
|
||||
public void accept(ReplicableEntry e) {
|
||||
ReplicatedChronicleMap<?, ?, ?> map = mh.m();
|
||||
if (e instanceof MapAbsentEntry && iterationContext.pos() != posToSkip) {
|
||||
long deleteTimeout = map.timeProvider.currentTime() - e.originTimestamp();
|
||||
map.timeProvider.systemTimeIntervalBetween(e.originTimestamp(),
|
||||
map.timeProvider.currentTime(), map.cleanupTimeoutUnit);
|
||||
if (deleteTimeout > map.cleanupTimeout && !e.isChanged()) {
|
||||
e.doRemoveCompletely();
|
||||
removedCompletely++;
|
||||
}
|
||||
}
|
||||
if (!(e instanceof MapAbsentEntry) || iterationContext.pos() == posToSkip)
|
||||
return;
|
||||
long currentTime = currentTime();
|
||||
if (e.originTimestamp() > currentTime)
|
||||
return; // presumably unsynchronized clocks
|
||||
long deleteTimeout = systemTimeIntervalBetween(
|
||||
e.originTimestamp(), currentTime, map.cleanupTimeoutUnit);
|
||||
if (deleteTimeout <= map.cleanupTimeout || e.isChanged())
|
||||
return;
|
||||
e.doRemoveCompletely();
|
||||
removedCompletely++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user