@ -5,103 +5,104 @@
//
// This file implements the "bridge" between Java and C++ and enables
// calling c++ ROCKSDB_NAMESPACE::BackupEnginge and
// ROCKSDB_NAMESPACE::BackupableDB Options methods from Java side.
// ROCKSDB_NAMESPACE::BackupEngine Options methods from Java side.
# include <jni.h>
# include <stdio.h>
# include <stdlib.h>
# include <string>
# include <vector>
# include "include/org_rocksdb_BackupableDB Options.h"
# include "rocksdb/utilities/backupable_db .h"
# include "include/org_rocksdb_BackupEngine Options.h"
# include "rocksdb/utilities/backup_engine .h"
# include "rocksjni/portal.h"
///////////////////////////////////////////////////////////////////////////
// BackupDBOptions
/*
* Class : org_rocksdb_BackupableDB Options
* Method : newBackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : newBackupEngine Options
* Signature : ( Ljava / lang / String ; ) J
*/
jlong Java_org_rocksdb_BackupableDBOptions_newBackupableDB Options (
jlong Java_org_rocksdb_BackupEngineOptions_newBackupEngine Options (
JNIEnv * env , jclass /*jcls*/ , jstring jpath ) {
const char * cpath = env - > GetStringUTFChars ( jpath , nullptr ) ;
if ( cpath = = nullptr ) {
// exception thrown: OutOfMemoryError
return 0 ;
}
auto * bopt = new ROCKSDB_NAMESPACE : : BackupableDB Options ( cpath ) ;
auto * bopt = new ROCKSDB_NAMESPACE : : BackupEngine Options ( cpath ) ;
env - > ReleaseStringUTFChars ( jpath , cpath ) ;
return reinterpret_cast < jlong > ( bopt ) ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : backupDir
* Signature : ( J ) Ljava / lang / String ;
*/
jstring Java_org_rocksdb_BackupableDB Options_backupDir ( JNIEnv * env ,
jstring Java_org_rocksdb_BackupEngine Options_backupDir ( JNIEnv * env ,
jobject /*jopt*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return env - > NewStringUTF ( bopt - > backup_dir . c_str ( ) ) ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setBackupEnv
* Signature : ( JJ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setBackupEnv (
void Java_org_rocksdb_BackupEngine Options_setBackupEnv (
JNIEnv * /*env*/ , jobject /*jopt*/ , jlong jhandle , jlong jrocks_env_handle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
auto * rocks_env =
reinterpret_cast < ROCKSDB_NAMESPACE : : Env * > ( jrocks_env_handle ) ;
bopt - > backup_env = rocks_env ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setShareTableFiles
* Signature : ( JZ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setShareTableFiles ( JNIEnv * /*env*/ ,
void Java_org_rocksdb_BackupEngine Options_setShareTableFiles ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ,
jboolean flag ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > share_table_files = flag ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : shareTableFiles
* Signature : ( J ) Z
*/
jboolean Java_org_rocksdb_BackupableDB Options_shareTableFiles ( JNIEnv * /*env*/ ,
jboolean Java_org_rocksdb_BackupEngine Options_shareTableFiles ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return bopt - > share_table_files ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setInfoLog
* Signature : ( JJ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setInfoLog ( JNIEnv * /*env*/ ,
void Java_org_rocksdb_BackupEngine Options_setInfoLog ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ,
jlong /*jlogger_handle*/ ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
auto * sptr_logger =
reinterpret_cast < std : : shared_ptr < ROCKSDB_NAMESPACE : : LoggerJniCallback > * > (
jhandle ) ;
@ -109,122 +110,122 @@ void Java_org_rocksdb_BackupableDBOptions_setInfoLog(JNIEnv* /*env*/,
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setSync
* Signature : ( JZ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setSync ( JNIEnv * /*env*/ ,
void Java_org_rocksdb_BackupEngine Options_setSync ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ,
jboolean flag ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > sync = flag ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : sync
* Signature : ( J ) Z
*/
jboolean Java_org_rocksdb_BackupableDB Options_sync ( JNIEnv * /*env*/ ,
jboolean Java_org_rocksdb_BackupEngine Options_sync ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return bopt - > sync ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setDestroyOldData
* Signature : ( JZ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setDestroyOldData ( JNIEnv * /*env*/ ,
void Java_org_rocksdb_BackupEngine Options_setDestroyOldData ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ,
jboolean flag ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > destroy_old_data = flag ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : destroyOldData
* Signature : ( J ) Z
*/
jboolean Java_org_rocksdb_BackupableDB Options_destroyOldData ( JNIEnv * /*env*/ ,
jboolean Java_org_rocksdb_BackupEngine Options_destroyOldData ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return bopt - > destroy_old_data ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setBackupLogFiles
* Signature : ( JZ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setBackupLogFiles ( JNIEnv * /*env*/ ,
void Java_org_rocksdb_BackupEngine Options_setBackupLogFiles ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ,
jboolean flag ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > backup_log_files = flag ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : backupLogFiles
* Signature : ( J ) Z
*/
jboolean Java_org_rocksdb_BackupableDB Options_backupLogFiles ( JNIEnv * /*env*/ ,
jboolean Java_org_rocksdb_BackupEngine Options_backupLogFiles ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return bopt - > backup_log_files ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setBackupRateLimit
* Signature : ( JJ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setBackupRateLimit (
void Java_org_rocksdb_BackupEngine Options_setBackupRateLimit (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ,
jlong jbackup_rate_limit ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > backup_rate_limit = jbackup_rate_limit ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : backupRateLimit
* Signature : ( J ) J
*/
jlong Java_org_rocksdb_BackupableDB Options_backupRateLimit ( JNIEnv * /*env*/ ,
jlong Java_org_rocksdb_BackupEngine Options_backupRateLimit ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return bopt - > backup_rate_limit ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setBackupRateLimiter
* Signature : ( JJ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setBackupRateLimiter (
void Java_org_rocksdb_BackupEngine Options_setBackupRateLimiter (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ,
jlong jrate_limiter_handle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
auto * sptr_rate_limiter =
reinterpret_cast < std : : shared_ptr < ROCKSDB_NAMESPACE : : RateLimiter > * > (
jrate_limiter_handle ) ;
@ -232,41 +233,41 @@ void Java_org_rocksdb_BackupableDBOptions_setBackupRateLimiter(
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setRestoreRateLimit
* Signature : ( JJ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setRestoreRateLimit (
void Java_org_rocksdb_BackupEngine Options_setRestoreRateLimit (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ,
jlong jrestore_rate_limit ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > restore_rate_limit = jrestore_rate_limit ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : restoreRateLimit
* Signature : ( J ) J
*/
jlong Java_org_rocksdb_BackupableDB Options_restoreRateLimit ( JNIEnv * /*env*/ ,
jlong Java_org_rocksdb_BackupEngine Options_restoreRateLimit ( JNIEnv * /*env*/ ,
jobject /*jobj*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return bopt - > restore_rate_limit ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setRestoreRateLimiter
* Signature : ( JJ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setRestoreRateLimiter (
void Java_org_rocksdb_BackupEngine Options_setRestoreRateLimiter (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ,
jlong jrate_limiter_handle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
auto * sptr_rate_limiter =
reinterpret_cast < std : : shared_ptr < ROCKSDB_NAMESPACE : : RateLimiter > * > (
jrate_limiter_handle ) ;
@ -274,90 +275,90 @@ void Java_org_rocksdb_BackupableDBOptions_setRestoreRateLimiter(
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setShareFilesWithChecksum
* Signature : ( JZ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setShareFilesWithChecksum (
void Java_org_rocksdb_BackupEngine Options_setShareFilesWithChecksum (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle , jboolean flag ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > share_files_with_checksum = flag ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : shareFilesWithChecksum
* Signature : ( J ) Z
*/
jboolean Java_org_rocksdb_BackupableDB Options_shareFilesWithChecksum (
jboolean Java_org_rocksdb_BackupEngine Options_shareFilesWithChecksum (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return bopt - > share_files_with_checksum ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setMaxBackgroundOperations
* Signature : ( JI ) V
*/
void Java_org_rocksdb_BackupableDB Options_setMaxBackgroundOperations (
void Java_org_rocksdb_BackupEngine Options_setMaxBackgroundOperations (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ,
jint max_background_operations ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > max_background_operations = static_cast < int > ( max_background_operations ) ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : maxBackgroundOperations
* Signature : ( J ) I
*/
jint Java_org_rocksdb_BackupableDB Options_maxBackgroundOperations (
jint Java_org_rocksdb_BackupEngine Options_maxBackgroundOperations (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return static_cast < jint > ( bopt - > max_background_operations ) ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : setCallbackTriggerIntervalSize
* Signature : ( JJ ) V
*/
void Java_org_rocksdb_BackupableDB Options_setCallbackTriggerIntervalSize (
void Java_org_rocksdb_BackupEngine Options_setCallbackTriggerIntervalSize (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ,
jlong jcallback_trigger_interval_size ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
bopt - > callback_trigger_interval_size =
static_cast < uint64_t > ( jcallback_trigger_interval_size ) ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : callbackTriggerIntervalSize
* Signature : ( J ) J
*/
jlong Java_org_rocksdb_BackupableDB Options_callbackTriggerIntervalSize (
jlong Java_org_rocksdb_BackupEngine Options_callbackTriggerIntervalSize (
JNIEnv * /*env*/ , jobject /*jobj*/ , jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
return static_cast < jlong > ( bopt - > callback_trigger_interval_size ) ;
}
/*
* Class : org_rocksdb_BackupableDB Options
* Class : org_rocksdb_BackupEngine Options
* Method : disposeInternal
* Signature : ( J ) V
*/
void Java_org_rocksdb_BackupableDB Options_disposeInternal ( JNIEnv * /*env*/ ,
void Java_org_rocksdb_BackupEngine Options_disposeInternal ( JNIEnv * /*env*/ ,
jobject /*jopt*/ ,
jlong jhandle ) {
auto * bopt =
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupableDB Options * > ( jhandle ) ;
reinterpret_cast < ROCKSDB_NAMESPACE : : BackupEngine Options * > ( jhandle ) ;
assert ( bopt ! = nullptr ) ;
delete bopt ;
}