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

## Class GridClientPartitionTopology

- java.lang.Object
- - org.apache.ignite.internal.processors.cache.distributed.dht.GridClientPartitionTopology

All Implemented Interfaces:
  GridDhtPartitionTopology

    @GridToStringExclude
    public class GridClientPartitionTopology
    extends Object
    implements GridDhtPartitionTopology

Partition topology for node which does not have any local partitions.

### Constructor Summary

Constructors
Constructor and Description
`GridClientPartitionTopology(GridCacheSharedContext cctx, int cacheId, GridDhtPartitionsExchangeFuture exchFut)`

### Method Summary

Methods
`boolean` `afterExchange(GridDhtPartitionsExchangeFuture exchFut)` Post-initializes this topology.
`void` `beforeExchange(GridDhtPartitionsExchangeFuture exchFut)` Pre-initializes this topology.
`int` `cacheId()`
`Collection<GridDhtLocalPartition>` `currentLocalPartitions()`
`long` `lastUpdateSequence()`
`GridDhtLocalPartition` `localPartition(int p, AffinityTopologyVersion topVer, boolean create)`
`GridDhtLocalPartition` `localPartition(Object key, boolean create)`
`GridDhtPartitionMap` `localPartitionMap()`
`List<GridDhtLocalPartition>` `localPartitions()`
`List<ClusterNode>` `moving(int p)`
`Collection<ClusterNode>` `nodes(int p, AffinityTopologyVersion topVer)`
`GridDhtLocalPartition` `onAdded(AffinityTopologyVersion topVer, GridDhtCacheEntry e)`
`void` `onEvicted(GridDhtLocalPartition part, boolean updateSeq)`
`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)`
`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 `GridDhtPartitionTopology.readLock()` method.
`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.
`GridDhtPartitionMap` `update(GridDhtPartitionExchangeId exchId, GridDhtPartitionFullMap partMap)`
`GridDhtPartitionMap` `update(GridDhtPartitionExchangeId exchId, GridDhtPartitionMap parts)`
`long` `updateSequence()`
`void` `updateTopologyVersion(GridDhtPartitionExchangeId exchId, GridDhtPartitionsExchangeFuture exchFut, long updSeq, boolean stopping)` Updates topology version.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### GridClientPartitionTopology

    public GridClientPartitionTopology(GridCacheSharedContext cctx,
                               int cacheId,
                               GridDhtPartitionsExchangeFuture exchFut)

Parameters:
  `cctx` - Context.
  `cacheId` - Cache ID.
  `exchFut` - Exchange ID.

### Method Detail

#### cacheId

    public int cacheId()

Returns:
  Cache ID.

#### readLock

    public void readLock()

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

Specified by:
  `readLock` in interface `GridDhtPartitionTopology`

#### readUnlock

    public void readUnlock()

Unlocks topology locked by `GridDhtPartitionTopology.readLock()` method.

Specified by:
  `readUnlock` in interface `GridDhtPartitionTopology`

#### updateTopologyVersion

    public void updateTopologyVersion(GridDhtPartitionExchangeId exchId,
                             GridDhtPartitionsExchangeFuture exchFut,
                             long updSeq,
                             boolean stopping)

Updates topology version.

Specified by:
  `updateTopologyVersion` in interface `GridDhtPartitionTopology`
Parameters:
  `exchId` - Exchange ID.
  `exchFut` - Exchange future.

#### topologyVersion

    public AffinityTopologyVersion topologyVersion()

Topology version.

Specified by:
  `topologyVersion` in interface `GridDhtPartitionTopology`
Returns:
  Topology version.

#### topologyVersionFuture

    public GridDhtTopologyFuture topologyVersionFuture()

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

Specified by:
  `topologyVersionFuture` in interface `GridDhtPartitionTopology`
Returns:
  Topology version ready future.

#### stopping

    public boolean stopping()

Specified by:
  `stopping` in interface `GridDhtPartitionTopology`
Returns:
  `True` if cache is being stopped.

#### beforeExchange

    public void beforeExchange(GridDhtPartitionsExchangeFuture exchFut)

Pre-initializes this topology.

Specified by:
  `beforeExchange` in interface `GridDhtPartitionTopology`
Parameters:
  `exchFut` - Exchange future.

#### afterExchange

    public boolean afterExchange(GridDhtPartitionsExchangeFuture exchFut)
                          throws IgniteCheckedException

Post-initializes this topology.

Specified by:
  `afterExchange` in interface `GridDhtPartitionTopology`
Parameters:
  `exchFut` - Exchange future.
Returns:
  `True` if mapping was changed.
Throws:
  `IgniteCheckedException` - If failed.

#### localPartition

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

Specified by:
  `localPartition` in interface `GridDhtPartitionTopology`
Parameters:
  `p` - Partition ID.
  `topVer` - Topology version at the time of creation.
  `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

    public GridDhtLocalPartition localPartition(Object key,
                                       boolean create)

Specified by:
  `localPartition` in interface `GridDhtPartitionTopology`
Parameters:
  `key` - Cache key.
  `create` - If `true`, then partition will be created if it's not there.
Returns:
  Local partition.

#### localPartitions

    public List<GridDhtLocalPartition> localPartitions()

Specified by:
  `localPartitions` in interface `GridDhtPartitionTopology`
Returns:
  All local partitions by copying them into another list.

#### currentLocalPartitions

    public Collection<GridDhtLocalPartition> currentLocalPartitions()

Specified by:
  `currentLocalPartitions` in interface `GridDhtPartitionTopology`
Returns:
  All current local partitions.

#### onAdded

    public GridDhtLocalPartition onAdded(AffinityTopologyVersion topVer,
                                GridDhtCacheEntry e)

Specified by:
  `onAdded` in interface `GridDhtPartitionTopology`
Parameters:
  `topVer` - Topology version.
  `e` - Entry added to cache.
Returns:
  Local partition.

#### onRemoved

    public void onRemoved(GridDhtCacheEntry e)

Specified by:
  `onRemoved` in interface `GridDhtPartitionTopology`
Parameters:
  `e` - Entry removed from cache.

#### localPartitionMap

    public GridDhtPartitionMap localPartitionMap()

Specified by:
  `localPartitionMap` in interface `GridDhtPartitionTopology`
Returns:
  Local IDs.

#### nodes

    public Collection<ClusterNode> nodes(int p,
                                AffinityTopologyVersion topVer)

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

#### owners

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

Specified by:
  `owners` in interface `GridDhtPartitionTopology`
Parameters:
  `p` - Partition ID.
  `topVer` - Topology version.
Returns:
  Collection of all nodes who `own` this partition.

#### owners

    public List<ClusterNode> owners(int p)

Specified by:
  `owners` in interface `GridDhtPartitionTopology`
Parameters:
  `p` - Partition ID.
Returns:
  Collection of all nodes who `own` this partition.

#### moving

    public List<ClusterNode> moving(int p)

Specified by:
  `moving` in interface `GridDhtPartitionTopology`
Parameters:
  `p` - Partition ID.
Returns:
  Collection of all nodes who `are preloading` this partition.

#### updateSequence

    public long updateSequence()

Specified by:
  `updateSequence` in interface `GridDhtPartitionTopology`
Returns:
  Current update sequence.

#### lastUpdateSequence

    public long lastUpdateSequence()

Returns:
  Last update sequence.

#### partitionMap

    public GridDhtPartitionFullMap partitionMap(boolean onlyActive)

Specified by:
  `partitionMap` in interface `GridDhtPartitionTopology`
Parameters:
  `onlyActive` - If `true`, then only `active` partitions will be returned.
Returns:
  Node IDs mapped to partitions.

#### update

    @Nullable
    public GridDhtPartitionMap update(@Nullable
                                      GridDhtPartitionExchangeId exchId,
                                      GridDhtPartitionFullMap partMap)

Specified by:
  `update` in interface `GridDhtPartitionTopology`
Parameters:
  `exchId` - Exchange ID.
  `partMap` - Update partition map.
Returns:
  Local partition map if there were evictions or `null` otherwise.

#### update

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

Specified by:
  `update` in interface `GridDhtPartitionTopology`
Parameters:
  `exchId` - Exchange ID.
  `parts` - Partitions.
Returns:
  Local partition map if there were evictions or `null` otherwise.

#### own

    public boolean own(GridDhtLocalPartition part)

Specified by:
  `own` in interface `GridDhtPartitionTopology`
Parameters:
  `part` - Partition to own.
Returns:
  `True` if owned.

#### onEvicted

    public void onEvicted(GridDhtLocalPartition part,
                 boolean updateSeq)

Specified by:
  `onEvicted` in interface `GridDhtPartitionTopology`
Parameters:
  `part` - Evicted partition.

#### partitions

    @Nullable
    public GridDhtPartitionMap partitions(UUID nodeId)

Specified by:
  `partitions` in interface `GridDhtPartitionTopology`
Parameters:
  `nodeId` - Node to get partitions for.
Returns:
  Partitions for node.

#### printMemoryStats

    public void printMemoryStats(int threshold)

Prints memory stats.

Specified by:
  `printMemoryStats` in interface `GridDhtPartitionTopology`
Parameters:
  `threshold` - Threshold for number of entries.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.1.0-incubating
Release Date | : May 20 2015