Permalink
Browse files

Added option to set rebalancing steal information using the admin tool

  • Loading branch information...
1 parent ff623f5 commit 6140f785a5bc39f9bd5f325a5924be7e223d0a7f @rsumbaly rsumbaly committed May 12, 2011
@@ -21,8 +21,6 @@ usage="Usage: voldemort-stop.sh"
bin=`dirname "$0"`
bin=`cd "$bin"; pwd`
-. "$bin/voldemort-config.sh"
-
if [ "$#" != "0" ]
then
echo $usage
@@ -39,6 +39,7 @@
import joptsimple.OptionParser;
import joptsimple.OptionSet;
+import org.apache.commons.io.FileUtils;
import org.codehaus.jackson.JsonFactory;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.map.ObjectMapper;
@@ -51,6 +52,7 @@
import voldemort.serialization.DefaultSerializerFactory;
import voldemort.serialization.Serializer;
import voldemort.serialization.SerializerFactory;
+import voldemort.server.rebalance.RebalancerState;
import voldemort.store.StoreDefinition;
import voldemort.store.metadata.MetadataStore;
import voldemort.store.metadata.MetadataStore.VoldemortState;
@@ -352,6 +354,15 @@ public static void main(String[] args) throws Exception {
adminClient,
MetadataStore.STORES_KEY,
mapper.writeStoreList(storeDefs));
+ } else if(metadataKey.compareTo(MetadataStore.REBALANCING_STEAL_INFO) == 0) {
+ if(!Utils.isReadableFile(metadataValue))
+ throw new VoldemortException("Rebalancing steal info file path incorrect");
+ String rebalancingStealInfoJsonString = FileUtils.readFileToString(new File(metadataValue));
+ RebalancerState state = RebalancerState.create(rebalancingStealInfoJsonString);
+ executeSetMetadata(nodeId,
+ adminClient,
+ MetadataStore.REBALANCING_STEAL_INFO,
+ state.toJsonString());
} else {
throw new VoldemortException("Incorrect metadata key");
}
@@ -494,9 +505,17 @@ public static void executeGetMetadata(Integer nodeId,
+ adminClient.getAdminClientCluster()
.getNodeById(currentNodeId)
.getId());
- Versioned<String> versioned = adminClient.getRemoteMetadata(currentNodeId, metadataKey);
+ Versioned<String> versioned = null;
+ try {
+ versioned = adminClient.getRemoteMetadata(currentNodeId, metadataKey);
+ } catch(Exception e) {
+ System.out.println("Error in retrieving " + e.getMessage());
+ System.out.println();
+ continue;
+ }
if(versioned == null) {
System.out.println("null");
+ System.out.println();
} else {
System.out.println(versioned.getVersion());
System.out.print(": ");
@@ -106,10 +106,9 @@
}
} catch(Exception e) {
if(null != requiredNodes && requiredNodes.contains(node.getId()))
- throw new VoldemortException("Failed to get Cluster version from node:" + node,
- e);
+ throw new VoldemortException("Failed to get cluster version from " + node, e);
else
- logger.info("Failed to get Cluster version from node:" + node, e);
+ logger.info("Failed to get cluster version from node " + node, e);
}
}

0 comments on commit 6140f78

Please sign in to comment.