|
|
@ -8,15 +8,17 @@ package org.rocksdb; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* This class is used to access information about backups and restore from them. |
|
|
|
* <p>This class is used to access information about backups and |
|
|
|
|
|
|
|
* restore from them.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
* Note that dispose() must be called before this instance become out-of-scope |
|
|
|
* <p>Note: {@code dispose()} must be called before this instance |
|
|
|
* to release the allocated memory in c++. |
|
|
|
* become out-of-scope to release the allocated |
|
|
|
|
|
|
|
* memory in c++.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public class RestoreBackupableDB extends RocksObject { |
|
|
|
public class RestoreBackupableDB extends RocksObject { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Constructor |
|
|
|
* <p>Construct new estoreBackupableDB instance.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @param options {@link org.rocksdb.BackupableDBOptions} instance |
|
|
|
* @param options {@link org.rocksdb.BackupableDBOptions} instance |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -26,16 +28,18 @@ public class RestoreBackupableDB extends RocksObject { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Restore from backup with backup_id |
|
|
|
* <p>Restore from backup with backup_id.</p> |
|
|
|
* 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. |
|
|
|
* <p><strong>Important</strong>: If options_.share_table_files == true |
|
|
|
* If you add new data to the DB and try creating a new backup now, the |
|
|
|
* and you restore DB from some backup that is not the latest, and you |
|
|
|
* database will diverge from backups 4 and 5 and the new backup will fail. |
|
|
|
* start creating new backups from the new DB, they will probably |
|
|
|
* If you want to create new backup, you will first have to delete backups 4 |
|
|
|
* fail.</p> |
|
|
|
* and 5. |
|
|
|
* |
|
|
|
|
|
|
|
* <p><strong>Example</strong>: 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. If you want to create new backup, you will first have |
|
|
|
|
|
|
|
* to delete backups 4 and 5.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @param backupId id pointing to backup |
|
|
|
* @param backupId id pointing to backup |
|
|
|
* @param dbDir database directory to restore to |
|
|
|
* @param dbDir database directory to restore to |
|
|
@ -47,12 +51,13 @@ public class RestoreBackupableDB extends RocksObject { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void restoreDBFromBackup(long backupId, String dbDir, String walDir, |
|
|
|
public void restoreDBFromBackup(long backupId, String dbDir, String walDir, |
|
|
|
RestoreOptions restoreOptions) throws RocksDBException { |
|
|
|
RestoreOptions restoreOptions) throws RocksDBException { |
|
|
|
|
|
|
|
assert(isInitialized()); |
|
|
|
restoreDBFromBackup0(nativeHandle_, backupId, dbDir, walDir, |
|
|
|
restoreDBFromBackup0(nativeHandle_, backupId, dbDir, walDir, |
|
|
|
restoreOptions.nativeHandle_); |
|
|
|
restoreOptions.nativeHandle_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Restore from the latest backup. |
|
|
|
* <p>Restore from the latest backup.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @param dbDir database directory to restore to |
|
|
|
* @param dbDir database directory to restore to |
|
|
|
* @param walDir directory where wal files are located |
|
|
|
* @param walDir directory where wal files are located |
|
|
@ -63,12 +68,13 @@ public class RestoreBackupableDB extends RocksObject { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void restoreDBFromLatestBackup(String dbDir, String walDir, |
|
|
|
public void restoreDBFromLatestBackup(String dbDir, String walDir, |
|
|
|
RestoreOptions restoreOptions) throws RocksDBException { |
|
|
|
RestoreOptions restoreOptions) throws RocksDBException { |
|
|
|
|
|
|
|
assert(isInitialized()); |
|
|
|
restoreDBFromLatestBackup0(nativeHandle_, dbDir, walDir, |
|
|
|
restoreDBFromLatestBackup0(nativeHandle_, dbDir, walDir, |
|
|
|
restoreOptions.nativeHandle_); |
|
|
|
restoreOptions.nativeHandle_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Deletes old backups, keeping latest numBackupsToKeep alive. |
|
|
|
* <p>Deletes old backups, keeping latest numBackupsToKeep alive.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @param numBackupsToKeep of latest backups to keep |
|
|
|
* @param numBackupsToKeep of latest backups to keep |
|
|
|
* |
|
|
|
* |
|
|
@ -76,11 +82,12 @@ public class RestoreBackupableDB extends RocksObject { |
|
|
|
* native library. |
|
|
|
* native library. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void purgeOldBackups(int numBackupsToKeep) throws RocksDBException { |
|
|
|
public void purgeOldBackups(int numBackupsToKeep) throws RocksDBException { |
|
|
|
|
|
|
|
assert(isInitialized()); |
|
|
|
purgeOldBackups0(nativeHandle_, numBackupsToKeep); |
|
|
|
purgeOldBackups0(nativeHandle_, numBackupsToKeep); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Deletes a specific backup. |
|
|
|
* <p>Deletes a specific backup.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @param backupId of backup to delete. |
|
|
|
* @param backupId of backup to delete. |
|
|
|
* |
|
|
|
* |
|
|
@ -88,16 +95,18 @@ public class RestoreBackupableDB extends RocksObject { |
|
|
|
* native library. |
|
|
|
* native library. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void deleteBackup(int backupId) throws RocksDBException { |
|
|
|
public void deleteBackup(int backupId) throws RocksDBException { |
|
|
|
|
|
|
|
assert(isInitialized()); |
|
|
|
deleteBackup0(nativeHandle_, backupId); |
|
|
|
deleteBackup0(nativeHandle_, backupId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Returns a list of {@link BackupInfo} instances, which describe |
|
|
|
* <p>Returns a list of {@link BackupInfo} instances, which describe |
|
|
|
* already made backups. |
|
|
|
* already made backups.</p> |
|
|
|
* |
|
|
|
* |
|
|
|
* @return List of {@link BackupInfo} instances. |
|
|
|
* @return List of {@link BackupInfo} instances. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<BackupInfo> getBackupInfos() { |
|
|
|
public List<BackupInfo> getBackupInfos() { |
|
|
|
|
|
|
|
assert(isInitialized()); |
|
|
|
return getBackupInfo(nativeHandle_); |
|
|
|
return getBackupInfo(nativeHandle_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -109,6 +118,7 @@ public class RestoreBackupableDB extends RocksObject { |
|
|
|
* @return list of backup ids as Integer. |
|
|
|
* @return list of backup ids as Integer. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public List<Integer> getCorruptedBackups() { |
|
|
|
public List<Integer> getCorruptedBackups() { |
|
|
|
|
|
|
|
assert(isInitialized()); |
|
|
|
return getCorruptedBackups(nativeHandle_); |
|
|
|
return getCorruptedBackups(nativeHandle_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -121,15 +131,15 @@ public class RestoreBackupableDB extends RocksObject { |
|
|
|
* native library. |
|
|
|
* native library. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void garbageCollect() throws RocksDBException { |
|
|
|
public void garbageCollect() throws RocksDBException { |
|
|
|
|
|
|
|
assert(isInitialized()); |
|
|
|
garbageCollect(nativeHandle_); |
|
|
|
garbageCollect(nativeHandle_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Release the memory allocated for the current instance |
|
|
|
* <p>Release the memory allocated for the current instance |
|
|
|
* in the c++ side. |
|
|
|
* in the c++ side.</p> |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override public synchronized void disposeInternal() { |
|
|
|
@Override public synchronized void disposeInternal() { |
|
|
|
assert(isInitialized()); |
|
|
|
|
|
|
|
dispose(nativeHandle_); |
|
|
|
dispose(nativeHandle_); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|