Package org.rocksdb

Class BackupableDBOptions

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    public class BackupableDBOptions
    extends RocksObject

    BackupableDBOptions to control the behavior of a backupable database. It will be used during the creation of a BackupEngine.

    Note that dispose() must be called before an Options instance become out-of-scope to release the allocated memory in c++.

    See Also:
    BackupEngine
    • Constructor Detail

      • BackupableDBOptions

        public BackupableDBOptions​(java.lang.String path)

        BackupableDBOptions constructor.

        Parameters:
        path - Where to keep the backup files. Has to be different than db name. Best to set this to db name_ + "/backups"
        Throws:
        java.lang.IllegalArgumentException - if illegal path is used.
    • Method Detail

      • backupDir

        public java.lang.String backupDir()

        Returns the path to the BackupableDB directory.

        Returns:
        the path to the BackupableDB directory.
      • setBackupEnv

        public BackupableDBOptions setBackupEnv​(Env env)
        Backup Env object. It will be used for backup file I/O. If it's null, backups will be written out using DBs Env. Otherwise backup's I/O will be performed using this object. If you want to have backups on HDFS, use HDFS Env here! Default: null
        Parameters:
        env - The environment to use
        Returns:
        instance of current BackupableDBOptions.
      • backupEnv

        public Env backupEnv()
        Backup Env object. It will be used for backup file I/O. If it's null, backups will be written out using DBs Env. Otherwise backup's I/O will be performed using this object. If you want to have backups on HDFS, use HDFS Env here! Default: null
        Returns:
        The environment in use
      • setShareTableFiles

        public BackupableDBOptions setShareTableFiles​(boolean shareTableFiles)

        Share table files between backups.

        Parameters:
        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

        Returns:
        instance of current BackupableDBOptions.
      • shareTableFiles

        public boolean shareTableFiles()

        Share table files between backups.

        Returns:
        boolean value indicating if SST files will be shared between backups.
      • setInfoLog

        public BackupableDBOptions setInfoLog​(Logger logger)
        Set the logger to use for Backup info and error messages
        Parameters:
        logger - The logger to use for the backup
        Returns:
        instance of current BackupableDBOptions.
      • infoLog

        public Logger infoLog()
        Set the logger to use for Backup info and error messages Default: null
        Returns:
        The logger in use for the backup
      • setSync

        public BackupableDBOptions setSync​(boolean sync)

        Set synchronous backups.

        Parameters:
        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

        Returns:
        instance of current BackupableDBOptions.
      • sync

        public boolean sync()

        Are synchronous backups activated.

        Returns:
        boolean value if synchronous backups are configured.
      • setDestroyOldData

        public BackupableDBOptions setDestroyOldData​(boolean destroyOldData)

        Set if old data will be destroyed.

        Parameters:
        destroyOldData - If true, it will delete whatever backups there are already.

        Default: false

        Returns:
        instance of current BackupableDBOptions.
      • destroyOldData

        public boolean destroyOldData()

        Returns if old data will be destroyed will performing new backups.

        Returns:
        boolean value indicating if old data will be destroyed.
      • setBackupLogFiles

        public BackupableDBOptions setBackupLogFiles​(boolean backupLogFiles)

        Set if log files shall be persisted.

        Parameters:
        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, but table files are in memory.

        Default: true

        Returns:
        instance of current BackupableDBOptions.
      • backupLogFiles

        public boolean backupLogFiles()

        Return information if log files shall be persisted.

        Returns:
        boolean value indicating if log files will be persisted.
      • setBackupRateLimit

        public BackupableDBOptions setBackupRateLimit​(long backupRateLimit)

        Set backup rate limit.

        Parameters:
        backupRateLimit - Max bytes that can be transferred in a second during backup. If 0 or negative, then go as fast as you can.

        Default: 0

        Returns:
        instance of current BackupableDBOptions.
      • backupRateLimit

        public long backupRateLimit()

        Return backup rate limit which described the max bytes that can be transferred in a second during backup.

        Returns:
        numerical value describing the backup transfer limit in bytes per second.
      • setBackupRateLimiter

        public BackupableDBOptions setBackupRateLimiter​(RateLimiter backupRateLimiter)
        Backup rate limiter. Used to control transfer speed for backup. If this is not null, backupRateLimit() is ignored. Default: null
        Parameters:
        backupRateLimiter - The rate limiter to use for the backup
        Returns:
        instance of current BackupableDBOptions.
      • backupRateLimiter

        public RateLimiter backupRateLimiter()
        Backup rate limiter. Used to control transfer speed for backup. If this is not null, backupRateLimit() is ignored. Default: null
        Returns:
        The rate limiter in use for the backup
      • setRestoreRateLimit

        public BackupableDBOptions setRestoreRateLimit​(long restoreRateLimit)

        Set restore rate limit.

        Parameters:
        restoreRateLimit - Max bytes that can be transferred in a second during restore. If 0 or negative, then go as fast as you can.

        Default: 0

        Returns:
        instance of current BackupableDBOptions.
      • restoreRateLimit

        public long restoreRateLimit()

        Return restore rate limit which described the max bytes that can be transferred in a second during restore.

        Returns:
        numerical value describing the restore transfer limit in bytes per second.
      • setRestoreRateLimiter

        public BackupableDBOptions setRestoreRateLimiter​(RateLimiter restoreRateLimiter)
        Restore rate limiter. Used to control transfer speed during restore. If this is not null, restoreRateLimit() is ignored. Default: null
        Parameters:
        restoreRateLimiter - The rate limiter to use during restore
        Returns:
        instance of current BackupableDBOptions.
      • restoreRateLimiter

        public RateLimiter restoreRateLimiter()
        Restore rate limiter. Used to control transfer speed during restore. If this is not null, restoreRateLimit() is ignored. Default: null
        Returns:
        The rate limiter in use during restore
      • setShareFilesWithChecksum

        public BackupableDBOptions setShareFilesWithChecksum​(boolean shareFilesWithChecksum)

        Only used if share_table_files is set to true. If true, will consider that backups can come from different databases, hence a sst is not uniquely identified by its name, but by the triple (file name, crc32, file length)

        Parameters:
        shareFilesWithChecksum - boolean value indicating if SST files are stored using the triple (file name, crc32, file length) and not its name.

        Note: this is an experimental option, and you'll need to set it manually turn it on only if you know what you're doing*

        Default: false

        Returns:
        instance of current BackupableDBOptions.
      • shareFilesWithChecksum

        public boolean shareFilesWithChecksum()

        Return of share files with checksum is active.

        Returns:
        boolean value indicating if share files with checksum is active.
      • setCallbackTriggerIntervalSize

        public BackupableDBOptions setCallbackTriggerIntervalSize​(long callbackTriggerIntervalSize)
        During backup user can get callback every time next callbackTriggerIntervalSize() bytes being copied. Default: 4194304
        Parameters:
        callbackTriggerIntervalSize - The interval size for the callback trigger
        Returns:
        instance of current BackupableDBOptions.
      • callbackTriggerIntervalSize

        public long callbackTriggerIntervalSize()
        During backup user can get callback every time next callbackTriggerIntervalSize() bytes being copied. Default: 4194304
        Returns:
        The interval size for the callback trigger