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

## Interface GridDhtPartitionTopology<K,V>

All Known Implementing Classes:
  GridClientPartitionTopology

    @GridToStringExclude
    public interface GridDhtPartitionTopology<K,V>

DHT partition topology.

### Method Summary

Methods
`boolean` `afterExchange(GridDhtPartitionExchangeId exchId)` Post-initializes this topology.
`void` `beforeExchange(GridDhtPartitionExchangeId exchId)` Pre-initializes this topology.
`Collection<GridDhtLocalPartition<K,V>>` `currentLocalPartitions()`
`GridDhtLocalPartition<K,V>` `localPartition(int p, long topVer, boolean create)`
`GridDhtLocalPartition<K,V>` `localPartition(K key, boolean create)`
`GridDhtPartitionMap` `localPartitionMap()`
`List<GridDhtLocalPartition<K,V>>` `localPartitions()`
`List<ClusterNode>` `moving(int p)`
`Collection<ClusterNode>` `nodes(int p, long topVer)`
`GridDhtLocalPartition<K,V>` `onAdded(long topVer, GridDhtCacheEntry<K,V> e)`
`void` `onEvicted(GridDhtLocalPartition<K,V> part, boolean updateSeq)`
`void` `onRemoved(GridDhtCacheEntry<K,V> e)`
`boolean` `own(GridDhtLocalPartition<K,V> part)`
`List<ClusterNode>` `owners(int p)`
`List<ClusterNode>` `owners(int p, long topVer)`
`GridDhtPartitionFullMap` `partitionMap(boolean onlyActive)`
`GridDhtPartitionMap` `partitions(UUID nodeId)`
`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.
`long` `topologyVersion()` Topology version.
`GridDhtTopologyFuture` `topologyVersionFuture()` Gets a future that will be completed when partition exchange map for this particular topology version is done.
`GridDhtPartitionMap` `update(GridDhtPartitionExchangeId exchId, GridDhtPartitionFullMap partMap)`
`GridDhtPartitionMap` `update(GridDhtPartitionExchangeId exchId, GridDhtPartitionMap parts)`
`long` `updateSequence()`
`void` `updateTopologyVersion(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture<K,V> exchFut)` 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(GridDhtPartitionExchangeId exchId,
                             GridDhtPartitionsExchangeFuture<K,V> exchFut)

Updates topology version.

Parameters:
  `exchId` - Exchange ID.
  `exchFut` - Exchange future.

#### topologyVersion

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

#### beforeExchange

    void beforeExchange(GridDhtPartitionExchangeId exchId)
                        throws IgniteCheckedException

Pre-initializes this topology.

Parameters:
  `exchId` - Exchange ID for this pre-initialization.
Throws:
  `IgniteCheckedException` - If failed.

#### afterExchange

    boolean afterExchange(GridDhtPartitionExchangeId exchId)
                          throws IgniteCheckedException

Post-initializes this topology.

Parameters:
  `exchId` - Exchange ID for this post-initialization.
Returns:
  `True` if mapping was changed.
Throws:
  `IgniteCheckedException` - If failed.

#### localPartition

    @Nullable
    GridDhtLocalPartition<K,V> localPartition(int p,
                                                     long 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<K,V> localPartition(K key,
                                                     boolean create)
                                              throws GridDhtInvalidPartitionException

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

#### localPartitions

    List<GridDhtLocalPartition<K,V>> localPartitions()

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

#### currentLocalPartitions

    Collection<GridDhtLocalPartition<K,V>> currentLocalPartitions()

Returns:
  All current local partitions.

#### localPartitionMap

    GridDhtPartitionMap localPartitionMap()

Returns:
  Local IDs.

#### updateSequence

    long updateSequence()

Returns:
  Current update sequence.

#### nodes

    Collection<ClusterNode> nodes(int p,
                                long topVer)

Parameters:
  `p` - Partition ID.
  `topVer` - Topology version.
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,
                           long 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.

#### onAdded

    GridDhtLocalPartition<K,V> onAdded(long topVer,
                                     GridDhtCacheEntry<K,V> e)

Parameters:
  `topVer` - Topology version.
  `e` - Entry added to cache.
Returns:
  Local partition.

#### onRemoved

    void onRemoved(GridDhtCacheEntry<K,V> e)

Parameters:
  `e` - Entry removed from cache.

#### update

    GridDhtPartitionMap update(@Nullable
                             GridDhtPartitionExchangeId exchId,
                             GridDhtPartitionFullMap partMap)

Parameters:
  `exchId` - Exchange ID.
  `partMap` - Update partition map.
Returns:
  Local partition map if there were evictions or `null` otherwise.

#### update

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

Parameters:
  `exchId` - Exchange ID.
  `parts` - Partitions.
Returns:
  Local partition map if there were evictions or `null` otherwise.

#### own

    boolean own(GridDhtLocalPartition<K,V> part)

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

#### onEvicted

    void onEvicted(GridDhtLocalPartition<K,V> part,
                 boolean updateSeq)

Parameters:
  `part` - Evicted partition.

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

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.0.0-RC1
Release Date | : February 17 2015