Class DefaultXSiteEntryMergePolicy<K,V>
- java.lang.Object
-
- org.infinispan.xsite.spi.DefaultXSiteEntryMergePolicy<K,V>
-
- All Implemented Interfaces:
XSiteEntryMergePolicy<K,V>
public class DefaultXSiteEntryMergePolicy<K,V> extends Object implements XSiteEntryMergePolicy<K,V>
The defaultXSiteEntryMergePolicy
implementation.It uses the site's name to deterministically choose the winning entry. The site with the name lexicographically lowers wins.
- Since:
- 12.0
- Author:
- Pedro Ruivo
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <U,W>
DefaultXSiteEntryMergePolicy<U,W>getInstance()
CompletionStage<SiteEntry<V>>
merge(K key, SiteEntry<V> localEntry, SiteEntry<V> remoteEntry)
Resolves conflicts for asynchronous cross-site replication.
-
-
-
Method Detail
-
getInstance
public static <U,W> DefaultXSiteEntryMergePolicy<U,W> getInstance()
-
merge
public CompletionStage<SiteEntry<V>> merge(K key, SiteEntry<V> localEntry, SiteEntry<V> remoteEntry)
Description copied from interface:XSiteEntryMergePolicy
Resolves conflicts for asynchronous cross-site replication.When a conflict is detected (concurrent updates on the same key in different sites), this method is invoked with the local data and the remote site's data (
SiteEntry
). It includes the value and theMetadata
associated.The value and the
Metadata
may benull
. If that is the case, it means thekey
doesn't exist (forlocalEntry
) or it is a remove operation (forremoteEntry
).The returned
SiteEntry
must be equal independent of the order of the arguments (i.e.resolve(k, s1, s2).equals(resolve(k, s2, s1))
) otherwise your date may be corrupted. It is allowed to return one of the arguments (localEntry
orremoteEntry
) and to create a newSiteEntry
with a new value.Note: if the return
SiteEntry.getValue()
isnull
, Infinispan will interpret it to remove thekey
.Note2: This method shouldn't block (I/O or locks). If it needs to block, use a different thread and complete the
CompletionStage
with the result. We recommend usingBlockingManager.supplyBlocking(Supplier, Object)
.- Specified by:
merge
in interfaceXSiteEntryMergePolicy<K,V>
- Parameters:
key
- The key that was updated concurrently.localEntry
- The local value andMetadata
stored.remoteEntry
- The remote value andMetadata
received.- Returns:
- A
CompletionStage
with theSiteEntry
.
-
-