org.apache.ignite.internal.processors.cache.distributed.dht

## Interface GridDhtPartitionTopology

All Known Implementing Classes:
  GridClientPartitionTopology, GridDhtPartitionTopologyImpl

    @GridToStringExclude
    public interface GridDhtPartitionTopology

DHT partition topology.

### Method Summary

All Methods Instance Methods Abstract Methods
`boolean` `afterExchange(GridDhtPartitionsExchangeFuture exchFut)` Post-initializes this topology.
`void` `applyUpdateCounters()` Applies update counters collected during exchange on coordinator.
`void` `beforeExchange(GridDhtPartitionsExchangeFuture exchFut, boolean affReady, boolean updateMoving)` Pre-initializes this topology.
`void` `collectUpdateCounters(CachePartitionPartialCountersMap cntrMap)` Collects update counters collected during exchange.
`Iterable<GridDhtLocalPartition>` `currentLocalPartitions()`
`boolean` `detectLostPartitions(AffinityTopologyVersion resTopVer, DiscoveryEvent discoEvt)` Checks if there is at least one owner for each partition in the cache topology.
`GridDhtLocalPartition` `forceCreatePartition(int p)` Unconditionally creates partition during restore of persisted partition state.
`CachePartitionFullCountersMap` `fullUpdateCounters()`
`int` `groupId()`
`boolean` `hasMovingPartitions()`
`void` `initPartitionsWhenAffinityReady(AffinityTopologyVersion affVer, GridDhtPartitionsExchangeFuture exchFut)`
`AffinityTopologyVersion` `lastTopologyChangeVersion()`
`GridDhtLocalPartition` `localPartition(int part)`
`GridDhtLocalPartition` `localPartition(int p, AffinityTopologyVersion topVer, boolean create)`
`GridDhtLocalPartition` `localPartition(int p, AffinityTopologyVersion topVer, boolean create, boolean showRenting)`
`GridDhtPartitionMap` `localPartitionMap()`
`List<GridDhtLocalPartition>` `localPartitions()`
`CachePartitionPartialCountersMap` `localUpdateCounters(boolean skipZeros)`
`Collection<Integer>` `lostPartitions()`
`List<ClusterNode>` `moving(int p)`
`List<ClusterNode>` `nodes(int p, AffinityAssignment affAssignment, List<ClusterNode> affNodes)`
`List<ClusterNode>` `nodes(int p, AffinityTopologyVersion topVer)`
`void` `onEvicted(GridDhtLocalPartition part, boolean updateSeq)`
`void` `onExchangeDone(GridDhtPartitionsExchangeFuture fut, AffinityAssignment assignment, boolean updateRebalanceVer)` Callback on exchange done.
`void` `onRemoved(GridDhtCacheEntry e)`
`boolean` `own(GridDhtLocalPartition part)`
`List<ClusterNode>` `owners(int p)`
`List<ClusterNode>` `owners(int p, AffinityTopologyVersion topVer)`
`GridDhtPartitionFullMap` `partitionMap(boolean onlyActive)`
`int` `partitions()`
`GridDhtPartitionMap` `partitions(UUID nodeId)`
`GridDhtPartitionState` `partitionState(UUID nodeId, int part)`
`void` `printMemoryStats(int threshold)` Prints memory stats.
`void` `readLock()` Locks the topology, usually during mapping on locks or transactions.
`void` `readUnlock()` Unlocks topology locked by `readLock()` method.
`AffinityTopologyVersion` `readyTopologyVersion()`
`boolean` `rebalanceFinished(AffinityTopologyVersion topVer)`
`void` `releasePartitions(int... parts)`
`void` `resetLostPartitions(AffinityTopologyVersion resTopVer)` Resets the state of all LOST partitions to OWNING.
`Set<UUID>` `setOwners(int p, Set<UUID> owners, boolean haveHistory, boolean updateSeq)` Make nodes from provided set owners for a given partition.
`boolean` `stopping()`
`GridDhtTopologyFuture` `topologyVersionFuture()` Gets a future that will be completed when partition exchange map for this particular topology version is done.
`boolean` `update(AffinityTopologyVersion exchangeResVer, GridDhtPartitionFullMap partMap, CachePartitionFullCountersMap cntrMap, Set<Integer> partsToReload, AffinityTopologyVersion msgTopVer)`
`boolean` `update(GridDhtPartitionExchangeId exchId, GridDhtPartitionMap parts, boolean force)`
`long` `updateSequence()`
`void` `updateTopologyVersion(GridDhtTopologyFuture exchFut, DiscoCache discoCache, long updateSeq, boolean stopping)` Updates topology version.

### Method Detail

#### partitions

    int partitions()

Returns:
  Total cache partitions.

#### readLock

    void readLock()

Locks the topology, usually during mapping on locks or transactions.

#### readUnlock

    void readUnlock()

Unlocks topology locked by `readLock()` method.

#### updateTopologyVersion

    void updateTopologyVersion(GridDhtTopologyFuture exchFut,
                               DiscoCache discoCache,
                               long updateSeq,
                               boolean stopping)
                        throws IgniteInterruptedCheckedException

Updates topology version.

Parameters:
  `exchFut` - Exchange future.
  `discoCache` - Discovery data cache.
  `updateSeq` - Update sequence.
  `stopping` - Stopping flag.
Throws:
  `IgniteInterruptedCheckedException` - If interrupted.

#### readyTopologyVersion

    AffinityTopologyVersion readyTopologyVersion()

Returns:
  Result topology version of last finished exchange.

#### lastTopologyChangeVersion

    AffinityTopologyVersion lastTopologyChangeVersion()

Returns:
  Start topology version of last exchange.

#### topologyVersionFuture

    GridDhtTopologyFuture topologyVersionFuture()

Gets a future that will be completed when partition exchange map for this particular topology version is done.

Returns:
  Topology version ready future.

#### stopping

    boolean stopping()

Returns:
  `True` if cache is being stopped.

#### groupId

    int groupId()

Returns:
  Cache group ID.

#### beforeExchange

    void beforeExchange(GridDhtPartitionsExchangeFuture exchFut,
                        boolean affReady,
                        boolean updateMoving)
                 throws IgniteCheckedException

Pre-initializes this topology.

Parameters:
  `exchFut` - Exchange future.
  `affReady` - Affinity ready flag.
  `updateMoving` -
Throws:
  `IgniteCheckedException` - If failed.

#### initPartitionsWhenAffinityReady

    void initPartitionsWhenAffinityReady(AffinityTopologyVersion affVer,
                                         GridDhtPartitionsExchangeFuture exchFut)
                                  throws IgniteInterruptedCheckedException

Parameters:
  `affVer` - Affinity version.
  `exchFut` - Exchange future.
Throws:
  `IgniteInterruptedCheckedException` - If interrupted.

#### afterExchange

    boolean afterExchange(GridDhtPartitionsExchangeFuture exchFut)
                   throws IgniteCheckedException

Post-initializes this topology.

Parameters:
  `exchFut` - Exchange future.
Returns:
  `True` if mapping was changed.
Throws:
  `IgniteCheckedException` - If failed.

#### localPartition

    @Nullable
    GridDhtLocalPartition localPartition(int p,
                                                   AffinityTopologyVersion topVer,
                                                   boolean create)
                                            throws GridDhtInvalidPartitionException

Parameters:
  `topVer` - Topology version at the time of creation.
  `p` - Partition ID.
  `create` - If `true`, then partition will be created if it's not there.
Returns:
  Local partition.
Throws:
  `GridDhtInvalidPartitionException` - If partition is evicted or absent and does not belong to this node.

#### forceCreatePartition

    GridDhtLocalPartition forceCreatePartition(int p)
                                        throws IgniteCheckedException

Unconditionally creates partition during restore of persisted partition state.

Parameters:
  `p` - Partition ID.
Returns:
  Partition.
Throws:
  `IgniteCheckedException` - If failed.

#### localPartition

    @Nullable
    GridDhtLocalPartition localPartition(int p,
                                                   AffinityTopologyVersion topVer,
                                                   boolean create,
                                                   boolean showRenting)
                                            throws GridDhtInvalidPartitionException

Parameters:
  `topVer` - Topology version at the time of creation.
  `p` - Partition ID.
  `create` - If `true`, then partition will be created if it's not there.
Returns:
  Local partition.
Throws:
  `GridDhtInvalidPartitionException` - If partition is evicted or absent and does not belong to this node.

#### releasePartitions

    void releasePartitions(int... parts)

Parameters:
  `parts` - Partitions to release (should be reserved before).

#### localPartition

    @Nullable
    GridDhtLocalPartition localPartition(int part)
                                            throws GridDhtInvalidPartitionException

Parameters:
  `part` - Partition number.
Returns:
  Local partition.
Throws:
  `GridDhtInvalidPartitionException` - If partition is evicted or absent and does not belong to this node.

#### localPartitions

    List<GridDhtLocalPartition> localPartitions()

Returns:
  All local partitions by copying them into another list.

#### currentLocalPartitions

    Iterable<GridDhtLocalPartition> currentLocalPartitions()

Returns:
  All current active local partitions.

#### localPartitionMap

    GridDhtPartitionMap localPartitionMap()

Returns:
  Local IDs.

#### partitionState

    GridDhtPartitionState partitionState(UUID nodeId,
                                         int part)

Parameters:
  `nodeId` - Node ID.
  `part` - Partition.
Returns:
  Partition state.

#### updateSequence

    long updateSequence()

Returns:
  Current update sequence.

#### nodes

    List<ClusterNode> nodes(int p,
                            AffinityTopologyVersion topVer)

Parameters:
  `p` - Partition ID.
  `topVer` - Topology version.
Returns:
  Collection of all nodes responsible for this partition with primary node being first.

#### nodes

    @Nullable
    List<ClusterNode> nodes(int p,
                                      AffinityAssignment affAssignment,
                                      List<ClusterNode> affNodes)

Parameters:
  `p` - Partition ID.
  `affAssignment` - Assignments.
  `affNodes` - Node assigned for given partition by affinity.
Returns:
  Collection of all nodes responsible for this partition with primary node being first. The first N elements of this collection (with N being 1 + backups) are actual DHT affinity nodes, other nodes are current additional owners of the partition after topology change.

#### owners

    List<ClusterNode> owners(int p)

Parameters:
  `p` - Partition ID.
Returns:
  Collection of all nodes who `own` this partition.

#### owners

    List<ClusterNode> owners(int p,
                             AffinityTopologyVersion topVer)

Parameters:
  `p` - Partition ID.
  `topVer` - Topology version.
Returns:
  Collection of all nodes who `own` this partition.

#### moving

    List<ClusterNode> moving(int p)

Parameters:
  `p` - Partition ID.
Returns:
  Collection of all nodes who `are preloading` this partition.

#### partitionMap

    GridDhtPartitionFullMap partitionMap(boolean onlyActive)

Parameters:
  `onlyActive` - If `true`, then only `active` partitions will be returned.
Returns:
  Node IDs mapped to partitions.

#### hasMovingPartitions

    boolean hasMovingPartitions()

Returns:
  `True` If one of cache nodes has partitions in `GridDhtPartitionState.MOVING` state.

#### onRemoved

    void onRemoved(GridDhtCacheEntry e)

Parameters:
  `e` - Entry removed from cache.

#### update

    boolean update(@Nullable
                   AffinityTopologyVersion exchangeResVer,
                   GridDhtPartitionFullMap partMap,
                   @Nullable
                   CachePartitionFullCountersMap cntrMap,
                   Set<Integer> partsToReload,
                   @Nullable
                   AffinityTopologyVersion msgTopVer)

Parameters:
  `exchangeResVer` - Result topology version for exchange. Value should be greater than previously passed. Null value means full map received is not related to exchange
  `partMap` - Update partition map.
  `cntrMap` - Partition update counters.
  `partsToReload` - Set of partitions that need to be reloaded.
  `msgTopVer` - Topology version from incoming message. This value is not null only for case message is not related to exchange. Value should be not less than previous 'Topology version from exchange'.
Returns:
  `True` if local state was changed.

#### update

    boolean update(@Nullable
                   GridDhtPartitionExchangeId exchId,
                   GridDhtPartitionMap parts,
                   boolean force)

Parameters:
  `exchId` - Exchange ID.
  `parts` - Partitions.
  `force` - `True` to skip stale update check.
Returns:
  `True` if local state was changed.

#### collectUpdateCounters

    void collectUpdateCounters(CachePartitionPartialCountersMap cntrMap)

Collects update counters collected during exchange. Called on coordinator.

Parameters:
  `cntrMap` - Counters map.

#### applyUpdateCounters

    void applyUpdateCounters()

Applies update counters collected during exchange on coordinator. Called on coordinator.

#### detectLostPartitions

    boolean detectLostPartitions(AffinityTopologyVersion resTopVer,
                                 DiscoveryEvent discoEvt)

Checks if there is at least one owner for each partition in the cache topology. If not, marks such a partition as LOST.

This method should be called on topology coordinator after all partition messages are received.

Parameters:
  `resTopVer` - Exchange result version.
  `discoEvt` - Discovery event for which we detect lost partitions.
Returns:
  `True` if partitions state got updated.

#### resetLostPartitions

    void resetLostPartitions(AffinityTopologyVersion resTopVer)

Resets the state of all LOST partitions to OWNING.

Parameters:
  `resTopVer` - Exchange result version.

#### lostPartitions

    Collection<Integer> lostPartitions()

Returns:
  Collection of lost partitions, if any.

#### fullUpdateCounters

    CachePartitionFullCountersMap fullUpdateCounters()

Returns:
  Partition update counters.

#### localUpdateCounters

    CachePartitionPartialCountersMap localUpdateCounters(boolean skipZeros)

Returns:
  Partition update counters.

#### own

    boolean own(GridDhtLocalPartition part)

Parameters:
  `part` - Partition to own.
Returns:
  `True` if owned.

#### onEvicted

    void onEvicted(GridDhtLocalPartition part,
                   boolean updateSeq)

Parameters:
  `part` - Evicted partition.
  `updateSeq` - Update sequence increment flag.

#### partitions

    @Nullable
    GridDhtPartitionMap partitions(UUID nodeId)

Parameters:
  `nodeId` - Node to get partitions for.
Returns:
  Partitions for node.

#### printMemoryStats

    void printMemoryStats(int threshold)

Prints memory stats.

Parameters:
  `threshold` - Threshold for number of entries.

#### rebalanceFinished

    boolean rebalanceFinished(AffinityTopologyVersion topVer)

Parameters:
  `topVer` - Topology version.
Returns:
  `True` if rebalance process finished.

#### setOwners

    Set<UUID> setOwners(int p,
                        Set<UUID> owners,
                        boolean haveHistory,
                        boolean updateSeq)

Make nodes from provided set owners for a given partition. State of all current owners that aren't contained in the set will be reset to MOVING.

Parameters:
  `p` - Partition ID.
  `updateSeq` - If should increment sequence when updated.
  `owners` - Set of new owners.
Returns:
  Set of node IDs that should reload partitions.

#### onExchangeDone

    void onExchangeDone(GridDhtPartitionsExchangeFuture fut,
                        AffinityAssignment assignment,
                        boolean updateRebalanceVer)

Callback on exchange done.

Parameters:
  `assignment` - New affinity assignment.
  `updateRebalanceVer` - `True` if need check rebalance state.

2018 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.4.0
Release Date | : March 5 2018