Class DefaultIracManager

java.lang.Object
org.infinispan.xsite.irac.DefaultIracManager
All Implemented Interfaces:
JmxStatisticsExposer, IracManager

@MBean(objectName="AsyncXSiteStatistics", description="Statistics for Asynchronous cross-site replication") public class DefaultIracManager extends Object implements IracManager, JmxStatisticsExposer
Default implementation of IracManager.

It tracks the keys updated by this site and sends them, periodically, to the configured remote sites.

The primary owner coordinates everything. It sends the updates request to the remote site and coordinates the local site backup owners. After sending the updates to the remote site, it sends a cleanup request to the local site backup owners

The backup owners only keeps a backup list of the tracked keys.

On topology change, the updated keys list is replicate to the new owner(s). Also, if a segment is being transferred (i.e. the primary owner isn't a write and read owner), no updates to the remote site is sent since, most likely, the node doesn't have the most up-to-date value.

Since:
11.0
Author:
Pedro Ruivo
  • Constructor Details Link icon

  • Method Details Link icon

    • inject Link icon

      public void inject(ScheduledExecutorService executorService, Executor blockingExecutor)
    • start Link icon

      public void start()
    • trackUpdatedKey Link icon

      public void trackUpdatedKey(int segment, Object key, Object lockOwner)
      Description copied from interface: IracManager
      Sets the key as changed by the lockOwner.
      Specified by:
      trackUpdatedKey in interface IracManager
      Parameters:
      segment - The key's segment.
      key - The key changed.
      lockOwner - The lock owner who updated the key.
    • trackExpiredKey Link icon

      public void trackExpiredKey(int segment, Object key, Object lockOwner)
      Description copied from interface: IracManager
      Similar to IracManager.trackUpdatedKey(int, Object, Object) but it tracks expired keys instead.

      Expired key need a different conflict resolution algorithm since remove expired should never win any conflict.

      Specified by:
      trackExpiredKey in interface IracManager
      Parameters:
      segment - The key's segment.
      key - The key expired.
      lockOwner - The lock owner who updated the key.
    • trackForStateTransfer Link icon

      public CompletionStage<Void> trackForStateTransfer(Collection<XSiteState> stateList)
      Description copied from interface: IracManager
      Tracks a set of keys to be sent to the remote site.

      There is no much difference between this method and IracManager.trackUpdatedKey(int, Object, Object). It just returns a CompletionStage to notify when the keys were sent. It is required by the cross-site state transfer protocol to know when it has finish.

      Specified by:
      trackForStateTransfer in interface IracManager
      Parameters:
      stateList - The list of XSiteState.
      Returns:
      A CompletionStage which is completed when all the keys in stateList have been sent to the remote site.
    • trackClear Link icon

      public void trackClear(boolean sendClear)
      Description copied from interface: IracManager
      Sets all keys as removed.
      Specified by:
      trackClear in interface IracManager
      Parameters:
      sendClear - if true, an IracClearKeysRequest is sent to the backup sites.
    • removeState Link icon

      public void removeState(IracManagerKeyInfo state)
      Description copied from interface: IracManager
      Removes the state associated to a single key.
      Specified by:
      removeState in interface IracManager
      Parameters:
      state - The state to remove.
    • onTopologyUpdate Link icon

      public void onTopologyUpdate(CacheTopology oldCacheTopology, CacheTopology newCacheTopology)
      Description copied from interface: IracManager
      Notifies a topology changed.
      Specified by:
      onTopologyUpdate in interface IracManager
      Parameters:
      oldCacheTopology - The old CacheTopology.
      newCacheTopology - The new CacheTopology.
    • requestState Link icon

      public void requestState(Address requestor, IntSet segments)
      Description copied from interface: IracManager
      Requests the state stored in this instance for the given segments.
      Specified by:
      requestState in interface IracManager
      Parameters:
      requestor - The requestor.
      segments - The segments requested.
    • receiveState Link icon

      public void receiveState(int segment, Object key, Object lockOwner, IracMetadata tombstone)
      Description copied from interface: IracManager
      Receives the state related to the key.
      Specified by:
      receiveState in interface IracManager
      Parameters:
      segment - The key's segment.
      key - The key modified.
      lockOwner - The last lockOwner.
      tombstone - The tombstone (can be null)
    • checkAndTrackExpiration Link icon

      public CompletionStage<Boolean> checkAndTrackExpiration(Object key)
      Description copied from interface: IracManager
      Checks if the given key is expired on all other sites. If the key is expired on all other sites this will return true
      Specified by:
      checkAndTrackExpiration in interface IracManager
      Parameters:
      key - The key to check if it is expired or not
      Returns:
      Whether this key is expired on all other sites
    • setBackOff Link icon

      public void setBackOff(Function<IracXSiteBackup,ExponentialBackOff> builder)
    • isEmpty Link icon

      public boolean isEmpty()
    • getQueueSize Link icon

      @ManagedAttribute(description="Number of keys that need to be sent to remote site(s)", displayName="Queue size", measurementType=DYNAMIC) public int getQueueSize()
    • getNumberOfTombstones Link icon

      @ManagedAttribute(description="Number of tombstones stored", displayName="Number of tombstones", measurementType=DYNAMIC) public int getNumberOfTombstones()
    • getNumberOfConflicts Link icon

      @ManagedAttribute(description="The total number of conflicts between local and remote sites.", displayName="Number of conflicts", measurementType=TRENDSUP) public long getNumberOfConflicts()
    • getNumberOfDiscards Link icon

      @ManagedAttribute(description="The number of updates from remote sites discarded (duplicate or old update).", displayName="Number of discards", measurementType=TRENDSUP) public long getNumberOfDiscards()
    • getNumberOfConflictsLocalWins Link icon

      @ManagedAttribute(description="The number of conflicts where the merge policy discards the remote update.", displayName="Number of conflicts where local value is used", measurementType=TRENDSUP) public long getNumberOfConflictsLocalWins()
    • getNumberOfConflictsRemoteWins Link icon

      @ManagedAttribute(description="The number of conflicts where the merge policy applies the remote update.", displayName="Number of conflicts where remote value is used", measurementType=TRENDSUP) public long getNumberOfConflictsRemoteWins()
    • getNumberOfConflictsMerged Link icon

      @ManagedAttribute(description="Number of conflicts where the merge policy created a new entry.", displayName="Number of conflicts merged", measurementType=TRENDSUP) public long getNumberOfConflictsMerged()
    • isTombstoneCleanupTaskRunning Link icon

      @ManagedAttribute(description="Is tombstone cleanup task running?", displayName="Tombstone cleanup task running", dataType=TRAIT) public boolean isTombstoneCleanupTaskRunning()
    • getTombstoneCleanupTaskCurrentDelay Link icon

      @ManagedAttribute(description="Current delay in milliseconds between tombstone cleanup tasks", displayName="Delay between tombstone cleanup tasks", measurementType=DYNAMIC) public long getTombstoneCleanupTaskCurrentDelay()
    • getStatisticsEnabled Link icon

      @ManagedAttribute(description="Enables or disables the gathering of statistics by this component", writable=true) public boolean getStatisticsEnabled()
      Description copied from interface: JmxStatisticsExposer
      Returns whether an interceptor's statistics are being captured.
      Specified by:
      getStatisticsEnabled in interface JmxStatisticsExposer
      Returns:
      true if statistics are captured
    • setStatisticsEnabled Link icon

      public void setStatisticsEnabled(boolean enabled)
      Description copied from interface: JmxStatisticsExposer
      Enables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean.
      Specified by:
      setStatisticsEnabled in interface JmxStatisticsExposer
      Parameters:
      enabled - whether gathering statistics for JMX are enabled.
    • resetStatistics Link icon

      @ManagedOperation(displayName="Reset Statistics", description="Resets statistics gathered by this component") public void resetStatistics()
      Resets statistics gathered. Is a no-op, and should be overridden if it is to be meaningful.
      Specified by:
      resetStatistics in interface JmxStatisticsExposer
    • incrementNumberOfDiscards Link icon

      public void incrementNumberOfDiscards()
      Description copied from interface: IracManager
      Increase the count of discards.
      Specified by:
      incrementNumberOfDiscards in interface IracManager
    • incrementNumberOfConflictLocalWins Link icon

      public void incrementNumberOfConflictLocalWins()
      Description copied from interface: IracManager
      Increase the count of conflicts if merge policy discard update (local value wins)
      Specified by:
      incrementNumberOfConflictLocalWins in interface IracManager
    • incrementNumberOfConflictRemoteWins Link icon

      public void incrementNumberOfConflictRemoteWins()
      Description copied from interface: IracManager
      Increase the count of conflicts if merge policy applies update (remote value wins)
      Specified by:
      incrementNumberOfConflictRemoteWins in interface IracManager
    • incrementNumberOfConflictMerged Link icon

      public void incrementNumberOfConflictMerged()
      Description copied from interface: IracManager
      Increase the count of conflicts if merge policy created a new value (merge remote value with local value)
      Specified by:
      incrementNumberOfConflictMerged in interface IracManager
    • containsKey Link icon

      public boolean containsKey(Object key)
      Description copied from interface: IracManager
      Checks if the key is present.

      A key is present as long as its latest update was not confirmed by all remote sites.

      Specified by:
      containsKey in interface IracManager
      Parameters:
      key - The key to check.
      Returns:
      true if the key is present.