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 void
clearInvalidations()
Forget all non-processed invalidations scheduled throughScatteredVersionManager.scheduleKeyInvalidation(Object, EntryVersion, boolean)
CompletableFuture<Void>
getBlockingFuture(int segment)
ScatteredVersionManager.SegmentState
getSegmentState(int segment)
EntryVersion
incrementVersion(int segment)
Generates a new version for an entry in given segment.void
initTopologyId()
boolean
isVersionActual(int segment, EntryVersion version)
void
notifyKeyTransferFinished(int segment, boolean expectValues, boolean cancelled)
All key + version data from given segment have been received, or the key transfer failed.void
notifyValueTransferFinished()
All entries have been received and we can put segments owned according to consistent hash toScatteredVersionManager.SegmentState.OWNED
state.void
registerSegment(int segment)
Move the segment toScatteredVersionManager.SegmentState.BLOCKED
state.protected void
regularInvalidationFinished(Object[] keys, int[] topologyIds, long[] versions, boolean[] isRemoved, boolean force)
protected void
removeInvalidationsFinished()
void
scheduleKeyInvalidation(K key, EntryVersion version, boolean removal)
Notifies the manager that an operation on given key with version previously retrieved fromScatteredVersionManager.incrementVersion(int)
has finished.void
setOwnedSegments(org.infinispan.commons.util.IntSet segments)
Move the segment fromScatteredVersionManager.SegmentState.NOT_OWNED
toScatteredVersionManager.SegmentState.OWNED
without transferring data.void
setTopologyId(int topologyId)
Set current topology id.void
setValuesTransferTopology(int topologyId)
void
start()
protected boolean
startFlush()
void
startKeyTransfer(org.infinispan.commons.util.IntSet segments)
Move the segments fromScatteredVersionManager.SegmentState.BLOCKED
toScatteredVersionManager.SegmentState.KEY_TRANSFER
state.void
stop()
void
unregisterSegment(int segment)
Move the segment toScatteredVersionManager.SegmentState.NOT_OWNED
state.void
updatePreloadedEntryVersion(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:ScatteredVersionManager
Generates a new version for an entry in given segment.- Specified by:
incrementVersion
in interfaceScatteredVersionManager<K>
-
scheduleKeyInvalidation
public void scheduleKeyInvalidation(K key, EntryVersion version, boolean removal)
Description copied from interface:ScatteredVersionManager
Notifies 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:
scheduleKeyInvalidation
in interfaceScatteredVersionManager<K>
-
startFlush
protected boolean startFlush()
-
registerSegment
public void registerSegment(int segment)
Description copied from interface:ScatteredVersionManager
Move the segment toScatteredVersionManager.SegmentState.BLOCKED
state.- Specified by:
registerSegment
in interfaceScatteredVersionManager<K>
-
unregisterSegment
public void unregisterSegment(int segment)
Description copied from interface:ScatteredVersionManager
Move the segment toScatteredVersionManager.SegmentState.NOT_OWNED
state.- Specified by:
unregisterSegment
in interfaceScatteredVersionManager<K>
-
isVersionActual
public boolean isVersionActual(int segment, EntryVersion version)
- Specified by:
isVersionActual
in 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:ScatteredVersionManager
All key + version data from given segment have been received, or the key transfer failed.- Specified by:
notifyKeyTransferFinished
in interfaceScatteredVersionManager<K>
expectValues
- True when the transfer failed and the segment will be moved to theScatteredVersionManager.SegmentState.OWNED
state 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:
getSegmentState
in interfaceScatteredVersionManager<K>
- Returns:
- Current
status
of the segment.
-
setValuesTransferTopology
public void setValuesTransferTopology(int topologyId)
- Specified by:
setValuesTransferTopology
in interfaceScatteredVersionManager<K>
-
notifyValueTransferFinished
public void notifyValueTransferFinished()
Description copied from interface:ScatteredVersionManager
All entries have been received and we can put segments owned according to consistent hash toScatteredVersionManager.SegmentState.OWNED
state.- Specified by:
notifyValueTransferFinished
in interfaceScatteredVersionManager<K>
-
getBlockingFuture
public CompletableFuture<Void> getBlockingFuture(int segment)
- Specified by:
getBlockingFuture
in interfaceScatteredVersionManager<K>
- Returns:
- A completable future that can be used to schedule an operation once that the segment has moved from
ScatteredVersionManager.SegmentState.BLOCKED
state.
-
setTopologyId
public void setTopologyId(int topologyId)
Description copied from interface:ScatteredVersionManager
Set current topology id.- Specified by:
setTopologyId
in interfaceScatteredVersionManager<K>
-
updatePreloadedEntryVersion
public void updatePreloadedEntryVersion(EntryVersion version)
Description copied from interface:ScatteredVersionManager
This 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:
updatePreloadedEntryVersion
in interfaceScatteredVersionManager<K>
-
valuesFuture
public CompletableFuture<Void> valuesFuture(int topologyId)
- Specified by:
valuesFuture
in interfaceScatteredVersionManager<K>
- Returns:
- A
CompletableFuture
that 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:ScatteredVersionManager
Move the segment fromScatteredVersionManager.SegmentState.NOT_OWNED
toScatteredVersionManager.SegmentState.OWNED
without transferring data.- Specified by:
setOwnedSegments
in interfaceScatteredVersionManager<K>
-
startKeyTransfer
public void startKeyTransfer(org.infinispan.commons.util.IntSet segments)
Description copied from interface:ScatteredVersionManager
Move the segments fromScatteredVersionManager.SegmentState.BLOCKED
toScatteredVersionManager.SegmentState.KEY_TRANSFER
state.- Specified by:
startKeyTransfer
in 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:ScatteredVersionManager
Forget all non-processed invalidations scheduled throughScatteredVersionManager.scheduleKeyInvalidation(Object, EntryVersion, boolean)
- Specified by:
clearInvalidations
in interfaceScatteredVersionManager<K>
-
-