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
StateConsumer
implementation.- Since:
- 5.2
- Author:
- anistor@redhat.com
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
StateConsumerImpl.KeyInvalidationListener
-
Field Summary
Fields Modifier and Type Field Description protected org.infinispan.factories.impl.ComponentRef<Cache<java.lang.Object,java.lang.Object>>
cache
protected java.lang.String
cacheName
protected CacheNotifier
cacheNotifier
protected CacheTopology
cacheTopology
protected CommandAckCollector
commandAckCollector
protected org.infinispan.commands.CommandsFactory
commandsFactory
protected CommitManager
commitManager
protected Configuration
configuration
protected org.infinispan.container.impl.InternalDataContainer<java.lang.Object,java.lang.Object>
dataContainer
protected DistributionManager
distributionManager
protected InvocationContextFactory
icf
protected AsyncInterceptorChain
interceptorChain
protected boolean
isFetchEnabled
protected boolean
isInvalidationMode
protected boolean
isTotalOrder
protected boolean
isTransactional
protected StateConsumerImpl.KeyInvalidationListener
keyInvalidationListener
protected KeyPartitioner
keyPartitioner
protected LocalTopologyManager
localTopologyManager
static java.lang.String
NO_KEY
protected static int
NO_STATE_TRANSFER_IN_PROGRESS
protected PersistenceManager
persistenceManager
protected BlockingTaskAwareExecutorService
remoteCommandsExecutor
protected RpcManager
rpcManager
protected RpcOptions
rpcOptions
protected static long
STATE_TRANSFER_FLAGS
protected LimitedExecutor
stateRequestExecutor
Push RPCs on a background threadprotected java.util.concurrent.ExecutorService
stateTransferExecutor
protected java.util.concurrent.CompletableFuture<java.lang.Void>
stateTransferFuture
protected StateTransferLock
stateTransferLock
protected java.util.concurrent.atomic.AtomicInteger
stateTransferTopologyId
Indicates if there is a state transfer in progress.protected long
timeout
protected TotalOrderManager
totalOrderManager
protected javax.transaction.TransactionManager
transactionManager
protected org.infinispan.transaction.impl.TransactionTable
transactionTable
protected java.lang.Object
transferMapsLock
protected java.util.Map<java.lang.Integer,java.util.List<InboundTransferTask>>
transfersBySegment
A map that keeps track of current inbound state transfers by segment id.protected TriangleOrderManager
triangleOrderManager
protected 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.
-
Constructor Summary
Constructors Constructor Description StateConsumerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addTransfer(InboundTransferTask inboundTransfer, IntSet segments)
java.util.concurrent.CompletionStage<?>
applyState(Address sender, int topologyId, boolean pushTransfer, java.util.Collection<StateChunk> stateChunks)
protected void
beforeTopologyInstalled(int topologyId, boolean startRebalance, ConsistentHash previousWriteCh, ConsistentHash newWriteCh)
protected void
cancelTransfers(IntSet removedSegments)
Cancel transfers for segments we no longer own.protected IntSet
getOwnedSegments(ConsistentHash consistentHash)
protected void
handleSegments(boolean startRebalance, IntSet addedSegments, IntSet removedSegments)
boolean
hasActiveTransfers()
boolean
isStateTransferInProgress()
boolean
isStateTransferInProgressForKey(java.lang.Object key)
protected boolean
notifyEndOfStateTransferIfNeeded()
protected void
onTaskCompletion(InboundTransferTask inboundTransfer)
java.util.concurrent.CompletableFuture<java.lang.Void>
onTopologyUpdate(CacheTopology cacheTopology, boolean isRebalance)
Receive notification of topology changes.boolean
ownsData()
protected void
removeStaleData(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 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:
stopApplyingState
in interfaceStateConsumer
-
hasActiveTransfers
public boolean hasActiveTransfers()
-
isStateTransferInProgress
public boolean isStateTransferInProgress()
- Specified by:
isStateTransferInProgress
in interfaceStateConsumer
-
isStateTransferInProgressForKey
public boolean isStateTransferInProgressForKey(java.lang.Object key)
- Specified by:
isStateTransferInProgressForKey
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 java.util.concurrent.CompletableFuture<java.lang.Void> onTopologyUpdate(CacheTopology cacheTopology, boolean isRebalance)
Description copied from interface:StateConsumer
Receive 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:
onTopologyUpdate
in 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:
applyState
in interfaceStateConsumer
-
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)
-
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)
-
-