public class GridClientPartitionAffinity extends Object implements GridClientDataAffinity, GridClientTopologyListener
backupFilter - Optional filter for back up nodes. If provided, then only
nodes that pass this filter will be selected as backup nodes and only nodes that
don't pass this filter will be selected as primary nodes. If not provided, then
primary and backup nodes will be selected out of all nodes available for this cache.
NOTE: In situations where there are no primary nodes at all, i.e. no nodes for which backup
filter returns false, first backup node for the key will be considered primary.
| Modifier and Type | Class and Description |
|---|---|
static interface |
GridClientPartitionAffinity.HashIdResolver
This resolver is used to provide alternate hash ID, other than node ID.
|
| Modifier and Type | Field and Description |
|---|---|
static int |
DFLT_PARTITION_CNT
Default number of partitions.
|
| Constructor and Description |
|---|
GridClientPartitionAffinity()
Empty constructor with all defaults.
|
GridClientPartitionAffinity(Integer parts,
GridClientPredicate<UUID> backupFilter)
Initializes optional counts for replicas and backups.
|
| Modifier and Type | Method and Description |
|---|---|
GridClientPredicate<UUID> |
getBackupFilter()
Gets optional backup filter.
|
GridClientPartitionAffinity.HashIdResolver |
getHashIdResolver()
Gets hash ID resolver for nodes.
|
int |
getPartitions()
Gets total number of key partitions.
|
GridClientNode |
node(Object key,
Collection<? extends GridClientNode> nodes)
Gets primary affinity node for a key.
|
void |
onNodeAdded(GridClientNode node)
Callback for new nodes joining the remote grid.
|
void |
onNodeRemoved(GridClientNode node)
Callback for nodes leaving the remote grid.
|
GridClientPartitionAffinity |
setBackupFilter(GridClientPredicate<UUID> backupFilter)
Sets optional backup filter.
|
GridClientPartitionAffinity |
setHashIdResolver(GridClientPartitionAffinity.HashIdResolver hashIdRslvr)
Sets hash ID resolver for nodes.
|
GridClientPartitionAffinity |
setPartitions(int parts)
Sets total number of partitions.
|
String |
toString() |
public static final int DFLT_PARTITION_CNT
public GridClientPartitionAffinity()
public GridClientPartitionAffinity(Integer parts, GridClientPredicate<UUID> backupFilter)
Note that excludeNeighbors parameter is ignored if backupFilter is set.
parts - Total number of partitions. If null than DFLT_PARTITION_CNT will be used.backupFilter - Optional back up filter for nodes. If provided, then primary nodes
will be selected from all nodes outside of this filter, and backups will be selected
from all nodes inside it.public int getPartitions()
Note that for fully replicated caches this method should always
return 1.
public GridClientPartitionAffinity setPartitions(int parts)
parts - Total number of partitions.this for chaining.public GridClientPartitionAffinity.HashIdResolver getHashIdResolver()
Node IDs constantly change when nodes get restarted, which causes them to be placed on different locations in the hash ring, and hence causing repartitioning. Providing an alternate hash ID, which survives node restarts, puts node on the same location on the hash ring, hence minimizing required repartitioning.
public GridClientPartitionAffinity setHashIdResolver(GridClientPartitionAffinity.HashIdResolver hashIdRslvr)
Node IDs constantly change when nodes get restarted, which causes them to be placed on different locations in the hash ring, and hence causing repartitioning. Providing an alternate hash ID, which survives node restarts, puts node on the same location on the hash ring, hence minimizing required repartitioning.
hashIdRslvr - Hash ID resolver.this for chaining.public GridClientPredicate<UUID> getBackupFilter()
null, then primary nodes will be
selected from all nodes outside of this filter, and backups will be selected
from all nodes inside it.
Note that excludeNeighbors parameter is ignored if backupFilter is set.
public GridClientPartitionAffinity setBackupFilter(GridClientPredicate<UUID> backupFilter)
Note that excludeNeighbors parameter is ignored if backupFilter is set.
backupFilter - Optional backup filter.this for chaining.public GridClientNode node(Object key, Collection<? extends GridClientNode> nodes)
node in interface GridClientDataAffinitykey - Key to get affinity for.nodes - Nodes to choose from.public void onNodeAdded(GridClientNode node)
onNodeAdded in interface GridClientTopologyListenernode - New remote node.public void onNodeRemoved(GridClientNode node)
onNodeRemoved in interface GridClientTopologyListenernode - Left node.
Follow @ApacheIgnite
Ignite Database and Caching Platform : ver. 2.10.0 Release Date : March 10 2021