voldemort.utils
Class PartitionBalanceUtils

java.lang.Object
  extended by voldemort.utils.PartitionBalanceUtils

public class PartitionBalanceUtils
extends java.lang.Object

PartitionBalanceUtils provides helper methods for interpreting, analyzing, and printing partition information. Most of these helper methods take one Cluster object, and possibly some other minor, simple arguments. The Cluster object defines the partition layout which is being interpreted/analzyed/printed.


Constructor Summary
PartitionBalanceUtils()
           
 
Method Summary
static java.lang.String analyzeInvalidMetadataRate(Cluster currentCluster, java.util.List<StoreDefinition> currentStoreDefs, Cluster finalCluster, java.util.List<StoreDefinition> finalStoreDefs)
          Compares current cluster with final cluster.
static java.lang.String compressedListOfPartitionsInZone(Cluster cluster, int zoneId)
          Compress contiguous partitions into format "e-i" instead of "e, f, g, h, i".
static java.lang.String getHotPartitionsDueToContiguity(Cluster cluster, int hotContiguityCutoff)
          Returns a pretty printed string of nodes that host specific "hot" partitions, where hot is defined as following a contiguous run of partitions of some length in another zone.
static java.util.Map<java.lang.Integer,java.lang.Integer> getMapOfContiguousPartitionRunLengths(Cluster cluster, int zoneId)
          Determines a histogram of contiguous runs of partitions within a zone.
static java.util.Map<java.lang.Integer,java.lang.Integer> getMapOfContiguousPartitions(Cluster cluster, int zoneId)
          Determines run length for each 'initial' partition ID.
static java.lang.String getPrettyMapOfContiguousPartitionRunLengths(Cluster cluster, int zoneId)
          Pretty prints the output of getMapOfContiguousPartitionRunLengths
static java.lang.String verboseClusterDump(Cluster cluster)
          Prints the details of cluster xml in various formats.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PartitionBalanceUtils

public PartitionBalanceUtils()
Method Detail

compressedListOfPartitionsInZone

public static java.lang.String compressedListOfPartitionsInZone(Cluster cluster,
                                                                int zoneId)
Compress contiguous partitions into format "e-i" instead of "e, f, g, h, i". This helps illustrate contiguous partitions within a zone.

Parameters:
cluster -
zoneId -
Returns:
pretty string of partitions per zone

getMapOfContiguousPartitions

public static java.util.Map<java.lang.Integer,java.lang.Integer> getMapOfContiguousPartitions(Cluster cluster,
                                                                                              int zoneId)
Determines run length for each 'initial' partition ID. Note that a contiguous run may "wrap around" the end of the ring.

Parameters:
cluster -
zoneId -
Returns:
map of initial partition Id to length of contiguous run of partition IDs within the same zone..

getMapOfContiguousPartitionRunLengths

public static java.util.Map<java.lang.Integer,java.lang.Integer> getMapOfContiguousPartitionRunLengths(Cluster cluster,
                                                                                                       int zoneId)
Determines a histogram of contiguous runs of partitions within a zone. I.e., for each run length of contiguous partitions, how many such runs are there. Does not correctly address "wrap around" of partition IDs (i.e., the fact that partition ID 0 is "next" to partition ID 'max')

Parameters:
cluster -
zoneId -
Returns:
map of length of contiguous run of partitions to count of number of such runs.

getPrettyMapOfContiguousPartitionRunLengths

public static java.lang.String getPrettyMapOfContiguousPartitionRunLengths(Cluster cluster,
                                                                           int zoneId)
Pretty prints the output of getMapOfContiguousPartitionRunLengths

Parameters:
cluster -
zoneId -
Returns:
pretty string of contiguous run lengths

getHotPartitionsDueToContiguity

public static java.lang.String getHotPartitionsDueToContiguity(Cluster cluster,
                                                               int hotContiguityCutoff)
Returns a pretty printed string of nodes that host specific "hot" partitions, where hot is defined as following a contiguous run of partitions of some length in another zone.

Parameters:
cluster - The cluster to analyze
hotContiguityCutoff - cutoff below which a contiguous run is not hot.
Returns:
pretty string of hot partitions

verboseClusterDump

public static java.lang.String verboseClusterDump(Cluster cluster)
Prints the details of cluster xml in various formats. Some information is repeated in different forms. This is intentional so that it is easy to find the specific view of the cluster xml that you want.

Parameters:
cluster -
Returns:
pretty string of cluster balance

analyzeInvalidMetadataRate

public static java.lang.String analyzeInvalidMetadataRate(Cluster currentCluster,
                                                          java.util.List<StoreDefinition> currentStoreDefs,
                                                          Cluster finalCluster,
                                                          java.util.List<StoreDefinition> finalStoreDefs)
Compares current cluster with final cluster. Uses pertinent store defs for each cluster to determine if a node that hosts a zone-primary in the current cluster will no longer host any zone-nary in the final cluster. This check is the precondition for a server returning an invalid metadata exception to a client on a normal-case put or get. Normal-case being that the zone-primary receives the pseudo-master put or the get operation.

Parameters:
currentCluster -
currentStoreDefs -
finalCluster -
finalStoreDefs -
Returns:
pretty-printed string documenting invalid metadata rates for each zone.


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