V
- the type of the returned merged valueT
- the type of the required merging value, e.g. a simple MergingValue<V>
or a composition like MergingEntry<String, V> & MergingHits<V> & MergingLastAccessTime<V>
public interface SplitBrainMergePolicy<V,T extends MergingValue<V>> extends DataSerializable
The values of merging and existing MergingValue
s are always in the in-memory format of the
backing data structure. This can be a serialized format, so the content cannot be processed without deserialization.
For most merge policies this will be fine, since the key or value are not used.
The deserialization is not done eagerly for two main reasons:
InMemoryFormat.BINARY
with a different
classpath on client and server. In this case a deserialization could throw a ClassNotFoundException
.MergingValue.getDeserializedValue()
or
MergingEntry.getDeserializedKey()
, which will deserialize the data lazily.
A merge policy can implement HazelcastInstanceAware
to get the HazelcastInstance
injected.
This can be used to retrieve the user context via HazelcastInstance.getUserContext()
,
which is an easy way to get user dependencies that are otherwise hard to obtain.
A merge policy can also implement NodeAware
to get an instance of Node
injected.
Modifier and Type | Method and Description |
---|---|
V |
merge(T mergingValue,
T existingValue)
Selects the value of either the merging or the existing
MergingValue which should be merged. |
readData, writeData
V merge(T mergingValue, T existingValue)
MergingValue
which should be merged.
Note that the existing MergingValue
instance may be null
if no matching data could be found to the merging MergingValue
.
mergingValue
- MergingValue
instance that has the merging data of the smaller sub-clusterexistingValue
- MergingValue
instance that has the existing data
or null
if no matching data existsCopyright © 2020 Hazelcast, Inc.. All Rights Reserved.