voldemort.routing
Class BaseStoreRoutingPlan

java.lang.Object
  extended by voldemort.routing.BaseStoreRoutingPlan

public class BaseStoreRoutingPlan
extends java.lang.Object

This class wraps up a Cluster object and a StoreDefinition. The methods are effectively helper or util style methods for querying the routing plan that will be generated for a given routing strategy upon store and cluster topology information. This object may be constructed in the fast path (e.g., during proxy'ing) and so this object must be fast/simple to construct. Invocations of getters to find replica lists and n-aries can be O(number of replicas). The intermingling of key-based interfaces and partition-based interfaces is ugly in this class. Partition-based interfaces should be in an underlying class and then key-based interfaces should wrap those up. Or, all of these types of class should implement the getMasterPartition(byte[]) interface from RoutingStrategy. Then the caller always does translation from key to partition ID, and the *StoreRouting* classes only offer partition-based interfaces.


Constructor Summary
BaseStoreRoutingPlan(Cluster cluster, StoreDefinition storeDefinition)
           
 
Method Summary
 Cluster getCluster()
           
 int getMasterPartitionId(byte[] key)
          Determines master partition ID for the key.
 int getNodeIdForZoneNary(int zoneId, int zoneNary, byte[] key)
          Given a key and a zoneNary (< zone replication factor), figure out the node that contains the key as the nth replica in the given zone.
 java.util.List<java.lang.Integer> getReplicationNodeList(byte[] key)
          Determines the list of nodes that the key replicates to
 StoreDefinition getStoreDefinition()
           
 int getZoneNAry(int zoneId, int nodeId, byte[] key)
          Given a key that belong to a given node, returns a number n (< zone replication factor), such that the given node holds the key as the nth replica of the given zone eg: if the method returns 1, then given node hosts the key as the zone secondary in the given zone
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BaseStoreRoutingPlan

public BaseStoreRoutingPlan(Cluster cluster,
                            StoreDefinition storeDefinition)
Method Detail

getCluster

public Cluster getCluster()

getStoreDefinition

public StoreDefinition getStoreDefinition()

getMasterPartitionId

public int getMasterPartitionId(byte[] key)
Determines master partition ID for the key.

Parameters:
key -
Returns:
master parition id

getZoneNAry

public int getZoneNAry(int zoneId,
                       int nodeId,
                       byte[] key)
Given a key that belong to a given node, returns a number n (< zone replication factor), such that the given node holds the key as the nth replica of the given zone eg: if the method returns 1, then given node hosts the key as the zone secondary in the given zone

Parameters:
zoneId -
nodeId -
key -
Returns:
zone n-ary level for key hosted on node id in zone id.

getNodeIdForZoneNary

public int getNodeIdForZoneNary(int zoneId,
                                int zoneNary,
                                byte[] key)
Given a key and a zoneNary (< zone replication factor), figure out the node that contains the key as the nth replica in the given zone.

Parameters:
zoneId -
zoneNary -
key -
Returns:
node id that hosts zone n-ary replica for the key

getReplicationNodeList

public java.util.List<java.lang.Integer> getReplicationNodeList(byte[] key)
Determines the list of nodes that the key replicates to

Parameters:
key -
Returns:
list of nodes that key replicates to


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