|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectvoldemort.utils.RebalanceUtils
public class RebalanceUtils
RebalanceUtils provide basic functionality for rebalancing.
Field Summary | |
---|---|
static java.util.List<java.lang.String> |
canRebalanceList
|
static java.lang.String |
currentClusterFileName
|
static java.lang.String |
finalClusterFileName
|
static java.lang.String |
finalStoresFileName
|
Constructor Summary | |
---|---|
RebalanceUtils()
|
Method Summary | |
---|---|
static int |
countTaskStores(java.util.List<RebalanceTaskInfo> infos)
|
static java.util.concurrent.ExecutorService |
createExecutors(int numThreads)
|
static Cluster |
dropZone(Cluster intermediateCluster,
int dropZoneId)
Given a interim cluster with a previously vacated zone, constructs a new cluster object with the drop zone completely removed |
static java.util.List<StoreDefinition> |
dropZone(java.util.List<StoreDefinition> currentStoreDefs,
int dropZoneId)
Similar to vacateZone(Cluster, int) , takes the
current store definitions in the cluster and creates store definitions
with the specified zone effectively dropped. |
static void |
dumpAnalysisToFile(java.lang.String outputDirName,
java.lang.String baseFileName,
PartitionBalance partitionBalance)
Prints a balance analysis to a file. |
static void |
dumpClusters(Cluster currentCluster,
Cluster finalCluster,
java.lang.String outputDirName)
Given the current and final cluster dumps it into the output directory |
static void |
dumpClusters(Cluster currentCluster,
Cluster finalCluster,
java.lang.String outputDirName,
java.lang.String filePrefix)
Given the initial and final cluster dumps it into the output directory |
static void |
dumpClusterToFile(java.lang.String outputDirName,
java.lang.String fileName,
Cluster cluster)
Prints a cluster xml to a file. |
static void |
dumpPlanToFile(java.lang.String outputDirName,
RebalancePlan plan)
Prints the plan to a file. |
static void |
dumpStoreDefsToFile(java.lang.String outputDirName,
java.lang.String fileName,
java.util.List<StoreDefinition> storeDefs)
Prints a stores xml to a file. |
static void |
executorShutDown(java.util.concurrent.ExecutorService executorService,
long timeOutSec)
Wait to shutdown service |
static java.util.List<RebalanceTaskInfo> |
filterTaskPlanWithStores(java.util.List<RebalanceTaskInfo> existingPlanList,
java.util.List<StoreDefinition> storeDefs)
Given a list of partition plans and a set of stores, copies the store names to every individual plan and creates a new list |
static Cluster |
getInterimCluster(Cluster currentCluster,
Cluster finalCluster)
Given the current cluster and final cluster, generates an interim cluster with empty new nodes (and zones). |
static java.util.List<java.lang.Integer> |
getStolenPrimaryPartitions(Cluster currentCluster,
Cluster finalCluster,
int stealNodeId)
For a particular stealer node find all the primary partitions tuples it will steal. |
static java.util.HashMap<java.lang.Integer,java.util.List<RebalanceTaskInfo>> |
groupPartitionsTaskByNode(java.util.List<RebalanceTaskInfo> rebalanceTaskPlanList,
boolean groupByStealerNode)
Given a list of partition infos, generates a map of stealer / donor node to list of partition infos |
static void |
printBatchLog(int batchId,
org.apache.log4j.Logger logger,
java.lang.String message)
Print log to the following logger ( Info level ) |
static void |
printBatchTaskLog(int batchId,
int taskId,
org.apache.log4j.Logger logger,
java.lang.String message)
Print log to the following logger ( Info level ) |
static void |
printErrorLog(int taskId,
org.apache.log4j.Logger logger,
java.lang.String message,
java.lang.Exception e)
Print log to the following logger ( Error level ) |
static Cluster |
vacateZone(Cluster currentCluster,
int dropZoneId)
Given the current cluster and a zone id that needs to be dropped, this method will remove all partitions from the zone that is being dropped and move it to the existing zones. |
static void |
validateClusterNodeCounts(Cluster lhs,
Cluster rhs)
Confirms that both clusters have the same number of nodes by comparing set of node Ids between clusters. |
static void |
validateClusterNodeState(Cluster subsetCluster,
Cluster supersetCluster)
Confirms that any nodes from supersetCluster that are in subsetCluster have the same state (i.e., node id, host name, and ports). |
static void |
validateClusterPartitionCounts(Cluster lhs,
Cluster rhs)
Confirms that both clusters have the same number of total partitions. |
static void |
validateClusterPartitionState(Cluster subsetCluster,
Cluster supersetCluster)
Confirm that all nodes shared between clusters host exact same partition IDs and that nodes only in the super set cluster have no partition IDs. |
static void |
validateClusterStores(Cluster cluster,
java.util.List<StoreDefinition> storeDefs)
Verify store definitions are congruent with cluster definition. |
static void |
validateClusterZonesSame(Cluster lhs,
Cluster rhs)
Confirms that both clusters have the same set of zones defined. |
static void |
validateCurrentFinalCluster(Cluster currentCluster,
Cluster finalCluster)
A final cluster ought to be a super set of current cluster. |
static void |
validateCurrentInterimCluster(Cluster currentCluster,
Cluster interimCluster)
An interim cluster ought to be a super set of current cluster. |
static void |
validateInterimFinalCluster(Cluster interimCluster,
Cluster finalCluster)
Interim and final clusters ought to have same partition counts, same zones, and same node state. |
static java.util.List<StoreDefinition> |
validateRebalanceStore(java.util.List<StoreDefinition> storeDefList)
Given a list of store definitions, makes sure that rebalance supports all of them. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final java.util.List<java.lang.String> canRebalanceList
public static final java.lang.String currentClusterFileName
public static final java.lang.String finalClusterFileName
public static final java.lang.String finalStoresFileName
Constructor Detail |
---|
public RebalanceUtils()
Method Detail |
---|
public static void validateClusterStores(Cluster cluster, java.util.List<StoreDefinition> storeDefs)
cluster
- storeDefs
- public static void validateCurrentFinalCluster(Cluster currentCluster, Cluster finalCluster)
currentCluster
- finalCluster
- public static void validateCurrentInterimCluster(Cluster currentCluster, Cluster interimCluster)
currentCluster
- interimCluster
- public static void validateInterimFinalCluster(Cluster interimCluster, Cluster finalCluster)
interimCluster
- finalCluster
- public static void validateClusterPartitionCounts(Cluster lhs, Cluster rhs)
lhs
- rhs
- public static void validateClusterPartitionState(Cluster subsetCluster, Cluster supersetCluster)
subsetCluster
- supersetCluster
- public static void validateClusterZonesSame(Cluster lhs, Cluster rhs)
lhs
- rhs
- public static void validateClusterNodeCounts(Cluster lhs, Cluster rhs)
lhs
- rhs
- public static void validateClusterNodeState(Cluster subsetCluster, Cluster supersetCluster)
subsetCluster
- supersetCluster
- public static Cluster getInterimCluster(Cluster currentCluster, Cluster finalCluster)
currentCluster
- Current cluster metadatafinalCluster
- Final cluster metadata
public static Cluster vacateZone(Cluster currentCluster, int dropZoneId)
currentCluster
- Current cluster metadata
public static Cluster dropZone(Cluster intermediateCluster, int dropZoneId)
intermediateCluster
- dropZoneId
-
public static java.util.List<StoreDefinition> dropZone(java.util.List<StoreDefinition> currentStoreDefs, int dropZoneId)
vacateZone(Cluster, int)
, takes the
current store definitions in the cluster and creates store definitions
with the specified zone effectively dropped.
In order to drop a zone, we adjust the total replication factor and
remove zone replication factor for the dropped zone
currentStoreDefs
- dropZoneId
-
public static java.util.List<java.lang.Integer> getStolenPrimaryPartitions(Cluster currentCluster, Cluster finalCluster, int stealNodeId)
currentCluster
- The cluster definition of the existing clusterfinalCluster
- The final cluster definitionstealNodeId
- Node id of the stealer node
public static void printBatchLog(int batchId, org.apache.log4j.Logger logger, java.lang.String message)
batchId
- Task idlogger
- Logger classmessage
- The message to printpublic static void printBatchTaskLog(int batchId, int taskId, org.apache.log4j.Logger logger, java.lang.String message)
batchId
- taskId
- logger
- message
- public static void printErrorLog(int taskId, org.apache.log4j.Logger logger, java.lang.String message, java.lang.Exception e)
taskId
- Stealer node idlogger
- Logger classmessage
- The message to printpublic static java.util.List<StoreDefinition> validateRebalanceStore(java.util.List<StoreDefinition> storeDefList)
storeDefList
- List of store definitions
public static void dumpClusters(Cluster currentCluster, Cluster finalCluster, java.lang.String outputDirName, java.lang.String filePrefix)
currentCluster
- Initial cluster metadatafinalCluster
- Final cluster metadataoutputDirName
- Output directory where to dump this filefilePrefix
- String to prepend to the initial & final cluster
metadata files
java.io.IOException
public static void dumpClusters(Cluster currentCluster, Cluster finalCluster, java.lang.String outputDirName)
currentCluster
- Initial cluster metadatafinalCluster
- Final cluster metadataoutputDirName
- Output directory where to dump this file
java.io.IOException
public static void dumpClusterToFile(java.lang.String outputDirName, java.lang.String fileName, Cluster cluster)
outputDirName
- fileName
- cluster
- public static void dumpStoreDefsToFile(java.lang.String outputDirName, java.lang.String fileName, java.util.List<StoreDefinition> storeDefs)
outputDirName
- fileName
- list
- of storeDefspublic static void dumpAnalysisToFile(java.lang.String outputDirName, java.lang.String baseFileName, PartitionBalance partitionBalance)
outputDirName
- baseFileName
- suffix '.analysis' is appended to baseFileName.partitionBalance
- public static void dumpPlanToFile(java.lang.String outputDirName, RebalancePlan plan)
outputDirName
- plan
- public static int countTaskStores(java.util.List<RebalanceTaskInfo> infos)
public static java.util.List<RebalanceTaskInfo> filterTaskPlanWithStores(java.util.List<RebalanceTaskInfo> existingPlanList, java.util.List<StoreDefinition> storeDefs)
existingPlanList
- Existing partition plan liststoreDefs
- List of store names we are rebalancing
public static java.util.HashMap<java.lang.Integer,java.util.List<RebalanceTaskInfo>> groupPartitionsTaskByNode(java.util.List<RebalanceTaskInfo> rebalanceTaskPlanList, boolean groupByStealerNode)
rebalanceTaskPlanList
- Complete list of partition plansgroupByStealerNode
- Boolean indicating if we want to group by
stealer node ( or donor node )
public static void executorShutDown(java.util.concurrent.ExecutorService executorService, long timeOutSec)
executorService
- Executor service to shutdowntimeOutSec
- Time we wait forpublic static java.util.concurrent.ExecutorService createExecutors(int numThreads)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |