mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-06 02:07:07 +00:00
Add more options to backupable DB
This commit is contained in:
@@ -18,15 +18,35 @@ public class BackupableDBTest {
|
||||
Options opt = new Options();
|
||||
opt.setCreateIfMissing(true);
|
||||
|
||||
BackupableDBOptions bopt = new BackupableDBOptions(backup_path);
|
||||
BackupableDBOptions bopt = new BackupableDBOptions(backup_path, false,
|
||||
true, false, true, 0, 0);
|
||||
BackupableDB bdb = null;
|
||||
|
||||
try {
|
||||
bdb = BackupableDB.open(opt, bopt, db_path);
|
||||
bdb.put("hello".getBytes(), "BackupableDB".getBytes());
|
||||
|
||||
bdb.put("abc".getBytes(), "def".getBytes());
|
||||
bdb.put("ghi".getBytes(), "jkl".getBytes());
|
||||
bdb.createNewBackup(true);
|
||||
byte[] value = bdb.get("hello".getBytes());
|
||||
assert(new String(value).equals("BackupableDB"));
|
||||
|
||||
// delete record after backup
|
||||
bdb.remove("abc".getBytes());
|
||||
byte[] value = bdb.get("abc".getBytes());
|
||||
assert(value == null);
|
||||
bdb.close();
|
||||
|
||||
// restore from backup
|
||||
RestoreBackupableDB rdb = new RestoreBackupableDB(bopt);
|
||||
rdb.restoreDBFromLatestBackup(db_path, db_path,
|
||||
new RestoreOptions(false));
|
||||
rdb.dispose();
|
||||
|
||||
// verify that backed up data contains deleted record
|
||||
bdb = BackupableDB.open(opt, bopt, db_path);
|
||||
value = bdb.get("abc".getBytes());
|
||||
assert(new String(value).equals("def"));
|
||||
|
||||
System.out.println("Backup and restore test passed");
|
||||
} catch (RocksDBException e) {
|
||||
System.err.format("[ERROR]: %s%n", e);
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user