Skip to content

Commit

Permalink
Added BDB native backup capabalities
Browse files Browse the repository at this point in the history
  • Loading branch information
jroper committed Oct 14, 2011
1 parent 74e0d94 commit fd5dbeb
Show file tree
Hide file tree
Showing 11 changed files with 879 additions and 71 deletions.
1 change: 1 addition & 0 deletions CONTRIBUTORS
Expand Up @@ -12,6 +12,7 @@ Eric Evans
Geir Magnusson Jr. Geir Magnusson Jr.
Ismael Juma Ismael Juma
Jakob Homan Jakob Homan
James Roper
Janne Hietamäki Janne Hietamäki
Jay Kreps Jay Kreps
Jonathan Traupman Jonathan Traupman
Expand Down
64 changes: 59 additions & 5 deletions clients/python/voldemort/protocol/voldemort_admin_pb2.py

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions src/java/voldemort/VoldemortAdminTool.java
Expand Up @@ -191,6 +191,15 @@ public static void main(String[] args) throws Exception {
.withValuesSeparatedBy(',') .withValuesSeparatedBy(',')
.ofType(Integer.class); .ofType(Integer.class);
parser.accepts("repair-job", "Clean after rebalancing is done"); parser.accepts("repair-job", "Clean after rebalancing is done");
parser.accepts("native-backup",
"Perform a native backup")
.withRequiredArg()
.describedAs("store-name")
.ofType(String.class);
parser.accepts("backup-dir")
.withRequiredArg()
.describedAs("backup-directory")
.ofType(String.class);


OptionSet options = parser.parse(args); OptionSet options = parser.parse(args);


Expand All @@ -206,7 +215,8 @@ public static void main(String[] args) throws Exception {
&& (options.has("add-stores") || options.has("delete-store") && (options.has("add-stores") || options.has("delete-store")
|| options.has("ro-metadata") || options.has("set-metadata") || options.has("ro-metadata") || options.has("set-metadata")
|| options.has("get-metadata") || options.has("check-metadata") || options.has("key-distribution")) || 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("truncate") || options.has("clear-rebalancing-metadata") || options.has("async")
|| options.has("native-backup"))) {
System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing)); System.err.println("Missing required arguments: " + Joiner.on(", ").join(missing));
printHelp(System.err, parser); printHelp(System.err, parser);
System.exit(1); System.exit(1);
Expand Down Expand Up @@ -268,11 +278,17 @@ public static void main(String[] args) throws Exception {
if(options.has("repair-job")) { if(options.has("repair-job")) {
ops += "l"; ops += "l";
} }
if(options.has("native-backup")) {
if (!options.has("backup-dir")) {
Utils.croak("A backup directory must be specified with dir");
}
ops += "n";
}
if(ops.length() < 1) { if(ops.length() < 1) {
Utils.croak("At least one of (delete-partitions, restore, add-node, fetch-entries, " 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, " + "fetch-keys, add-stores, delete-store, update-entries, get-metadata, ro-metadata, "
+ "set-metadata, check-metadata, key-distribution, clear-rebalancing-metadata, async, repair-job) " + "set-metadata, check-metadata, key-distribution, clear-rebalancing-metadata, async, "
+ "must be specified"); + "repair-job, native-backup) must be specified");
} }


List<String> storeNames = null; List<String> storeNames = null;
Expand Down Expand Up @@ -421,6 +437,11 @@ public static void main(String[] args) throws Exception {
if(ops.contains("l")) { if(ops.contains("l")) {
executeRepairJob(nodeId, adminClient); executeRepairJob(nodeId, adminClient);
} }
if (ops.contains("n")) {
String backupDir = (String) options.valueOf("backup-dir");
String storeName = (String) options.valueOf("native-backup");
adminClient.nativeBackup(nodeId, storeName, backupDir);
}
} catch(Exception e) { } catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
Utils.croak(e.getMessage()); Utils.croak(e.getMessage());
Expand Down
31 changes: 31 additions & 0 deletions src/java/voldemort/client/protocol/admin/AdminClient.java
Expand Up @@ -2234,4 +2234,35 @@ private HashMap<Integer, List<RebalancePartitionsInfo>> groupPartitionsInfoBySte
return stealerNodeToPlan; return stealerNodeToPlan;
} }


/**
* Native backup a store
*
* @param nodeId The node id to backup
* @param storeName The name of the store to backup
* @param destinationDirPath The destination path
*/
public void nativeBackup(int nodeId,
String storeName,
String destinationDirPath) {
Node node = this.getAdminClientCluster().getNodeById(nodeId);

VAdminProto.NativeBackupRequest nativeBackupRequest = VAdminProto.NativeBackupRequest.newBuilder()
.setStoreName(storeName)
.setBackupDir(destinationDirPath)
.build();
VAdminProto.VoldemortAdminRequest adminRequest = VAdminProto.VoldemortAdminRequest.newBuilder()
.setNativeBackup(nativeBackupRequest)
.setType(VAdminProto.AdminRequestType.NATIVE_BACKUP)
.build();
VAdminProto.AsyncOperationStatusResponse.Builder response = sendAndReceive(nodeId,
adminRequest,
VAdminProto.AsyncOperationStatusResponse.newBuilder());

if (response.hasError()) {
throwException(response.getError());
}

int asyncId = response.getRequestId();
waitForCompletion(nodeId, asyncId, 3, TimeUnit.MINUTES);
}
} }

0 comments on commit fd5dbeb

Please sign in to comment.