Package org.rocksdb

Class BackupEngineOptions

All Implemented Interfaces:
AutoCloseable

public class BackupEngineOptions extends RocksObject

BackupEngineOptions controls the behavior 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:
  • Constructor Details

    • BackupEngineOptions

      public BackupEngineOptions(String path)

      BackupEngineOptions constructor.

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

    • backupDir

      public String backupDir()

      Returns the path to the BackupEngine directory.

      Returns:
      the path to the BackupEngine directory.
    • setBackupEnv

      public BackupEngineOptions 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.

      Default: null

      Parameters:
      env - The environment to use
      Returns:
      instance of current BackupEngineOptions.
    • 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.

      Default: null

      Returns:
      The environment in use
    • setShareTableFiles

      public BackupEngineOptions 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 BackupEngineOptions.
    • shareTableFiles

      public boolean shareTableFiles()

      Share table files between backups.

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

      public BackupEngineOptions 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 BackupEngineOptions.
    • 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 BackupEngineOptions 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 backups are consistent.

      Default: true

      Returns:
      instance of current BackupEngineOptions.
    • sync

      public boolean sync()

      Are synchronous backups activated.

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

      public BackupEngineOptions 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 BackupEngineOptions.
    • 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 BackupEngineOptions setBackupLogFiles(boolean backupLogFiles)

      Set if log files shall be persisted.

      Parameters:
      backupLogFiles - If false, we won't back up 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 BackupEngineOptions.
    • backupLogFiles

      public boolean backupLogFiles()

      Return information if log files shall be persisted.

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

      public BackupEngineOptions 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 BackupEngineOptions.
    • 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 BackupEngineOptions 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 BackupEngineOptions.
    • 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 BackupEngineOptions 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 BackupEngineOptions.
    • 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 BackupEngineOptions 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 BackupEngineOptions.
    • 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 BackupEngineOptions 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 BackupEngineOptions.
    • shareFilesWithChecksum

      public boolean shareFilesWithChecksum()

      Return of share files with checksum is active.

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

      public BackupEngineOptions setMaxBackgroundOperations(int maxBackgroundOperations)
      Parameters:
      maxBackgroundOperations - The maximum number of background threads
      Returns:
      instance of current BackupEngineOptions.
    • maxBackgroundOperations

      public int maxBackgroundOperations()
      Returns:
      The maximum number of background threads
    • setCallbackTriggerIntervalSize

      public BackupEngineOptions 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 BackupEngineOptions.
    • 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
    • disposeInternal

      protected final void disposeInternal(long handle)
      Specified by:
      disposeInternal in class RocksObject