mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-06 02:07:07 +00:00
Removing code from portal.h for setting handle of RestoreOptions and RestoreBackupableDB
This commit is contained in:
@@ -11,26 +11,26 @@ package org.rocksdb;
|
||||
*
|
||||
* Note that dispose() must be called before an Options instance
|
||||
* become out-of-scope to release the allocated memory in c++.
|
||||
*
|
||||
*
|
||||
* @param path Where to keep the backup files. Has to be different than dbname.
|
||||
Best to set this to dbname_ + "/backups"
|
||||
* @param shareTableFiles If share_table_files == true, backup will assume that
|
||||
* table files with same name have the same contents. This enables
|
||||
* incremental backups and avoids unnecessary data copies. If
|
||||
* share_table_files == false, each backup will be on its own and will not
|
||||
* @param shareTableFiles If share_table_files == true, backup will assume that
|
||||
* table files with same name have the same contents. This enables
|
||||
* incremental backups and avoids unnecessary data copies. If
|
||||
* share_table_files == false, each backup will be on its own and will not
|
||||
* share any data with other backups. default: true
|
||||
* @param sync If sync == true, we can guarantee you'll get consistent backup
|
||||
* even on a machine crash/reboot. Backup process is slower with sync
|
||||
* @param sync If sync == true, we can guarantee you'll get consistent backup
|
||||
* even on a machine crash/reboot. Backup process is slower with sync
|
||||
* enabled. If sync == false, we don't guarantee anything on machine reboot.
|
||||
* However, chances are some of the backups are consistent. Default: true
|
||||
* @param destroyOldData If true, it will delete whatever backups there are
|
||||
* @param destroyOldData If true, it will delete whatever backups there are
|
||||
* already. Default: false
|
||||
* @param backupLogFiles If false, we won't backup log files. This option can be
|
||||
* useful for backing up in-memory databases where log file are persisted,
|
||||
* useful for backing up in-memory databases where log file are persisted,
|
||||
* but table files are in memory. Default: true
|
||||
* @param backupRateLimit Max bytes that can be transferred in a second during
|
||||
* @param backupRateLimit Max bytes that can be transferred in a second during
|
||||
* backup. If 0, go as fast as you can. Default: 0
|
||||
* @param restoreRateLimit Max bytes that can be transferred in a second during
|
||||
* @param restoreRateLimit Max bytes that can be transferred in a second during
|
||||
* restore. If 0, go as fast as you can. Default: 0
|
||||
*/
|
||||
public class BackupableDBOptions extends RocksObject {
|
||||
|
||||
@@ -7,24 +7,24 @@ package org.rocksdb;
|
||||
|
||||
/**
|
||||
* This class is used to access information about backups and restore from them.
|
||||
*
|
||||
* Note that dispose() must be called before this instance become out-of-scope
|
||||
*
|
||||
* Note that dispose() must be called before this instance become out-of-scope
|
||||
* to release the allocated memory in c++.
|
||||
*
|
||||
*
|
||||
* @param options Instance of BackupableDBOptions.
|
||||
*/
|
||||
public class RestoreBackupableDB extends RocksObject {
|
||||
public RestoreBackupableDB(BackupableDBOptions options) {
|
||||
super();
|
||||
newRestoreBackupableDB(options.nativeHandle_);
|
||||
nativeHandle_ = newRestoreBackupableDB(options.nativeHandle_);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restore from backup with backup_id
|
||||
* IMPORTANT -- if options_.share_table_files == true and you restore DB
|
||||
* from some backup that is not the latest, and you start creating new
|
||||
* backups from the new DB, they will probably fail.
|
||||
*
|
||||
*
|
||||
* Example: Let's say you have backups 1, 2, 3, 4, 5 and you restore 3.
|
||||
* If you add new data to the DB and try creating a new backup now, the
|
||||
* database will diverge from backups 4 and 5 and the new backup will fail.
|
||||
@@ -36,7 +36,7 @@ public class RestoreBackupableDB extends RocksObject {
|
||||
restoreDBFromBackup0(nativeHandle_, backupId, dbDir, walDir,
|
||||
restoreOptions.nativeHandle_);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Restore from the latest backup.
|
||||
*/
|
||||
@@ -45,25 +45,25 @@ public class RestoreBackupableDB extends RocksObject {
|
||||
restoreDBFromLatestBackup0(nativeHandle_, dbDir, walDir,
|
||||
restoreOptions.nativeHandle_);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes old backups, keeping latest numBackupsToKeep alive.
|
||||
*
|
||||
*
|
||||
* @param Number of latest backups to keep
|
||||
*/
|
||||
public void purgeOldBackups(int numBackupsToKeep) throws RocksDBException {
|
||||
purgeOldBackups0(nativeHandle_, numBackupsToKeep);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deletes a specific backup.
|
||||
*
|
||||
*
|
||||
* @param ID of backup to delete.
|
||||
*/
|
||||
public void deleteBackup(long backupId) throws RocksDBException {
|
||||
deleteBackup0(nativeHandle_, backupId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Release the memory allocated for the current instance
|
||||
* in the c++ side.
|
||||
@@ -71,10 +71,11 @@ public class RestoreBackupableDB extends RocksObject {
|
||||
@Override public synchronized void dispose() {
|
||||
if (isInitialized()) {
|
||||
dispose(nativeHandle_);
|
||||
nativeHandle_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private native void newRestoreBackupableDB(long options);
|
||||
|
||||
private native long newRestoreBackupableDB(long options);
|
||||
private native void restoreDBFromBackup0(long nativeHandle, long backupId,
|
||||
String dbDir, String walDir, long restoreOptions) throws RocksDBException;
|
||||
private native void restoreDBFromLatestBackup0(long nativeHandle,
|
||||
|
||||
@@ -8,21 +8,21 @@ package org.rocksdb;
|
||||
/**
|
||||
* RestoreOptions to control the behavior of restore.
|
||||
*
|
||||
* Note that dispose() must be called before this instance become out-of-scope
|
||||
* Note that dispose() must be called before this instance become out-of-scope
|
||||
* to release the allocated memory in c++.
|
||||
*
|
||||
*
|
||||
* @param If true, restore won't overwrite the existing log files in wal_dir. It
|
||||
* will also move all log files from archive directory to wal_dir. Use this
|
||||
* option in combination with BackupableDBOptions::backup_log_files = false
|
||||
* option in combination with BackupableDBOptions::backup_log_files = false
|
||||
* for persisting in-memory databases.
|
||||
* Default: false
|
||||
*/
|
||||
public class RestoreOptions extends RocksObject {
|
||||
public RestoreOptions(boolean keepLogFiles) {
|
||||
super();
|
||||
newRestoreOptions(keepLogFiles);
|
||||
nativeHandle_ = newRestoreOptions(keepLogFiles);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Release the memory allocated for the current instance
|
||||
* in the c++ side.
|
||||
@@ -30,9 +30,10 @@ public class RestoreOptions extends RocksObject {
|
||||
@Override public synchronized void dispose() {
|
||||
if (isInitialized()) {
|
||||
dispose(nativeHandle_);
|
||||
nativeHandle_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
private native void newRestoreOptions(boolean keepLogFiles);
|
||||
|
||||
private native long newRestoreOptions(boolean keepLogFiles);
|
||||
private native void dispose(long handle);
|
||||
}
|
||||
|
||||
@@ -36,10 +36,12 @@ public class BackupableDBTest {
|
||||
bdb.close();
|
||||
|
||||
// restore from backup
|
||||
RestoreOptions ropt = new RestoreOptions(false);
|
||||
RestoreBackupableDB rdb = new RestoreBackupableDB(bopt);
|
||||
rdb.restoreDBFromLatestBackup(db_path, db_path,
|
||||
new RestoreOptions(false));
|
||||
ropt);
|
||||
rdb.dispose();
|
||||
ropt.dispose();
|
||||
|
||||
// verify that backed up data contains deleted record
|
||||
bdb = BackupableDB.open(opt, bopt, db_path);
|
||||
|
||||
Reference in New Issue
Block a user