Class GridDhtLocalPartition

    • Constructor Detail

      • GridDhtLocalPartition

        public GridDhtLocalPartition​(GridCacheSharedContext ctx,
                                     CacheGroupContext grp,
                                     int id,
                                     boolean recovery)
        Parameters:
        ctx - Context.
        grp - Cache group.
        id - Partition ID.
        recovery - Flag indicates that partition is created during recovery phase.
    • Method Detail

      • internalSize

        public int internalSize()
        Returns the number of key-value mappings in this map. It does not include entries from underlying data store.
        Specified by:
        internalSize in interface GridCacheConcurrentMap
        Returns:
        the number of key-value mappings in this map.
      • addReservation

        public boolean addReservation​(GridDhtPartitionsReservation r)
        Adds group reservation to this partition.
        Parameters:
        r - Reservation.
        Returns:
        false If such reservation already added.
      • id

        public int id()
        Returns:
        Partition ID.
      • createTime

        public long createTime()
        Returns:
        Create time.
      • reservations

        public int reservations()
        Returns:
        Reservations.
      • isEmpty

        public boolean isEmpty()
        Returns:
        True if partition is empty.
      • valid

        public boolean valid()
        Returns:
        If partition is moving or owning or renting.
      • onRemoved

        public void onRemoved​(GridDhtCacheEntry entry)
        Parameters:
        entry - Entry to remove.
      • onDeferredDelete

        public void onDeferredDelete​(int cacheId,
                                     KeyCacheObject key,
                                     GridCacheVersion ver)
        Parameters:
        cacheId - cacheId Cache ID.
        key - Removed key.
        ver - Removed version.
      • reserve

        public boolean reserve()
        Reserves the partition so it won't be cleared or evicted. Only MOVING, OWNING and LOST partitions can be reserved.
        Specified by:
        reserve in interface GridReservable
        Overrides:
        reserve in class GridCacheConcurrentMapImpl
        Returns:
        True if reserved.
      • restoreState

        public void restoreState​(GridDhtPartitionState stateToRestore)
        Parameters:
        stateToRestore - State to restore.
      • setState

        public void setState​(GridDhtPartitionState toState)
        For testing purposes only.
        Parameters:
        toState - State to set.
      • own

        public boolean own()
        Returns:
        True if transitioned to OWNING state.
      • moving

        public boolean moving()
        Forcibly moves partition to a MOVING state.
        Returns:
        True if a partition was switched to MOVING state.
      • updateClearVersion

        public void updateClearVersion()
        Records a version for row clearing. Must be called when a partition is marked for full rebalancing.
        See Also:
        clearAll(EvictionContext)
      • updateClearVersion

        public void updateClearVersion​(long clearVer)
        Used to set a version from PartitionClearingStartRecord when need to repeat a clearing after node restart.
        Parameters:
        clearVer - Clear version.
      • markLost

        public boolean markLost()
        Returns:
        True if partition state changed.
      • rent

        public IgniteInternalFuture<?> rent()
        Initiates partition eviction process and returns an eviction future. Future will be completed when a partition is moved to EVICTED state (possibly not yet physically deleted). If partition has reservations, eviction will be delayed and continued after all reservations will be released.
        Returns:
        Future to signal that this node is no longer an owner or backup or null if corresponding partition state is RENTING or EVICTED.
      • tryContinueClearing

        public void tryContinueClearing()
        Continue clearing if it was delayed before due to reservation and topology version not changed.
      • clearAsync

        public IgniteInternalFuture<?> clearAsync()
        Initiates a partition clearing attempt.
        Returns:
        A future what will be finished then a current clearing attempt is done.
      • finishEviction

        public void finishEviction()
        Moves partition state to EVICTED if possible.
      • isClearing

        public boolean isClearing()
        Returns:
        True if clearing process is running at the moment on the partition.
      • onUnlock

        public void onUnlock()
        On partition unlock callback. Tries to continue delayed partition clearing.
      • primary

        public boolean primary​(AffinityTopologyVersion topVer)
        Parameters:
        topVer - Topology version.
        Returns:
        True if local node is primary for this partition.
      • backup

        public boolean backup​(AffinityTopologyVersion topVer)
        Parameters:
        topVer - Topology version.
        Returns:
        True if local node is backup for this partition.
      • nextUpdateCounter

        public long nextUpdateCounter​(int cacheId,
                                      AffinityTopologyVersion topVer,
                                      boolean primary,
                                      boolean init,
                                      @Nullable
                                      @Nullable Long primaryCntr)
        Returns new update counter for primary node or passed counter for backup node.

        Used for non-tx cases.

        Counter generation/update logic is delegated to counter implementation.

        Parameters:
        cacheId - ID of cache initiated counter update.
        topVer - Topology version for current operation.
        init - True if initial update.
        Returns:
        Next update index.
      • nextUpdateCounter

        public long nextUpdateCounter​(int cacheId,
                                      IgniteInternalTx tx,
                                      @Nullable
                                      @Nullable Long primaryCntr)
        Used for transactions.
        Parameters:
        cacheId - Cache id.
        tx - Tx.
        primaryCntr - Primary counter.
      • updateCounter

        public long updateCounter()
        Returns:
        Current update counter (LWM).
      • highestAppliedCounter

        public long highestAppliedCounter()
        Returns:
        Highest applied update counter.
      • reservedCounter

        public long reservedCounter()
        Returns:
        Current reserved counter (HWM).
      • updateCounter

        public void updateCounter​(long val)
        Parameters:
        val - Update counter value.
      • initialUpdateCounter

        public long initialUpdateCounter()
        Returns:
        Initial update counter.
      • getAndIncrementUpdateCounter

        public long getAndIncrementUpdateCounter​(long delta)
        Increments cache update counter on primary node.
        Parameters:
        delta - Value to be added to update counter.
        Returns:
        Update counter value before update.
      • updateCounter

        public boolean updateCounter​(long start,
                                     long delta)
        Updates cache update counter on backup node.
        Parameters:
        start - Start position
        delta - Delta.
      • resetUpdateCounter

        public void resetUpdateCounter()
        Reset partition update counter.
      • resetInitialUpdateCounter

        public void resetInitialUpdateCounter()
        Reset partition initial update counter.
      • fullSize

        public long fullSize()
        Returns:
        Total size of all caches.
      • clearDeferredDeletes

        public void clearDeferredDeletes()
        Removes all deferred delete requests from rmvQueue.
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • publicSize

        public int publicSize​(int cacheId)
        Returns the number of publicly available key-value mappings in this map. It excludes entries that are marked as deleted. It also does not include entries from underlying data store.
        Specified by:
        publicSize in interface GridCacheConcurrentMap
        Parameters:
        cacheId - Cache ID.
        Returns:
        the number of publicly available key-value mappings in this map.
      • group

        public CacheGroupContext group()
        Returns group context.
        Returns:
        Group context.
      • onCacheStopped

        public void onCacheStopped​(int cacheId)
        Parameters:
        cacheId - Cache ID.
      • finalizeUpdateCounters

        public GridLongList finalizeUpdateCounters()
        Flushes pending update counters closing all possible gaps.
        Returns:
        Even-length array of pairs [start, end] for each gap.
      • beforeApplyBatch

        public void beforeApplyBatch​(boolean last)
        Called before next batch is about to be applied during rebalance. Currently used for tests.
        Parameters:
        last - True if last batch for partition.
      • dumpDebugInfo

        public void dumpDebugInfo​(SB buf)
        Collects detailed info about the partition.
        Parameters:
        buf - Buffer.