Permalink
Browse files

Added BDB native backup capabalities

  • Loading branch information...
1 parent 74e0d94 commit fd5dbeb5113ffed51cf1836ac78b129a4bea4cb6 @jroper jroper committed Oct 14, 2011
View
@@ -12,6 +12,7 @@ Eric Evans
Geir Magnusson Jr.
Ismael Juma
Jakob Homan
+James Roper
Janne Hietamäki
Jay Kreps
Jonathan Traupman
Oops, something went wrong.
@@ -191,6 +191,15 @@ public static void main(String[] args) throws Exception {
.withValuesSeparatedBy(',')
.ofType(Integer.class);
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);
@@ -206,7 +215,8 @@ 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("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));
printHelp(System.err, parser);
System.exit(1);
@@ -268,11 +278,17 @@ public static void main(String[] args) throws Exception {
if(options.has("repair-job")) {
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) {
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, repair-job) "
- + "must be specified");
+ + "set-metadata, check-metadata, key-distribution, clear-rebalancing-metadata, async, "
+ + "repair-job, native-backup) must be specified");
}
List<String> storeNames = null;
@@ -421,6 +437,11 @@ public static void main(String[] args) throws Exception {
if(ops.contains("l")) {
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) {
e.printStackTrace();
Utils.croak(e.getMessage());
@@ -2234,4 +2234,35 @@ private void individualStateChange(int nodeId,
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);
+ }
}
Oops, something went wrong.

0 comments on commit fd5dbeb

Please sign in to comment.