All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rocksdb.BackupableDBOptions Maven / Gradle / Ivy

Go to download

RocksDB fat jar to use with Apache Flink that contains .so files for linux32 and linux64, jnilib files for Mac OSX, and a .dll for Windows x64.

There is a newer version: 5.17.2-artisans-2.0
Show newest version
// Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
// This source code is licensed under the BSD-style license found in the
// LICENSE file in the root directory of this source tree. An additional grant
// of patent rights can be found in the PATENTS file in the same directory.

package org.rocksdb;

import java.io.File;

/**
 * 

BackupableDBOptions to control the behavior of a backupable database. * It will be used during the creation of a {@link org.rocksdb.BackupableDB}. *

*

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

* * @see org.rocksdb.BackupableDB */ public class BackupableDBOptions extends RocksObject { /** *

BackupableDBOptions constructor.

* * @param path Where to keep the backup files. Has to be different than db * name. Best to set this to {@code db name_ + "/backups"} * @throws java.lang.IllegalArgumentException if illegal path is used. */ public BackupableDBOptions(final String path) { super(newBackupableDBOptions(ensureWritableFile(path))); } private static String ensureWritableFile(final String path) { final File backupPath = path == null ? null : new File(path); if (backupPath == null || !backupPath.isDirectory() || !backupPath.canWrite()) { throw new IllegalArgumentException("Illegal path provided."); } else { return path; } } /** *

Returns the path to the BackupableDB directory.

* * @return the path to the BackupableDB directory. */ public String backupDir() { assert(isOwningHandle()); return backupDir(nativeHandle_); } /** *

Share table files between backups.

* * @param shareTableFiles If {@code 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 * {@code share_table_files == false}, each backup will be on its own and * will not share any data with other backups. * *

Default: true

* * @return instance of current BackupableDBOptions. */ public BackupableDBOptions setShareTableFiles(final boolean shareTableFiles) { assert(isOwningHandle()); setShareTableFiles(nativeHandle_, shareTableFiles); return this; } /** *

Share table files between backups.

* * @return boolean value indicating if SST files will be shared between * backups. */ public boolean shareTableFiles() { assert(isOwningHandle()); return shareTableFiles(nativeHandle_); } /** *

Set synchronous backups.

* * @param sync If {@code sync == true}, we can guarantee you'll get consistent * backup even on a machine crash/reboot. Backup process is slower with sync * enabled. If {@code sync == false}, we don't guarantee anything on machine * reboot. However, chances are some of the backups are consistent. * *

Default: true

* * @return instance of current BackupableDBOptions. */ public BackupableDBOptions setSync(final boolean sync) { assert(isOwningHandle()); setSync(nativeHandle_, sync); return this; } /** *

Are synchronous backups activated.

* * @return boolean value if synchronous backups are configured. */ public boolean sync() { assert(isOwningHandle()); return sync(nativeHandle_); } /** *

Set if old data will be destroyed.

* * @param destroyOldData If true, it will delete whatever backups there are * already. * *

Default: false

* * @return instance of current BackupableDBOptions. */ public BackupableDBOptions setDestroyOldData(final boolean destroyOldData) { assert(isOwningHandle()); setDestroyOldData(nativeHandle_, destroyOldData); return this; } /** *

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

* * @return boolean value indicating if old data will be destroyed. */ public boolean destroyOldData() { assert(isOwningHandle()); return destroyOldData(nativeHandle_); } /** *

Set if log files shall be persisted.

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

Default: true

* * @return instance of current BackupableDBOptions. */ public BackupableDBOptions setBackupLogFiles(final boolean backupLogFiles) { assert(isOwningHandle()); setBackupLogFiles(nativeHandle_, backupLogFiles); return this; } /** *

Return information if log files shall be persisted.

* * @return boolean value indicating if log files will be persisted. */ public boolean backupLogFiles() { assert(isOwningHandle()); return backupLogFiles(nativeHandle_); } /** *

Set backup rate limit.

* * @param 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

* * @return instance of current BackupableDBOptions. */ public BackupableDBOptions setBackupRateLimit(long backupRateLimit) { assert(isOwningHandle()); backupRateLimit = (backupRateLimit <= 0) ? 0 : backupRateLimit; setBackupRateLimit(nativeHandle_, backupRateLimit); return this; } /** *

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

* * @return numerical value describing the backup transfer limit in bytes per * second. */ public long backupRateLimit() { assert(isOwningHandle()); return backupRateLimit(nativeHandle_); } /** *

Set restore rate limit.

* * @param 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

* * @return instance of current BackupableDBOptions. */ public BackupableDBOptions setRestoreRateLimit(long restoreRateLimit) { assert(isOwningHandle()); restoreRateLimit = (restoreRateLimit <= 0) ? 0 : restoreRateLimit; setRestoreRateLimit(nativeHandle_, restoreRateLimit); return this; } /** *

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

* * @return numerical value describing the restore transfer limit in bytes per * second. */ public long restoreRateLimit() { assert(isOwningHandle()); return restoreRateLimit(nativeHandle_); } /** *

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) *

* * @param 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

* * @return instance of current BackupableDBOptions. */ public BackupableDBOptions setShareFilesWithChecksum( final boolean shareFilesWithChecksum) { assert(isOwningHandle()); setShareFilesWithChecksum(nativeHandle_, shareFilesWithChecksum); return this; } /** *

Return of share files with checksum is active.

* * @return boolean value indicating if share files with checksum * is active. */ public boolean shareFilesWithChecksum() { assert(isOwningHandle()); return shareFilesWithChecksum(nativeHandle_); } private native static long newBackupableDBOptions(final String path); private native String backupDir(long handle); private native void setShareTableFiles(long handle, boolean flag); private native boolean shareTableFiles(long handle); private native void setSync(long handle, boolean flag); private native boolean sync(long handle); private native void setDestroyOldData(long handle, boolean flag); private native boolean destroyOldData(long handle); private native void setBackupLogFiles(long handle, boolean flag); private native boolean backupLogFiles(long handle); private native void setBackupRateLimit(long handle, long rateLimit); private native long backupRateLimit(long handle); private native void setRestoreRateLimit(long handle, long rateLimit); private native long restoreRateLimit(long handle); private native void setShareFilesWithChecksum(long handle, boolean flag); private native boolean shareFilesWithChecksum(long handle); @Override protected final native void disposeInternal(final long handle); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy