Enum Class XSiteMergePolicy
- All Implemented Interfaces:
Serializable,Comparable<XSiteMergePolicy>,Constable,XSiteEntryMergePolicy<Object,Object>
XSiteEntryMergePolicy.
To be used in SitesConfigurationBuilder.mergePolicy(XSiteEntryMergePolicy)
- Since:
- 12.0
- Author:
- Pedro Ruivo
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
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 class with the specified name.static XSiteMergePolicy[]values()Returns an array containing the constants of this enum class, 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 class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class 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
-