Delete deprecated backup classes in Java

Summary: Corresponding change to D56331.

Test Plan:
Now build succeeds:

  $ make jclean && make rocksdbjava

Reviewers: yhchiang, IslamAbdelRahman, adamretter

Reviewed By: adamretter

Subscribers: andrewkr, dhruba, leveldb

Differential Revision: https://reviews.facebook.net/D56913
main
Andrew Kryczka 9 years ago
parent a2466c8851
commit 9385fd72c0
  1. 3
      java/Makefile
  2. 112
      java/rocksjni/backupablejni.cc
  3. 157
      java/rocksjni/restorejni.cc
  4. 326
      java/src/test/java/org/rocksdb/BackupableDBTest.java

@ -2,7 +2,6 @@ NATIVE_JAVA_CLASSES = org.rocksdb.AbstractCompactionFilter\
org.rocksdb.AbstractComparator\
org.rocksdb.AbstractSlice\
org.rocksdb.BackupEngine\
org.rocksdb.BackupableDB\
org.rocksdb.BackupableDBOptions\
org.rocksdb.BlockBasedTableConfig\
org.rocksdb.BloomFilter\
@ -26,7 +25,6 @@ NATIVE_JAVA_CLASSES = org.rocksdb.AbstractCompactionFilter\
org.rocksdb.PlainTableConfig\
org.rocksdb.ReadOptions\
org.rocksdb.RemoveEmptyValueCompactionFilter\
org.rocksdb.RestoreBackupableDB\
org.rocksdb.RestoreOptions\
org.rocksdb.RocksDB\
org.rocksdb.RocksEnv\
@ -62,7 +60,6 @@ endif
JAVA_TESTS = org.rocksdb.BackupableDBOptionsTest\
org.rocksdb.BackupEngineTest\
org.rocksdb.BackupableDBTest\
org.rocksdb.BlockBasedTableConfigTest\
org.rocksdb.util.BytewiseComparatorTest\
org.rocksdb.CheckPointTest\

@ -13,122 +13,10 @@
#include <string>
#include <vector>
#include "include/org_rocksdb_BackupableDB.h"
#include "include/org_rocksdb_BackupableDBOptions.h"
#include "rocksjni/portal.h"
#include "rocksdb/utilities/backupable_db.h"
/*
* Class: org_rocksdb_BackupableDB
* Method: open
* Signature: (JJ)J
*/
jlong Java_org_rocksdb_BackupableDB_open(
JNIEnv* env, jclass jcls, jlong jdb_handle, jlong jopt_handle) {
auto* db = reinterpret_cast<rocksdb::DB*>(jdb_handle);
auto* opt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jopt_handle);
auto bdb = new rocksdb::BackupableDB(db, *opt);
// as BackupableDB extends RocksDB on the java side, we can reuse
// the RocksDB portal here.
return reinterpret_cast<jlong>(bdb);
}
/*
* Class: org_rocksdb_BackupableDB
* Method: createNewBackup
* Signature: (JZ)V
*/
void Java_org_rocksdb_BackupableDB_createNewBackup(
JNIEnv* env, jobject jbdb, jlong jhandle, jboolean jflag) {
rocksdb::Status s =
reinterpret_cast<rocksdb::BackupableDB*>(jhandle)->CreateNewBackup(jflag);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_BackupableDB
* Method: purgeOldBackups
* Signature: (JI)V
*/
void Java_org_rocksdb_BackupableDB_purgeOldBackups(
JNIEnv* env, jobject jbdb, jlong jhandle, jint jnumBackupsToKeep) {
rocksdb::Status s =
reinterpret_cast<rocksdb::BackupableDB*>(jhandle)->
PurgeOldBackups(jnumBackupsToKeep);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_BackupableDB
* Method: deleteBackup0
* Signature: (JI)V
*/
void Java_org_rocksdb_BackupableDB_deleteBackup0(JNIEnv* env,
jobject jobj, jlong jhandle, jint jbackup_id) {
auto rdb = reinterpret_cast<rocksdb::BackupableDB*>(jhandle);
rocksdb::Status s = rdb->DeleteBackup(jbackup_id);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_BackupableDB
* Method: getBackupInfo
* Signature: (J)Ljava/util/List;
*/
jobject Java_org_rocksdb_BackupableDB_getBackupInfo(
JNIEnv* env, jobject jbdb, jlong jhandle) {
std::vector<rocksdb::BackupInfo> backup_infos;
reinterpret_cast<rocksdb::BackupableDB*>(jhandle)->
GetBackupInfo(&backup_infos);
return rocksdb::BackupInfoListJni::getBackupInfo(env,
backup_infos);
}
/*
* Class: org_rocksdb_BackupableDB
* Method: getCorruptedBackups
* Signature: (J)[I;
*/
jintArray Java_org_rocksdb_BackupableDB_getCorruptedBackups(
JNIEnv* env, jobject jbdb, jlong jhandle) {
std::vector<rocksdb::BackupID> backup_ids;
reinterpret_cast<rocksdb::BackupableDB*>(jhandle)->
GetCorruptedBackups(&backup_ids);
// store backupids in int array
std::vector<jint> int_backup_ids(backup_ids.begin(), backup_ids.end());
// Store ints in java array
jintArray ret_backup_ids;
// Its ok to loose precision here (64->32)
jsize ret_backup_ids_size = static_cast<jsize>(backup_ids.size());
ret_backup_ids = env->NewIntArray(ret_backup_ids_size);
env->SetIntArrayRegion(ret_backup_ids, 0, ret_backup_ids_size,
int_backup_ids.data());
return ret_backup_ids;
}
/*
* Class: org_rocksdb_BackupableDB
* Method: garbageCollect
* Signature: (J)V
*/
void Java_org_rocksdb_BackupableDB_garbageCollect(JNIEnv* env,
jobject jobj, jlong jhandle) {
auto db = reinterpret_cast<rocksdb::BackupableDB*>(jhandle);
rocksdb::Status s = db->GarbageCollect();
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
///////////////////////////////////////////////////////////////////////////
// BackupDBOptions

@ -13,7 +13,6 @@
#include <string>
#include "include/org_rocksdb_RestoreOptions.h"
#include "include/org_rocksdb_RestoreBackupableDB.h"
#include "rocksjni/portal.h"
#include "rocksdb/utilities/backupable_db.h"
/*
@ -38,159 +37,3 @@ void Java_org_rocksdb_RestoreOptions_disposeInternal(JNIEnv* env, jobject jobj,
assert(ropt);
delete ropt;
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: newRestoreBackupableDB
* Signature: (J)J
*/
jlong Java_org_rocksdb_RestoreBackupableDB_newRestoreBackupableDB(JNIEnv* env,
jclass jcls, jlong jopt_handle) {
auto* opt = reinterpret_cast<rocksdb::BackupableDBOptions*>(jopt_handle);
auto rdb = new rocksdb::RestoreBackupableDB(rocksdb::Env::Default(), *opt);
return reinterpret_cast<jlong>(rdb);
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: restoreDBFromBackup0
* Signature: (JJLjava/lang/String;Ljava/lang/String;J)V
*/
void Java_org_rocksdb_RestoreBackupableDB_restoreDBFromBackup0(JNIEnv* env,
jobject jobj, jlong jhandle, jlong jbackup_id, jstring jdb_dir,
jstring jwal_dir, jlong jopt_handle) {
auto opt = reinterpret_cast<rocksdb::RestoreOptions*>(jopt_handle);
const char* cdb_dir = env->GetStringUTFChars(jdb_dir, 0);
const char* cwal_dir = env->GetStringUTFChars(jwal_dir, 0);
auto rdb = reinterpret_cast<rocksdb::RestoreBackupableDB*>(jhandle);
rocksdb::Status s = rdb->RestoreDBFromBackup(
static_cast<rocksdb::BackupID>(jbackup_id), cdb_dir, cwal_dir, *opt);
env->ReleaseStringUTFChars(jdb_dir, cdb_dir);
env->ReleaseStringUTFChars(jwal_dir, cwal_dir);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: restoreDBFromLatestBackup0
* Signature: (JLjava/lang/String;Ljava/lang/String;J)V
*/
void Java_org_rocksdb_RestoreBackupableDB_restoreDBFromLatestBackup0(
JNIEnv* env, jobject jobj, jlong jhandle, jstring jdb_dir, jstring jwal_dir,
jlong jopt_handle) {
auto opt = reinterpret_cast<rocksdb::RestoreOptions*>(jopt_handle);
const char* cdb_dir = env->GetStringUTFChars(jdb_dir, 0);
const char* cwal_dir = env->GetStringUTFChars(jwal_dir, 0);
auto rdb = reinterpret_cast<rocksdb::RestoreBackupableDB*>(jhandle);
rocksdb::Status s =
rdb->RestoreDBFromLatestBackup(cdb_dir, cwal_dir, *opt);
env->ReleaseStringUTFChars(jdb_dir, cdb_dir);
env->ReleaseStringUTFChars(jwal_dir, cwal_dir);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: purgeOldBackups0
* Signature: (JI)V
*/
void Java_org_rocksdb_RestoreBackupableDB_purgeOldBackups0(JNIEnv* env,
jobject jobj, jlong jhandle, jint jnum_backups_to_keep) {
auto rdb = reinterpret_cast<rocksdb::RestoreBackupableDB*>(jhandle);
rocksdb::Status s = rdb->PurgeOldBackups(jnum_backups_to_keep);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: deleteBackup0
* Signature: (JI)V
*/
void Java_org_rocksdb_RestoreBackupableDB_deleteBackup0(JNIEnv* env,
jobject jobj, jlong jhandle, jint jbackup_id) {
auto rdb = reinterpret_cast<rocksdb::RestoreBackupableDB*>(jhandle);
rocksdb::Status s = rdb->DeleteBackup(jbackup_id);
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: getBackupInfo
* Signature: (J)Ljava/util/List;
*/
jobject Java_org_rocksdb_RestoreBackupableDB_getBackupInfo(
JNIEnv* env, jobject jbdb, jlong jhandle) {
std::vector<rocksdb::BackupInfo> backup_infos;
reinterpret_cast<rocksdb::RestoreBackupableDB*>(jhandle)->
GetBackupInfo(&backup_infos);
return rocksdb::BackupInfoListJni::getBackupInfo(env,
backup_infos);
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: getCorruptedBackups
* Signature: (J)[I;
*/
jintArray Java_org_rocksdb_RestoreBackupableDB_getCorruptedBackups(
JNIEnv* env, jobject jbdb, jlong jhandle) {
std::vector<rocksdb::BackupID> backup_ids;
reinterpret_cast<rocksdb::RestoreBackupableDB*>(jhandle)->
GetCorruptedBackups(&backup_ids);
// store backupids in int array
std::vector<jint> int_backup_ids(backup_ids.begin(), backup_ids.end());
// Store ints in java array
jintArray ret_backup_ids;
// Its ok to loose precision here (64->32)
jsize ret_backup_ids_size = static_cast<jsize>(backup_ids.size());
ret_backup_ids = env->NewIntArray(ret_backup_ids_size);
env->SetIntArrayRegion(ret_backup_ids, 0, ret_backup_ids_size,
int_backup_ids.data());
return ret_backup_ids;
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: garbageCollect
* Signature: (J)V
*/
void Java_org_rocksdb_RestoreBackupableDB_garbageCollect(
JNIEnv* env, jobject jobj, jlong jhandle) {
auto db = reinterpret_cast<rocksdb::RestoreBackupableDB*>(
jhandle);
rocksdb::Status s = db->GarbageCollect();
if (!s.ok()) {
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
}
}
/*
* Class: org_rocksdb_RestoreBackupableDB
* Method: disposeInternal
* Signature: (J)V
*/
void Java_org_rocksdb_RestoreBackupableDB_disposeInternal(JNIEnv* env,
jobject jobj, jlong jhandle) {
auto ropt = reinterpret_cast<rocksdb::RestoreBackupableDB*>(jhandle);
assert(ropt);
delete ropt;
}

@ -1,326 +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 org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.util.List;
import static org.assertj.core.api.Assertions.assertThat;
public class BackupableDBTest {
@ClassRule
public static final RocksMemoryResource rocksMemoryResource =
new RocksMemoryResource();
@Rule
public TemporaryFolder dbFolder = new TemporaryFolder();
@Rule
public TemporaryFolder backupFolder = new TemporaryFolder();
@Test
public void backupDb() throws RocksDBException {
try (final Options opt = new Options().setCreateIfMissing(true);
final BackupableDBOptions bopt = new BackupableDBOptions(
backupFolder.getRoot().getAbsolutePath())) {
assertThat(bopt.backupDir()).isEqualTo(
backupFolder.getRoot().getAbsolutePath());
// Open empty database.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Fill database with some test values
prepareDatabase(bdb);
// Create two backups
bdb.createNewBackup(false);
bdb.createNewBackup(true);
verifyNumberOfValidBackups(bdb, 2);
}
}
}
@Test
public void deleteBackup() throws RocksDBException {
try (final Options opt = new Options().setCreateIfMissing(true);
final BackupableDBOptions bopt = new BackupableDBOptions(
backupFolder.getRoot().getAbsolutePath())) {
assertThat(bopt.backupDir()).isEqualTo(
backupFolder.getRoot().getAbsolutePath());
// Open empty database.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Fill database with some test values
prepareDatabase(bdb);
// Create two backups
bdb.createNewBackup(false);
bdb.createNewBackup(true);
List<BackupInfo> backupInfo =
verifyNumberOfValidBackups(bdb, 2);
// Delete the first backup
bdb.deleteBackup(backupInfo.get(0).backupId());
final List<BackupInfo> newBackupInfo =
verifyNumberOfValidBackups(bdb, 1);
// The second backup must remain.
assertThat(newBackupInfo.get(0).backupId()).
isEqualTo(backupInfo.get(1).backupId());
}
}
}
@Test
public void deleteBackupWithRestoreBackupableDB()
throws RocksDBException {
try (final Options opt = new Options().setCreateIfMissing(true);
final BackupableDBOptions bopt = new BackupableDBOptions(
backupFolder.getRoot().getAbsolutePath())) {
assertThat(bopt.backupDir()).isEqualTo(
backupFolder.getRoot().getAbsolutePath());
// Open empty database.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Fill database with some test values
prepareDatabase(bdb);
// Create two backups
bdb.createNewBackup(false);
bdb.createNewBackup(true);
final List<BackupInfo> backupInfo =
verifyNumberOfValidBackups(bdb, 2);
// init RestoreBackupableDB
try (final RestoreBackupableDB rdb = new RestoreBackupableDB(bopt)) {
// Delete the first backup
rdb.deleteBackup(backupInfo.get(0).backupId());
// Fetch backup info using RestoreBackupableDB
List<BackupInfo> newBackupInfo = verifyNumberOfValidBackups(rdb, 1);
// The second backup must remain.
assertThat(newBackupInfo.get(0).backupId()).
isEqualTo(backupInfo.get(1).backupId());
}
}
}
}
@Test
public void purgeOldBackups() throws RocksDBException {
try (final Options opt = new Options().setCreateIfMissing(true);
final BackupableDBOptions bopt = new BackupableDBOptions(
backupFolder.getRoot().getAbsolutePath())) {
assertThat(bopt.backupDir()).isEqualTo(
backupFolder.getRoot().getAbsolutePath());
// Open empty database.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Fill database with some test values
prepareDatabase(bdb);
// Create two backups
bdb.createNewBackup(false);
bdb.createNewBackup(true);
bdb.createNewBackup(true);
bdb.createNewBackup(true);
final List<BackupInfo> backupInfo =
verifyNumberOfValidBackups(bdb, 4);
// Delete everything except the latest backup
bdb.purgeOldBackups(1);
final List<BackupInfo> newBackupInfo =
verifyNumberOfValidBackups(bdb, 1);
// The latest backup must remain.
assertThat(newBackupInfo.get(0).backupId()).
isEqualTo(backupInfo.get(3).backupId());
}
}
}
@Test
public void purgeOldBackupsWithRestoreBackupableDb()
throws RocksDBException {
try (final Options opt = new Options().setCreateIfMissing(true);
final BackupableDBOptions bopt =
new BackupableDBOptions(backupFolder.getRoot().getAbsolutePath())
) {
assertThat(bopt.backupDir()).isEqualTo(
backupFolder.getRoot().getAbsolutePath());
// Open empty database.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Fill database with some test values
prepareDatabase(bdb);
// Create two backups
bdb.createNewBackup(false);
bdb.createNewBackup(true);
bdb.createNewBackup(true);
bdb.createNewBackup(true);
List<BackupInfo> infos = verifyNumberOfValidBackups(bdb, 4);
assertThat(infos.get(1).size()).
isEqualTo(infos.get(2).size());
assertThat(infos.get(1).numberFiles()).
isEqualTo(infos.get(2).numberFiles());
long maxTimeBeforePurge = Long.MIN_VALUE;
for (BackupInfo backupInfo : infos) {
if (maxTimeBeforePurge < backupInfo.timestamp()) {
maxTimeBeforePurge = backupInfo.timestamp();
}
}
// init RestoreBackupableDB
try (final RestoreBackupableDB rdb = new RestoreBackupableDB(bopt)) {
// the same number of backups must
// exist using RestoreBackupableDB.
verifyNumberOfValidBackups(rdb, 4);
rdb.purgeOldBackups(1);
infos = verifyNumberOfValidBackups(rdb, 1);
assertThat(infos.get(0).timestamp()).
isEqualTo(maxTimeBeforePurge);
}
}
}
}
@Test
public void restoreLatestBackup()
throws RocksDBException {
try (final Options opt = new Options().setCreateIfMissing(true);
final BackupableDBOptions bopt =
new BackupableDBOptions(
backupFolder.getRoot().getAbsolutePath())) {
assertThat(bopt.backupDir()).isEqualTo(
backupFolder.getRoot().getAbsolutePath());
// Open empty database.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Fill database with some test values
prepareDatabase(bdb);
bdb.createNewBackup(true);
verifyNumberOfValidBackups(bdb, 1);
bdb.put("key1".getBytes(), "valueV2".getBytes());
bdb.put("key2".getBytes(), "valueV2".getBytes());
bdb.createNewBackup(true);
verifyNumberOfValidBackups(bdb, 2);
bdb.put("key1".getBytes(), "valueV3".getBytes());
bdb.put("key2".getBytes(), "valueV3".getBytes());
assertThat(new String(bdb.get("key1".getBytes()))).endsWith("V3");
assertThat(new String(bdb.get("key2".getBytes()))).endsWith("V3");
}
// init RestoreBackupableDB
try (final RestoreBackupableDB rdb = new RestoreBackupableDB(bopt)) {
verifyNumberOfValidBackups(rdb, 2);
// restore db from latest backup
rdb.restoreDBFromLatestBackup(dbFolder.getRoot().getAbsolutePath(),
dbFolder.getRoot().getAbsolutePath(),
new RestoreOptions(false));
}
// Open database again.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Values must have suffix V2 because of restoring latest backup.
assertThat(new String(bdb.get("key1".getBytes()))).endsWith("V2");
assertThat(new String(bdb.get("key2".getBytes()))).endsWith("V2");
}
}
}
@Test
public void restoreFromBackup()
throws RocksDBException {
try (final Options opt = new Options().setCreateIfMissing(true);
final BackupableDBOptions bopt = new BackupableDBOptions(
backupFolder.getRoot().getAbsolutePath())) {
assertThat(bopt.backupDir()).isEqualTo(
backupFolder.getRoot().getAbsolutePath());
// Open empty database.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Fill database with some test values
prepareDatabase(bdb);
bdb.createNewBackup(true);
verifyNumberOfValidBackups(bdb, 1);
bdb.put("key1".getBytes(), "valueV2".getBytes());
bdb.put("key2".getBytes(), "valueV2".getBytes());
bdb.createNewBackup(true);
verifyNumberOfValidBackups(bdb, 2);
bdb.put("key1".getBytes(), "valueV3".getBytes());
bdb.put("key2".getBytes(), "valueV3".getBytes());
assertThat(new String(bdb.get("key1".getBytes()))).endsWith("V3");
assertThat(new String(bdb.get("key2".getBytes()))).endsWith("V3");
}
// init RestoreBackupableDB
try (final RestoreBackupableDB rdb = new RestoreBackupableDB(bopt)) {
final List<BackupInfo> backupInfo = verifyNumberOfValidBackups(rdb, 2);
// restore db from first backup
rdb.restoreDBFromBackup(backupInfo.get(0).backupId(),
dbFolder.getRoot().getAbsolutePath(),
dbFolder.getRoot().getAbsolutePath(),
new RestoreOptions(false));
}
// Open database again.
try (final BackupableDB bdb = BackupableDB.open(opt, bopt,
dbFolder.getRoot().getAbsolutePath())) {
// Values must have suffix V2 because of restoring latest backup.
assertThat(new String(bdb.get("key1".getBytes()))).endsWith("V1");
assertThat(new String(bdb.get("key2".getBytes()))).endsWith("V1");
}
}
}
/**
* Verify backups.
*
* @param bdb {@link BackupableDB} instance.
* @param expectedNumberOfBackups numerical value
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
private List<BackupInfo> verifyNumberOfValidBackups(final BackupableDB bdb,
final int expectedNumberOfBackups) throws RocksDBException {
// Verify that backups exist
assertThat(bdb.getCorruptedBackups().length).
isEqualTo(0);
bdb.garbageCollect();
List<BackupInfo> backupInfo = bdb.getBackupInfos();
assertThat(backupInfo.size()).
isEqualTo(expectedNumberOfBackups);
return backupInfo;
}
/**
* Verify backups.
*
* @param rdb {@link RestoreBackupableDB} instance.
* @param expectedNumberOfBackups numerical value
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
private List<BackupInfo> verifyNumberOfValidBackups(
final RestoreBackupableDB rdb, final int expectedNumberOfBackups)
throws RocksDBException {
// Verify that backups exist
assertThat(rdb.getCorruptedBackups().length).
isEqualTo(0);
rdb.garbageCollect();
List<BackupInfo> backupInfo = rdb.getBackupInfos();
assertThat(backupInfo.size()).
isEqualTo(expectedNumberOfBackups);
return backupInfo;
}
/**
* Fill database with some test values.
*
* @param db {@link RocksDB} instance.
* @throws RocksDBException thrown if an error occurs within the native
* part of the library.
*/
private void prepareDatabase(final RocksDB db)
throws RocksDBException {
db.put("key1".getBytes(), "valueV1".getBytes());
db.put("key2".getBytes(), "valueV1".getBytes());
}
}
Loading…
Cancel
Save