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 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-null
value if available (write/remove conflict, write wins), otherwise uses theDEFAULT
.Chooses thenull
value if available (write/remove conflict, remove wins), otherwise uses theDEFAULT
. -
Method Summary
Modifier and TypeMethodDescriptionstatic <K,
V> XSiteMergePolicy fromInstance
(XSiteEntryMergePolicy<K, V> r2) static XSiteMergePolicy
fromString
(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 XSiteMergePolicy
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 Details
-
PREFER_NON_NULL
Chooses thenon-null
value if available (write/remove conflict, write wins), otherwise uses theDEFAULT
.- See Also:
-
PREFER_NULL
Chooses thenull
value 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: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
-