Class DefaultIracManager
- java.lang.Object
-
- org.infinispan.xsite.irac.DefaultIracManager
-
- All Implemented Interfaces:
Runnable,IracManager
public class DefaultIracManager extends Object implements IracManager, Runnable
Default implementation ofIracManager.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 Summary
Constructors Constructor Description DefaultIracManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanupKey(Object key, Object lockOwner, IracMetadata tombstone)Sets thekeyas not changed and remove any tombstone related to it.booleanisEmpty()Stream<?>keysFromMods(Stream<WriteCommand> modifications)voidonTopologyUpdate(CacheTopology oldCacheTopology, CacheTopology newCacheTopology)Notifies a topology changed.voidreceiveState(Object key, Object lockOwner, IracMetadata tombstone)Receives the state related to thekey.voidrequestState(Address origin, org.infinispan.commons.util.IntSet segments)Requests the state stored in this instance for the givensegments.voidrun()voidsendStateIfNeeded(Address origin, org.infinispan.commons.util.IntSet segments, Object key, Object lockOwner)voidsetBackOff(ExponentialBackOff backOff)voidstart()voidstop()voidtrackClear()Sets all keys as removed.voidtrackKeysFromTransaction(Stream<WriteCommand> modifications, GlobalTransaction lockOwner)Sets all keys affected by the transaction as changed.voidtrackUpdatedKey(Object key, Object lockOwner)Sets thekeyas changed by thelockOwner.<K> voidtrackUpdatedKeys(Collection<K> keys, Object lockOwner)Sets all the keys inkeysas changed by thelockOwner.
-
-
-
Method Detail
-
start
public void start()
-
stop
public void stop()
-
trackUpdatedKey
public void trackUpdatedKey(Object key, Object lockOwner)
Description copied from interface:IracManagerSets thekeyas changed by thelockOwner.- Specified by:
trackUpdatedKeyin interfaceIracManager- Parameters:
key- The key changed.lockOwner- The lock owner who updated the key.
-
trackUpdatedKeys
public <K> void trackUpdatedKeys(Collection<K> keys, Object lockOwner)
Description copied from interface:IracManagerSets all the keys inkeysas changed by thelockOwner.- Specified by:
trackUpdatedKeysin interfaceIracManager- Parameters:
keys- ACollectionof keys changed.lockOwner- The lock owner who updated the keys.
-
trackKeysFromTransaction
public void trackKeysFromTransaction(Stream<WriteCommand> modifications, GlobalTransaction lockOwner)
Description copied from interface:IracManagerSets all keys affected by the transaction as changed.- Specified by:
trackKeysFromTransactionin interfaceIracManager- Parameters:
modifications- TheStreamof modifications made by the transaction.lockOwner- TheGlobalTransaction.
-
trackClear
public void trackClear()
Description copied from interface:IracManagerSets all keys as removed.- Specified by:
trackClearin interfaceIracManager
-
cleanupKey
public void cleanupKey(Object key, Object lockOwner, IracMetadata tombstone)
Description copied from interface:IracManagerSets thekeyas not changed and remove any tombstone related to it.If
lockOwnerisn't the last one who updated the key, this method is a no-op.- Specified by:
cleanupKeyin interfaceIracManager- Parameters:
key- The key.lockOwner- The lock owner who updated the key.tombstone- The tombstone (can benull).
-
onTopologyUpdate
public void onTopologyUpdate(CacheTopology oldCacheTopology, CacheTopology newCacheTopology)
Description copied from interface:IracManagerNotifies a topology changed.- Specified by:
onTopologyUpdatein interfaceIracManager- Parameters:
oldCacheTopology- The oldCacheTopology.newCacheTopology- The newCacheTopology.
-
requestState
public void requestState(Address origin, org.infinispan.commons.util.IntSet segments)
Description copied from interface:IracManagerRequests the state stored in this instance for the givensegments.- Specified by:
requestStatein interfaceIracManager- Parameters:
origin- The requestor.segments- The segments requested.
-
receiveState
public void receiveState(Object key, Object lockOwner, IracMetadata tombstone)
Description copied from interface:IracManagerReceives the state related to thekey.- Specified by:
receiveStatein interfaceIracManager- Parameters:
key- The key modified.lockOwner- The lastlockOwner.tombstone- The tombstone (can benull)
-
sendStateIfNeeded
public void sendStateIfNeeded(Address origin, org.infinispan.commons.util.IntSet segments, Object key, Object lockOwner)
-
keysFromMods
public Stream<?> keysFromMods(Stream<WriteCommand> modifications)
-
setBackOff
public void setBackOff(ExponentialBackOff backOff)
-
isEmpty
public boolean isEmpty()
-
-