Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added option to list / stop async jobs

  • Loading branch information...
commit 2755820e490b8c09fd8aaa20230eb2828bdf07c5 1 parent 05fa1b8
@rsumbaly rsumbaly authored
Showing with 108 additions and 10 deletions.
  1. +108 −10 src/java/voldemort/VoldemortAdminTool.java
View
118 src/java/voldemort/VoldemortAdminTool.java
@@ -180,6 +180,16 @@ public static void main(String[] args) throws Exception {
.ofType(String.class);
parser.accepts("key-distribution", "Prints the current key distribution of the cluster");
parser.accepts("clear-rebalancing-metadata", "Remove the metadata related to rebalancing");
+ parser.accepts("async",
+ "a) Get a list of async job ids [get] b) Stop async job ids [stop] ")
+ .withRequiredArg()
+ .describedAs("op-type")
+ .ofType(String.class);
+ parser.accepts("async-id", "Comma separated list of async ids to stop")
+ .withOptionalArg()
+ .describedAs("job-ids")
+ .withValuesSeparatedBy(',')
+ .ofType(Integer.class);
OptionSet options = parser.parse(args);
@@ -195,7 +205,7 @@ public static void main(String[] args) throws Exception {
&& (options.has("add-stores") || options.has("delete-store")
|| options.has("ro-metadata") || options.has("set-metadata")
|| options.has("get-metadata") || options.has("check-metadata") || options.has("key-distribution"))
- || options.has("truncate") || options.has("clear-rebalancing-metadata"))) {
+ || options.has("truncate") || options.has("clear-rebalancing-metadata") || options.has("async"))) {
System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
printHelp(System.err, parser);
System.exit(1);
@@ -251,8 +261,14 @@ public static void main(String[] args) throws Exception {
if(options.has("clear-rebalancing-metadata")) {
ops += "i";
}
+ if(options.has("async")) {
+ ops += "b";
+ }
if(ops.length() < 1) {
- Utils.croak("At least one of (delete-partitions, restore, add-node, fetch-entries, fetch-keys, add-stores, delete-store, update-entries, get-metadata, ro-metadata, set-metadata, check-metadata, key-distribution, clear-rebalancing-metadata) must be specified");
+ Utils.croak("At least one of (delete-partitions, restore, add-node, fetch-entries, "
+ + "fetch-keys, add-stores, delete-store, update-entries, get-metadata, ro-metadata, "
+ + "set-metadata, check-metadata, key-distribution, clear-rebalancing-metadata, async) "
+ + "must be specified");
}
List<String> storeNames = null;
@@ -388,6 +404,13 @@ public static void main(String[] args) throws Exception {
if(ops.contains("i")) {
executeClearRebalancing(nodeId, adminClient);
}
+ if(ops.contains("b")) {
+ String asyncKey = (String) options.valueOf("async");
+ List<Integer> asyncIds = null;
+ if(options.hasArgument("async-id"))
+ asyncIds = (List<Integer>) options.valuesOf("async-id");
+ executeAsync(nodeId, adminClient, asyncKey, asyncIds);
+ }
} catch(Exception e) {
e.printStackTrace();
Utils.croak(e.getMessage());
@@ -399,20 +422,39 @@ public static void printHelp(PrintStream stream, OptionParser parser) throws IOE
stream.println("------------------");
stream.println("CHANGE METADATA");
stream.println("\t1) Get metadata from all nodes");
- stream.println("\t\t./bin/voldemort-admin-tool.sh --get-metadata [metadata-key] --url [url]");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --get-metadata ["
+ + MetadataStore.CLUSTER_KEY + ", " + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.STORES_KEY + ", " + MetadataStore.REBALANCING_STEAL_INFO
+ + "] --url [url]");
stream.println("\t2) Get metadata from a particular node");
- stream.println("\t\t./bin/voldemort-admin-tool.sh --get-metadata [metadata-key] --url [url] --node [node-id]");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --get-metadata ["
+ + MetadataStore.CLUSTER_KEY + ", " + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.STORES_KEY + ", " + MetadataStore.REBALANCING_STEAL_INFO
+ + "] --url [url] --node [node-id]");
stream.println("\t3) Get metadata from a particular node and store to a directory");
- stream.println("\t\t./bin/voldemort-admin-tool.sh --get-metadata [metadata-key] --url [url] --node [node-id] --outdir [directory]");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --get-metadata ["
+ + MetadataStore.CLUSTER_KEY + ", " + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.STORES_KEY + ", " + MetadataStore.REBALANCING_STEAL_INFO
+ + "] --url [url] --node [node-id] --outdir [directory]");
stream.println("\t4) Set metadata on all nodes");
- stream.println("\t\t./bin/voldemort-admin-tool.sh --set-metadata [metadata-key] --set-metadata-value [metadata-value] --url [url]");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --set-metadata ["
+ + MetadataStore.CLUSTER_KEY + ", " + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.STORES_KEY + ", " + MetadataStore.REBALANCING_STEAL_INFO
+ + "] --set-metadata-value [metadata-value] --url [url]");
stream.println("\t5) Set metadata for a particular node");
- stream.println("\t\t./bin/voldemort-admin-tool.sh --set-metadata [metadata-key] --set-metadata-value [metadata-value] --url [url] --node [node-id]");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --set-metadata ["
+ + MetadataStore.CLUSTER_KEY + ", " + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.STORES_KEY + ", " + MetadataStore.REBALANCING_STEAL_INFO
+ + "] --set-metadata-value [metadata-value] --url [url] --node [node-id]");
stream.println("\t6) Check if metadata is same on all nodes");
- stream.println("\t\t./bin/voldemort-admin-tool.sh --check-metadata [metadata-key] --url [url]");
- stream.println("\t7) Clear rebalancing metadata ( server.state & rebalancing.steal.info.key ) on all node ");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --check-metadata ["
+ + MetadataStore.CLUSTER_KEY + ", " + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.STORES_KEY + "] --url [url]");
+ stream.println("\t7) Clear rebalancing metadata [" + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.REBALANCING_STEAL_INFO + "] on all node ");
stream.println("\t\t./bin/voldemort-admin-tool.sh --clear-rebalancing-metadata --url [url]");
- stream.println("\t8) Clear rebalancing metadata ( server.state & rebalancing.steal.info.key ) on a particular node ");
+ stream.println("\t8) Clear rebalancing metadata [" + MetadataStore.SERVER_STATE_KEY + ", "
+ + MetadataStore.REBALANCING_STEAL_INFO + "] on a particular node ");
stream.println("\t\t./bin/voldemort-admin-tool.sh --clear-rebalancing-metadata --url [url] --node [node-id]");
stream.println();
stream.println("ADD / DELETE STORES");
@@ -459,6 +501,14 @@ public static void printHelp(PrintStream stream, OptionParser parser) throws IOE
stream.println("\t2) Retrieve metadata information of read-only data for all nodes and a set of store");
stream.println("\t\t./bin/voldemort-admin-tool.sh --ro-metadata [current | max | storage-format] --url [url] --stores [comma-separated list of store names]");
stream.println();
+ stream.println("ASYNC JOBS");
+ stream.println("\t1) Get a list of async jobs on all nodes");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --async get --url [url]");
+ stream.println("\t2) Get a list of async jobs on a particular node");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --async get --url [url] --node [node-id]");
+ stream.println("\t3) Stop a list of async jobs on a particular node");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --async stop --async-id [list of async id] --url [url] --node [node-id]");
+ stream.println();
stream.println("OTHERS");
stream.println("\t1) Restore a particular node completely from its replicas");
stream.println("\t\t./bin/voldemort-admin-tool.sh --restore --url [url] --node [node-id]");
@@ -470,6 +520,54 @@ public static void printHelp(PrintStream stream, OptionParser parser) throws IOE
parser.printHelpOn(stream);
}
+ private static void executeAsync(Integer nodeId,
+ AdminClient adminClient,
+ String asyncKey,
+ List<Integer> asyncIdsToStop) {
+
+ if(asyncKey.compareTo("get") == 0) {
+ List<Integer> nodeIds = Lists.newArrayList();
+ if(nodeId < 0) {
+ for(Node node: adminClient.getAdminClientCluster().getNodes()) {
+ nodeIds.add(node.getId());
+ }
+ } else {
+ nodeIds.add(nodeId);
+ }
+
+ // Print the job information
+ for(int currentNodeId: nodeIds) {
+ System.out.println("Printing async jobs from node " + currentNodeId);
+ List<Integer> asyncIds = adminClient.getAsyncRequestList(currentNodeId);
+
+ for(int asyncId: asyncIds) {
+ System.out.println("Async Job Id : " + asyncId);
+ System.out.println("Async Job Status : "
+ + adminClient.getAsyncRequestStatus(currentNodeId,
+ currentNodeId));
+ System.out.println();
+ }
+ }
+ } else if(asyncKey.compareTo("stop") == 0) {
+ if(nodeId < 0) {
+ throw new VoldemortException("Cannot stop job ids without node id");
+ }
+
+ if(asyncIdsToStop == null || asyncIdsToStop.size() == 0) {
+ throw new VoldemortException("Async ids cannot be null / zero");
+ }
+
+ for(int asyncId: asyncIdsToStop) {
+ System.out.println("Stopping async id " + asyncId);
+ adminClient.stopAsyncRequest(nodeId, asyncId);
+ System.out.println("Stopped async id " + asyncId);
+ }
+ } else {
+ throw new VoldemortException("Unsupported async operation type " + asyncKey);
+ }
+
+ }
+
private static void executeClearRebalancing(int nodeId, AdminClient adminClient) {
System.out.println("Setting " + MetadataStore.SERVER_STATE_KEY + " to "
+ MetadataStore.VoldemortState.NORMAL_SERVER);
Please sign in to comment.
Something went wrong with that request. Please try again.