Enum XSiteMergePolicy
- All Implemented Interfaces:
Serializable,Comparable<XSiteMergePolicy>,XSiteEntryMergePolicy<Object,Object>
XSiteEntryMergePolicy.
To be used in SitesConfigurationBuilder.mergePolicy(XSiteEntryMergePolicy)
- Since:
- 12.0
- Author:
- Pedro Ruivo
- See Also:
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAlways remove the key if there is a conflict.The default implementation chooses the entry with the lower lexicographically site name (SiteEntry.getSiteName()).Chooses thenon-nullvalue if available (write/remove conflict, write wins), otherwise uses theDEFAULT.Chooses thenullvalue if available (write/remove conflict, remove wins), otherwise uses theDEFAULT. -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,V> XSiteMergePolicy fromInstance(XSiteEntryMergePolicy<K, V> r2) static XSiteMergePolicyfromString(String str) abstract <K,V> XSiteEntryMergePolicy<K, V> static <T,U> XSiteEntryMergePolicy<T, U> instanceFromString(String value, ClassLoader classLoader) Resolves conflicts for asynchronous cross-site replication.static XSiteMergePolicyReturns the enum constant of this type with the specified name.static XSiteMergePolicy[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
Enum Constant Details
-
PREFER_NON_NULL
Chooses thenon-nullvalue if available (write/remove conflict, write wins), otherwise uses theDEFAULT.- See Also:
-
PREFER_NULL
Chooses thenullvalue if available (write/remove conflict, remove wins), otherwise uses theDEFAULT.- See Also:
-
ALWAYS_REMOVE
Always remove the key if there is a conflict.- See Also:
-
DEFAULT
The default implementation chooses the entry with the lower lexicographically site name (SiteEntry.getSiteName()).- See Also:
-
-
Method Details
-
values
Returns an array containing the constants of this enum type, in the order they are declared.- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
fromString
-
fromInstance
-
instanceFromString
public static <T,U> XSiteEntryMergePolicy<T,U> instanceFromString(String value, ClassLoader classLoader) -
merge
public CompletionStage<SiteEntry<Object>> merge(Object key, SiteEntry<Object> localEntry, SiteEntry<Object> remoteEntry) Description copied from interface:XSiteEntryMergePolicyResolves 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 theMetadataassociated.The value and the
Metadatamay benull. If that is the case, it means thekeydoesn't exist (forlocalEntry) or it is a remove operation (forremoteEntry).The returned
SiteEntrymust 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 (localEntryorremoteEntry) and to create a newSiteEntrywith 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
CompletionStagewith the result. We recommend usingBlockingManager.supplyBlocking(Supplier, Object).- Specified by:
mergein interfaceXSiteEntryMergePolicy<Object,Object> - Parameters:
key- The key that was updated concurrently.localEntry- The local value andMetadatastored.remoteEntry- The remote value andMetadatareceived.- Returns:
- A
CompletionStagewith theSiteEntry.
-
getInstance
-