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:
- anistor@redhat.com
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ComponentRef<Cache<Object,Object>> protected Stringprotected CacheNotifier<?,?> protected CacheTopologyprotected CommandAckCollectorprotected CommandsFactoryprotected CommitManagerprotected Configurationprotected InternalConflictManager<?,?> protected InternalDataContainer<Object,Object> protected DistributionManagerprotected InvocationContextFactoryprotected AsyncInterceptorChainprotected static final longprotected booleanprotected booleanprotected booleanprotected KeyPartitionerprotected LocalPublisherManager<Object,Object> protected LocalTopologyManagerstatic final Stringprotected static final intprotected Executorprotected PersistenceManagerprotected RpcManagerprotected RpcOptionsprotected static final longprotected LimitedExecutorLimit to one state request at a time.protected CompletableFuture<Void>protected StateTransferLockprotected final AtomicIntegerIndicates if there is a state transfer in progress.protected longprotected javax.transaction.TransactionManagerprotected TransactionTableprotected final Objectprotected final Map<Integer,List<InboundTransferTask>> A map that keeps track of current inbound state transfers by segment id.protected TriangleOrderManagerprotected final AtomicBooleanIndicates if there is a rebalance in progress and there the local node has not yet received all the new segments yet. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddTransfer(InboundTransferTask inboundTransfer, org.infinispan.commons.util.IntSet segments) applyState(Address sender, int topologyId, boolean pushTransfer, Collection<StateChunk> stateChunks) protected voidbeforeTopologyInstalled(int topologyId, ConsistentHash previousWriteCh, ConsistentHash newWriteCh) protected voidcancelTransfers(org.infinispan.commons.util.IntSet removedSegments) Cancel transfers for segments we no longer own.protected org.infinispan.commons.util.IntSetgetOwnedSegments(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) booleanlongReturns the number of in-flight requested segments.longReturns the number of in-flight transactional requested segments.protected CompletionStage<Void>invalidateBatch(Collection<Object> keysToRemove) booleanbooleanprotected booleanprotected voidonCompletedSegment(int segmentId) protected voidonTaskCompletion(InboundTransferTask inboundTransfer) onTopologyUpdate(CacheTopology cacheTopology, boolean isRebalance) Receive notification of topology changes.booleanownsData()protected CompletionStage<Void>removeStaleData(org.infinispan.commons.util.IntSet removedSegments) protected booleanremoveTransfer(InboundTransferTask inboundTransfer) voidsetKeyInvalidationListener(StateConsumerImpl.KeyInvalidationListener keyInvalidationListener) voidstart()voidstop()Cancels all incoming state transfers.voidstopApplyingState(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:
stopApplyingStatein interfaceStateConsumer- Parameters:
topologyId- Topology id at the end of state transfer
-
hasActiveTransfers
public boolean hasActiveTransfers() -
isStateTransferInProgress
public boolean isStateTransferInProgress()- Specified by:
isStateTransferInProgressin interfaceStateConsumer
-
isStateTransferInProgressForKey
- Specified by:
isStateTransferInProgressForKeyin interfaceStateConsumer
-
inflightRequestCount
public long inflightRequestCount()Description copied from interface:StateConsumerReturns the number of in-flight requested segments.- Specified by:
inflightRequestCountin interfaceStateConsumer
-
inflightTransactionSegmentCount
public long inflightTransactionSegmentCount()Description copied from interface:StateConsumerReturns the number of in-flight transactional requested segments.- Specified by:
inflightTransactionSegmentCountin interfaceStateConsumer
-
ownsData
public boolean ownsData()- Specified by:
ownsDatain 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:StateConsumerReceive notification of topology changes.StateTransferStartCommand, orScatteredStateGetKeysCommandforCacheMode.SCATTERED_SYNC, are issued for segments that are new to this member and the segments that are no longer owned are discarded.- Specified by:
onTopologyUpdatein 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:
applyStatein interfaceStateConsumer
-
onCompletedSegment
protected void onCompletedSegment(int segmentId) -
start
public void start() -
stop
public void stop()Description copied from interface:StateConsumerCancels all incoming state transfers. The already received data is not discarded. This is executed when the cache is shutting down.- Specified by:
stopin 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
-