Skip to content
Browse files

updated rebalance command shell.

  • Loading branch information...
1 parent fb948b2 commit b76b3f66586b7a3b9099df7a108964a8ba55577e @bbansal bbansal committed Jan 8, 2010
View
6 bin/voldemort-rebalance-shell.sh
@@ -16,12 +16,6 @@
# limitations under the License.
#
-if [ $# -lt 3 ];
-then
- echo 'USAGE: bin/voldemort-rebalance-shell.sh bootstrapURL targetCluster.xml maxParallelRebalancing'
- exit 1
-fi
-
base_dir=$(dirname $0)/..
$base_dir/bin/run-class.sh jline.ConsoleRunner voldemort.client.rebalance.RebalanceCommandShell $@
View
25 src/java/voldemort/client/rebalance/RebalanceCommandShell.java
@@ -3,24 +3,43 @@
import java.io.File;
import voldemort.cluster.Cluster;
-import voldemort.utils.Utils;
import voldemort.xml.ClusterMapper;
public class RebalanceCommandShell {
private static RebalanceController rebalanceClient;
private static ClusterMapper clusterMapper = new ClusterMapper();
+ private static void printUsage() {
+ StringBuilder builder = new StringBuilder();
+ builder.append("java RebalanceCommandShell bootstrapURL targetCluster.xml maxParallelRebalancing deleteAfterRebalancing\n");
+ builder.append("Arguments:\n");
+ builder.append("bootstrapUrl: bootstrap voldemort server url.(should point to a node in the cluster and not the new nodes)\n");
+ builder.append("targetCluster.xml: The final desired cluster configuration.\n");
+ builder.append("maxParallelRebalancing: maximum parallel transfers to start\n");
+ builder.append("deleteAfterRebalancing: delete data from original nodes after transfering.\n");
+
+ System.out.println(builder.toString());
+ System.exit(0);
+ }
+
public static void main(String[] args) throws Exception {
- if(args.length != 3)
- Utils.croak("USAGE: java RebalanceCommandShell bootstrapURL targetCluster.xml maxParallelRebalancing");
+ if(args.length != 4)
+ printUsage();
String bootstrapURL = args[0];
Cluster targetCluster = clusterMapper.readCluster(new File(args[1]));
int maxParallelRebalancing = Integer.parseInt(args[2]);
+ if(!"true".equals(args[3]) && !"false".equals(args[3])) {
+ printUsage();
+ }
+
+ boolean deleteAfterRebalancing = Boolean.parseBoolean(args[3]);
+
RebalanceClientConfig config = new RebalanceClientConfig();
config.setMaxParallelRebalancing(maxParallelRebalancing);
+ config.setDeleteAfterRebalancingEnabled(deleteAfterRebalancing);
rebalanceClient = new RebalanceController(bootstrapURL, config);
View
27 src/java/voldemort/client/rebalance/RebalanceController.java
@@ -71,10 +71,26 @@ public Thread newThread(Runnable r) {
public void rebalance(final Cluster targetCluster) {
Versioned<Cluster> currentVersionedCluster = RebalanceUtils.getLatestCluster(new ArrayList<Integer>(),
adminClient);
- logger.info("Current Cluster configuration:" + currentVersionedCluster);
+ rebalance(currentVersionedCluster.getValue(), targetCluster);
+ }
+
+ /**
+ * Voldemort dynamic cluster membership rebalancing mechanism. <br>
+ * Migrate partitions across nodes to managed changes in cluster
+ * memberships. <br>
+ * Takes targetCluster as parameters, fetches the current cluster
+ * configuration from the cluster compares and makes a list of partitions
+ * need to be transferred.<br>
+ * The cluster is kept consistent during rebalancing using a proxy mechanism
+ * via {@link RedirectingStore}<br>
+ *
+ *
+ * @param targetCluster: target Cluster configuration
+ */
+ public void rebalance(Cluster currentCluster, final Cluster targetCluster) {
+ logger.info("Current Cluster configuration:" + currentCluster);
logger.info("Target Cluster configuration:" + targetCluster);
- Cluster currentCluster = currentVersionedCluster.getValue();
adminClient.setAdminClientCluster(currentCluster);
List<String> storeList = RebalanceUtils.getStoreNameList(currentCluster, adminClient);
@@ -89,10 +105,13 @@ public void rebalance(final Cluster targetCluster) {
currentCluster = getClusterWithNewNodes(currentCluster, targetCluster);
adminClient.setAdminClientCluster(currentCluster);
Node firstNode = currentCluster.getNodes().iterator().next();
+ VectorClock latestClock = (VectorClock) RebalanceUtils.getLatestCluster(new ArrayList<Integer>(),
+ adminClient)
+ .getVersion();
RebalanceUtils.propagateCluster(adminClient,
currentCluster,
- ((VectorClock) currentVersionedCluster.getVersion()).incremented(firstNode.getId(),
- System.currentTimeMillis()),
+ latestClock.incremented(firstNode.getId(),
+ System.currentTimeMillis()),
new ArrayList<Integer>());
ExecutorService executor = createExecutors(rebalanceConfig.getMaxParallelRebalancing());
View
2 src/java/voldemort/server/VoldemortConfig.java
@@ -276,7 +276,7 @@ public VoldemortConfig(Props props) {
this.requestFormatType = RequestFormatType.fromCode(requestFormatName);
// rebalancing parameters
- this.maxRebalancingAttempt = props.getInt("max.rebalancing.attempts", Integer.MAX_VALUE);
+ this.maxRebalancingAttempt = props.getInt("max.rebalancing.attempts", 3);
this.rebalancingTimeoutInSeconds = props.getInt("rebalancing.timeout.seconds", 60 * 60);
this.rebalancingServicePeriod = props.getInt("rebalancing.service.period.ms", 1000);
this.failureDetectorImplementation = props.getString("failuredetector.implementation",

0 comments on commit b76b3f6

Please sign in to comment.
Something went wrong with that request. Please try again.