Enum XSiteMergePolicy
- java.lang.Object
-
- java.lang.Enum<XSiteMergePolicy>
-
- org.infinispan.xsite.spi.XSiteMergePolicy
-
- All Implemented Interfaces:
Serializable
,Comparable<XSiteMergePolicy>
,XSiteEntryMergePolicy<Object,Object>
public enum XSiteMergePolicy extends Enum<XSiteMergePolicy> implements XSiteEntryMergePolicy<Object,Object>
An alias with the provided implementation ofXSiteEntryMergePolicy
.To be used in
SitesConfigurationBuilder.mergePolicy(XSiteEntryMergePolicy)
- Since:
- 12.0
- Author:
- Pedro Ruivo
- See Also:
XSiteEntryMergePolicy
,PreferNonNullXSiteEntryMergePolicy
,PreferNullXSiteEntryMergePolicy
,AlwaysRemoveXSiteEntryMergePolicy
,DefaultXSiteEntryMergePolicy
-
-
Enum Constant Summary
Enum Constants Enum Constant Description ALWAYS_REMOVE
Always remove the key if there is a conflict.DEFAULT
The default implementation chooses the entry with the lower lexicographically site name (SiteEntry.getSiteName()
).PREFER_NON_NULL
Chooses thenon-null
value if available (write/remove conflict, write wins), otherwise uses theDEFAULT
.PREFER_NULL
Chooses thenull
value if available (write/remove conflict, remove wins), otherwise uses theDEFAULT
.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static <K,V>
XSiteMergePolicyfromInstance(XSiteEntryMergePolicy<K,V> r2)
static XSiteMergePolicy
fromString(String str)
abstract <K,V>
XSiteEntryMergePolicy<K,V>getInstance()
static <T,U>
XSiteEntryMergePolicy<T,U>instanceFromString(String value, ClassLoader classLoader)
CompletionStage<SiteEntry<Object>>
merge(Object key, SiteEntry<Object> localEntry, SiteEntry<Object> remoteEntry)
Resolves conflicts for asynchronous cross-site replication.static XSiteMergePolicy
valueOf(String name)
Returns 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 Detail
-
PREFER_NON_NULL
public static final XSiteMergePolicy PREFER_NON_NULL
Chooses thenon-null
value if available (write/remove conflict, write wins), otherwise uses theDEFAULT
.- See Also:
PreferNonNullXSiteEntryMergePolicy
-
PREFER_NULL
public static final XSiteMergePolicy PREFER_NULL
Chooses thenull
value if available (write/remove conflict, remove wins), otherwise uses theDEFAULT
.- See Also:
PreferNullXSiteEntryMergePolicy
-
ALWAYS_REMOVE
public static final XSiteMergePolicy ALWAYS_REMOVE
Always remove the key if there is a conflict.- See Also:
AlwaysRemoveXSiteEntryMergePolicy
-
DEFAULT
public static final XSiteMergePolicy DEFAULT
The default implementation chooses the entry with the lower lexicographically site name (SiteEntry.getSiteName()
).- See Also:
DefaultXSiteEntryMergePolicy
-
-
Method Detail
-
values
public static XSiteMergePolicy[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (XSiteMergePolicy c : XSiteMergePolicy.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static XSiteMergePolicy valueOf(String name)
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
public static XSiteMergePolicy fromString(String str)
-
fromInstance
public static <K,V> XSiteMergePolicy fromInstance(XSiteEntryMergePolicy<K,V> r2)
-
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: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<Object,Object>
- 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
.
-
getInstance
public abstract <K,V> XSiteEntryMergePolicy<K,V> getInstance()
-
-