Class DefaultIracManager
- All Implemented Interfaces:
JmxStatisticsExposer,IracManager
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Collection<IracXSiteBackup>asyncBackups(Configuration config) Checks if the given key is expired on all other sites.booleancontainsKey(Object key) Checks if the key is present.longlonglonglonglongintintbooleanReturns whether an interceptor's statistics are being captured.longvoidIncrease the count of conflicts if merge policy discard update (local value wins)voidIncrease the count of conflicts if merge policy created a new value (merge remote value with local value)voidIncrease the count of conflicts if merge policy applies update (remote value wins)voidIncrease the count of discards.voidinject(ScheduledExecutorService executorService, Executor blockingExecutor) booleanisEmpty()booleanvoidonTopologyUpdate(CacheTopology oldCacheTopology, CacheTopology newCacheTopology) Notifies a topology changed.voidreceiveState(int segment, Object key, Object lockOwner, IracMetadata tombstone) Receives the state related to thekey.voidremoveState(IracManagerKeyInfo state) Removes the state associated to a single key.voidrequestState(Address requestor, IntSet segments) Requests the state stored in this instance for the givensegments.voidResets statistics gathered.voidsetBackOff(ExponentialBackOff backOff) voidsetStatisticsEnabled(boolean enabled) Enables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean.voidstart()voidtrackClear(boolean sendClear) Sets all keys as removed.voidtrackExpiredKey(int segment, Object key, Object lockOwner) Similar toIracManager.trackUpdatedKey(int, Object, Object)but it tracks expired keys instead.trackForStateTransfer(Collection<XSiteState> stateList) Tracks a set of keys to be sent to the remote site.voidtrackUpdatedKey(int segment, Object key, Object lockOwner) Sets thekeyas changed by thelockOwner.
-
Constructor Details
-
DefaultIracManager
-
-
Method Details
-
asyncBackups
-
inject
-
start
public void start() -
trackUpdatedKey
Description copied from interface:IracManagerSets thekeyas changed by thelockOwner.- Specified by:
trackUpdatedKeyin interfaceIracManager- Parameters:
segment- The key's segment.key- The key changed.lockOwner- The lock owner who updated the key.
-
trackExpiredKey
Description copied from interface:IracManagerSimilar toIracManager.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:
trackExpiredKeyin interfaceIracManager- Parameters:
segment- The key's segment.key- The key expired.lockOwner- The lock owner who updated the key.
-
trackForStateTransfer
Description copied from interface:IracManagerTracks 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 aCompletionStageto notify when the keys were sent. It is required by the cross-site state transfer protocol to know when it has finish.- Specified by:
trackForStateTransferin interfaceIracManager- Parameters:
stateList- The list ofXSiteState.- Returns:
- A
CompletionStagewhich is completed when all the keys instateListhave been sent to the remote site.
-
trackClear
public void trackClear(boolean sendClear) Description copied from interface:IracManagerSets all keys as removed.- Specified by:
trackClearin interfaceIracManager- Parameters:
sendClear- iftrue, anIracClearKeysRequestis sent to the backup sites.
-
removeState
Description copied from interface:IracManagerRemoves the state associated to a single key.- Specified by:
removeStatein interfaceIracManager- Parameters:
state- The state to remove.
-
onTopologyUpdate
Description copied from interface:IracManagerNotifies a topology changed.- Specified by:
onTopologyUpdatein interfaceIracManager- Parameters:
oldCacheTopology- The oldCacheTopology.newCacheTopology- The newCacheTopology.
-
requestState
Description copied from interface:IracManagerRequests the state stored in this instance for the givensegments.- Specified by:
requestStatein interfaceIracManager- Parameters:
requestor- The requestor.segments- The segments requested.
-
receiveState
Description copied from interface:IracManagerReceives the state related to thekey.- Specified by:
receiveStatein interfaceIracManager- Parameters:
segment- The key's segment.key- The key modified.lockOwner- The lastlockOwner.tombstone- The tombstone (can benull)
-
checkAndTrackExpiration
Description copied from interface:IracManagerChecks 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:
checkAndTrackExpirationin interfaceIracManager- Parameters:
key- The key to check if it is expired or not- Returns:
- Whether this key is expired on all other sites
-
setBackOff
-
isEmpty
public boolean isEmpty() -
getQueueSize
@ManagedAttribute(description="Number of keys that need to be sent to remote site(s)", displayName="Queue size", measurementType=DYNAMIC) public int getQueueSize() -
getNumberOfTombstones
@ManagedAttribute(description="Number of tombstones stored", displayName="Number of tombstones", measurementType=DYNAMIC) public int getNumberOfTombstones() -
getNumberOfConflicts
@ManagedAttribute(description="The total number of conflicts between local and remote sites.", displayName="Number of conflicts", measurementType=TRENDSUP) public long getNumberOfConflicts() -
getNumberOfDiscards
@ManagedAttribute(description="The number of updates from remote sites discarded (duplicate or old update).", displayName="Number of discards", measurementType=TRENDSUP) public long getNumberOfDiscards() -
getNumberOfConflictsLocalWins
@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
@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
@ManagedAttribute(description="Number of conflicts where the merge policy created a new entry.", displayName="Number of conflicts merged", measurementType=TRENDSUP) public long getNumberOfConflictsMerged() -
isTombstoneCleanupTaskRunning
@ManagedAttribute(description="Is tombstone cleanup task running?", displayName="Tombstone cleanup task running", dataType=TRAIT) public boolean isTombstoneCleanupTaskRunning() -
getTombstoneCleanupTaskCurrentDelay
@ManagedAttribute(description="Current delay in milliseconds between tombstone cleanup tasks", displayName="Delay between tombstone cleanup tasks", measurementType=DYNAMIC) public long getTombstoneCleanupTaskCurrentDelay() -
getStatisticsEnabled
@ManagedAttribute(description="Enables or disables the gathering of statistics by this component", writable=true) public boolean getStatisticsEnabled()Description copied from interface:JmxStatisticsExposerReturns whether an interceptor's statistics are being captured.- Specified by:
getStatisticsEnabledin interfaceJmxStatisticsExposer- Returns:
- true if statistics are captured
-
setStatisticsEnabled
public void setStatisticsEnabled(boolean enabled) Description copied from interface:JmxStatisticsExposerEnables an interceptor's cache statistics If true, the interceptor will capture statistics and make them available through the mbean.- Specified by:
setStatisticsEnabledin interfaceJmxStatisticsExposer- Parameters:
enabled- whether gathering statistics for JMX are enabled.
-
resetStatistics
@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:
resetStatisticsin interfaceJmxStatisticsExposer
-
incrementNumberOfDiscards
public void incrementNumberOfDiscards()Description copied from interface:IracManagerIncrease the count of discards.- Specified by:
incrementNumberOfDiscardsin interfaceIracManager
-
incrementNumberOfConflictLocalWins
public void incrementNumberOfConflictLocalWins()Description copied from interface:IracManagerIncrease the count of conflicts if merge policy discard update (local value wins)- Specified by:
incrementNumberOfConflictLocalWinsin interfaceIracManager
-
incrementNumberOfConflictRemoteWins
public void incrementNumberOfConflictRemoteWins()Description copied from interface:IracManagerIncrease the count of conflicts if merge policy applies update (remote value wins)- Specified by:
incrementNumberOfConflictRemoteWinsin interfaceIracManager
-
incrementNumberOfConflictMerged
public void incrementNumberOfConflictMerged()Description copied from interface:IracManagerIncrease the count of conflicts if merge policy created a new value (merge remote value with local value)- Specified by:
incrementNumberOfConflictMergedin interfaceIracManager
-
containsKey
Description copied from interface:IracManagerChecks if the key is present.A key is present as long as its latest update was not confirmed by all remote sites.
- Specified by:
containsKeyin interfaceIracManager- Parameters:
key- The key to check.- Returns:
trueif the key is present.
-