Package org.infinispan.statetransfer
Class StateConsumerImpl
- java.lang.Object
-
- org.infinispan.statetransfer.StateConsumerImpl
-
- All Implemented Interfaces:
StateConsumer
public class StateConsumerImpl extends 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
-
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)voidapplyState(Address sender, int topologyId, boolean pushTransfer, 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(Object key)protected booleannotifyEndOfStateTransferIfNeeded()protected voidonTaskCompletion(InboundTransferTask inboundTransfer)CompletableFuture<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
-
cache
protected org.infinispan.factories.impl.ComponentRef<Cache> cache
-
localTopologyManager
protected LocalTopologyManager localTopologyManager
-
configuration
protected Configuration configuration
-
rpcManager
protected RpcManager rpcManager
-
transactionManager
protected TransactionManager transactionManager
-
commandsFactory
protected org.infinispan.commands.CommandsFactory commandsFactory
-
transactionTable
protected org.infinispan.transaction.impl.TransactionTable transactionTable
-
dataContainer
protected org.infinispan.container.impl.InternalDataContainer<Object,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 ExecutorService stateTransferExecutor
-
commandAckCollector
protected CommandAckCollector commandAckCollector
-
triangleOrderManager
protected TriangleOrderManager triangleOrderManager
-
distributionManager
protected DistributionManager distributionManager
-
keyPartitioner
protected KeyPartitioner keyPartitioner
-
cacheName
protected 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 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 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 CompletableFuture<Void> stateTransferFuture
-
transferMapsLock
protected final Object transferMapsLock
-
transfersBySegment
protected final Map<Integer,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(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 CompletableFuture<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 void applyState(Address sender, int topologyId, boolean pushTransfer, 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 InterruptedException
- Throws:
InterruptedException
-
addTransfer
protected void addTransfer(InboundTransferTask inboundTransfer, IntSet segments)
-
removeTransfer
protected boolean removeTransfer(InboundTransferTask inboundTransfer)
-
onTaskCompletion
protected void onTaskCompletion(InboundTransferTask inboundTransfer)
-
-