implements Serializable {
* This method is called whenever a new value is put for the key in the map during calls of such
* methods as {@link ChronicleMap#put put}, {@link ChronicleMap#putIfAbsent putIfAbsent}, {@link
* ChronicleMap#replace(Object, Object, Object) replace}, etc. When a new value is {@linkplain
- * ChronicleMapBuilder#defaultValue(Object) default} for the map or obtained during
- * {@link ChronicleMap#acquireUsing acquireUsing} call is put for the key, this method is called
- * as well.
+ * ChronicleMapBuilder#defaultValue(Object) default} for the map or obtained during {@link
+ * ChronicleMap#acquireUsing acquireUsing} call is put for the key, this method is called as
+ * well.
*
* This method is called when put is already happened.
- * @param key the key the given value is put for
- * @param newValue the value which is now associated with the given key
- * @param replacedValue the value which was replaced by {@code newValue}, {@code null} if the
- * key was absent in the map before current {@code ChronicleMap}
+ *
+ * @param key the key the given value is put for
+ * @param newValue the value which is now associated with the given key
+ * @param replacedValue the value which was replaced by {@code newValue}, {@code null} if the
+ * key was absent in the map before current {@code ChronicleMap}
* @param replicationEvent
*/
- public void onPut(K key, V newValue, @Nullable V replacedValue, boolean replicationEvent) {
+ public void onPut(K key,
+ V newValue,
+ @Nullable V replacedValue,
+ boolean replicationEvent,
+ boolean added) {
// do nothing
}
/**
* This is called when an entry is removed. Misses, i. e. when {@code map.remove(key)} is
* called, but key is already absent in the map, are not notified.
- * @param key the key removed from the map
- * @param value the value which was associated with the given key
+ *
+ * @param key the key removed from the map
+ * @param value the value which was associated with the given key
* @param replicationEvent
*/
public void onRemove(K key, V value, boolean replicationEvent) {
diff --git a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java
index 70a0a877b..a47c018ef 100644
--- a/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java
+++ b/src/main/java/net/openhft/chronicle/map/ReplicatedChronicleMap.java
@@ -962,7 +962,7 @@ final class ReplicatedChronicleMap,
RV, VB extends RV, VBI, MVBI extends MetaBytesInterop>
UpdateResult update(@Nullable ThreadLocalCopies copies, @Nullable SegmentState segmentState,
- MKBI metaKeyInterop, KBI keyInterop, KB key, long keySize,
- InstanceOrBytesToInstance toKey,
- GetValueInterops getValueInterops, VB value,
- InstanceOrBytesToInstance super VB, V> toValue,
- long hash2,
- byte identifier, long timeStamp) {
+ MKBI metaKeyInterop, KBI keyInterop, KB key, long keySize,
+ InstanceOrBytesToInstance toKey,
+ GetValueInterops getValueInterops, VB value,
+ InstanceOrBytesToInstance super VB, V> toValue,
+ long hash2,
+ byte identifier, long timeStamp) {
segmentStateNotNullImpliesCopiesNotNull(copies, segmentState);
if (segmentState == null) {
copies = SegmentState.getCopies(copies);
@@ -1157,7 +1157,8 @@ final class ReplicatedChronicleMap
- * We can reject put() and removes() when comparing times stamps with remote systems
+ *
We can reject put() and removes() when comparing times stamps with remote
+ * systems
*
* @param entry the maps entry
* @param timestamp the time the entry was created or updated
diff --git a/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java b/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java
index 7c4068fbb..875475168 100644
--- a/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java
+++ b/src/main/java/net/openhft/chronicle/map/ReplicationHubFindByName.java
@@ -57,8 +57,9 @@ class ReplicationHubFindByName implements FindByName {
// creates a map based on the details that are sent to the map of builders
@Override
public void onPut(CharSequence key, MapInstanceBuilder value,
- MapInstanceBuilder replacedValue, boolean replicationEvent) {
- super.onPut(key, value, replacedValue, replicationEvent);
+ MapInstanceBuilder replacedValue, boolean replicationEvent,
+ boolean added0) {
+ super.onPut(key, value, replacedValue, replicationEvent, added0);
boolean added = replacedValue == null;
if (!added || value == null)
return;
diff --git a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java
index 8d5e7bcea..c2b8e1be8 100755
--- a/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java
+++ b/src/main/java/net/openhft/chronicle/map/VanillaChronicleMap.java
@@ -2132,7 +2132,7 @@ class VanillaChronicleMap,
}
if (eventListener != null) {
eventListener.onPut(toKey.toInstance(copies, key, keySize),
- toValue.toInstance(copies, v, valueSize), null, false);
+ toValue.toInstance(copies, v, valueSize), null, false, true);
}
return v;
@@ -2168,11 +2168,11 @@ class VanillaChronicleMap,
,
RV, VB extends RV, VBI, MVBI extends MetaBytesInterop>
UpdateResult update(@Nullable ThreadLocalCopies copies, @Nullable SegmentState segmentState,
- MKBI metaKeyInterop, KBI keyInterop, KB key, long keySize,
- InstanceOrBytesToInstance toKey,
- GetValueInterops getValueInterops, VB value,
- InstanceOrBytesToInstance super VB, V> toValue,
- long hash2) {
+ MKBI metaKeyInterop, KBI keyInterop, KB key, long keySize,
+ InstanceOrBytesToInstance toKey,
+ GetValueInterops getValueInterops, VB value,
+ InstanceOrBytesToInstance super VB, V> toValue,
+ long hash2) {
shouldNotBeCalledFromReplicatedChronicleMap("Segment.update");
segmentStateNotNullImpliesCopiesNotNull(copies, segmentState);
if (segmentState == null) {
@@ -2222,7 +2222,8 @@ class VanillaChronicleMap,
bytesEventListener.onPut(entry, 0L, metaDataBytes, valueSizePos, false, false);
if (eventListener != null) {
eventListener.onPut(toKey.toInstance(copies, key, keySize),
- toValue.toInstance(copies, value, valueSize), null, false);
+ toValue.toInstance(copies, value, valueSize), null, false,
+ false);
}
}
}
@@ -2241,7 +2242,7 @@ class VanillaChronicleMap,
segmentState.valueSizePos, true, false);
if (eventListener != null)
eventListener.onPut(toKey.toInstance(copies, key, keySize),
- toValue.toInstance(copies, value, valueSize), null, false);
+ toValue.toInstance(copies, value, valueSize), null, false, true);
return UpdateResult.INSERT;
} finally {
@@ -2334,7 +2335,7 @@ class VanillaChronicleMap,
segmentState.valueSizePos, true, false);
if (eventListener != null)
eventListener.onPut(toKey.toInstance(copies, key, keySize),
- toValue.toInstance(copies, value, valueSize), oldValue, false);
+ toValue.toInstance(copies, value, valueSize), oldValue, false, true);
return resultUnused ? null : readValue.readNull();
}
@@ -2383,7 +2384,8 @@ class VanillaChronicleMap,
bytesEventListener.onPut(entry, 0L, metaDataBytes, valueSizePos, false, remote);
if (eventListener != null) {
eventListener.onPut(toKey.toInstance(copies, key, keySize),
- toValue.toInstance(copies, value, valueSize), prevValueInstance, remote);
+ toValue.toInstance(copies, value, valueSize), prevValueInstance, remote,
+ true);
}
return resultUnused ? null : prevValue;
@@ -2764,7 +2766,7 @@ class VanillaChronicleMap,
if (eventListener != null)
eventListener.onPut(toKey.toInstance(copies, key, keySize),
toValue.toInstance(copies, newValue, newValueSize),
- toValue.toInstance(copies, prevValue, valueSize), false);
+ toValue.toInstance(copies, prevValue, valueSize), false, true);
return expectedValue == null ? prevValue : Boolean.TRUE;
}
@@ -2971,7 +2973,7 @@ class VanillaChronicleMap,
final Segment segment = segments[segIndex];
ThreadLocalCopies copies = SegmentState.getCopies(null);
try (SegmentState segmentState = SegmentState.get(copies)) {
- segment.readLock(null);
+ segment.readLock(null);
if (segment.hashLookup().getPositions().isClear(pos)) {
// the pos was removed after the previous advance
diff --git a/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java b/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java
index 4fe7324f4..df8ca8941 100644
--- a/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java
+++ b/src/test/java/net/openhft/chronicle/map/EventListenerWithTCPSocketReplicationTest.java
@@ -54,7 +54,8 @@ public class EventListenerWithTCPSocketReplicationTest {
private static final long serialVersionUID = 1L;
@Override
- public void onPut(Integer key, CharSequence value, CharSequence replacedValue, boolean replicationEvent) {
+ public void onPut(Integer key, CharSequence value, CharSequence replacedValue,
+ boolean replicationEvent, boolean added) {
putWasCalled.getAndSet(true);
keyRef.set(key);
valueRef.set(value);