org.apache.ignite.internal.client.thin

## Class ClientCacheAffinityContext

- java.lang.Object
- - org.apache.ignite.internal.client.thin.ClientCacheAffinityContext

    public class ClientCacheAffinityContext
    extends Object

Client cache partition awareness context.

### Constructor Summary

Constructors
Constructor and Description
`ClientCacheAffinityContext(IgniteBinary binary, @Nullable ClientPartitionAwarenessMapperFactory factory)`

### Method Summary

All Methods Instance Methods Concrete Methods
`UUID` `affinityNode(int cacheId, int part)` Calculates affinity node for given cache and partition.
`UUID` `affinityNode(int cacheId, Object key)` Calculates affinity node for given cache and key.
`boolean` `affinityUpdateRequired(int cacheId)` Is affinity update required for given cache.
`protected ClientCacheAffinityMapping` `currentMapping()` Current affinity mapping.
`org.apache.ignite.internal.client.thin.ClientCacheAffinityContext.TopologyNodes` `lastTopology()` Gets last topology information.
`boolean` `readPartitionsUpdateResponse(org.apache.ignite.internal.client.thin.PayloadInputChannel ch)`
`void` `registerCache(String cacheName)`
`void` `reset(org.apache.ignite.internal.client.thin.ClientCacheAffinityContext.TopologyNodes top)` Resets affinity context.
`void` `unregisterCache(String cacheName)`
`boolean` `updateLastTopologyVersion(AffinityTopologyVersion topVer, UUID nodeId)` Update topology version if it's greater than current version and store nodes for last topology.
`void` `writePartitionsUpdateRequest(org.apache.ignite.internal.client.thin.PayloadOutputChannel ch)`

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

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

### Constructor Detail

#### ClientCacheAffinityContext

    public ClientCacheAffinityContext(IgniteBinary binary,
                                      @Nullable
                                      @Nullable ClientPartitionAwarenessMapperFactory factory)

Parameters:
  `binary` - Binary data processor.
  `factory` - Factory for caches with custom affinity.

### Method Detail

#### updateLastTopologyVersion

    public boolean updateLastTopologyVersion(AffinityTopologyVersion topVer,
                                             UUID nodeId)

Update topology version if it's greater than current version and store nodes for last topology.

Parameters:
  `topVer` - Topology version.
  `nodeId` - Node id.
Returns:
  `True` if last topology was updated to the new version.

#### affinityUpdateRequired

    public boolean affinityUpdateRequired(int cacheId)

Is affinity update required for given cache.

Parameters:
  `cacheId` - Cache id.

#### writePartitionsUpdateRequest

    public void writePartitionsUpdateRequest(org.apache.ignite.internal.client.thin.PayloadOutputChannel ch)

Parameters:
  `ch` - Payload output channel.

#### readPartitionsUpdateResponse

    public boolean readPartitionsUpdateResponse(org.apache.ignite.internal.client.thin.PayloadInputChannel ch)

Parameters:
  `ch` - Payload input channel.

#### lastTopology

    public org.apache.ignite.internal.client.thin.ClientCacheAffinityContext.TopologyNodes lastTopology()

Gets last topology information.

#### reset

    public void reset(org.apache.ignite.internal.client.thin.ClientCacheAffinityContext.TopologyNodes top)

Resets affinity context.

Parameters:
  `top` - Topology which triggers reset.

#### affinityNode

    public UUID affinityNode(int cacheId,
                             Object key)

Calculates affinity node for given cache and key.

Parameters:
  `cacheId` - Cache ID.
  `key` - Key.
Returns:
  Affinity node id or `null` if affinity node can't be determined for given cache and key.

#### affinityNode

    public UUID affinityNode(int cacheId,
                             int part)

Calculates affinity node for given cache and partition.

Parameters:
  `cacheId` - Cache ID.
  `part` - Partition.
Returns:
  Affinity node id or `null` if affinity node can't be determined for given cache and partition.

#### currentMapping

    protected ClientCacheAffinityMapping currentMapping()

Current affinity mapping.

#### registerCache

    public void registerCache(String cacheName)

Parameters:
  `cacheName` - Cache name.

#### unregisterCache

    public void unregisterCache(String cacheName)

Parameters:
  `cacheName` - Cache name.

${current.year} Copyright © Apache Software Foundation

Follow @ApacheIgnite

Ignite Database and Caching Platform | : ver. 2.16.0
Release Date | : December 15 2023