Package org.infinispan.statetransfer
Class StateConsumerImpl
- java.lang.Object
-
- org.infinispan.statetransfer.StateConsumerImpl
-
- All Implemented Interfaces:
StateConsumer
public class StateConsumerImpl extends java.lang.Object implements StateConsumer
StateConsumerimplementation.- Since:
- 5.2
- Author:
- anistor@redhat.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceStateConsumerImpl.KeyInvalidationListener
-
Field Summary
Fields Modifier and Type Field Description protected org.infinispan.factories.impl.ComponentRef<Cache<java.lang.Object,java.lang.Object>>cacheprotected java.lang.StringcacheNameprotected CacheNotifiercacheNotifierprotected CacheTopologycacheTopologyprotected CommandAckCollectorcommandAckCollectorprotected org.infinispan.commands.CommandsFactorycommandsFactoryprotected CommitManagercommitManagerprotected Configurationconfigurationprotected org.infinispan.container.impl.InternalDataContainer<java.lang.Object,java.lang.Object>dataContainerprotected DistributionManagerdistributionManagerprotected InvocationContextFactoryicfprotected AsyncInterceptorChaininterceptorChainprotected booleanisFetchEnabledprotected booleanisInvalidationModeprotected booleanisTotalOrderprotected booleanisTransactionalprotected StateConsumerImpl.KeyInvalidationListenerkeyInvalidationListenerprotected KeyPartitionerkeyPartitionerprotected LocalTopologyManagerlocalTopologyManagerstatic java.lang.StringNO_KEYprotected static intNO_STATE_TRANSFER_IN_PROGRESSprotected PersistenceManagerpersistenceManagerprotected BlockingTaskAwareExecutorServiceremoteCommandsExecutorprotected RpcManagerrpcManagerprotected RpcOptionsrpcOptionsprotected static longSTATE_TRANSFER_FLAGSprotected LimitedExecutorstateRequestExecutorPush RPCs on a background threadprotected java.util.concurrent.ExecutorServicestateTransferExecutorprotected java.util.concurrent.CompletableFuture<java.lang.Void>stateTransferFutureprotected StateTransferLockstateTransferLockprotected java.util.concurrent.atomic.AtomicIntegerstateTransferTopologyIdIndicates if there is a state transfer in progress.protected longtimeoutprotected TotalOrderManagertotalOrderManagerprotected javax.transaction.TransactionManagertransactionManagerprotected org.infinispan.transaction.impl.TransactionTabletransactionTableprotected java.lang.ObjecttransferMapsLockprotected java.util.Map<java.lang.Integer,java.util.List<InboundTransferTask>>transfersBySegmentA map that keeps track of current inbound state transfers by segment id.protected TriangleOrderManagertriangleOrderManagerprotected java.util.concurrent.atomic.AtomicBooleanwaitingForStateIndicates if there is a rebalance in progress and there the local node has not yet received all the new segments yet.
-
Constructor Summary
Constructors Constructor Description StateConsumerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddTransfer(InboundTransferTask inboundTransfer, IntSet segments)java.util.concurrent.CompletionStage<?>applyState(Address sender, int topologyId, boolean pushTransfer, java.util.Collection<StateChunk> stateChunks)protected voidbeforeTopologyInstalled(int topologyId, boolean startRebalance, ConsistentHash previousWriteCh, ConsistentHash newWriteCh)protected voidcancelTransfers(IntSet removedSegments)Cancel transfers for segments we no longer own.CacheTopologygetCacheTopology()protected IntSetgetOwnedSegments(ConsistentHash consistentHash)protected voidhandleSegments(boolean startRebalance, IntSet addedSegments, IntSet removedSegments)booleanhasActiveTransfers()booleanisStateTransferInProgress()booleanisStateTransferInProgressForKey(java.lang.Object key)protected booleannotifyEndOfStateTransferIfNeeded()protected voidonTaskCompletion(InboundTransferTask inboundTransfer)java.util.concurrent.CompletableFuture<java.lang.Void>onTopologyUpdate(CacheTopology cacheTopology, boolean isRebalance)Receive notification of topology changes.booleanownsData()protected voidremoveStaleData(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 Detail
-
NO_STATE_TRANSFER_IN_PROGRESS
protected static final int NO_STATE_TRANSFER_IN_PROGRESS
- See Also:
- Constant Field Values
-
STATE_TRANSFER_FLAGS
protected static final long STATE_TRANSFER_FLAGS
-
NO_KEY
public static final java.lang.String NO_KEY
- See Also:
- Constant Field Values
-
cache
protected org.infinispan.factories.impl.ComponentRef<Cache<java.lang.Object,java.lang.Object>> cache
-
localTopologyManager
protected LocalTopologyManager localTopologyManager
-
configuration
protected Configuration configuration
-
rpcManager
protected RpcManager rpcManager
-
transactionManager
protected javax.transaction.TransactionManager transactionManager
-
commandsFactory
protected org.infinispan.commands.CommandsFactory commandsFactory
-
transactionTable
protected org.infinispan.transaction.impl.TransactionTable transactionTable
-
dataContainer
protected org.infinispan.container.impl.InternalDataContainer<java.lang.Object,java.lang.Object> dataContainer
-
persistenceManager
protected PersistenceManager persistenceManager
-
interceptorChain
protected AsyncInterceptorChain interceptorChain
-
icf
protected InvocationContextFactory icf
-
stateTransferLock
protected StateTransferLock stateTransferLock
-
cacheNotifier
protected CacheNotifier cacheNotifier
-
totalOrderManager
protected TotalOrderManager totalOrderManager
-
remoteCommandsExecutor
protected BlockingTaskAwareExecutorService remoteCommandsExecutor
-
commitManager
protected CommitManager commitManager
-
stateTransferExecutor
protected java.util.concurrent.ExecutorService stateTransferExecutor
-
commandAckCollector
protected CommandAckCollector commandAckCollector
-
triangleOrderManager
protected TriangleOrderManager triangleOrderManager
-
distributionManager
protected DistributionManager distributionManager
-
keyPartitioner
protected KeyPartitioner keyPartitioner
-
cacheName
protected java.lang.String cacheName
-
timeout
protected long timeout
-
isFetchEnabled
protected boolean isFetchEnabled
-
isTransactional
protected boolean isTransactional
-
isInvalidationMode
protected boolean isInvalidationMode
-
isTotalOrder
protected boolean isTotalOrder
-
keyInvalidationListener
protected volatile StateConsumerImpl.KeyInvalidationListener keyInvalidationListener
-
cacheTopology
protected volatile CacheTopology cacheTopology
-
stateTransferTopologyId
protected final java.util.concurrent.atomic.AtomicInteger 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
protected final java.util.concurrent.atomic.AtomicBoolean 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
protected java.util.concurrent.CompletableFuture<java.lang.Void> stateTransferFuture
-
transferMapsLock
protected final java.lang.Object transferMapsLock
-
transfersBySegment
protected final java.util.Map<java.lang.Integer,java.util.List<InboundTransferTask>> 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
protected LimitedExecutor stateRequestExecutor
Push RPCs on a background thread
-
rpcOptions
protected RpcOptions rpcOptions
-
-
Method Detail
-
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
-
hasActiveTransfers
public boolean hasActiveTransfers()
-
isStateTransferInProgress
public boolean isStateTransferInProgress()
- Specified by:
isStateTransferInProgressin interfaceStateConsumer
-
isStateTransferInProgressForKey
public boolean isStateTransferInProgressForKey(java.lang.Object key)
- Specified by:
isStateTransferInProgressForKeyin interfaceStateConsumer
-
ownsData
public boolean ownsData()
- Specified by:
ownsDatain interfaceStateConsumer- Returns:
- true if this node has already received the first rebalance command
-
onTopologyUpdate
public java.util.concurrent.CompletableFuture<java.lang.Void> onTopologyUpdate(CacheTopology cacheTopology, boolean isRebalance)
Description copied from interface:StateConsumerReceive notification of topology changes. StateRequestCommands 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:
- future that is completed when the state transfer has finished
-
beforeTopologyInstalled
protected void beforeTopologyInstalled(int topologyId, boolean startRebalance, ConsistentHash previousWriteCh, ConsistentHash newWriteCh)
-
handleSegments
protected void handleSegments(boolean startRebalance, IntSet addedSegments, IntSet removedSegments)
-
notifyEndOfStateTransferIfNeeded
protected boolean notifyEndOfStateTransferIfNeeded()
-
getOwnedSegments
protected IntSet getOwnedSegments(ConsistentHash consistentHash)
-
applyState
public java.util.concurrent.CompletionStage<?> applyState(Address sender, int topologyId, boolean pushTransfer, java.util.Collection<StateChunk> stateChunks)
- Specified by:
applyStatein interfaceStateConsumer
-
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
-
getCacheTopology
public CacheTopology getCacheTopology()
- Specified by:
getCacheTopologyin interfaceStateConsumer
-
setKeyInvalidationListener
public void setKeyInvalidationListener(StateConsumerImpl.KeyInvalidationListener keyInvalidationListener)
-
cancelTransfers
protected void cancelTransfers(IntSet removedSegments)
Cancel transfers for segments we no longer own.- Parameters:
removedSegments- segments to be cancelled
-
removeStaleData
protected void removeStaleData(IntSet removedSegments) throws java.lang.InterruptedException
- Throws:
java.lang.InterruptedException
-
addTransfer
protected void addTransfer(InboundTransferTask inboundTransfer, IntSet segments)
-
removeTransfer
protected boolean removeTransfer(InboundTransferTask inboundTransfer)
-
onTaskCompletion
protected void onTaskCompletion(InboundTransferTask inboundTransfer)
-
-