voldemort.cluster
Class Cluster

java.lang.Object
  extended by voldemort.cluster.Cluster
All Implemented Interfaces:
java.io.Serializable

public class Cluster
extends java.lang.Object
implements java.io.Serializable

A representation of the voldemort cluster

See Also:
Serialized Form

Constructor Summary
Cluster(java.lang.String name, java.util.List<Node> nodes)
           
Cluster(java.lang.String name, java.util.List<Node> nodes, java.util.List<Zone> zones)
           
 
Method Summary
static Cluster cloneCluster(Cluster cluster)
          Clones the cluster by constructing a new one with same name, partition layout, and nodes.
 boolean equals(java.lang.Object second)
           
 java.lang.String getName()
           
 Node getNodeById(int id)
           
 Node getNodeForPartitionId(int partitionId)
           
 java.util.Set<java.lang.Integer> getNodeIds()
           
 java.util.Set<java.lang.Integer> getNodeIdsInZone(java.lang.Integer zoneId)
           
 java.util.Collection<Node> getNodes()
           
 int getNumberOfNodes()
           
 int getNumberOfNodesInZone(java.lang.Integer zoneId)
           
 int getNumberOfPartitions()
           
 int getNumberOfPartitionsInZone(java.lang.Integer zoneId)
           
 int getNumberOfZones()
           
 java.util.Set<java.lang.Integer> getPartitionIdsInZone(java.lang.Integer zoneId)
           
 Node[] getPartitionIdToNodeArray()
           
 java.util.Map<java.lang.Integer,java.lang.Integer> getPartitionIdToNodeIdMap()
           
 Zone getZoneById(int id)
           
 Zone getZoneForPartitionId(int partitionId)
           
 java.util.Set<java.lang.Integer> getZoneIds()
           
 java.util.Collection<Zone> getZones()
           
 int hashCode()
           
 boolean hasNodeWithId(int nodeId)
          Given a cluster and a node id checks if the node exists
 java.lang.String toString()
           
 java.lang.String toString(boolean isDetailed)
          Return a detailed string representation of the current cluster
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Cluster

public Cluster(java.lang.String name,
               java.util.List<Node> nodes)

Cluster

public Cluster(java.lang.String name,
               java.util.List<Node> nodes,
               java.util.List<Zone> zones)
Method Detail

getName

public java.lang.String getName()

getNodes

public java.util.Collection<Node> getNodes()

getNodeIds

public java.util.Set<java.lang.Integer> getNodeIds()
Returns:
Sorted set of node Ids

getZoneIds

public java.util.Set<java.lang.Integer> getZoneIds()
Returns:
Sorted set of Zone Ids

getZones

public java.util.Collection<Zone> getZones()

getZoneById

public Zone getZoneById(int id)

getNumberOfZones

public int getNumberOfZones()

getNumberOfPartitionsInZone

public int getNumberOfPartitionsInZone(java.lang.Integer zoneId)

getNumberOfNodesInZone

public int getNumberOfNodesInZone(java.lang.Integer zoneId)

getNodeIdsInZone

public java.util.Set<java.lang.Integer> getNodeIdsInZone(java.lang.Integer zoneId)
Returns:
Sorted set of node Ids for given zone

getPartitionIdsInZone

public java.util.Set<java.lang.Integer> getPartitionIdsInZone(java.lang.Integer zoneId)
Returns:
Sorted set of partition Ids for given zone

getZoneForPartitionId

public Zone getZoneForPartitionId(int partitionId)

getNodeForPartitionId

public Node getNodeForPartitionId(int partitionId)

getPartitionIdToNodeArray

public Node[] getPartitionIdToNodeArray()

getPartitionIdToNodeIdMap

public java.util.Map<java.lang.Integer,java.lang.Integer> getPartitionIdToNodeIdMap()
Returns:
Map of partition id to node id.

getNodeById

public Node getNodeById(int id)

hasNodeWithId

public boolean hasNodeWithId(int nodeId)
Given a cluster and a node id checks if the node exists

Parameters:
nodeId - The node id to search for
Returns:
True if cluster contains the node id, else false

getNumberOfNodes

public int getNumberOfNodes()

getNumberOfPartitions

public int getNumberOfPartitions()

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

toString

public java.lang.String toString(boolean isDetailed)
Return a detailed string representation of the current cluster

Parameters:
isDetailed -
Returns:
descripton of cluster

cloneCluster

public static Cluster cloneCluster(Cluster cluster)
Clones the cluster by constructing a new one with same name, partition layout, and nodes.

Parameters:
cluster -
Returns:
clone of Cluster cluster.

equals

public boolean equals(java.lang.Object second)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object


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