List of all members.
Detailed Description
Affinity function for partitioned cache. This function supports the following configuration:
-
backups - Use ths flag to control how many back up nodes will be assigned to every key. The default value is defined by DFLT_BACKUP_CNT.
-
replicas - Generally the more replicas a node gets, the more key assignments it will receive. You can configure different number of replicas for a node by setting user attribute with name getReplicaCountAttributeName() to some number. Default value is 512 defined by DFLT_REPLICA_CNT constant.
-
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.
Constructor & Destructor Documentation
| GridClientPartitionAffinity::GridClientPartitionAffinity |
( |
|
) |
|
| GridClientPartitionAffinity::~GridClientPartitionAffinity |
( |
|
) |
[virtual] |
Member Function Documentation
| void GridClientPartitionAffinity::checkRemoved |
( |
const GridClientNode & |
node |
) |
|
Cleans up removed nodes.
- Parameters:
-
| node | Node that was removed from topology. |
| const TGridClientNodePredicatePtr GridClientPartitionAffinity::getBackupFilter |
( |
|
) |
|
Gets optional backup filter. If not null, then primary nodes will be selected from all nodes outside of this filter, and backups will be selected from all nodes inside it.
- Returns:
- Optional backup filter.
| int GridClientPartitionAffinity::getDefaultReplicas |
( |
|
) |
const |
Gets default count of virtual replicas on the consistent hash ring.
To determine node replicas, node attribute with getReplicaCountAttributeName() name will be checked first. If it is absent, then this value will be used.
- Returns:
- Count of virtual replicas in consistent hash ring.
| GridHashIdResolver GridClientPartitionAffinity::getHashIdResolver |
( |
|
) |
const |
Gets function for defining ID for node hashing.
- Returns:
- Hash ID resolver function.
| int GridClientPartitionAffinity::getKeyBackups |
( |
|
) |
const |
Gets count of key backups for redundancy.
- Returns:
- Key backup count.
| TGridClientNodePtr GridClientPartitionAffinity::getNode |
( |
const TNodesSet & |
nodes, |
|
|
const GridClientHasheableObject & |
key | |
|
) |
| | [virtual] |
Maps the key to the primary node.
- Parameters:
-
| nodes | The set of nodes representing cache topology. |
| key | The key to be mapped to a node. |
- Returns:
- The affinity node for the given key.
Implements GridClientDataAffinity.
| int GridClientPartitionAffinity::getPartitions |
( |
|
) |
const |
Gets total number of key partitions. To ensure that all partitions are equally distributed across all nodes, please make sure that this number is significantly larger than a number of nodes. Also, partition size should be relatively small. Try to avoid having partitions with more than quarter million keys.
Note that for fully replicated caches this method should always return 1.
- Returns:
- Total partition count.
| std::string GridClientPartitionAffinity::getReplicaCountAttributeName |
( |
|
) |
const |
Gets optional attribute name for replica count. If not provided, the default is DFLT_REPLICA_CNT_ATTR_NAME.
- Returns:
- User attribute name for replica count for a node.
| int GridClientPartitionAffinity::getReplicas |
( |
const GridClientNode & |
n |
) |
|
- Parameters:
-
- Returns:
- Replicas.
| void GridClientPartitionAffinity::setBackupFilter |
( |
const TGridClientNodePredicatePtr |
backupFilter |
) |
|
Sets optional backup filter. 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.
- Parameters:
-
| backupFilter | Optional backup filter. |
| void GridClientPartitionAffinity::setDefaultReplicas |
( |
int |
replicas |
) |
|
Sets default count of virtual replicas in consistent hash ring.
To determine node replicas, node attribute with getReplicaCountAttributeName name will be checked first. If it is absent, then this value will be used.
- Parameters:
-
| replicas | Count of virtual replicas in consistent hash ring.s |
| void GridClientPartitionAffinity::setHashIdResolver |
( |
GridHashIdResolver & |
hashIdResolver |
) |
|
Sets function for defining ID for node hashing.
- Parameters:
-
| hashIdResolver | Hash ID resolver function. |
| void GridClientPartitionAffinity::setKeyBackups |
( |
int |
backups |
) |
|
Sets count of key backups for redundancy.
- Parameters:
-
| backups | Key backup count. |
| void GridClientPartitionAffinity::setPartitions |
( |
int |
parts |
) |
|
Sets total number of partitions.
- Parameters:
-
| parts | Total number of partitions. |
| void GridClientPartitionAffinity::setReplicaCountAttributeName |
( |
const std::string & |
attrName |
) |
|
Sets optional attribute name for replica count. If not provided, the default is DFLT_REPLICA_CNT_ATTR_NAME.
- Parameters:
-
| attrName | User attribute name for replica count for a node. |
Member Data Documentation
Default number of backups.
Default number of partitions.
Default replica count for partitioned caches.
Name of node attribute to specify number of replicas for a node. Default value is gg:affinity:node:replicas.
The documentation for this class was generated from the following files: