Public Member Functions | Static Public Attributes

GridClientPartitionAffinity Class Reference

#include <gridclientpartitionedaffinity.hpp>

Inheritance diagram for GridClientPartitionAffinity:
GridClientDataAffinity

List of all members.

Public Member Functions

 GridClientPartitionAffinity ()
virtual ~GridClientPartitionAffinity ()
virtual TGridClientNodePtr getNode (const TNodesSet &nodes, const GridClientHasheableObject &key)
int getDefaultReplicas () const
void setDefaultReplicas (int replicas)
int getKeyBackups () const
void setKeyBackups (int backups)
int getPartitions () const
void setPartitions (int parts)
const TGridClientNodePredicatePtr getBackupFilter ()
void setBackupFilter (const TGridClientNodePredicatePtr backupFilter)
std::string getReplicaCountAttributeName () const
void setReplicaCountAttributeName (const std::string &attrName)
GridHashIdResolver getHashIdResolver () const
void setHashIdResolver (GridHashIdResolver &hashIdResolver)
void checkRemoved (const GridClientNode &node)
int getReplicas (const GridClientNode &n)

Static Public Attributes

static const int DFLT_PARTITION_CNT = 10000
static const int DFLT_BACKUP_CNT = 1
static const int DFLT_REPLICA_CNT = 128
static const char * DFLT_REPLICA_CNT_ATTR_NAME = "gg:affinity:node:replicas"

Detailed Description

Affinity function for partitioned cache. This function supports the following configuration:


Constructor & Destructor Documentation

GridClientPartitionAffinity::GridClientPartitionAffinity (  ) 

Default constructor.

GridClientPartitionAffinity::~GridClientPartitionAffinity (  )  [virtual]

Vitrual destructor.


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:
n Node.
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.

const char * GridClientPartitionAffinity::DFLT_REPLICA_CNT_ATTR_NAME = "gg:affinity:node:replicas" [static]

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:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends