mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Make checksum computation delayed, on lock release
This commit is contained in:
@@ -92,6 +92,7 @@ public abstract class MapEntryStages<K, V> extends HashEntryStages<K>
|
||||
}
|
||||
|
||||
public void writeValue(Data<?> value) {
|
||||
initDelayedUpdateChecksum(true);
|
||||
// In acquireContext(), replaceValue() is called for
|
||||
// 1) executing custom replaceValue() logic, if defined, from configured MapEntryOperations
|
||||
// 2) Update replication status (bits, timestamp)
|
||||
|
||||
@@ -43,6 +43,7 @@ public abstract class ReplicatedMapEntryStages<K, V> extends MapEntryStages<K, V
|
||||
}
|
||||
|
||||
void updateReplicationState(long timestamp, byte identifier) {
|
||||
initDelayedUpdateChecksum(true);
|
||||
Bytes segmentBytes = s.segmentBytesForWrite();
|
||||
segmentBytes.writePosition(replicationBytesOffset);
|
||||
segmentBytes.writeLong(timestamp);
|
||||
|
||||
@@ -95,32 +95,11 @@ public abstract class ReplicatedInput<K, V, R>
|
||||
mh.m().setLastModificationTime(riId, bootstrapTimestamp);
|
||||
|
||||
q.initInputKey(replicatedInputKeyBytesValue);
|
||||
|
||||
boolean debugEnabled = lh.LOG.isDebugEnabled();
|
||||
|
||||
s.innerUpdateLock.lock();
|
||||
if (isDeleted) {
|
||||
if (debugEnabled) {
|
||||
lh.LOG.debug("READING FROM SOURCE - into local-id={}, remote={}, remove(key={})",
|
||||
mh.m().identifier(), riId, ks.inputKey);
|
||||
}
|
||||
mh.m().remoteOperations.remove(this);
|
||||
return;
|
||||
}
|
||||
|
||||
String message = null;
|
||||
if (debugEnabled) {
|
||||
message = String.format(
|
||||
"READING FROM SOURCE - into local-id=%d, remote-id=%d, put(key=%s,",
|
||||
mh.m().identifier(), riId, ks.inputKey);
|
||||
}
|
||||
|
||||
|
||||
mh.m().remoteOperations.put(this, replicatedInputValueBytesValue);
|
||||
|
||||
|
||||
if (debugEnabled) {
|
||||
lh.LOG.debug(message + "value=" + replicatedInputValueBytesValue + ")");
|
||||
} else {
|
||||
mh.m().remoteOperations.put(this, replicatedInputValueBytesValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,7 +39,6 @@ public abstract class MapSegmentIteration<K, V, R> extends HashSegmentIteration<
|
||||
checkOnEachPublicOperation.checkOnEachPublicOperation();
|
||||
try {
|
||||
entry.innerDefaultReplaceValue(newValue);
|
||||
entry.checksumStrategy.computeAndStoreChecksum();
|
||||
} finally {
|
||||
s.innerWriteLock.unlock();
|
||||
}
|
||||
|
||||
-3
@@ -59,7 +59,6 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
entry.innerDefaultReplaceValue(newValue);
|
||||
ru.updateChange();
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
} finally {
|
||||
s.innerWriteLock.unlock();
|
||||
}
|
||||
@@ -121,7 +120,6 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
e.writeEntryDeleted();
|
||||
ru.updateChange();
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
s.deleted(s.deleted() + 1);
|
||||
} finally {
|
||||
s.innerWriteLock.unlock();
|
||||
@@ -148,7 +146,6 @@ public abstract class ReplicatedMapSegmentIteration<K, V, R> extends MapSegmentI
|
||||
e.writeEntryPresent();
|
||||
ru.updateChange();
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
} finally {
|
||||
s.innerWriteLock.unlock();
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ public abstract class MapAbsent<K, V> implements Absent<K, V> {
|
||||
s.incrementModCount();
|
||||
ks.setSearchState(PRESENT);
|
||||
q.initPresenceOfEntry(EntryPresence.PRESENT);
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"Entry is present in the map when doInsert() is called");
|
||||
|
||||
@@ -99,11 +99,6 @@ public abstract class MapQuery<K, V, R> extends HashQuery<K>
|
||||
|
||||
@Override
|
||||
public void doReplaceValue(Data<V> newValue) {
|
||||
doReplaceValueWithoutChecksum(newValue);
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
}
|
||||
|
||||
public void doReplaceValueWithoutChecksum(Data<V> newValue) {
|
||||
putPrefix();
|
||||
if (entryPresent()) {
|
||||
e.innerDefaultReplaceValue(newValue);
|
||||
|
||||
@@ -51,7 +51,6 @@ public abstract class ReplicatedMapAbsent<K, V> extends MapAbsent<K, V> {
|
||||
s.incrementModCount();
|
||||
e.writeEntryPresent();
|
||||
ru.updateChange();
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"Entry is present in the map when doInsert() is called");
|
||||
|
||||
@@ -78,7 +78,6 @@ public abstract class ReplicatedMapQuery<K, V, R> extends MapQuery<K, V, R>
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
e.writeEntryDeleted();
|
||||
ru.updateChange();
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
s.deleted(s.deleted() + 1);
|
||||
} else {
|
||||
throw new IllegalStateException("Entry is absent in the map when doRemove() is called");
|
||||
@@ -95,9 +94,8 @@ public abstract class ReplicatedMapQuery<K, V, R> extends MapQuery<K, V, R>
|
||||
|
||||
@Override
|
||||
public void doReplaceValue(Data<V> newValue) {
|
||||
doReplaceValueWithoutChecksum(newValue);
|
||||
super.doReplaceValue(newValue);
|
||||
ru.updateChange();
|
||||
e.updatedReplicationStateOnPresentEntry();
|
||||
e.checksumStrategy.computeAndStoreChecksum();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user