public class BackupableDB extends RocksDB
A subclass of RocksDB which supports backup-related operations.
BackupableDBOptions
DEFAULT_COLUMN_FAMILY, NOT_FOUND, options_
nativeHandle_
Modifier | Constructor and Description |
---|---|
protected |
BackupableDB(long nativeHandle)
A protected construction that will be used in the static
factory method
open(Options, BackupableDBOptions, String) . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the BackupableDB instance and release resource.
|
void |
createNewBackup(boolean flushBeforeBackup)
Captures the state of the database in the latest backup.
|
protected void |
createNewBackup(long handle,
boolean flag) |
void |
deleteBackup(int backupId)
Deletes a specific backup.
|
protected void |
finalize()
Simply calls
AbstractNativeReference.dispose() to free
any underlying C++ object reference which has not yet been manually
released. |
void |
garbageCollect()
Will delete all the files we don't need anymore.
|
protected java.util.List<BackupInfo> |
getBackupInfo(long handle) |
java.util.List<BackupInfo> |
getBackupInfos()
Returns a list of
BackupInfo instances, which describe
already made backups. |
int[] |
getCorruptedBackups()
Returns a list of corrupted backup ids.
|
protected static long |
open(long rocksDBHandle,
long backupDBOptionsHandle) |
static BackupableDB |
open(Options opt,
BackupableDBOptions bopt,
java.lang.String db_path)
Open a
BackupableDB under the specified path. |
void |
purgeOldBackups(int numBackupsToKeep)
Deletes old backups, keeping latest numBackupsToKeep alive.
|
protected void |
purgeOldBackups(long handle,
int numBackupsToKeep) |
compactRange, compactRange, compactRange, compactRange, compactRange, compactRange, compactRange, compactRange, continueBackgroundWork, createColumnFamily, disableFileDeletions, disposeInternal, dropColumnFamily, enableFileDeletions, flush, flush, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, get, getDefaultColumnFamily, getLatestSequenceNumber, getLongProperty, getLongProperty, getLongProperty, getLongProperty, getProperty, getProperty, getProperty0, getProperty0, getSnapshot, getSnapshot, getUpdatesSince, iterator, iterator, iteratorCF, iteratorCF, iterators, keyMayExist, keyMayExist, keyMayExist, keyMayExist, keyMayExist, keyMayExist, keyMayExist, keyMayExist, listColumnFamilies, listColumnFamilies, loadLibrary, loadLibrary, merge, merge, merge, merge, merge, merge, merge, merge, multiGet, multiGet, multiGet, multiGet, multiGet, multiGet, multiGet, multiGet, newIterator, newIterator, newIterator, newIterator, newIterators, newIterators, open, open, open, open, open, open, openReadOnly, openReadOnly, openReadOnly, openReadOnly, openROnly, openROnly, pauseBackgroundWork, put, put, put, put, put, put, put, put, releaseSnapshot, releaseSnapshot, remove, remove, remove, remove, remove, remove, remove, remove, write, write, write0, write1
disposeInternal
disOwnNativeHandle, isOwningHandle
dispose
protected BackupableDB(long nativeHandle)
A protected construction that will be used in the static
factory method open(Options, BackupableDBOptions, String)
.
nativeHandle
- The native handle of the C++ BackupableDB objectpublic static BackupableDB open(Options opt, BackupableDBOptions bopt, java.lang.String db_path) throws RocksDBException
Open a BackupableDB
under the specified path.
Note that the backup path should be set properly in the
input BackupableDBOptions.
opt
- Options
to set for the database.bopt
- BackupableDBOptions
to use.db_path
- Path to store data to. The path for storing the backup
should be specified in the BackupableDBOptions
.BackupableDB
reference to the opened database.RocksDBException
- thrown if error happens in underlying
native library.public void createNewBackup(boolean flushBeforeBackup) throws RocksDBException
Captures the state of the database in the latest backup. Note that this function is not thread-safe.
flushBeforeBackup
- if true, then all data will be flushed
before creating backup.RocksDBException
- thrown if error happens in underlying
native library.public void purgeOldBackups(int numBackupsToKeep) throws RocksDBException
Deletes old backups, keeping latest numBackupsToKeep alive.
numBackupsToKeep
- Number of latest backups to keep.RocksDBException
- thrown if error happens in underlying
native library.public void deleteBackup(int backupId) throws RocksDBException
Deletes a specific backup.
backupId
- of backup to delete.RocksDBException
- thrown if error happens in underlying
native library.public java.util.List<BackupInfo> getBackupInfos()
Returns a list of BackupInfo
instances, which describe
already made backups.
BackupInfo
instances.public int[] getCorruptedBackups()
Returns a list of corrupted backup ids. If there is no corrupted backup the method will return an empty list.
public void garbageCollect() throws RocksDBException
Will delete all the files we don't need anymore. It will do the full scan of the files/ directory and delete all the files that are not referenced.
RocksDBException
- thrown if error happens in underlying
native library.public void close()
Close the BackupableDB instance and release resource.
Internally, BackupableDB
owns the rocksdb::DB
pointer to its associated RocksDB
.
The release of that RocksDB pointer is handled in the destructor
of the c++ rocksdb::BackupableDB
and should be transparent
to Java developers.
close
in interface java.lang.AutoCloseable
close
in class AbstractImmutableNativeReference
protected void finalize() throws java.lang.Throwable
AbstractNativeReference
AbstractNativeReference.dispose()
to free
any underlying C++ object reference which has not yet been manually
released.finalize
in class AbstractNativeReference
java.lang.Throwable
protected static long open(long rocksDBHandle, long backupDBOptionsHandle)
protected void createNewBackup(long handle, boolean flag) throws RocksDBException
RocksDBException
protected void purgeOldBackups(long handle, int numBackupsToKeep) throws RocksDBException
RocksDBException
protected java.util.List<BackupInfo> getBackupInfo(long handle)