Package org.infinispan.statetransfer
Class StateConsumerImpl
java.lang.Object
org.infinispan.statetransfer.StateConsumerImpl
- All Implemented Interfaces:
StateConsumer
- Direct Known Subclasses:
ScatteredStateConsumerImpl
StateConsumer
implementation.- Since:
- 5.2
- Author:
- [email protected]
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected ComponentRef<Cache<Object,
Object>> protected String
protected CacheNotifier<?,
?> protected CacheTopology
protected CommandAckCollector
protected CommandsFactory
protected CommitManager
protected Configuration
protected InternalConflictManager<?,
?> protected InternalDataContainer<Object,
Object> protected DistributionManager
protected InvocationContextFactory
protected AsyncInterceptorChain
protected static final long
protected boolean
protected boolean
protected boolean
protected KeyPartitioner
protected LocalPublisherManager<Object,
Object> protected LocalTopologyManager
static final String
protected static final int
protected Executor
protected PersistenceManager
protected RpcManager
protected RpcOptions
protected static final long
protected LimitedExecutor
Limit to one state request at a time.protected CompletableFuture<Void>
protected StateTransferLock
protected final AtomicInteger
Indicates if there is a state transfer in progress.protected long
protected javax.transaction.TransactionManager
protected TransactionTable
protected final Object
protected final Map<Integer,
List<InboundTransferTask>> A map that keeps track of current inbound state transfers by segment id.protected TriangleOrderManager
protected final AtomicBoolean
Indicates if there is a rebalance in progress and there the local node has not yet received all the new segments yet. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
addTransfer
(InboundTransferTask inboundTransfer, org.infinispan.commons.util.IntSet segments) applyState
(Address sender, int topologyId, boolean pushTransfer, Collection<StateChunk> stateChunks) protected void
beforeTopologyInstalled
(int topologyId, ConsistentHash previousWriteCh, ConsistentHash newWriteCh) protected void
cancelTransfers
(org.infinispan.commons.util.IntSet removedSegments) Cancel transfers for segments we no longer own.protected org.infinispan.commons.util.IntSet
getOwnedSegments
(ConsistentHash consistentHash) protected CompletionStage<Void>
handleSegments
(boolean startRebalance, org.infinispan.commons.util.IntSet addedSegments, org.infinispan.commons.util.IntSet removedSegments, org.infinispan.commons.util.IntSet transactionOnlySegments) boolean
long
Returns the number of in-flight requested segments.long
Returns the number of in-flight transactional requested segments.protected CompletionStage<Void>
invalidateBatch
(Collection<Object> keysToRemove) boolean
boolean
protected boolean
protected void
onCompletedSegment
(int segmentId, InboundTransferTask inboundTransfer) protected void
onTaskCompletion
(InboundTransferTask inboundTransfer) onTopologyUpdate
(CacheTopology cacheTopology, boolean isRebalance) Receive notification of topology changes.boolean
ownsData()
protected CompletionStage<Void>
removeStaleData
(org.infinispan.commons.util.IntSet removedSegments) protected boolean
removeTransfer
(InboundTransferTask inboundTransfer) void
setKeyInvalidationListener
(StateConsumerImpl.KeyInvalidationListener keyInvalidationListener) void
start()
void
stop()
Cancels all incoming state transfers.void
stopApplyingState
(int topologyId) Stops applying incoming state.
-
Field Details
-
NO_STATE_TRANSFER_IN_PROGRESS
protected static final int NO_STATE_TRANSFER_IN_PROGRESS- See Also:
-
STATE_TRANSFER_FLAGS
protected static final long STATE_TRANSFER_FLAGS -
INVALIDATE_FLAGS
protected static final long INVALIDATE_FLAGS -
NO_KEY
- See Also:
-
cache
-
localTopologyManager
-
configuration
-
rpcManager
-
transactionManager
protected javax.transaction.TransactionManager transactionManager -
commandsFactory
-
transactionTable
-
dataContainer
-
persistenceManager
-
interceptorChain
-
icf
-
stateTransferLock
-
cacheNotifier
-
commitManager
-
nonBlockingExecutor
-
commandAckCollector
-
triangleOrderManager
-
distributionManager
-
keyPartitioner
-
conflictManager
-
localPublisherManager
-
cacheName
-
timeout
protected long timeout -
isFetchEnabled
protected boolean isFetchEnabled -
isTransactional
protected boolean isTransactional -
isInvalidationMode
protected boolean isInvalidationMode -
keyInvalidationListener
-
cacheTopology
-
stateTransferTopologyId
Indicates if there is a state transfer in progress. It is set to the new topology id when onTopologyUpdate with isRebalance==true is called. It is changed back to NO_REBALANCE_IN_PROGRESS when a topology update with a null pending CH is received. -
waitingForState
Indicates if there is a rebalance in progress and there the local node has not yet received all the new segments yet. It is set to true when rebalance starts and becomes when all inbound transfers have completed (before stateTransferTopologyId is set back to NO_REBALANCE_IN_PROGRESS). -
stateTransferFuture
-
transferMapsLock
-
transfersBySegment
A map that keeps track of current inbound state transfers by segment id. There is at most one transfers per segment. This works in tandem with transfersBySource so they always need to be kept in sync and updates to both of them need to be atomic. -
stateRequestExecutor
Limit to one state request at a time. -
rpcOptions
-
-
Constructor Details
-
StateConsumerImpl
public StateConsumerImpl()
-
-
Method Details
-
stopApplyingState
public void stopApplyingState(int topologyId) Stops applying incoming state. Also stops tracking updated keys. Should be called at the end of state transfer or when a ClearCommand is committed during state transfer.- Specified by:
stopApplyingState
in interfaceStateConsumer
- Parameters:
topologyId
- Topology id at the end of state transfer
-
hasActiveTransfers
public boolean hasActiveTransfers() -
isStateTransferInProgress
public boolean isStateTransferInProgress()- Specified by:
isStateTransferInProgress
in interfaceStateConsumer
-
isStateTransferInProgressForKey
- Specified by:
isStateTransferInProgressForKey
in interfaceStateConsumer
-
inflightRequestCount
public long inflightRequestCount()Description copied from interface:StateConsumer
Returns the number of in-flight requested segments.- Specified by:
inflightRequestCount
in interfaceStateConsumer
-
inflightTransactionSegmentCount
public long inflightTransactionSegmentCount()Description copied from interface:StateConsumer
Returns the number of in-flight transactional requested segments.- Specified by:
inflightTransactionSegmentCount
in interfaceStateConsumer
-
ownsData
public boolean ownsData()- Specified by:
ownsData
in interfaceStateConsumer
- Returns:
- true if this node has already received the first rebalance command
-
onTopologyUpdate
public CompletionStage<CompletionStage<Void>> onTopologyUpdate(CacheTopology cacheTopology, boolean isRebalance) Description copied from interface:StateConsumer
Receive notification of topology changes.StateTransferStartCommand
, orScatteredStateGetKeysCommand
forCacheMode.SCATTERED_SYNC
, are issued for segments that are new to this member and the segments that are no longer owned are discarded.- Specified by:
onTopologyUpdate
in interfaceStateConsumer
- Returns:
- completion stage that is completed when the topology update is processed, wrapping another completion stage that is completed when the state transfer has finished
-
beforeTopologyInstalled
protected void beforeTopologyInstalled(int topologyId, ConsistentHash previousWriteCh, ConsistentHash newWriteCh) -
notifyEndOfStateTransferIfNeeded
protected boolean notifyEndOfStateTransferIfNeeded() -
getOwnedSegments
-
applyState
public CompletionStage<?> applyState(Address sender, int topologyId, boolean pushTransfer, Collection<StateChunk> stateChunks) - Specified by:
applyState
in interfaceStateConsumer
-
onCompletedSegment
-
start
public void start() -
stop
public void stop()Description copied from interface:StateConsumer
Cancels all incoming state transfers. The already received data is not discarded. This is executed when the cache is shutting down.- Specified by:
stop
in interfaceStateConsumer
-
setKeyInvalidationListener
public void setKeyInvalidationListener(StateConsumerImpl.KeyInvalidationListener keyInvalidationListener) -
handleSegments
protected CompletionStage<Void> handleSegments(boolean startRebalance, org.infinispan.commons.util.IntSet addedSegments, org.infinispan.commons.util.IntSet removedSegments, org.infinispan.commons.util.IntSet transactionOnlySegments) -
cancelTransfers
protected void cancelTransfers(org.infinispan.commons.util.IntSet removedSegments) Cancel transfers for segments we no longer own.- Parameters:
removedSegments
- segments to be cancelled
-
removeStaleData
-
invalidateBatch
-
addTransfer
protected void addTransfer(InboundTransferTask inboundTransfer, org.infinispan.commons.util.IntSet segments) -
removeTransfer
-
onTaskCompletion
-