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

Methods
`boolean` `afterExchange(GridDhtPartitionsExchangeFuture exchFut)` Post-initializes this topology.
`void` `applyUpdateCounters(Map<Integer,T2<Long,Long>> cntrMap)`
`void` `beforeExchange(GridDhtPartitionsExchangeFuture exchFut, boolean affReady)` Pre-initializes this topology.
`Iterable<GridDhtLocalPartition>` `currentLocalPartitions()`
`boolean` `detectLostPartitions(DiscoveryEvent discoEvt)` Checks if there is at least one owner for each partition in the cache topology.
`int` `groupId()`
`boolean` `hasMovingPartitions()`
`void` `initPartitions(GridDhtPartitionsExchangeFuture exchFut)`
`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()`
`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(AffinityAssignment assignment)` 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)`
`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.
`boolean` `rebalanceFinished(AffinityTopologyVersion topVer)`
`void` `releasePartitions(int... parts)`
`void` `resetLostPartitions()` 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()`
`AffinityTopologyVersion` `topologyVersion()` Topology version.
`GridDhtTopologyFuture` `topologyVersionFuture()` Gets a future that will be completed when partition exchange map for this particular topology version is done.
`boolean` `update(AffinityTopologyVersion exchangeVer, GridDhtPartitionFullMap partMap, Map<Integer,T2<Long,Long>> cntrMap, Set<Integer> partsToReload)`
`boolean` `update(GridDhtPartitionExchangeId exchId, GridDhtPartitionMap parts)`
`Map<Integer,T2<Long,Long>>` `updateCounters(boolean skipZeros)`
`long` `updateSequence()`
`void` `updateTopologyVersion(GridDhtTopologyFuture exchFut, DiscoCache discoCache, long updateSeq, boolean stopping)` Updates topology version.

### Method Detail

#### 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.

#### topologyVersion

    AffinityTopologyVersion topologyVersion()

Topology version.

Returns:
  Topology version.

#### 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)
                        throws IgniteCheckedException

Pre-initializes this topology.

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

#### initPartitions

    void initPartitions(GridDhtPartitionsExchangeFuture exchFut)
                        throws IgniteInterruptedCheckedException

Parameters:
  `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.

#### 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.

#### 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 exchangeVer,
                 GridDhtPartitionFullMap partMap,
                 @Nullable
                 Map<Integer,T2<Long,Long>> cntrMap,
                 Set<Integer> partsToReload)

Parameters:
  `exchangeVer` - Exchange version.
  `partMap` - Update partition map.
  `cntrMap` - Partition update counters.
Returns:
  `True` if local state was changed.

#### update

    boolean update(@Nullable
                 GridDhtPartitionExchangeId exchId,
                 GridDhtPartitionMap parts)

Parameters:
  `exchId` - Exchange ID.
  `parts` - Partitions.
Returns:
  `True` if local state was changed.

#### applyUpdateCounters

    void applyUpdateCounters(Map<Integer,T2<Long,Long>> cntrMap)

Parameters:
  `cntrMap` - Counters map.

#### detectLostPartitions

    boolean detectLostPartitions(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:
  `discoEvt` - Discovery event for which we detect lost partitions.
Returns:
  `True` if partitions state got updated.

#### resetLostPartitions

    void resetLostPartitions()

Resets the state of all LOST partitions to OWNING.

#### lostPartitions

    Collection<Integer> lostPartitions()

Returns:
  Collection of lost partitions, if any.

#### updateCounters

    Map<Integer,T2<Long,Long>> updateCounters(boolean skipZeros)

Parameters:
  `skipZeros` - If `true` then filters out zero counters.
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(AffinityAssignment assignment)

Callback on exchange done.

Parameters:
  `assignment` - New affinity assignment.

2017 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 2.2.0
Release Date | : September 15 2017