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 of XSiteEntryMergePolicy.

To be used in SitesConfigurationBuilder.mergePolicy(XSiteEntryMergePolicy)

Since:
12.0
Author:
Pedro Ruivo
See Also:
  • Enum Constant Details

  • Method Details

    • values

      public static XSiteMergePolicy[] 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

      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 name
      NullPointerException - 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 the Metadata associated.

      The value and the Metadata may be null. If that is the case, it means the key doesn't exist (for localEntry) or it is a remove operation (for remoteEntry).

      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 or remoteEntry) and to create a new SiteEntry with a new value.

      Note: if the return SiteEntry.getValue() is null, Infinispan will interpret it to remove the key.

      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 using BlockingManager.supplyBlocking(Supplier, Object).

      Specified by:
      merge in interface XSiteEntryMergePolicy<Object,Object>
      Parameters:
      key - The key that was updated concurrently.
      localEntry - The local value and Metadata stored.
      remoteEntry - The remote value and Metadata received.
      Returns:
      A CompletionStage with the SiteEntry.
    • getInstance

      public abstract <K, V> XSiteEntryMergePolicy<K,V> getInstance()