Class PreferNullXSiteEntryMergePolicy<K,V>

All Implemented Interfaces:

public class PreferNullXSiteEntryMergePolicy<K,V> extends Object implements XSiteEntryMergePolicy<K,V>
A XSiteEntryMergePolicy implementation that chooses a null entry.

If both entries are null (or non-null), then it uses the DefaultXSiteEntryMergePolicy to resolve the conflict.

Pedro Ruivo
See Also:
  • Method Details

    • getInstance

      public static <T, U> PreferNullXSiteEntryMergePolicy<T,U> getInstance()
    • merge

      public CompletionStage<SiteEntry<V>> merge(K key, SiteEntry<V> localEntry, SiteEntry<V> 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<K,V>
      key - The key that was updated concurrently.
      localEntry - The local value and Metadata stored.
      remoteEntry - The remote value and Metadata received.
      A CompletionStage with the SiteEntry.