Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added rollback capability to the Admin tool

  • Loading branch information...
commit a22e6f073a68a6821f28da913160ac8b99c6fa6f 1 parent 4957e95
Chinmay Soman authored
Showing with 35 additions and 1 deletion.
  1. +35 −1 src/java/voldemort/VoldemortAdminTool.java
View
36 src/java/voldemort/VoldemortAdminTool.java
@@ -208,6 +208,14 @@ public static void main(String[] args) throws Exception {
parser.accepts("backup-incremental",
"Perform an incremental backup for point-in-time recovery."
+ " By default backup has latest consistent snapshot.");
+ parser.accepts("rollback", "rollback a store")
+ .withRequiredArg()
+ .describedAs("store-name")
+ .ofType(String.class);
+ parser.accepts("version", "version of store to rollback to")
+ .withRequiredArg()
+ .describedAs("version")
+ .ofType(Long.class);
OptionSet options = parser.parse(args);
@@ -224,7 +232,7 @@ public static void main(String[] args) throws Exception {
|| 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("async") || options.has("native-backup"))) {
+ || options.has("async") || options.has("native-backup") || options.has("rollback"))) {
System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
printHelp(System.err, parser);
System.exit(1);
@@ -292,6 +300,12 @@ public static void main(String[] args) throws Exception {
}
ops += "n";
}
+ if(options.has("rollback")) {
+ if(!options.has("version")) {
+ Utils.croak("A version of the read-only store must be specified with rollback option");
+ }
+ ops += "o";
+ }
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, "
@@ -456,12 +470,30 @@ public static void main(String[] args) throws Exception {
options.has("backup-verify"),
options.has("backup-incremental"));
}
+ if(ops.contains("o")) {
+ String storeName = (String) options.valueOf("rollback");
+ long pushVersion = (Long) options.valueOf("version");
+ executeRollback(nodeId, storeName, pushVersion, adminClient);
+ }
} catch(Exception e) {
e.printStackTrace();
Utils.croak(e.getMessage());
}
}
+ private static void executeRollback(Integer nodeId,
+ String storeName,
+ long pushVersion,
+ AdminClient adminClient) {
+ if(nodeId < 0) {
+ for(Node node: adminClient.getAdminClientCluster().getNodes()) {
+ adminClient.rollbackStore(node.getId(), storeName, pushVersion);
+ }
+ } else {
+ adminClient.rollbackStore(nodeId, storeName, pushVersion);
+ }
+ }
+
private static void executeRepairJob(Integer nodeId, AdminClient adminClient) {
if(nodeId < 0) {
for(Node node: adminClient.getAdminClientCluster().getNodes()) {
@@ -573,6 +605,8 @@ public static void printHelp(PrintStream stream, OptionParser parser) throws IOE
stream.println("\t5) Backup bdb data natively");
stream.println("\t\t./bin/voldemort-admin-tool.sh --native-backup [store] --backup-dir [outdir] "
+ "--backup-timeout [mins] [--backup-verify] [--backup-incremental] --url [url] --node [node-id]");
+ stream.println("\t6) Rollback a read-only store for the specified version");
+ stream.println("\t\t./bin/voldemort-admin-tool.sh --rollback [store-name] --url [url] --node [node-id] --version [version-num] ");
parser.printHelpOn(stream);
}
Please sign in to comment.
Something went wrong with that request. Please try again.