diff --git a/java/CMakeLists.txt b/java/CMakeLists.txt index 92c4a0e97..e2ed6ea7c 100644 --- a/java/CMakeLists.txt +++ b/java/CMakeLists.txt @@ -48,7 +48,6 @@ set(NATIVE_JAVA_CLASSES org.rocksdb.AbstractRocksIterator org.rocksdb.AbstractSlice org.rocksdb.AbstractWriteBatch - org.rocksdb.BackupableDB org.rocksdb.BackupableDBOptions org.rocksdb.BackupEngine org.rocksdb.BackupEngineTest @@ -84,7 +83,6 @@ set(NATIVE_JAVA_CLASSES org.rocksdb.RateLimiter org.rocksdb.ReadOptions org.rocksdb.RemoveEmptyValueCompactionFilter - org.rocksdb.RestoreBackupableDB org.rocksdb.RestoreOptions org.rocksdb.RocksDB org.rocksdb.RocksDBExceptionTest diff --git a/java/rocksjni/backupablejni.cc b/java/rocksjni/backupablejni.cc index c31dbdbab..6da4575a1 100644 --- a/java/rocksjni/backupablejni.cc +++ b/java/rocksjni/backupablejni.cc @@ -4,7 +4,7 @@ // of patent rights can be found in the PATENTS file in the same directory. // // This file implements the "bridge" between Java and C++ and enables -// calling c++ rocksdb::BackupableDB and rocksdb::BackupableDBOptions methods +// calling c++ rocksdb::BackupEnginge and rocksdb::BackupableDBOptions methods // from Java side. #include diff --git a/java/rocksjni/env_options.cc b/java/rocksjni/env_options.cc index b5e612ad0..77703ff6e 100644 --- a/java/rocksjni/env_options.cc +++ b/java/rocksjni/env_options.cc @@ -4,7 +4,7 @@ // of patent rights can be found in the PATENTS file in the same directory. // // This file implements the "bridge" between Java and C++ and enables -// calling c++ rocksdb::BackupableDB and rocksdb::BackupableDBOptions methods +// calling C++ rocksdb::EnvOptions methods // from Java side. #include diff --git a/java/rocksjni/external_sst_file_info.cc b/java/rocksjni/external_sst_file_info.cc index ded618052..3bbcd4801 100644 --- a/java/rocksjni/external_sst_file_info.cc +++ b/java/rocksjni/external_sst_file_info.cc @@ -4,7 +4,7 @@ // of patent rights can be found in the PATENTS file in the same directory. // // This file implements the "bridge" between Java and C++ and enables -// calling c++ rocksdb::BackupableDB and rocksdb::BackupableDBOptions methods +// calling C++ rocksdb::ExternalSstFileInfo methods // from Java side. #include diff --git a/java/rocksjni/restorejni.cc b/java/rocksjni/restorejni.cc index d8ec147ea..84c8706f0 100644 --- a/java/rocksjni/restorejni.cc +++ b/java/rocksjni/restorejni.cc @@ -4,7 +4,7 @@ // of patent rights can be found in the PATENTS file in the same directory. // // This file implements the "bridge" between Java and C++ and enables -// calling c++ rocksdb::RestoreBackupableDB and rocksdb::RestoreOptions methods +// calling C++ rocksdb::RestoreOptions methods // from Java side. #include diff --git a/java/rocksjni/sst_file_writerjni.cc b/java/rocksjni/sst_file_writerjni.cc index 879f93e07..97f3351c7 100644 --- a/java/rocksjni/sst_file_writerjni.cc +++ b/java/rocksjni/sst_file_writerjni.cc @@ -4,7 +4,7 @@ // of patent rights can be found in the PATENTS file in the same directory. // // This file implements the "bridge" between Java and C++ and enables -// calling c++ rocksdb::BackupableDB and rocksdb::BackupableDBOptions methods +// calling C++ rocksdb::SstFileWriter methods // from Java side. #include diff --git a/java/src/main/java/org/rocksdb/BackupInfo.java b/java/src/main/java/org/rocksdb/BackupInfo.java index 4f3a62845..f2132c56c 100644 --- a/java/src/main/java/org/rocksdb/BackupInfo.java +++ b/java/src/main/java/org/rocksdb/BackupInfo.java @@ -6,14 +6,13 @@ package org.rocksdb; /** * Instances of this class describe a Backup made by - * {@link org.rocksdb.BackupableDB}. + * {@link org.rocksdb.BackupEngine}. */ public class BackupInfo { /** * Package private constructor used to create instances - * of BackupInfo by {@link org.rocksdb.BackupableDB} and - * {@link org.rocksdb.RestoreBackupableDB}. + * of BackupInfo by {@link org.rocksdb.BackupEngine} * * @param backupId id of backup * @param timestamp timestamp of backup diff --git a/java/src/main/java/org/rocksdb/BackupableDB.java b/java/src/main/java/org/rocksdb/BackupableDB.java deleted file mode 100644 index cebd69f67..000000000 --- a/java/src/main/java/org/rocksdb/BackupableDB.java +++ /dev/null @@ -1,167 +0,0 @@ -// 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.util.List; - -/** - *

A subclass of RocksDB which supports - * backup-related operations.

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

Open a {@code BackupableDB} under the specified path. - * Note that the backup path should be set properly in the - * input BackupableDBOptions.

- * - * @param opt {@link org.rocksdb.Options} to set for the database. - * @param bopt {@link org.rocksdb.BackupableDBOptions} to use. - * @param db_path Path to store data to. The path for storing the backup - * should be specified in the {@link org.rocksdb.BackupableDBOptions}. - * - * @return {@link BackupableDB} reference to the opened database. - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public static BackupableDB open( - final Options opt, final BackupableDBOptions bopt, final String db_path) - throws RocksDBException { - - final RocksDB db = RocksDB.open(opt, db_path); - final BackupableDB bdb = new BackupableDB(open(db.nativeHandle_, - bopt.nativeHandle_)); - - // Prevent the RocksDB object from attempting to delete - // the underly C++ DB object. - db.disOwnNativeHandle(); - - return bdb; - } - - /** - *

Captures the state of the database in the latest backup. - * Note that this function is not thread-safe.

- * - * @param flushBeforeBackup if true, then all data will be flushed - * before creating backup. - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void createNewBackup(final boolean flushBeforeBackup) - throws RocksDBException { - assert(isOwningHandle()); - createNewBackup(nativeHandle_, flushBeforeBackup); - } - - /** - *

Deletes old backups, keeping latest numBackupsToKeep alive.

- * - * @param numBackupsToKeep Number of latest backups to keep. - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void purgeOldBackups(final int numBackupsToKeep) - throws RocksDBException { - assert(isOwningHandle()); - purgeOldBackups(nativeHandle_, numBackupsToKeep); - } - - /** - *

Deletes a specific backup.

- * - * @param backupId of backup to delete. - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void deleteBackup(final int backupId) throws RocksDBException { - assert(isOwningHandle()); - deleteBackup0(nativeHandle_, backupId); - } - - /** - *

Returns a list of {@link BackupInfo} instances, which describe - * already made backups.

- * - * @return List of {@link BackupInfo} instances. - */ - public List getBackupInfos() { - assert(isOwningHandle()); - return getBackupInfo(nativeHandle_); - } - - /** - *

Returns a list of corrupted backup ids. If there - * is no corrupted backup the method will return an - * empty list.

- * - * @return array of backup ids as int ids. - */ - public int[] getCorruptedBackups() { - assert(isOwningHandle()); - return getCorruptedBackups(nativeHandle_); - } - - /** - *

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.

- * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void garbageCollect() throws RocksDBException { - assert(isOwningHandle()); - garbageCollect(nativeHandle_); - } - - /** - *

Close the BackupableDB instance and release resource.

- * - *

Internally, {@link BackupableDB} owns the {@code rocksdb::DB} - * pointer to its associated {@link org.rocksdb.RocksDB}. - * The release of that RocksDB pointer is handled in the destructor - * of the c++ {@code rocksdb::BackupableDB} and should be transparent - * to Java developers.

- */ - @Override public void close() { - super.close(); - } - - /** - *

A protected construction that will be used in the static - * factory method {@link #open(Options, BackupableDBOptions, String)}. - *

- * - * @param nativeHandle The native handle of the C++ BackupableDB object - */ - protected BackupableDB(final long nativeHandle) { - super(nativeHandle); - } - - @Override protected void finalize() throws Throwable { - close(); - super.finalize(); - } - - protected native static long open(final long rocksDBHandle, - final long backupDBOptionsHandle); - protected native void createNewBackup(long handle, boolean flag) - throws RocksDBException; - protected native void purgeOldBackups(long handle, int numBackupsToKeep) - throws RocksDBException; - private native void deleteBackup0(long nativeHandle, int backupId) - throws RocksDBException; - protected native List getBackupInfo(long handle); - private native int[] getCorruptedBackups(long handle); - private native void garbageCollect(long handle) - throws RocksDBException; -} diff --git a/java/src/main/java/org/rocksdb/BackupableDBOptions.java b/java/src/main/java/org/rocksdb/BackupableDBOptions.java index 453dd9832..53a2bb314 100644 --- a/java/src/main/java/org/rocksdb/BackupableDBOptions.java +++ b/java/src/main/java/org/rocksdb/BackupableDBOptions.java @@ -9,12 +9,12 @@ 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}. + * It will be used during the creation of a {@link org.rocksdb.BackupEngine}. *

*

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 + * @see org.rocksdb.BackupEngine */ public class BackupableDBOptions extends RocksObject { @@ -375,8 +375,8 @@ public class BackupableDBOptions extends RocksObject { /** * Up to this many background threads will copy files for - * {@link BackupableDB#createNewBackup(boolean)} and - * {@link RestoreBackupableDB#restoreDBFromBackup(long, String, String, RestoreOptions)} + * {@link BackupEngine#createNewBackup(RocksDB, boolean)} and + * {@link BackupEngine#restoreDbFromBackup(int, String, String, RestoreOptions)} * * Default: 1 * @@ -392,8 +392,8 @@ public class BackupableDBOptions extends RocksObject { /** * Up to this many background threads will copy files for - * {@link BackupableDB#createNewBackup(boolean)} and - * {@link RestoreBackupableDB#restoreDBFromBackup(long, String, String, RestoreOptions)} + * {@link BackupEngine#createNewBackup(RocksDB, boolean)} and + * {@link BackupEngine#restoreDbFromBackup(int, String, String, RestoreOptions)} * * Default: 1 * diff --git a/java/src/main/java/org/rocksdb/RestoreBackupableDB.java b/java/src/main/java/org/rocksdb/RestoreBackupableDB.java deleted file mode 100644 index f303b1507..000000000 --- a/java/src/main/java/org/rocksdb/RestoreBackupableDB.java +++ /dev/null @@ -1,158 +0,0 @@ -// 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.util.List; - -/** - *

This class is used to access information about backups and - * restore from them.

- * - *

Note: {@code dispose()} must be called before this instance - * become out-of-scope to release the allocated - * memory in c++.

- * - */ -public class RestoreBackupableDB extends RocksObject { - /** - *

Construct new estoreBackupableDB instance.

- * - * @param options {@link org.rocksdb.BackupableDBOptions} instance - */ - public RestoreBackupableDB(final BackupableDBOptions options) { - super(newRestoreBackupableDB(options.nativeHandle_)); - } - - /** - *

Restore from backup with backup_id.

- * - *

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

- * - * @param backupId id pointing to backup - * @param dbDir database directory to restore to - * @param walDir directory where wal files are located - * @param restoreOptions {@link org.rocksdb.RestoreOptions} instance. - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void restoreDBFromBackup(final long backupId, final String dbDir, - final String walDir, final RestoreOptions restoreOptions) - throws RocksDBException { - assert(isOwningHandle()); - restoreDBFromBackup0(nativeHandle_, backupId, dbDir, walDir, - restoreOptions.nativeHandle_); - } - - /** - *

Restore from the latest backup.

- * - * @param dbDir database directory to restore to - * @param walDir directory where wal files are located - * @param restoreOptions {@link org.rocksdb.RestoreOptions} instance - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void restoreDBFromLatestBackup(final String dbDir, - final String walDir, final RestoreOptions restoreOptions) - throws RocksDBException { - assert(isOwningHandle()); - restoreDBFromLatestBackup0(nativeHandle_, dbDir, walDir, - restoreOptions.nativeHandle_); - } - - /** - *

Deletes old backups, keeping latest numBackupsToKeep alive.

- * - * @param numBackupsToKeep of latest backups to keep - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void purgeOldBackups(final int numBackupsToKeep) - throws RocksDBException { - assert(isOwningHandle()); - purgeOldBackups0(nativeHandle_, numBackupsToKeep); - } - - /** - *

Deletes a specific backup.

- * - * @param backupId of backup to delete. - * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void deleteBackup(final int backupId) - throws RocksDBException { - assert(isOwningHandle()); - deleteBackup0(nativeHandle_, backupId); - } - - /** - *

Returns a list of {@link BackupInfo} instances, which describe - * already made backups.

- * - * @return List of {@link BackupInfo} instances. - */ - public List getBackupInfos() { - assert(isOwningHandle()); - return getBackupInfo(nativeHandle_); - } - - /** - *

Returns a list of corrupted backup ids. If there - * is no corrupted backup the method will return an - * empty list.

- * - * @return array of backup ids as int ids. - */ - public int[] getCorruptedBackups() { - assert(isOwningHandle()); - return getCorruptedBackups(nativeHandle_); - } - - /** - *

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.

- * - * @throws RocksDBException thrown if error happens in underlying - * native library. - */ - public void garbageCollect() throws RocksDBException { - assert(isOwningHandle()); - garbageCollect(nativeHandle_); - } - - private native static long newRestoreBackupableDB(final long options); - private native void restoreDBFromBackup0(long nativeHandle, long backupId, - String dbDir, String walDir, long restoreOptions) - throws RocksDBException; - private native void restoreDBFromLatestBackup0(long nativeHandle, - String dbDir, String walDir, long restoreOptions) - throws RocksDBException; - private native void purgeOldBackups0(long nativeHandle, int numBackupsToKeep) - throws RocksDBException; - private native void deleteBackup0(long nativeHandle, int backupId) - throws RocksDBException; - private native List getBackupInfo(long handle); - private native int[] getCorruptedBackups(long handle); - private native void garbageCollect(long handle) - throws RocksDBException; - @Override protected final native void disposeInternal( - final long nativeHandle); -}