org.apache.ignite.internal.processors.affinity

## Class GridAffinityFunctionContextImpl

- java.lang.Object
- - org.apache.ignite.internal.processors.affinity.GridAffinityFunctionContextImpl

All Implemented Interfaces:
  AffinityFunctionContext

    public class GridAffinityFunctionContextImpl
    extends Object
    implements AffinityFunctionContext

Cache affinity function context implementation. Simple bean that holds all required fields.

### Constructor Summary

Constructors
Constructor and Description
`GridAffinityFunctionContextImpl(List<ClusterNode> topSnapshot, List<List<ClusterNode>> prevAssignment, DiscoveryEvent discoEvt, AffinityTopologyVersion topVer, int backups)`

### Method Summary

Methods
`int` `backups()` Gets number of backups for new assignment.
`List<ClusterNode>` `currentTopologySnapshot()` Gets current topology snapshot.
`AffinityTopologyVersion` `currentTopologyVersion()` Gets current topology version number.
`DiscoveryEvent` `discoveryEvent()` Gets discovery event caused topology change.
`List<ClusterNode>` `previousAssignment(int part)` Gets affinity assignment for given partition on previous topology version.

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

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

### Constructor Detail

#### GridAffinityFunctionContextImpl

    public GridAffinityFunctionContextImpl(List<ClusterNode> topSnapshot,
                                   List<List<ClusterNode>> prevAssignment,
                                   DiscoveryEvent discoEvt,
                                   @NotNull
                                   AffinityTopologyVersion topVer,
                                   int backups)

Parameters:
  `topSnapshot` - Topology snapshot.
  `topVer` - Topology version.

### Method Detail

#### previousAssignment

    @Nullable
    public List<ClusterNode> previousAssignment(int part)

Gets affinity assignment for given partition on previous topology version. First node in returned list is a primary node, other nodes are backups.

Specified by:
  `previousAssignment` in interface `AffinityFunctionContext`
Parameters:
  `part` - Partition to get previous assignment for.
Returns:
  List of nodes assigned to given partition on previous topology version or `null` if this information is not available.

#### currentTopologySnapshot

    public List<ClusterNode> currentTopologySnapshot()

Gets current topology snapshot. Snapshot will contain only nodes on which particular cache is configured. List of passed nodes is guaranteed to be sorted in a same order on all nodes on which partition assignment is performed.

Specified by:
  `currentTopologySnapshot` in interface `AffinityFunctionContext`
Returns:
  Cache topology snapshot.

#### currentTopologyVersion

    public AffinityTopologyVersion currentTopologyVersion()

Gets current topology version number.

Specified by:
  `currentTopologyVersion` in interface `AffinityFunctionContext`
Returns:
  Current topology version number.

#### discoveryEvent

    @Nullable
    public DiscoveryEvent discoveryEvent()

Gets discovery event caused topology change.

Specified by:
  `discoveryEvent` in interface `AffinityFunctionContext`
Returns:
  Discovery event caused latest topology change or `null` if this information is not available.

#### backups

    public int backups()

Gets number of backups for new assignment.

Specified by:
  `backups` in interface `AffinityFunctionContext`
Returns:
  Number of backups for new assignment.

2015 Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Fabric | : ver. 1.5.0.final
Release Date | : December 29 2015