voldemort.routing
Class ConsistentRoutingStrategy

java.lang.Object
  extended by voldemort.routing.ConsistentRoutingStrategy
All Implemented Interfaces:
RoutingStrategy
Direct Known Subclasses:
ZoneRoutingStrategy

public class ConsistentRoutingStrategy
extends java.lang.Object
implements RoutingStrategy

A Routing strategy that routes each request to the first N nodes where N is a user defined replication factor. The mapping is computed by creating partitions of a fixed size, and maintaining a mapping from partition tag to Node. These nodes are mapped onto a ring. A preference list of nodes to route to is created by taking the partition into which the key hashes, and then taking the next N nodes on the ring.


Constructor Summary
ConsistentRoutingStrategy(java.util.Collection<Node> nodes, int numReplicas)
           
ConsistentRoutingStrategy(HashFunction hash, java.util.Collection<Node> nodes, int numReplicas)
           
 
Method Summary
 java.lang.Integer getMasterPartition(byte[] key)
          Obtain the master partition for a given key
 java.util.Set<Node> getNodes()
          Get the collection of nodes that are candidates for routing.
 int getNumReplicas()
          Return the number of replicas
 java.util.List<java.lang.Integer> getPartitionList(byte[] key)
          Get the partition list for the given key.
 Node[] getPartitionToNode()
           
 java.util.List<java.lang.Integer> getReplicatingPartitionList(int index)
          Get the replication partitions list for the given partition.
 java.lang.String getType()
          Get the type of RoutingStrategyType
 java.util.List<Node> routeRequest(byte[] key)
          Get the node preference list for the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConsistentRoutingStrategy

public ConsistentRoutingStrategy(java.util.Collection<Node> nodes,
                                 int numReplicas)

ConsistentRoutingStrategy

public ConsistentRoutingStrategy(HashFunction hash,
                                 java.util.Collection<Node> nodes,
                                 int numReplicas)
Method Detail

getNumReplicas

public int getNumReplicas()
Description copied from interface: RoutingStrategy
Return the number of replicas

Specified by:
getNumReplicas in interface RoutingStrategy
Returns:
The number of replicas

getPartitionToNode

public Node[] getPartitionToNode()

routeRequest

public java.util.List<Node> routeRequest(byte[] key)
Description copied from interface: RoutingStrategy
Get the node preference list for the given key. The preference list is a list of nodes to perform an operation on.

Specified by:
routeRequest in interface RoutingStrategy
Parameters:
key - The key the operation is operating on
Returns:
The preference list for the given key

getReplicatingPartitionList

public java.util.List<java.lang.Integer> getReplicatingPartitionList(int index)
Description copied from interface: RoutingStrategy
Get the replication partitions list for the given partition.

Specified by:
getReplicatingPartitionList in interface RoutingStrategy
Returns:
The List of partitionId where this partition is replicated.

getMasterPartition

public java.lang.Integer getMasterPartition(byte[] key)
Obtain the master partition for a given key

Specified by:
getMasterPartition in interface RoutingStrategy
Parameters:
key -
Returns:

getNodes

public java.util.Set<Node> getNodes()
Description copied from interface: RoutingStrategy
Get the collection of nodes that are candidates for routing.

Specified by:
getNodes in interface RoutingStrategy
Returns:
The collection of nodes

getPartitionList

public java.util.List<java.lang.Integer> getPartitionList(byte[] key)
Description copied from interface: RoutingStrategy
Get the partition list for the given key.

Specified by:
getPartitionList in interface RoutingStrategy
Parameters:
key - The key the operation is operating on
Returns:
The partition list for the given key

getType

public java.lang.String getType()
Description copied from interface: RoutingStrategy
Get the type of RoutingStrategyType

Specified by:
getType in interface RoutingStrategy
Returns:
RoutingStrategyType


Jay Kreps, Roshan Sumbaly, Alex Feinberg, Bhupesh Bansal, Lei Gao, Chinmay Soman, Vinoth Chandar, Zhongjie Wu