Interface SplitBrainMergePolicy<V,T extends MergingValue<V>,R>
- Type Parameters:
V- the (deserialized) type of the merging valueT- the type of the required merging value, e.g. a simpleMergingValue<V>or a composition likeMergingEntry<String, V> & MergingHits & MergingLastAccessTimeR- the type of the merged value as returned bymerge(MergingValue, MergingValue)
- All Superinterfaces:
DataSerializable
- All Known Implementing Classes:
com.hazelcast.spi.impl.merge.AbstractSplitBrainMergePolicy,DiscardMergePolicy,ExpirationTimeMergePolicy,HigherHitsMergePolicy,HyperLogLogMergePolicy,LatestAccessMergePolicy,LatestUpdateMergePolicy,PassThroughMergePolicy,PutIfAbsentMergePolicy
The values of merging and existing MergingValues 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:
- The deserialization is quite expensive and should be avoided, if the result is not needed.
- There is no need to locate classes of stored entries
on the server side, when the entries are not deserialized.
So you can put entries from a client by using
InMemoryFormat.BINARYwith a different classpath on client and server. In this case a deserialization could throw aClassNotFoundException.
MergingValue.getDeserializedValue()
or MergingEntry.getKey(),
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.
- Since:
- 3.10
-
Method Summary
Modifier and TypeMethodDescriptionSelects the value of either the merging or the existingMergingValuewhich should be merged.Methods inherited from interface com.hazelcast.nio.serialization.DataSerializable
readData, writeData
-
Method Details
-
merge
Selects the value of either the merging or the existingMergingValuewhich should be merged.Note that the existing
MergingValueinstance may benullif no matching data could be found to the mergingMergingValue.- Parameters:
mergingValue-MergingValueinstance that has the merging data of the smaller sub-clusterexistingValue-MergingValueinstance that has the existing data ornullif no matching data exists- Returns:
- the selected value for merging
-