Public Member Functions

GridClientConsistentHashImpl Class Reference

#include <gridconsistenhashimpl.hpp>

List of all members.

Public Member Functions

 GridClientConsistentHashImpl ()
virtual ~GridClientConsistentHashImpl ()
virtual void addNode (const NodeInfo &node, int replicas)
virtual void removeNode (const NodeInfo &node)
virtual std::set< NodeInfo > getNodes () const
virtual NodeInfo node (const GridClientHasheableObject &value, const std::set< NodeInfo > &inc) const
size_t nodesSize () const
size_t circlesSize () const
void clear ()
int32_t hash (const GridClientHasheableObject &key) const

Detailed Description

Implementation of GridClientConsistentHash.


Constructor & Destructor Documentation

GridClientConsistentHashImpl::GridClientConsistentHashImpl (  ) 

Default constructor.

virtual GridClientConsistentHashImpl::~GridClientConsistentHashImpl (  )  [inline, virtual]

Destructor.


Member Function Documentation

void GridClientConsistentHashImpl::addNode ( const NodeInfo &  node,
int  replicas 
) [virtual]

Adds a node to consistent hash algorithm.

Parameters:
node New node (if null then no-op).
replicas Number of replicas for the node.
Returns:
True if node was added, false if it is null or is already contained in the hash.
size_t GridClientConsistentHashImpl::circlesSize (  )  const [inline]

Gets the total elements in the cycle.

Returns:
The count of elements in the circle.
void GridClientConsistentHashImpl::clear (  )  [inline]

Removes all the nodes and their replicas from the ring.

std::set< NodeInfo > GridClientConsistentHashImpl::getNodes (  )  const [virtual]

Gets set of all distinct nodes in the consistent hash (in no particular order).

Returns:
Set of all distinct nodes in the consistent hash.
int32_t GridClientConsistentHashImpl::hash ( const GridClientHasheableObject &  key  )  const

Calculates hash for a hashable object.

Parameters:
key Object to calculate hash for.
Returns:
Hash code.
NodeInfo GridClientConsistentHashImpl::node ( const GridClientHasheableObject &  value,
const std::set< NodeInfo > &  inc 
) const [virtual]

Gets node for a key.

Parameters:
key Key.
inc Node IDs to include.
Returns:
Node.
size_t GridClientConsistentHashImpl::nodesSize (  )  const [inline]

Gets the total of the unique nodes.

Returns:
The count of unique nodes.
void GridClientConsistentHashImpl::removeNode ( const NodeInfo &  node  )  [virtual]

Removes a node and all of its replicas.

Parameters:
node Node to remove.

The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends