Class StateConsumerImpl

    • 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
      • 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
      • stateTransferExecutor

        protected java.util.concurrent.ExecutorService stateTransferExecutor
      • 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
      • 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
    • Constructor Detail

      • StateConsumerImpl

        public StateConsumerImpl()
    • 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 interface StateConsumer
      • hasActiveTransfers

        public boolean hasActiveTransfers()
      • ownsData

        public boolean ownsData()
        Specified by:
        ownsData in interface StateConsumer
        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 interface StateConsumer
        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()
      • 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 interface StateConsumer
      • 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