[Java] Add purgeOldBackups API
Summary: 1. Check status of CreateNewBackup. If status is not OK, then throw. 2. Add purgeOldBackups API Test Plan: make test make sample Reviewers: haobo, sdong, zzbennett, swapnilghike, yhchiang Reviewed By: yhchiang Subscribers: leveldb Differential Revision: https://reviews.facebook.net/D21753
This commit is contained in:
parent
6c4c159b2c
commit
2da53b1e06
@ -47,6 +47,15 @@ public class BackupableDB extends RocksDB {
|
||||
public void createNewBackup(boolean flushBeforeBackup) {
|
||||
createNewBackup(nativeHandle_, flushBeforeBackup);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes old backups, keeping latest numBackupsToKeep alive.
|
||||
*
|
||||
* @param numBackupsToKeep Number of latest backups to keep.
|
||||
*/
|
||||
public void purgeOldBackups(int numBackupsToKeep) {
|
||||
purgeOldBackups(nativeHandle_, numBackupsToKeep);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@ -77,4 +86,5 @@ public class BackupableDB extends RocksDB {
|
||||
|
||||
protected native void open(long rocksDBHandle, long backupDBOptionsHandle);
|
||||
protected native void createNewBackup(long handle, boolean flag);
|
||||
protected native void purgeOldBackups(long handle, int numBackupsToKeep);
|
||||
}
|
||||
|
@ -40,7 +40,26 @@ void Java_org_rocksdb_BackupableDB_open(
|
||||
*/
|
||||
void Java_org_rocksdb_BackupableDB_createNewBackup(
|
||||
JNIEnv* env, jobject jbdb, jlong jhandle, jboolean jflag) {
|
||||
reinterpret_cast<rocksdb::BackupableDB*>(jhandle)->CreateNewBackup(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, jboolean jnumBackupsToKeep) {
|
||||
rocksdb::Status s =
|
||||
reinterpret_cast<rocksdb::BackupableDB*>(jhandle)->
|
||||
PurgeOldBackups(jnumBackupsToKeep);
|
||||
if (!s.ok()) {
|
||||
rocksdb::RocksDBExceptionJni::ThrowNew(env, s);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
Loading…
Reference in New Issue
Block a user