Package org.infinispan.scattered.impl
Class ScatteredVersionManagerImpl<K>
- java.lang.Object
-
- org.infinispan.scattered.impl.ScatteredVersionManagerImpl<K>
-
- All Implemented Interfaces:
ScatteredVersionManager<K>
public class ScatteredVersionManagerImpl<K> extends Object implements ScatteredVersionManager<K>
- Author:
- Radim Vansa <rvansa@redhat.com>
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.infinispan.scattered.ScatteredVersionManager
ScatteredVersionManager.SegmentState
-
-
Constructor Summary
Constructors Constructor Description ScatteredVersionManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclearInvalidations()Forget all non-processed invalidations scheduled throughScatteredVersionManager.scheduleKeyInvalidation(Object, EntryVersion, boolean)CompletableFuture<Void>getBlockingFuture(int segment)ScatteredVersionManager.SegmentStategetSegmentState(int segment)EntryVersionincrementVersion(int segment)Generates a new version for an entry in given segment.voidinitTopologyId()booleanisVersionActual(int segment, EntryVersion version)voidnotifyKeyTransferFinished(int segment, boolean expectValues, boolean cancelled)All key + version data from given segment have been received, or the key transfer failed.voidnotifyValueTransferFinished()All entries have been received and we can put segments owned according to consistent hash toScatteredVersionManager.SegmentState.OWNEDstate.voidregisterSegment(int segment)Move the segment toScatteredVersionManager.SegmentState.BLOCKEDstate.protected voidregularInvalidationFinished(Object[] keys, int[] topologyIds, long[] versions, boolean[] isRemoved, boolean force)protected voidremoveInvalidationsFinished()voidscheduleKeyInvalidation(K key, EntryVersion version, boolean removal)Notifies the manager that an operation on given key with version previously retrieved fromScatteredVersionManager.incrementVersion(int)has finished.voidsetOwnedSegments(org.infinispan.commons.util.IntSet segments)Move the segment fromScatteredVersionManager.SegmentState.NOT_OWNEDtoScatteredVersionManager.SegmentState.OWNEDwithout transferring data.voidsetTopologyId(int topologyId)Set current topology id.voidsetValuesTransferTopology(int topologyId)voidstart()protected booleanstartFlush()voidstartKeyTransfer(org.infinispan.commons.util.IntSet segments)Move the segments fromScatteredVersionManager.SegmentState.BLOCKEDtoScatteredVersionManager.SegmentState.KEY_TRANSFERstate.voidstop()voidunregisterSegment(int segment)Move the segment toScatteredVersionManager.SegmentState.NOT_OWNEDstate.voidupdatePreloadedEntryVersion(EntryVersion version)This is called only during preload.CompletableFuture<Void>valuesFuture(int topologyId)
-
-
-
Field Detail
-
log
protected static final Log log
-
trace
protected static final boolean trace
-
-
Method Detail
-
start
public void start()
-
initTopologyId
public void initTopologyId()
-
stop
public void stop()
-
incrementVersion
public EntryVersion incrementVersion(int segment)
Description copied from interface:ScatteredVersionManagerGenerates a new version for an entry in given segment.- Specified by:
incrementVersionin interfaceScatteredVersionManager<K>
-
scheduleKeyInvalidation
public void scheduleKeyInvalidation(K key, EntryVersion version, boolean removal)
Description copied from interface:ScatteredVersionManagerNotifies the manager that an operation on given key with version previously retrieved fromScatteredVersionManager.incrementVersion(int)has finished. This operation has to be executed on originator of the operation once the entry was stored on both nodes. Eventually order versions of entries will be removed on other nodes. When the entry was completely removed by the operation, the nodes have stored a tombstone of that entry. The older versions will be dropped regularly and after this is confirmed the tombstones will be invalidated, too.- Specified by:
scheduleKeyInvalidationin interfaceScatteredVersionManager<K>
-
startFlush
protected boolean startFlush()
-
registerSegment
public void registerSegment(int segment)
Description copied from interface:ScatteredVersionManagerMove the segment toScatteredVersionManager.SegmentState.BLOCKEDstate.- Specified by:
registerSegmentin interfaceScatteredVersionManager<K>
-
unregisterSegment
public void unregisterSegment(int segment)
Description copied from interface:ScatteredVersionManagerMove the segment toScatteredVersionManager.SegmentState.NOT_OWNEDstate.- Specified by:
unregisterSegmentin interfaceScatteredVersionManager<K>
-
isVersionActual
public boolean isVersionActual(int segment, EntryVersion version)- Specified by:
isVersionActualin interfaceScatteredVersionManager<K>- Returns:
- True if the version was generated by this node after most recently becoming owner of the given segment.
-
notifyKeyTransferFinished
public void notifyKeyTransferFinished(int segment, boolean expectValues, boolean cancelled)Description copied from interface:ScatteredVersionManagerAll key + version data from given segment have been received, or the key transfer failed.- Specified by:
notifyKeyTransferFinishedin interfaceScatteredVersionManager<K>expectValues- True when the transfer failed and the segment will be moved to theScatteredVersionManager.SegmentState.OWNEDstate without waiting for values.cancelled- True is the transfer was cancelled due to a new topology - in that case the segment will end up inScatteredVersionManager.SegmentState.NOT_OWNED. This takes precedence overexpectValues.
-
getSegmentState
public ScatteredVersionManager.SegmentState getSegmentState(int segment)
- Specified by:
getSegmentStatein interfaceScatteredVersionManager<K>- Returns:
- Current
statusof the segment.
-
setValuesTransferTopology
public void setValuesTransferTopology(int topologyId)
- Specified by:
setValuesTransferTopologyin interfaceScatteredVersionManager<K>
-
notifyValueTransferFinished
public void notifyValueTransferFinished()
Description copied from interface:ScatteredVersionManagerAll entries have been received and we can put segments owned according to consistent hash toScatteredVersionManager.SegmentState.OWNEDstate.- Specified by:
notifyValueTransferFinishedin interfaceScatteredVersionManager<K>
-
getBlockingFuture
public CompletableFuture<Void> getBlockingFuture(int segment)
- Specified by:
getBlockingFuturein interfaceScatteredVersionManager<K>- Returns:
- A completable future that can be used to schedule an operation once that the segment has moved from
ScatteredVersionManager.SegmentState.BLOCKEDstate.
-
setTopologyId
public void setTopologyId(int topologyId)
Description copied from interface:ScatteredVersionManagerSet current topology id.- Specified by:
setTopologyIdin interfaceScatteredVersionManager<K>
-
updatePreloadedEntryVersion
public void updatePreloadedEntryVersion(EntryVersion version)
Description copied from interface:ScatteredVersionManagerThis is called only during preload. Makes sure that the cache will start with topology higher than the one stored in a cache store.- Specified by:
updatePreloadedEntryVersionin interfaceScatteredVersionManager<K>
-
valuesFuture
public CompletableFuture<Void> valuesFuture(int topologyId)
- Specified by:
valuesFuturein interfaceScatteredVersionManager<K>- Returns:
- A
CompletableFuturethat completes when value transfer has finished for the given topology id.
-
setOwnedSegments
public void setOwnedSegments(org.infinispan.commons.util.IntSet segments)
Description copied from interface:ScatteredVersionManagerMove the segment fromScatteredVersionManager.SegmentState.NOT_OWNEDtoScatteredVersionManager.SegmentState.OWNEDwithout transferring data.- Specified by:
setOwnedSegmentsin interfaceScatteredVersionManager<K>
-
startKeyTransfer
public void startKeyTransfer(org.infinispan.commons.util.IntSet segments)
Description copied from interface:ScatteredVersionManagerMove the segments fromScatteredVersionManager.SegmentState.BLOCKEDtoScatteredVersionManager.SegmentState.KEY_TRANSFERstate.- Specified by:
startKeyTransferin interfaceScatteredVersionManager<K>
-
regularInvalidationFinished
protected void regularInvalidationFinished(Object[] keys, int[] topologyIds, long[] versions, boolean[] isRemoved, boolean force)
-
removeInvalidationsFinished
protected void removeInvalidationsFinished()
-
clearInvalidations
public void clearInvalidations()
Description copied from interface:ScatteredVersionManagerForget all non-processed invalidations scheduled throughScatteredVersionManager.scheduleKeyInvalidation(Object, EntryVersion, boolean)- Specified by:
clearInvalidationsin interfaceScatteredVersionManager<K>
-
-