Class StateConsumerImpl

java.lang.Object
org.infinispan.statetransfer.StateConsumerImpl
All Implemented Interfaces:
StateConsumer
Direct Known Subclasses:
ScatteredStateConsumerImpl

public class StateConsumerImpl extends Object implements StateConsumer
StateConsumer implementation.
Since:
5.2
Author:
[email protected]
  • 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

      public static final String NO_KEY
      See Also:
    • cache

      protected ComponentRef<Cache<Object,Object>> cache
    • localTopologyManager

      protected LocalTopologyManager localTopologyManager
    • configuration

      protected Configuration configuration
    • rpcManager

      protected RpcManager rpcManager
    • transactionManager

      protected javax.transaction.TransactionManager transactionManager
    • commandsFactory

      protected CommandsFactory commandsFactory
    • transactionTable

      protected TransactionTable transactionTable
    • dataContainer

      protected InternalDataContainer<Object,Object> dataContainer
    • persistenceManager

      protected PersistenceManager persistenceManager
    • interceptorChain

      protected AsyncInterceptorChain interceptorChain
    • icf

      protected InvocationContextFactory icf
    • stateTransferLock

      protected StateTransferLock stateTransferLock
    • cacheNotifier

      protected CacheNotifier<?,?> cacheNotifier
    • commitManager

      protected CommitManager commitManager
    • nonBlockingExecutor

      protected Executor nonBlockingExecutor
    • commandAckCollector

      protected CommandAckCollector commandAckCollector
    • triangleOrderManager

      protected TriangleOrderManager triangleOrderManager
    • distributionManager

      protected DistributionManager distributionManager
    • keyPartitioner

      protected KeyPartitioner keyPartitioner
    • conflictManager

      protected InternalConflictManager<?,?> conflictManager
    • localPublisherManager

      protected LocalPublisherManager<Object,Object> localPublisherManager
    • cacheName

      protected String cacheName
    • timeout

      protected long timeout
    • isFetchEnabled

      protected boolean isFetchEnabled
    • isTransactional

      protected boolean isTransactional
    • isInvalidationMode

      protected boolean isInvalidationMode
    • 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
      Limit to one state request at a time.
    • rpcOptions

      protected RpcOptions 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:
      stopApplyingState in interface StateConsumer
      Parameters:
      topologyId - Topology id at the end of state transfer
    • hasActiveTransfers

      public boolean hasActiveTransfers()
    • isStateTransferInProgress

      public boolean isStateTransferInProgress()
      Specified by:
      isStateTransferInProgress in interface StateConsumer
    • isStateTransferInProgressForKey

      public boolean isStateTransferInProgressForKey(Object key)
      Specified by:
      isStateTransferInProgressForKey in interface StateConsumer
    • inflightRequestCount

      public long inflightRequestCount()
      Description copied from interface: StateConsumer
      Returns the number of in-flight requested segments.
      Specified by:
      inflightRequestCount in interface StateConsumer
    • inflightTransactionSegmentCount

      public long inflightTransactionSegmentCount()
      Description copied from interface: StateConsumer
      Returns the number of in-flight transactional requested segments.
      Specified by:
      inflightTransactionSegmentCount in interface StateConsumer
    • ownsData

      public boolean ownsData()
      Specified by:
      ownsData in interface StateConsumer
      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: StateConsumer
      Receive notification of topology changes. StateTransferStartCommand, or ScatteredStateGetKeysCommand for CacheMode.SCATTERED_SYNC, 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:
      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

      protected org.infinispan.commons.util.IntSet getOwnedSegments(ConsistentHash consistentHash)
    • applyState

      public CompletionStage<?> applyState(Address sender, int topologyId, boolean pushTransfer, Collection<StateChunk> stateChunks)
      Specified by:
      applyState in interface StateConsumer
    • onCompletedSegment

      protected void onCompletedSegment(int segmentId, InboundTransferTask inboundTransfer)
    • 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
    • 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

      protected CompletionStage<Void> removeStaleData(org.infinispan.commons.util.IntSet removedSegments)
    • invalidateBatch

      protected CompletionStage<Void> invalidateBatch(Collection<Object> keysToRemove)
    • addTransfer

      protected void addTransfer(InboundTransferTask inboundTransfer, org.infinispan.commons.util.IntSet segments)
    • removeTransfer

      protected boolean removeTransfer(InboundTransferTask inboundTransfer)
    • onTaskCompletion

      protected void onTaskCompletion(InboundTransferTask inboundTransfer)