diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index 2bb07cf45828..447e80979a4e 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -393,6 +393,116 @@ void Java_org_rocksdb_Options_setParanoidChecks(JNIEnv*, jclass, jlong jhandle, static_cast(paranoid_checks); } +/* + * Class: org_rocksdb_Options + * Method: setFlushVerifyMemtableCount + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setFlushVerifyMemtableCount(JNIEnv*, jclass, + jlong jhandle, jboolean flush_verify_memtable_count) { + reinterpret_cast(jhandle)->flush_verify_memtable_count = + static_cast(flush_verify_memtable_count); +} + +/* + * Class: org_rocksdb_Options + * Method: compactionVerifyRecordCount + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_compactionVerifyRecordCount(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->flush_verify_memtable_count; +} + +/* + * Class: org_rocksdb_Options + * Method: setCompactionVerifyRecordCount + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setCompactionVerifyRecordCount(JNIEnv*, jclass, + jlong jhandle, jboolean compaction_verify_record_count) { + reinterpret_cast(jhandle)->compaction_verify_record_count = + static_cast(compaction_verify_record_count); +} + +/* + * Class: org_rocksdb_Options + * Method: flushVerifyMemtableCount + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_flushVerifyMemtableCount(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->flush_verify_memtable_count; +} + +/* + * Class: org_rocksdb_Options + * Method: setTrackAndVerifyWalsInManifest + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setTrackAndVerifyWalsInManifest(JNIEnv*, jclass, + jlong jhandle, jboolean track_and_verify_wals_in_manifest) { + reinterpret_cast(jhandle)->track_and_verify_wals_in_manifest = + static_cast(track_and_verify_wals_in_manifest); +} + +/* + * Class: org_rocksdb_Options + * Method: trackAndVerifyWalsInManifest + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_trackAndVerifyWalsInManifest(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->track_and_verify_wals_in_manifest; +} + +/* + * Class: org_rocksdb_Options + * Method: setTrackAndVerifyWals + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setTrackAndVerifyWals(JNIEnv*, jclass, + jlong jhandle, jboolean track_and_verify_wals) { + reinterpret_cast(jhandle)->track_and_verify_wals = + static_cast(track_and_verify_wals); +} + +/* + * Class: org_rocksdb_Options + * Method: trackAndVerifyWals + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_trackAndVerifyWals(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->track_and_verify_wals; +} + +/* + * Class: org_rocksdb_Options + * Method: setVerifySstUniqueIdInManifest + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setVerifySstUniqueIdInManifest(JNIEnv*, jclass, + jlong jhandle, jboolean verify_sst_unique_id_in_manifest) { + reinterpret_cast(jhandle)->verify_sst_unique_id_in_manifest = + static_cast(verify_sst_unique_id_in_manifest); +} + +/* + * Class: org_rocksdb_Options + * Method: verifySstUniqueIdInManifest + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_verifySstUniqueIdInManifest(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->verify_sst_unique_id_in_manifest; +} + /* * Class: org_rocksdb_Options * Method: setEnv @@ -730,6 +840,28 @@ void Java_org_rocksdb_Options_setMaxBackgroundFlushes( ->max_background_flushes = static_cast(max_background_flushes); } +/* + * Class: org_rocksdb_Options + * Method: maxManifestSpaceAmpPet + * Signature: (J)I + */ +jint Java_org_rocksdb_Options_maxManifestSpaceAmpPet(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->max_manifest_space_amp_pct; +} + +/* + * Class: org_rocksdb_Options + * Method: setMaxManifestSpaceAmpPet + * Signature: (JI)V + */ +void Java_org_rocksdb_Options_setMaxManifestSpaceAmpPet( + JNIEnv*, jclass, jlong jhandle, jint max_manifest_space_amp_pct) { + reinterpret_cast(jhandle) + ->max_manifest_space_amp_pct = static_cast(max_manifest_space_amp_pct); +} + /* * Class: org_rocksdb_Options * Method: maxBackgroundJobs @@ -2007,6 +2139,30 @@ jbyte Java_org_rocksdb_Options_walRecoveryMode(JNIEnv*, jclass, jlong jhandle) { opt->wal_recovery_mode); } +/* + * Class: org_rocksdb_Options + * Method: setWalCompression + * Signature: (JB)V + */ +void Java_org_rocksdb_Options_setWalCompression( + JNIEnv*, jclass, jlong jhandle, jbyte jwal_compression_value) { + auto* opt = reinterpret_cast(jhandle); + opt->wal_compression = + ROCKSDB_NAMESPACE::CompressionTypeJni::toCppCompressionType( + jwal_compression_value); +} + +/* + * Class: org_rocksdb_Options + * Method: walCompression + * Signature: (J)B + */ +jbyte Java_org_rocksdb_Options_walCompression(JNIEnv*, jclass, jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return ROCKSDB_NAMESPACE::CompressionTypeJni::toJavaCompressionType( + opt->wal_compression); +} + /* * Class: org_rocksdb_Options * Method: setAllow2pc @@ -2122,6 +2278,28 @@ jboolean Java_org_rocksdb_Options_avoidUnnecessaryBlockingIO(JNIEnv*, jclass, return static_cast(opt->avoid_unnecessary_blocking_io); } +/* + * Class: org_rocksdb_Options + * Method: setPrefixSeekOptInOnly + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setPrefixSeekOptInOnly( + JNIEnv*, jclass, jlong jhandle, jboolean prefix_seek_opt_in_only) { + auto* opt = reinterpret_cast(jhandle); + opt->prefix_seek_opt_in_only = static_cast(prefix_seek_opt_in_only); +} + +/* + * Class: org_rocksdb_Options + * Method: prefixSeekOptInOnly + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_prefixSeekOptInOnly(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->prefix_seek_opt_in_only); +} + /* * Class: org_rocksdb_Options * Method: setPersistStatsToDisk @@ -2189,6 +2367,29 @@ jlong Java_org_rocksdb_Options_logReadaheadSize(JNIEnv*, jclass, return static_cast(opt->log_readahead_size); } +/* + * Class: org_rocksdb_Options + * Method: setFileChecksumGenFactory + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setFileChecksumGenFactory(JNIEnv*, jclass, + jlong jhandle, + jlong jfile_checksum_gen_factory) { + auto* opt = reinterpret_cast(jhandle); + opt->file_checksum_gen_factory = static_cast(jfile_checksum_gen_factory); +} + +/* + * Class: org_rocksdb_Options + * Method: fileChecksumGenFactory + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_fileChecksumGenFactory(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->file_checksum_gen_factory); +} + /* * Class: org_rocksdb_Options * Method: setBestEffortsRecovery @@ -2256,6 +2457,149 @@ jlong Java_org_rocksdb_Options_bgerrorResumeRetryInterval(JNIEnv*, jclass, return static_cast(opt->bgerror_resume_retry_interval); } +/* + * Class: org_rocksdb_Options + * Method: setAllowDataInErrors + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setAllowDataInErrors( + JNIEnv*, jclass, jlong jhandle, jboolean jallow_data_in_errors) { + auto* opt = reinterpret_cast(jhandle); + opt->allow_data_in_errors = static_cast(jallow_data_in_errors); +} + +/* + * Class: org_rocksdb_Options + * Method: allowDataInErrors + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_allowDataInErrors(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->allow_data_in_errors); +} + +/* + * Class: org_rocksdb_Options + * Method: setDbHostId + * Signature: (JLjava/lang/String)V + */ +void Java_org_rocksdb_Options_setDbHostId(JNIEnv* env, jclass, jlong jhandle, + jstring jdb_host_id) { +const char* host_id = env->GetStringUTFChars(jdb_host_id, nullptr); + if (host_id == nullptr) { + // exception thrown: OutOfMemoryError + return; + } + + reinterpret_cast(jhandle)->db_host_id.assign( + host_id); + env->ReleaseStringUTFChars(jdb_host_id, host_id); +} + +/* + * Class: org_rocksdb_Options + * Method: dbHostId + * Signature: (J)Ljava/lang/String + */ +jstring Java_org_rocksdb_Options_dbHostId(JNIEnv* env, jclass, + jlong jhandle) { + return env->NewStringUTF( + reinterpret_cast(jhandle) + ->db_host_id.c_str()); +} + +/* + * Class: org_rocksdb_Options + * Method: setEnforceSingleDelContracts + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setEnforceSingleDelContracts( + JNIEnv*, jclass, jlong jhandle, jboolean jenforce_single_del_contracts) { + auto* opt = reinterpret_cast(jhandle); + opt->enforce_single_del_contracts = static_cast(jenforce_single_del_contracts); +} + +/* + * Class: org_rocksdb_Options + * Method: enforceSingleDelContracts + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_enforceSingleDelContracts(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->enforce_single_del_contracts); +} + +/* + * Class: org_rocksdb_Options + * Method: setFollowerRefreshCatchupPeriodMs + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setFollowerRefreshCatchupPeriodMs( + JNIEnv*, jclass, jlong jhandle, jlong jfollower_refresh_catchup_period_ms) { + auto* opt = reinterpret_cast(jhandle); + opt->follower_refresh_catchup_period_ms = + static_cast(jfollower_refresh_catchup_period_ms); +} + +/* + * Class: org_rocksdb_Options + * Method: followerRefreshCatchupPeriodMs + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_followerRefreshCatchupPeriodMs(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->follower_refresh_catchup_period_ms); +} + +/* + * Class: org_rocksdb_Options + * Method: setFollowerRefreshCatchupRetryCount + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setFollowerRefreshCatchupRetryCount( + JNIEnv*, jclass, jlong jhandle, jlong jfollower_catchup_retry_count) { + auto* opt = reinterpret_cast(jhandle); + opt->follower_catchup_retry_count = + static_cast(jfollower_catchup_retry_count); +} + +/* + * Class: org_rocksdb_Options + * Method: followerRefreshCatchupRetryCount + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_followerRefreshCatchupRetryCount(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->follower_catchup_retry_count); +} + +/* + * Class: org_rocksdb_Options + * Method: setFollowerCatchupRetryWaitMs + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setFollowerCatchupRetryWaitMs( + JNIEnv*, jclass, jlong jhandle, jlong jfollower_catchup_retry_wait_ms) { + auto* opt = reinterpret_cast(jhandle); + opt->follower_catchup_retry_wait_ms = + static_cast(jfollower_catchup_retry_wait_ms); +} + +/* + * Class: org_rocksdb_Options + * Method: followerCatchupRetryWaitMs + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_followerCatchupRetryWaitMs(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->follower_catchup_retry_wait_ms); +} + /* * Class: org_rocksdb_Options * Method: setDailyOffpeakTimeUTC @@ -2374,6 +2718,28 @@ jboolean Java_org_rocksdb_Options_manualWalFlush(JNIEnv*, jclass, return static_cast(opt->manual_wal_flush); } +/* + * Class: org_rocksdb_Options + * Method: setBackgroundCloseInactiveWals + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setBackgroundCloseInactiveWals(JNIEnv*, jclass, jlong jhandle, + jboolean jbackground_close_inactive_wals) { + auto* opt = reinterpret_cast(jhandle); + opt->background_close_inactive_wals = jbackground_close_inactive_wals == JNI_TRUE; +} + +/* + * Class: org_rocksdb_Options + * Method: backgroundCloseInactiveWals + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_backgroundCloseInactiveWals(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->background_close_inactive_wals); +} + /* * Class: org_rocksdb_Options * Method: setAtomicFlush @@ -6020,6 +6386,116 @@ jboolean Java_org_rocksdb_DBOptions_paranoidChecks(JNIEnv*, jclass, ->paranoid_checks; } +/* + * Class: org_rocksdb_DBOptions + * Method: setFlushVerifyMemtableCount + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setFlushVerifyMemtableCount(JNIEnv*, jclass, + jlong jhandle, jboolean flush_verify_memtable_count) { + reinterpret_cast(jhandle)->flush_verify_memtable_count = + static_cast(flush_verify_memtable_count); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: flushVerifyMemtableCount + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_flushVerifyMemtableCount(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->flush_verify_memtable_count; +} + +/* + * Class: org_rocksdb_DBOptions + * Method: compactionVerifyRecordCount + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_compactionVerifyRecordCount(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->flush_verify_memtable_count; +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setCompactionVerifyRecordCount + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setCompactionVerifyRecordCount(JNIEnv*, jclass, + jlong jhandle, jboolean compaction_verify_record_count) { + reinterpret_cast(jhandle)->compaction_verify_record_count = + static_cast(compaction_verify_record_count); +} + +/* + * Class: org_rocksdb_Options + * Method: setTrackAndVerifyWalsInManifest + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setTrackAndVerifyWalsInManifest(JNIEnv*, jclass, + jlong jhandle, jboolean track_and_verify_wals_in_manifest) { + reinterpret_cast(jhandle)->track_and_verify_wals_in_manifest = + static_cast(track_and_verify_wals_in_manifest); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: trackAndVerifyWalsInManifest + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_trackAndVerifyWalsInManifest(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->track_and_verify_wals_in_manifest; +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setTrackAndVerifyWals + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setTrackAndVerifyWals(JNIEnv*, jclass, + jlong jhandle, jboolean track_and_verify_wals) { + reinterpret_cast(jhandle)->track_and_verify_wals = + static_cast(track_and_verify_wals); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: trackAndVerifyWals + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_trackAndVerifyWals(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->track_and_verify_wals; +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setVerifySstUniqueIdInManifest + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setVerifySstUniqueIdInManifest(JNIEnv*, jclass, + jlong jhandle, jboolean verify_sst_unique_id_in_manifest) { + reinterpret_cast(jhandle)->verify_sst_unique_id_in_manifest = + static_cast(verify_sst_unique_id_in_manifest); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: verifySstUniqueIdInManifest + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_verifySstUniqueIdInManifest(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->verify_sst_unique_id_in_manifest; +} + /* * Class: org_rocksdb_DBOptions * Method: setRateLimiter @@ -6456,6 +6932,28 @@ jint Java_org_rocksdb_DBOptions_maxBackgroundFlushes(JNIEnv*, jclass, ->max_background_flushes; } +/* + * Class: org_rocksdb_DBOptions + * Method: maxManifestSpaceAmpPet + * Signature: (J)I + */ +jint Java_org_rocksdb_DBOptions_maxManifestSpaceAmpPet(JNIEnv*, jclass, + jlong jhandle) { + return reinterpret_cast(jhandle) + ->max_manifest_space_amp_pct; +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setMaxManifestSpaceAmpPet + * Signature: (JI)V + */ +void Java_org_rocksdb_DBOptions_setMaxManifestSpaceAmpPet( + JNIEnv*, jclass, jlong jhandle, jint max_manifest_space_amp_pct) { + reinterpret_cast(jhandle) + ->max_manifest_space_amp_pct = static_cast(max_manifest_space_amp_pct); +} + /* * Class: org_rocksdb_DBOptions * Method: setMaxBackgroundJobs @@ -7408,6 +7906,30 @@ jbyte Java_org_rocksdb_DBOptions_walRecoveryMode(JNIEnv*, jclass, opt->wal_recovery_mode); } +/* + * Class: org_rocksdb_DBOptions + * Method: setWalCompression + * Signature: (JB)V + */ +void Java_org_rocksdb_DBOptions_setWalCompression( + JNIEnv*, jclass, jlong jhandle, jbyte jwal_compression_value) { + auto* opt = reinterpret_cast(jhandle); + opt->wal_compression = + ROCKSDB_NAMESPACE::CompressionTypeJni::toCppCompressionType( + jwal_compression_value); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: walCompression + * Signature: (J)B + */ +jbyte Java_org_rocksdb_DBOptions_walCompression(JNIEnv*, jclass, jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return ROCKSDB_NAMESPACE::CompressionTypeJni::toJavaCompressionType( + opt->wal_compression); +} + /* * Class: org_rocksdb_DBOptions * Method: setAllow2pc @@ -7569,6 +8091,28 @@ jboolean Java_org_rocksdb_DBOptions_manualWalFlush(JNIEnv*, jclass, return static_cast(opt->manual_wal_flush); } +/* + * Class: org_rocksdb_DBOptions + * Method: setBackgroundCloseInactiveWals + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setBackgroundCloseInactiveWals(JNIEnv*, jclass, jlong jhandle, + jboolean jbackground_close_inactive_wals) { + auto* opt = reinterpret_cast(jhandle); + opt->background_close_inactive_wals = jbackground_close_inactive_wals == JNI_TRUE; +} + +/* + * Class: org_rocksdb_DBOptions + * Method: backgroundCloseInactiveWals + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_backgroundCloseInactiveWals(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->background_close_inactive_wals); +} + /* * Class: org_rocksdb_DBOptions * Method: setAtomicFlush @@ -7636,6 +8180,28 @@ jboolean Java_org_rocksdb_DBOptions_avoidUnnecessaryBlockingIO(JNIEnv*, jclass, return static_cast(opt->avoid_unnecessary_blocking_io); } +/* + * Class: org_rocksdb_DBOptions + * Method: setPrefixSeekOptInOnly + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setPrefixSeekOptInOnly( + JNIEnv*, jclass, jlong jhandle, jboolean prefix_seek_opt_in_only) { + auto* opt = reinterpret_cast(jhandle); + opt->prefix_seek_opt_in_only = static_cast(prefix_seek_opt_in_only); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: prefixSeekOptInOnly + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_prefixSeekOptInOnly(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->prefix_seek_opt_in_only); +} + /* * Class: org_rocksdb_DBOptions * Method: setPersistStatsToDisk @@ -7680,6 +8246,28 @@ jboolean Java_org_rocksdb_DBOptions_writeDbidToManifest(JNIEnv*, jclass, return static_cast(opt->write_dbid_to_manifest); } +/* + * Class: org_rocksdb_DBOptions + * Method: setWriteIdentityFile + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setWriteIdentityFile( + JNIEnv*, jclass, jlong jhandle, jboolean jwrite_identity_file) { + auto* opt = reinterpret_cast(jhandle); + opt->write_identity_file = static_cast(jwrite_identity_file); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: writeIdentityFile + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_writeIdentityFile(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->write_identity_file); +} + /* * Class: org_rocksdb_DBOptions * Method: setLogReadaheadSize @@ -7770,6 +8358,148 @@ jlong Java_org_rocksdb_DBOptions_bgerrorResumeRetryInterval(JNIEnv*, jclass, return static_cast(opt->bgerror_resume_retry_interval); } +/* + * Class: org_rocksdb_DBOptions + * Method: setAllowDataInErrors + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setAllowDataInErrors( + JNIEnv*, jclass, jlong jhandle, jboolean jallow_data_in_errors) { + auto* opt = reinterpret_cast(jhandle); + opt->allow_data_in_errors = static_cast(jallow_data_in_errors); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: allowDataInErrors + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_allowDataInErrors(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->allow_data_in_errors); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setDbHostId + * Signature: (JLjava/lang/String)V + */ +void Java_org_rocksdb_DBOptions_setDbHostId(JNIEnv* env, jclass, jlong jhandle, + jstring jdb_host_id) { + const char* host_id = env->GetStringUTFChars(jdb_host_id, nullptr); + if (host_id == nullptr) { + // exception thrown: OutOfMemoryError + return; + } + + reinterpret_cast(jhandle)->db_host_id.assign(host_id); + env->ReleaseStringUTFChars(jdb_host_id, host_id); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: dbHostId + * Signature: (J)Ljava/lang/String + */ +jstring Java_org_rocksdb_DBOptions_dbHostId(JNIEnv* env, jclass, + jlong jhandle) { + return env->NewStringUTF( + reinterpret_cast(jhandle) + ->db_host_id.c_str()); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setEnforceSingleDelContracts + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setEnforceSingleDelContracts( + JNIEnv*, jclass, jlong jhandle, jboolean jenforce_single_del_contracts) { + auto* opt = reinterpret_cast(jhandle); + opt->enforce_single_del_contracts = static_cast(jenforce_single_del_contracts); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: enforceSingleDelContracts + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_enforceSingleDelContracts(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->enforce_single_del_contracts); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setFollowerRefreshCatchupPeriodMs + * Signature: (JJ)V + */ +void Java_org_rocksdb_DBOptions_setFollowerRefreshCatchupPeriodMs( + JNIEnv*, jclass, jlong jhandle, jlong jfollower_refresh_catchup_period_ms) { + auto* opt = reinterpret_cast(jhandle); + opt->follower_refresh_catchup_period_ms = + static_cast(jfollower_refresh_catchup_period_ms); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: followerRefreshCatchupPeriodMs + * Signature: (J)J + */ +jlong Java_org_rocksdb_DBOptions_followerRefreshCatchupPeriodMs(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->follower_refresh_catchup_period_ms); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setFollowerRefreshCatchupRetryCount + * Signature: (JJ)V + */ +void Java_org_rocksdb_DBOptions_setFollowerRefreshCatchupRetryCount( + JNIEnv*, jclass, jlong jhandle, jlong jfollower_catchup_retry_count) { + auto* opt = reinterpret_cast(jhandle); + opt->follower_catchup_retry_count = + static_cast(jfollower_catchup_retry_count); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: followerRefreshCatchupRetryCount + * Signature: (J)J + */ +jlong Java_org_rocksdb_DBOptions_followerRefreshCatchupRetryCount(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->follower_catchup_retry_count); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setFollowerCatchupRetryWaitMs + * Signature: (JJ)V + */ +void Java_org_rocksdb_DBOptions_setFollowerCatchupRetryWaitMs( + JNIEnv*, jclass, jlong jhandle, jlong jfollower_catchup_retry_wait_ms) { + auto* opt = reinterpret_cast(jhandle); + opt->follower_catchup_retry_wait_ms = + static_cast(jfollower_catchup_retry_wait_ms); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: followerCatchupRetryWaitMs + * Signature: (J)J + */ +jlong Java_org_rocksdb_DBOptions_followerCatchupRetryWaitMs(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->follower_catchup_retry_wait_ms); +} + /* * Class: org_rocksdb_DBOptions * Method: setDailyOffpeakTimeUTC diff --git a/java/src/main/java/org/rocksdb/DBOptions.java b/java/src/main/java/org/rocksdb/DBOptions.java index 0221a63fba07..e3f528c5ac75 100644 --- a/java/src/main/java/org/rocksdb/DBOptions.java +++ b/java/src/main/java/org/rocksdb/DBOptions.java @@ -185,6 +185,76 @@ public boolean paranoidChecks() { return paranoidChecks(nativeHandle_); } + @Override + public DBOptions setFlushVerifyMemtableCount( + final boolean flushVerifyMemtableCount) { + assert(isOwningHandle()); + setFlushVerifyMemtableCount(nativeHandle_, flushVerifyMemtableCount); + return this; + } + + @Override + public boolean flushVerifyMemtableCount() { + assert(isOwningHandle()); + return flushVerifyMemtableCount(nativeHandle_); + } + + @Override + public DBOptions setCompactionVerifyRecordCount( + final boolean compactionVerifyRecordCount) { + assert(isOwningHandle()); + setCompactionVerifyRecordCount(nativeHandle_, compactionVerifyRecordCount); + return this; + } + + @Override + public boolean compactionVerifyRecordCount() { + assert(isOwningHandle()); + return compactionVerifyRecordCount(nativeHandle_); + } + + @Override + public DBOptions setTrackAndVerifyWalsInManifest( + final boolean trackAndVerifyWalsInManifest) { + assert(isOwningHandle()); + setTrackAndVerifyWalsInManifest(nativeHandle_, trackAndVerifyWalsInManifest); + return this; + } + + @Override + public boolean trackAndVerifyWalsInManifest() { + assert(isOwningHandle()); + return trackAndVerifyWalsInManifest(nativeHandle_); + } + + @Override + public DBOptions setTrackAndVerifyWals( + final boolean trackAndVerifyWals) { + assert(isOwningHandle()); + setTrackAndVerifyWals(nativeHandle_, trackAndVerifyWals); + return this; + } + + @Override + public boolean trackAndVerifyWals() { + assert(isOwningHandle()); + return trackAndVerifyWals(nativeHandle_); + } + + @Override + public DBOptions setVerifySstUniqueIdInManifest( + final boolean verifySstUniqueIdInManifest) { + assert(isOwningHandle()); + setVerifySstUniqueIdInManifest(nativeHandle_, verifySstUniqueIdInManifest); + return this; + } + + @Override + public boolean verifySstUniqueIdInManifest() { + assert(isOwningHandle()); + return verifySstUniqueIdInManifest(nativeHandle_); + } + @Override public DBOptions setEnv(final Env env) { setEnv(nativeHandle_, env.nativeHandle_); @@ -399,6 +469,19 @@ public int maxBackgroundJobs() { return maxBackgroundJobs(nativeHandle_); } + @Override + public DBOptions setMaxManifestSpaceAmpPet(final int maxManifestSpaceAmpPet) { + assert(isOwningHandle()); + setMaxManifestSpaceAmpPet(nativeHandle_, maxManifestSpaceAmpPet); + return this; + } + + @Override + public int maxManifestSpaceAmpPet() { + assert(isOwningHandle()); + return maxManifestSpaceAmpPet(nativeHandle_); + } + @Override @Deprecated public DBOptions setMaxBackgroundCompactions( @@ -988,6 +1071,19 @@ public WALRecoveryMode walRecoveryMode() { return WALRecoveryMode.getWALRecoveryMode(walRecoveryMode(nativeHandle_)); } + @Override + public DBOptions setWalCompression(final CompressionType walCompression) { + assert(isOwningHandle()); + setWalCompression(nativeHandle_, walCompression.getValue()); + return this; + } + + @Override + public CompressionType walCompression() { + assert(isOwningHandle()); + return CompressionType.getCompressionType(walCompression(nativeHandle_)); + } + @Override public DBOptions setAllow2pc(final boolean allow2pc) { assert(isOwningHandle()); @@ -1029,19 +1125,6 @@ public WalFilter walFilter() { return this.walFilter_; } - @Override - public DBOptions setFailIfOptionsFileError(final boolean failIfOptionsFileError) { - assert(isOwningHandle()); - setFailIfOptionsFileError(nativeHandle_, failIfOptionsFileError); - return this; - } - - @Override - public boolean failIfOptionsFileError() { - assert(isOwningHandle()); - return failIfOptionsFileError(nativeHandle_); - } - @Override public DBOptions setDumpMallocStats(final boolean dumpMallocStats) { assert(isOwningHandle()); @@ -1120,6 +1203,19 @@ public boolean manualWalFlush() { return manualWalFlush(nativeHandle_); } + @Override + public DBOptions setBackgroundCloseInactiveWals(final boolean manualWalFlush) { + assert(isOwningHandle()); + setBackgroundCloseInactiveWals(nativeHandle_, manualWalFlush); + return this; + } + + @Override + public boolean backgroundCloseInactiveWals() { + assert(isOwningHandle()); + return backgroundCloseInactiveWals(nativeHandle_); + } + @Override public DBOptions setAtomicFlush(final boolean atomicFlush) { setAtomicFlush(nativeHandle_, atomicFlush); @@ -1143,6 +1239,18 @@ public boolean avoidUnnecessaryBlockingIO() { return avoidUnnecessaryBlockingIO(nativeHandle_); } + @Override + public DBOptions setPrefixSeekOptInOnly(final boolean prefixSeekOptInOnly) { + setPrefixSeekOptInOnly(nativeHandle_, prefixSeekOptInOnly); + return this; + } + + @Override + public boolean prefixSeekOptInOnly() { + assert (isOwningHandle()); + return prefixSeekOptInOnly(nativeHandle_); + } + @Override public DBOptions setPersistStatsToDisk(final boolean persistStatsToDisk) { setPersistStatsToDisk(nativeHandle_, persistStatsToDisk); @@ -1167,6 +1275,18 @@ public boolean writeDbidToManifest() { return writeDbidToManifest(nativeHandle_); } + @Override + public DBOptions setWriteIdentityFile(final boolean writeIdentityFile) { + setWriteIdentityFile(nativeHandle_, writeIdentityFile); + return this; + } + + @Override + public boolean writeIdentityFile() { + assert (isOwningHandle()); + return writeIdentityFile(nativeHandle_); + } + @Override public DBOptions setLogReadaheadSize(final long logReadaheadSize) { setLogReadaheadSize(nativeHandle_, logReadaheadSize); @@ -1215,6 +1335,84 @@ public long bgerrorResumeRetryInterval() { return bgerrorResumeRetryInterval(nativeHandle_); } + @Override + public DBOptions setAllowDataInErrors(final boolean allowDataInErrors) { + assert(isOwningHandle()); + setAllowDataInErrors(nativeHandle_, allowDataInErrors); + return this; + } + + @Override + public boolean allowDataInErrors() { + assert(isOwningHandle()); + return allowDataInErrors(nativeHandle_); + } + + @Override + public String dbHostId() { + assert(isOwningHandle()); + return dbHostId(nativeHandle_); + } + + @Override + public DBOptions setDbHostId(final String dbHostId) { + assert(isOwningHandle()); + setDbHostId(nativeHandle_, dbHostId); + return this; + } + + @Override + public DBOptions setEnforceSingleDelContracts(final boolean enforceSingleDelContracts) { + assert(isOwningHandle()); + setEnforceSingleDelContracts(nativeHandle_, enforceSingleDelContracts); + return this; + } + + @Override + public boolean enforceSingleDelContracts() { + assert(isOwningHandle()); + return enforceSingleDelContracts(nativeHandle_); + } + + @Override + public DBOptions setFollowerRefreshCatchupPeriodMs(final long followerRefreshCatchupPeriodMs) { + assert(isOwningHandle()); + setFollowerRefreshCatchupPeriodMs(nativeHandle_, followerRefreshCatchupPeriodMs); + return this; + } + + @Override + public long followerRefreshCatchupPeriodMs() { + assert(isOwningHandle()); + return followerRefreshCatchupPeriodMs(nativeHandle_); + } + + @Override + public DBOptions setFollowerRefreshCatchupRetryCount(final long followerRefreshCatchupRetryCount) { + assert(isOwningHandle()); + setFollowerRefreshCatchupRetryCount(nativeHandle_, followerRefreshCatchupRetryCount); + return this; + } + + @Override + public long followerRefreshCatchupRetryCount() { + assert(isOwningHandle()); + return followerRefreshCatchupRetryCount(nativeHandle_); + } + + @Override + public DBOptions setFollowerCatchupRetryWaitMs(final long followerCatchupRetryWaitMs) { + assert(isOwningHandle()); + setFollowerCatchupRetryWaitMs(nativeHandle_, followerCatchupRetryWaitMs); + return this; + } + + @Override + public long followerCatchupRetryWaitMs() { + assert(isOwningHandle()); + return followerCatchupRetryWaitMs(nativeHandle_); + } + static final int DEFAULT_NUM_SHARD_BITS = -1; @@ -1257,6 +1455,16 @@ protected final void disposeInternal(final long handle) { private static native boolean errorIfExists(long handle); private static native void setParanoidChecks(long handle, boolean paranoidChecks); private static native boolean paranoidChecks(long handle); + private static native void setFlushVerifyMemtableCount(long handle, boolean flushVerifyMemtableCount); + private static native boolean flushVerifyMemtableCount(long handle); + private static native void setCompactionVerifyRecordCount(long handle, boolean compactionVerifyRecordCount); + private static native boolean compactionVerifyRecordCount(long handle); + private static native void setTrackAndVerifyWalsInManifest(long handle, boolean trackAndVerifyWalsInManifest); + private static native boolean trackAndVerifyWalsInManifest(long handle); + private static native void setTrackAndVerifyWals(long handle, boolean trackAndVerifyWals); + private static native boolean trackAndVerifyWals(long handle); + private static native void setVerifySstUniqueIdInManifest(long handle, boolean trackAndVerifyWals); + private static native boolean verifySstUniqueIdInManifest(long handle); private static native void setRateLimiter(long handle, long rateLimiterHandle); private static native void setSstFileManager(final long handle, final long sstFileManagerHandle); private static native void setLogger( @@ -1293,6 +1501,8 @@ private static native void dbPaths( private static native int maxBackgroundFlushes(long handle); private static native void setMaxBackgroundJobs(long handle, int maxBackgroundJobs); private static native int maxBackgroundJobs(long handle); + private static native void setMaxManifestSpaceAmpPet(long handle, int maxManifestSpaceAmpPet); + private static native int maxManifestSpaceAmpPet(long handle); private static native void setMaxLogFileSize(long handle, long maxLogFileSize) throws IllegalArgumentException; private static native long maxLogFileSize(long handle); @@ -1394,13 +1604,12 @@ private static native void setSkipCheckingSstFileSizesOnDbOpen( private static native boolean skipCheckingSstFileSizesOnDbOpen(final long handle); private static native void setWalRecoveryMode(final long handle, final byte walRecoveryMode); private static native byte walRecoveryMode(final long handle); + private static native void setWalCompression(final long handle, final byte walCompression); + private static native byte walCompression(final long handle); private static native void setAllow2pc(final long handle, final boolean allow2pc); private static native boolean allow2pc(final long handle); private static native void setRowCache(final long handle, final long rowCacheHandle); private static native void setWalFilter(final long handle, final long walFilterHandle); - private static native void setFailIfOptionsFileError( - final long handle, final boolean failIfOptionsFileError); - private static native boolean failIfOptionsFileError(final long handle); private static native void setDumpMallocStats(final long handle, final boolean dumpMallocStats); private static native boolean dumpMallocStats(final long handle); private static native void setAvoidFlushDuringRecovery( @@ -1416,17 +1625,25 @@ private static native void setAllowIngestBehind( private static native boolean twoWriteQueues(final long handle); private static native void setManualWalFlush(final long handle, final boolean manualWalFlush); private static native boolean manualWalFlush(final long handle); + private static native void setBackgroundCloseInactiveWals(final long handle, final boolean manualWalFlush); + private static native boolean backgroundCloseInactiveWals(final long handle); private static native void setAtomicFlush(final long handle, final boolean atomicFlush); private static native boolean atomicFlush(final long handle); private static native void setAvoidUnnecessaryBlockingIO( final long handle, final boolean avoidBlockingIO); private static native boolean avoidUnnecessaryBlockingIO(final long handle); + private static native void setPrefixSeekOptInOnly( + final long handle, final boolean prefixSeekOptInOnly); + private static native boolean prefixSeekOptInOnly(final long handle); private static native void setPersistStatsToDisk( final long handle, final boolean persistStatsToDisk); private static native boolean persistStatsToDisk(final long handle); private static native void setWriteDbidToManifest( final long handle, final boolean writeDbidToManifest); private static native boolean writeDbidToManifest(final long handle); + private static native void setWriteIdentityFile( + final long handle, final boolean writeDbidToManifest); + private static native boolean writeIdentityFile(final long handle); private static native void setLogReadaheadSize(final long handle, final long logReadaheadSize); private static native long logReadaheadSize(final long handle); private static native void setBestEffortsRecovery( @@ -1438,6 +1655,18 @@ private static native void setMaxBgErrorResumeCount( private static native void setBgerrorResumeRetryInterval( final long handle, final long bgerrorResumeRetryInterval); private static native long bgerrorResumeRetryInterval(final long handle); + private static native void setAllowDataInErrors(final long handle, final boolean allowDataInErrors); + private static native boolean allowDataInErrors(final long handle); + private static native void setDbHostId(long handle, String dbLogDir); + private static native String dbHostId(long handle); + private static native void setEnforceSingleDelContracts(final long handle, final boolean allowDataInErrors); + private static native boolean enforceSingleDelContracts(final long handle); + private static native void setFollowerRefreshCatchupPeriodMs(final long handle, final long followerRefreshCatchupPeriodMs); + private static native long followerRefreshCatchupPeriodMs(final long handle); + private static native void setFollowerRefreshCatchupRetryCount(final long handle, final long followerRefreshCatchupRetryCount); + private static native long followerRefreshCatchupRetryCount(final long handle); + private static native void setFollowerCatchupRetryWaitMs(final long handle, final long followerCatchupRetryWaitMs); + private static native long followerCatchupRetryWaitMs(final long handle); // instance variables // NOTE: If you add new member variables, please update the copy constructor above! diff --git a/java/src/main/java/org/rocksdb/DBOptionsInterface.java b/java/src/main/java/org/rocksdb/DBOptionsInterface.java index bc9d9acbd65e..44d2da704da0 100644 --- a/java/src/main/java/org/rocksdb/DBOptionsInterface.java +++ b/java/src/main/java/org/rocksdb/DBOptionsInterface.java @@ -145,6 +145,224 @@ public interface DBOptionsInterface> { */ boolean paranoidChecks(); + /** + * @deprecated This option might be removed in a future release. + *

+ * If true, during memtable flush, RocksDB will validate total entries + * read in flush, total entries written in the SST and compare them with + * counter of keys added. + *

+ * The option is here to turn the feature off in case this new validation + * feature has a bug. The option may be removed in the future once the + * feature is stable. + *

+ * Default: {@code true} + * + * @param flushVerifyMemtableCount a flag to indicate whether the verification is on + * + * @return {@code this} + */ + @Deprecated + T setFlushVerifyMemtableCount(boolean flushVerifyMemtableCount); + + /** + * @deprecated This option might be removed in a future release. + *

+ * If true, during memtable flush, RocksDB will validate total entries + * read in flush, total entries written in the SST and compare them with + * counter of keys added. + *

+ * The option is here to turn the feature off in case this new validation + * feature has a bug. The option may be removed in the future once the + * feature is stable. + * + * @return a flag indicating whether the verification is on + */ + @Deprecated + boolean flushVerifyMemtableCount(); + + /** + * @deprecated This option might be removed in a future release. + *

+ * If true, during compaction, RocksDB will count the number of entries + * read and compare it against the number of entries in the compaction + * input files. This is intended to add protection against corruption + * during compaction. Note that + * - this verification is not done for compactions during which a compaction + * filter returns kRemoveAndSkipUntil, and + * - the number of range deletions is not verified. + *

+ * The option is here to turn the feature off in case this new validation + * feature has a bug. The option may be removed in the future once the + * feature is stable. + *

+ * Default: true + * + * @param compactionVerifyRecordCount a flag to indicate whether compaction count is on + * + * @return {@code this} + */ + @Deprecated + T setCompactionVerifyRecordCount(boolean compactionVerifyRecordCount); + + /** + * @deprecated This option might be removed in a future release. + *

+ * If true, during compaction, RocksDB will count the number of entries + * read and compare it against the number of entries in the compaction + * input files. This is intended to add protection against corruption + * during compaction. Note that + * - this verification is not done for compactions during which a compaction + * filter returns kRemoveAndSkipUntil, and + * - the number of range deletions is not verified. + *

+ * The option is here to turn the feature off in case this new validation + * feature has a bug. The option may be removed in the future once the + * feature is stable. + * + * @return A flag to indicate whether compaction count is on + */ + @Deprecated + boolean compactionVerifyRecordCount(); + + /** + * If true, the log numbers and sizes of the synced WALs are tracked + * in MANIFEST. During DB recovery, if a synced WAL is missing + * from disk, or the WAL's size does not match the recorded size in + * MANIFEST, an error will be reported and the recovery will be aborted. + *

+ * This is one additional protection against WAL corruption besides the + * per-WAL-entry checksum. + *

+ * Note that this option does not work with secondary instance. + * Currently, only syncing closed WALs are tracked. Calling `DB::SyncWAL()`, + * etc. or writing with `WriteOptions::sync=true` to sync the live WAL is not + * tracked for performance/efficiency reasons. + *

+ * Default: false + * + * @param trackAndVerifyWalsInManifest A flag to indicate whether to track log numbers and sizes in MANIFEST. + * + * @return {@code this} + */ + T setTrackAndVerifyWalsInManifest(boolean trackAndVerifyWalsInManifest); + + /** + * If true, the log numbers and sizes of the synced WALs are tracked + * in MANIFEST. During DB recovery, if a synced WAL is missing + * from disk, or the WAL's size does not match the recorded size in + * MANIFEST, an error will be reported and the recovery will be aborted. + *

+ * This is one additional protection against WAL corruption besides the + * per-WAL-entry checksum. + *

+ * Note that this option does not work with secondary instance. + * Currently, only syncing closed WALs are tracked. Calling `DB::SyncWAL()`, + * etc. or writing with `WriteOptions::sync=true` to sync the live WAL is not + * tracked for performance/efficiency reasons. + * + * @return A flag indicating whether to track log numbers and sizes in MANIFEST. + */ + boolean trackAndVerifyWalsInManifest(); + + /** + * EXPERIMENTAL + *

+ * If true, each new WAL will record various information about its predecessor + * WAL for verification on the predecessor WAL during WAL recovery. + *

+ * It verifies the following: + * 1. There exists at least some WAL in the DB + * - It's not compatible with `RepairDB()` since this option imposes a + * stricter requirement on WAL than the DB went through `RepariDB()` can + * normally meet + * 2. There exists no WAL hole where new WAL data presents while some old WAL + * data not yet obsolete is missing. The DB manifest indicates which WALs are + * obsolete. + *

+ * This is intended to be a better replacement to + * {@link #setTrackAndVerifyWalsInManifest(boolean)}. + *

+ * Default: false + * + * @param trackAndVerifyWals A flag to indicate whether each new WAL should record information about its predecessor for verification purposes + * + * @return {@code this} + */ + T setTrackAndVerifyWals(boolean trackAndVerifyWals); + + /** + * EXPERIMENTAL + *

+ * If true, each new WAL will record various information about its predecessor + * WAL for verification on the predecessor WAL during WAL recovery. + *

+ * It verifies the following: + * 1. There exists at least some WAL in the DB + * - It's not compatible with `RepairDB()` since this option imposes a + * stricter requirement on WAL than the DB went through `RepariDB()` can + * normally meet + * 2. There exists no WAL hole where new WAL data presents while some old WAL + * data not yet obsolete is missing. The DB manifest indicates which WALs are + * obsolete. + *

+ * This is intended to be a better replacement to + * {@link #trackAndVerifyWalsInManifest()}. + * + * @return A flag indicating whether each new WAL will record information about its predecessor for verification purposes + */ + boolean trackAndVerifyWals(); + + /** + * If true, verifies the SST unique id between MANIFEST and actual file + * each time an SST file is opened. This check ensures an SST file is not + * overwritten or misplaced. A corruption error will be reported if mismatch + * detected, but only when MANIFEST tracks the unique id, which starts from + * RocksDB version 7.3. Although the tracked internal unique id is related + * to the one returned by GetUniqueIdFromTableProperties, that is subject to + * change. + * NOTE: verification is currently only done on SST files using block-based + * table format. + *

+ * Setting to false should only be needed in case of unexpected problems. + *

+ * Although an early version of this option opened all SST files for + * verification on DB::Open, that is no longer guaranteed. However, as + * documented in an above option, if max_open_files is -1, DB will open all + * files on DB::Open(). + *

+ * Default: true + * + * @param verifySstUniqueIdInManifest A flag indicating whether the SST unique ID + * should be verified against MANIFEST on every opening of an SST file + * + * @return {@code this} + */ + T setVerifySstUniqueIdInManifest(boolean verifySstUniqueIdInManifest); + + /** + * If true, verifies the SST unique id between MANIFEST and actual file + * each time an SST file is opened. This check ensures an SST file is not + * overwritten or misplaced. A corruption error will be reported if mismatch + * detected, but only when MANIFEST tracks the unique id, which starts from + * RocksDB version 7.3. Although the tracked internal unique id is related + * to the one returned by GetUniqueIdFromTableProperties, that is subject to + * change. + * NOTE: verification is currently only done on SST files using block-based + * table format. + *

+ * Setting to false should only be needed in case of unexpected problems. + *

+ * Although an early version of this option opened all SST files for + * verification on DB::Open, that is no longer guaranteed. However, as + * documented in an above option, if max_open_files is -1, DB will open all + * files on DB::Open(). + * + * @return A flag indicating whether the SST unique ID + * will be verified against MANIFEST on every opening of an SST file + */ + boolean verifySstUniqueIdInManifest(); + /** * Use to control write rate of flush and compaction. Flush has higher * priority than compaction. Rate limiting is disabled if nullptr. @@ -1264,6 +1482,30 @@ T setEnableWriteThreadAdaptiveYield( */ WALRecoveryMode walRecoveryMode(); + /** + * If enabled WAL records will be compressed before they are written. Only + * ZSTD (= kZSTD) is supported (until streaming support is adapted for other + * compression types). Compressed WAL records will be read in supported + * versions (>= RocksDB 7.4.0 for ZSTD) regardless of this setting when + * the WAL is read. + * + * @param walCompression The {@link CompressionType} + * + * @return {@code this} + */ + T setWalCompression(CompressionType walCompression); + + /** + * If enabled WAL records will be compressed before they are written. Only + * ZSTD (= kZSTD) is supported (until streaming support is adapted for other + * compression types). Compressed WAL records will be read in supported + * versions (>= RocksDB 7.4.0 for ZSTD) regardless of this setting when + * the WAL is read. + * + * @return The {@link CompressionType} + */ + CompressionType walCompression(); + /** * if set to false then recovery will fail when a prepared * transaction is encountered in the WAL @@ -1327,31 +1569,6 @@ T setEnableWriteThreadAdaptiveYield( */ WalFilter walFilter(); - /** - * If true, then DB::Open / CreateColumnFamily / DropColumnFamily - * / SetOptions will fail if options file is not detected or properly - * persisted. - * - * DEFAULT: false - * - * @param failIfOptionsFileError true if we should fail if there is an error - * in the options file - * - * @return the reference to the current options. - */ - T setFailIfOptionsFileError(boolean failIfOptionsFileError); - - /** - * If true, then DB::Open / CreateColumnFamily / DropColumnFamily - * / SetOptions will fail if options file is not detected or properly - * persisted. - * - * DEFAULT: false - * - * @return true if we should fail if there is an error in the options file - */ - boolean failIfOptionsFileError(); - /** * If true, then print malloc stats together with rocksdb.stats * when printing to LOG. @@ -1473,6 +1690,36 @@ T setEnableWriteThreadAdaptiveYield( */ boolean manualWalFlush(); + /** + * Set to true to re-instate an old behavior of keeping complete, synced WAL + * files open for write until they are collected for deletion by a + * background thread. This should not be needed unless there is a + * performance issue with file Close(), but setting it to true means that + * Checkpoint might call LinkFile on a WAL still open for write, which might + * be unsupported on some FileSystem implementations. As this is intended as + * a temporary kill switch, it is already DEPRECATED. + * + * @param manualWalFlush + * + * @return + */ + @Deprecated + T setBackgroundCloseInactiveWals(boolean manualWalFlush); + + /** + * Set to true to re-instate an old behavior of keeping complete, synced WAL + * files open for write until they are collected for deletion by a + * background thread. This should not be needed unless there is a + * performance issue with file Close(), but setting it to true means that + * Checkpoint might call LinkFile on a WAL still open for write, which might + * be unsupported on some FileSystem implementations. As this is intended as + * a temporary kill switch, it is already DEPRECATED. + * + * @return + */ + @Deprecated + boolean backgroundCloseInactiveWals(); + /** * If true, RocksDB supports flushing multiple column families and committing * their results atomically to MANIFEST. Note that it is not @@ -1528,6 +1775,38 @@ T setEnableWriteThreadAdaptiveYield( */ boolean avoidUnnecessaryBlockingIO(); + /** + * Historically, when prefix_extractor != nullptr, iterators have an + * unfortunate default semantics of *possibly* only returning data + * within the same prefix. To avoid "spooky action at a distance," iterator + * bounds should come from the instantiation or seeking of the iterator, + * not from a mutable column family option. + *

+ * When set to true, it is as if every iterator is created with + * total_order_seek=true and only auto_prefix_mode=true and + * prefix_same_as_start=true can take advantage of prefix seek optimizations. + * + * @param prefixSeekOptInOnly A flag that indicates whether every iterator should be created with total_order_seek=true + * + * @return {@code this} + */ + T setPrefixSeekOptInOnly(boolean prefixSeekOptInOnly); + + /** + * Historically, when prefix_extractor != nullptr, iterators have an + * unfortunate default semantics of *possibly* only returning data + * within the same prefix. To avoid "spooky action at a distance," iterator + * bounds should come from the instantiation or seeking of the iterator, + * not from a mutable column family option. + *

+ * When set to true, it is as if every iterator is created with + * total_order_seek=true and only auto_prefix_mode=true and + * prefix_same_as_start=true can take advantage of prefix seek optimizations. + * + * @return A flag that indicates whether every iterator will be created with total_order_seek=true + */ + boolean prefixSeekOptInOnly(); + /** * If true, automatically persist stats to a hidden column family (column * family name: ___rocksdb_stats_history___) every @@ -1592,6 +1871,30 @@ T setEnableWriteThreadAdaptiveYield( */ boolean writeDbidToManifest(); + /** + * It is expected that the Identity file will be obsoleted by recording + * DB ID in the manifest (see write_dbid_to_manifest). Setting this to true + * maintains the historical behavior of writing an Identity file, while + * setting to false is expected to be the future default. This option might + * eventually be obsolete and removed as Identity files are phased out. + * + * @param writeIdentityFile Indicates whether to write an identity file + * + * @return {@code this} + */ + T setWriteIdentityFile(boolean writeIdentityFile); + + /** + * It is expected that the Identity file will be obsoleted by recording + * DB ID in the manifest (see write_dbid_to_manifest). Setting this to true + * maintains the historical behavior of writing an Identity file, while + * setting to false is expected to be the future default. This option might + * eventually be obsolete and removed as Identity files are phased out. + * + * @return A flag indicating whether an identity file will be written + */ + boolean writeIdentityFile(); + /** * The number of bytes to prefetch when reading the log. This is mostly useful * for reading a remotely located log, as it can save the number of @@ -1697,6 +2000,177 @@ T setEnableWriteThreadAdaptiveYield( */ long bgerrorResumeRetryInterval(); + /** + * It allows user to opt-in to get error messages containing corrupted + * keys/values. Corrupt keys, values will be logged in the + * messages/logs/status that will help users with the useful information + * regarding affected data. By default value is set false to prevent users + * data to be exposed in the logs/messages etc. + *

+ * Default: false + * + * @param allowDataInErrors Indicates whether corrupt keys/values should in the error messages + * + * @return {@code this} + */ + T setAllowDataInErrors(boolean allowDataInErrors); + + /** + * It allows user to opt-in to get error messages containing corrupted + * keys/values. Corrupt keys, values will be logged in the + * messages/logs/status that will help users with the useful information + * regarding affected data. By default value is set false to prevent users + * data to be exposed in the logs/messages etc. + * + * @return whether corrupt keys/values will in the error messages + */ + boolean allowDataInErrors(); + + /** + * A string identifying the machine hosting the DB. This + * will be written as a property in every SST file written by the DB (or + * by offline writers such as SstFileWriter and RepairDB). It can be useful + * for troubleshooting in memory corruption caused by a failing host when + * writing a file, by tracing back to the writing host. These corruptions + * may not be caught by the checksum since they happen before checksumming. + * If left as default, the table writer will substitute it with the actual + * hostname when writing the SST file. If set to an empty string, the + * property will not be written to the SST file. + *

+ * Default: hostname + * + * @return The DB host identifier + */ + String dbHostId(); + + /** + * A string identifying the machine hosting the DB. This + * will be written as a property in every SST file written by the DB (or + * by offline writers such as SstFileWriter and RepairDB). It can be useful + * for troubleshooting in memory corruption caused by a failing host when + * writing a file, by tracing back to the writing host. These corruptions + * may not be caught by the checksum since they happen before checksumming. + * If left as default, the table writer will substitute it with the actual + * hostname when writing the SST file. If set to an empty string, the + * property will not be written to the SST file. + *

+ * Default: hostname + * + * @param dbHostId A string identifying the machine hosting the DB + * + * @return {@code this} + */ + T setDbHostId(String dbHostId); + + /** + * DEPRECATED: This option might be removed in a future release. + * + * If set to false, when compaction or flush sees a SingleDelete followed by + * a Delete for the same user key, compaction job will not fail. + * Otherwise, compaction job will fail. + * This is a temporary option to help existing use cases migrate, and + * will be removed in a future release. + * Warning: do not set to false unless you are trying to migrate existing + * data in which the contract of single delete + * (https://github.com/facebook/rocksdb/wiki/Single-Delete) is not enforced, + * thus has Delete mixed with SingleDelete for the same user key. Violation + * of the contract leads to undefined behaviors with high possibility of data + * inconsistency, e.g. deleted old data become visible again, etc. + * + * @param enforceSingleDelContracts + * + * @return {@code this} + */ + @Deprecated + T setEnforceSingleDelContracts(boolean enforceSingleDelContracts); + + /** + * DEPRECATED: This option might be removed in a future release. + * + * If set to false, when compaction or flush sees a SingleDelete followed by + * a Delete for the same user key, compaction job will not fail. + * Otherwise, compaction job will fail. + * This is a temporary option to help existing use cases migrate, and + * will be removed in a future release. + * Warning: do not set to false unless you are trying to migrate existing + * data in which the contract of single delete + * (https://github.com/facebook/rocksdb/wiki/Single-Delete) is not enforced, + * thus has Delete mixed with SingleDelete for the same user key. Violation + * of the contract leads to undefined behaviors with high possibility of data + * inconsistency, e.g. deleted old data become visible again, etc. + * + * @return + */ + @Deprecated + boolean enforceSingleDelContracts(); + + /** + * When a RocksDB database is opened in follower mode, this option + * is set by the user to request the frequency of the follower + * attempting to refresh its view of the leader. RocksDB may choose to + * trigger catch ups more frequently if it detects any changes in the + * database state. + * Default every 10s. + * + * @param followerRefreshCatchupPeriodMs The intended frequency of the follower attempting to refresh its view of the leader + * + * @return {@code this} + */ + T setFollowerRefreshCatchupPeriodMs(long followerRefreshCatchupPeriodMs); + + /** + * When a RocksDB database is opened in follower mode, this option + * is set by the user to request the frequency of the follower + * attempting to refresh its view of the leader. RocksDB may choose to + * trigger catch ups more frequently if it detects any changes in the + * database state. + * + * @return The frequency of the follower attempting to refresh its view of the leader + */ + long followerRefreshCatchupPeriodMs(); + + /** + * For a given catch up attempt, this option specifies the number of times + * to tail the MANIFEST and try to install a new, consistent version before + * giving up. Though it should be extremely rare, the catch up may fail if + * the leader is mutating the LSM at a very high rate and the follower is + * unable to get a consistent view. + * Default to 10 attempts + * + * @param followerRefreshCatchupRetryCount The number of times to tail the MANIFEST and try to install a new, consistent version + * + * @return {@code this} + */ + T setFollowerRefreshCatchupRetryCount(long followerRefreshCatchupRetryCount); + + /** + * For a given catch up attempt, this option specifies the number of times + * to tail the MANIFEST and try to install a new, consistent version before + * giving up. Though it should be extremely rare, the catch up may fail if + * the leader is mutating the LSM at a very high rate and the follower is + * unable to get a consistent view. + * + * @return The number of times to tail the MANIFEST and try to install a new, consistent version + */ + long followerRefreshCatchupRetryCount(); + + /** + * Time to wait between consecutive catch up attempts + * Default 100ms + * + * @param followerCatchupRetryWaitMs Time to wait between consecutive catch up attempts + * + * @return {@code this} + */ + T setFollowerCatchupRetryWaitMs(long followerCatchupRetryWaitMs); + + /** + * Time to wait between consecutive catch up attempts + * + * @return Time to wait between consecutive catch up attempts + */ + long followerCatchupRetryWaitMs(); + /** * Implementing off-peak duration awareness in RocksDB. In this context, * "off-peak time" signifies periods characterized by significantly less read diff --git a/java/src/main/java/org/rocksdb/MutableDBOptions.java b/java/src/main/java/org/rocksdb/MutableDBOptions.java index 894154e0df45..0c5009e16ec8 100644 --- a/java/src/main/java/org/rocksdb/MutableDBOptions.java +++ b/java/src/main/java/org/rocksdb/MutableDBOptions.java @@ -77,6 +77,7 @@ public enum DBOption implements MutableDBOptionKey { wal_bytes_per_sync(ValueType.LONG), strict_bytes_per_sync(ValueType.BOOLEAN), compaction_readahead_size(ValueType.LONG), + max_manifest_space_amp_pct(ValueType.INT), daily_offpeak_time_utc(ValueType.STRING); @@ -132,6 +133,16 @@ public int maxBackgroundJobs() { return getInt(DBOption.max_background_jobs); } + @Override + public MutableDBOptionsBuilder setMaxManifestSpaceAmpPet(final int maxManifestSpaceAmpPet) { + return setInt(DBOption.max_manifest_space_amp_pct, maxManifestSpaceAmpPet); + } + + @Override + public int maxManifestSpaceAmpPet() { + return getInt(DBOption.max_manifest_space_amp_pct); + } + @Override @Deprecated public MutableDBOptionsBuilder setMaxBackgroundCompactions( diff --git a/java/src/main/java/org/rocksdb/MutableDBOptionsInterface.java b/java/src/main/java/org/rocksdb/MutableDBOptionsInterface.java index 37c654454af3..71f0858140b8 100644 --- a/java/src/main/java/org/rocksdb/MutableDBOptionsInterface.java +++ b/java/src/main/java/org/rocksdb/MutableDBOptionsInterface.java @@ -21,6 +21,100 @@ public interface MutableDBOptionsInterface + * max(max_manifest_file_size, + * est_compacted_manifest_size * (1 + max_manifest_space_amp_pct/100)) + *

+ * where est_compacted_manifest_size is an estimate of how big a new compacted + * version of the current manifest would be. Currently, the estimate used is + * the last newly-written manifest, in its "compacted" form. + *

+ * Space amplification in the manifest file might be less of a concern for + * primary storage space and more of a concern for DB recover time and size of + * backup files that aren't incremental between backups. To minimize manifest + * churn on initial DB population, setting max_manifest_file_size to something + * not too small, like 1MB, should suffice. Similarly, write amp on the + * manifest file is likely not a direct concern but completed compactions and + * flushes cannot (currently) be committed while the (relatively small) + * manifest file is being compacted. Manifest compactions should not + * interfere with user write latency or throughput unless the DB is + * chronically stalling or close to stalling writes already. + *

+ * For this option to have a meaningful effect, it is recommended to set + * max_manifest_file_size to something modest like 1MB. Then we can interpret + * values for this option as follows, starting with minimum space amp and + * maximum write amp: + * * 0 - Every manifest write (flush, compaction, etc.) generates a whole new + * manifest. Only useful for testing. + * * very small - Doesn't take many manifest writes to generate a whole new + * manifest. + * * 100 - In a DB with pretty consistent number of SST files, etc., achieves + * about 1.0 write amp (writing about 2x the theoretical minimum) and a max of + * about 1.0 space amp (manifest up to 2x the compacted size). + * * 500 - Recommended and default: 0.2 write amp and up to roughly 5.0 space + * amp. + * * 10000 - 0.01 write amp and up to 100 space amp on the manifest. + *

+ * This option is mutable with SetDBOptions(), taking effect on the next + * manifest write (e.g. completed DB compaction or flush). + * + * @param maxManifestSpaceAmpPet + * + * @return {@code this} + */ + T setMaxManifestSpaceAmpPet(int maxManifestSpaceAmpPet); + + /** + * This option mostly replaces max_manifest_file_size to control an auto-tuned + * balance of manifest write amplification and space amplification. A new + * manifest file is created with the "compacted" contents of the old one when + * current_manifest_size + * > + * max(max_manifest_file_size, + * est_compacted_manifest_size * (1 + max_manifest_space_amp_pct/100)) + *

+ * where est_compacted_manifest_size is an estimate of how big a new compacted + * version of the current manifest would be. Currently, the estimate used is + * the last newly-written manifest, in its "compacted" form. + *

+ * Space amplification in the manifest file might be less of a concern for + * primary storage space and more of a concern for DB recover time and size of + * backup files that aren't incremental between backups. To minimize manifest + * churn on initial DB population, setting max_manifest_file_size to something + * not too small, like 1MB, should suffice. Similarly, write amp on the + * manifest file is likely not a direct concern but completed compactions and + * flushes cannot (currently) be committed while the (relatively small) + * manifest file is being compacted. Manifest compactions should not + * interfere with user write latency or throughput unless the DB is + * chronically stalling or close to stalling writes already. + *

+ * For this option to have a meaningful effect, it is recommended to set + * max_manifest_file_size to something modest like 1MB. Then we can interpret + * values for this option as follows, starting with minimum space amp and + * maximum write amp: + * * 0 - Every manifest write (flush, compaction, etc.) generates a whole new + * manifest. Only useful for testing. + * * very small - Doesn't take many manifest writes to generate a whole new + * manifest. + * * 100 - In a DB with pretty consistent number of SST files, etc., achieves + * about 1.0 write amp (writing about 2x the theoretical minimum) and a max of + * about 1.0 space amp (manifest up to 2x the compacted size). + * * 500 - Recommended and default: 0.2 write amp and up to roughly 5.0 space + * amp. + * * 10000 - 0.01 write amp and up to 100 space amp on the manifest. + *

+ * This option is mutable with SetDBOptions(), taking effect on the next + * manifest write (e.g. completed DB compaction or flush). + * + * @return + */ + int maxManifestSpaceAmpPet(); + /** * NOT SUPPORTED ANYMORE: RocksDB automatically decides this based on the * value of max_background_jobs. For backwards compatibility we will set diff --git a/java/src/main/java/org/rocksdb/Options.java b/java/src/main/java/org/rocksdb/Options.java index 675837df7a09..72bb9df6eb85 100644 --- a/java/src/main/java/org/rocksdb/Options.java +++ b/java/src/main/java/org/rocksdb/Options.java @@ -25,7 +25,7 @@ public class Options extends RocksObject * @return The Options-style representation of those properties. */ public static String getOptionStringFromProps(final Properties properties) { - if (properties == null || properties.size() == 0) { + if (properties == null || properties.isEmpty()) { throw new IllegalArgumentException("Properties value must contain at least one value."); } final StringBuilder stringBuilder = new StringBuilder(); @@ -324,6 +324,76 @@ public Options setParanoidChecks(final boolean paranoidChecks) { return this; } + @Override + public Options setFlushVerifyMemtableCount( + final boolean flushVerifyMemtableCount) { + assert(isOwningHandle()); + setFlushVerifyMemtableCount(nativeHandle_, flushVerifyMemtableCount); + return this; + } + + @Override + public boolean flushVerifyMemtableCount() { + assert(isOwningHandle()); + return flushVerifyMemtableCount(nativeHandle_); + } + + @Override + public Options setCompactionVerifyRecordCount( + final boolean compactionVerifyRecordCount) { + assert(isOwningHandle()); + setCompactionVerifyRecordCount(nativeHandle_, compactionVerifyRecordCount); + return this; + } + + @Override + public boolean compactionVerifyRecordCount() { + assert(isOwningHandle()); + return compactionVerifyRecordCount(nativeHandle_); + } + + @Override + public Options setTrackAndVerifyWalsInManifest( + final boolean trackAndVerifyWalsInManifest) { + assert(isOwningHandle()); + setTrackAndVerifyWalsInManifest(nativeHandle_, trackAndVerifyWalsInManifest); + return this; + } + + @Override + public boolean trackAndVerifyWalsInManifest() { + assert(isOwningHandle()); + return trackAndVerifyWalsInManifest(nativeHandle_); + } + + @Override + public Options setTrackAndVerifyWals( + final boolean trackAndVerifyWals) { + assert(isOwningHandle()); + setTrackAndVerifyWals(nativeHandle_, trackAndVerifyWals); + return this; + } + + @Override + public boolean trackAndVerifyWals() { + assert(isOwningHandle()); + return trackAndVerifyWals(nativeHandle_); + } + + @Override + public Options setVerifySstUniqueIdInManifest( + final boolean verifySstUniqueIdInManifest) { + assert(isOwningHandle()); + setVerifySstUniqueIdInManifest(nativeHandle_, verifySstUniqueIdInManifest); + return this; + } + + @Override + public boolean verifySstUniqueIdInManifest() { + assert(isOwningHandle()); + return verifySstUniqueIdInManifest(nativeHandle_); + } + @Override public int maxOpenFiles() { assert(isOwningHandle()); @@ -529,6 +599,19 @@ public Options setMaxBackgroundJobs(final int maxBackgroundJobs) { return this; } + @Override + public Options setMaxManifestSpaceAmpPet(final int maxManifestSpaceAmpPet) { + assert(isOwningHandle()); + setMaxManifestSpaceAmpPet(nativeHandle_, maxManifestSpaceAmpPet); + return this; + } + + @Override + public int maxManifestSpaceAmpPet() { + assert(isOwningHandle()); + return maxManifestSpaceAmpPet(nativeHandle_); + } + @Override public long maxLogFileSize() { assert(isOwningHandle()); @@ -1071,6 +1154,19 @@ public WALRecoveryMode walRecoveryMode() { return WALRecoveryMode.getWALRecoveryMode(walRecoveryMode(nativeHandle_)); } + @Override + public Options setWalCompression(final CompressionType walCompression) { + assert(isOwningHandle()); + setWalCompression(nativeHandle_, walCompression.getValue()); + return this; + } + + @Override + public CompressionType walCompression() { + assert(isOwningHandle()); + return CompressionType.getCompressionType(walCompression(nativeHandle_)); + } + @Override public Options setAllow2pc(final boolean allow2pc) { assert(isOwningHandle()); @@ -1112,19 +1208,6 @@ public WalFilter walFilter() { return this.walFilter_; } - @Override - public Options setFailIfOptionsFileError(final boolean failIfOptionsFileError) { - assert(isOwningHandle()); - setFailIfOptionsFileError(nativeHandle_, failIfOptionsFileError); - return this; - } - - @Override - public boolean failIfOptionsFileError() { - assert(isOwningHandle()); - return failIfOptionsFileError(nativeHandle_); - } - @Override public Options setDumpMallocStats(final boolean dumpMallocStats) { assert(isOwningHandle()); @@ -1203,6 +1286,19 @@ public boolean manualWalFlush() { return manualWalFlush(nativeHandle_); } + @Override + public Options setBackgroundCloseInactiveWals(final boolean manualWalFlush) { + assert(isOwningHandle()); + setBackgroundCloseInactiveWals(nativeHandle_, manualWalFlush); + return this; + } + + @Override + public boolean backgroundCloseInactiveWals() { + assert(isOwningHandle()); + return backgroundCloseInactiveWals(nativeHandle_); + } + @Override public MemTableConfig memTableConfig() { return this.memTableConfig_; @@ -1869,6 +1965,18 @@ public boolean avoidUnnecessaryBlockingIO() { return avoidUnnecessaryBlockingIO(nativeHandle_); } + @Override + public Options setPrefixSeekOptInOnly(final boolean prefixSeekOptInOnly) { + setPrefixSeekOptInOnly(nativeHandle_, prefixSeekOptInOnly); + return this; + } + + @Override + public boolean prefixSeekOptInOnly() { + assert (isOwningHandle()); + return prefixSeekOptInOnly(nativeHandle_); + } + @Override public Options setPersistStatsToDisk(final boolean persistStatsToDisk) { setPersistStatsToDisk(nativeHandle_, persistStatsToDisk); @@ -1893,6 +2001,18 @@ public boolean writeDbidToManifest() { return writeDbidToManifest(nativeHandle_); } + @Override + public Options setWriteIdentityFile(final boolean writeIdentityFile) { + setWriteIdentityFile(nativeHandle_, writeIdentityFile); + return this; + } + + @Override + public boolean writeIdentityFile() { + assert (isOwningHandle()); + return writeIdentityFile(nativeHandle_); + } + @Override public Options setLogReadaheadSize(final long logReadaheadSize) { setLogReadaheadSize(nativeHandle_, logReadaheadSize); @@ -1941,6 +2061,84 @@ public long bgerrorResumeRetryInterval() { return bgerrorResumeRetryInterval(nativeHandle_); } + @Override + public Options setAllowDataInErrors(final boolean allowDataInErrors) { + assert(isOwningHandle()); + setAllowDataInErrors(nativeHandle_, allowDataInErrors); + return this; + } + + @Override + public boolean allowDataInErrors() { + assert(isOwningHandle()); + return allowDataInErrors(nativeHandle_); + } + + @Override + public String dbHostId() { + assert(isOwningHandle()); + return dbHostId(nativeHandle_); + } + + @Override + public Options setDbHostId(final String dbHostId) { + assert(isOwningHandle()); + setDbHostId(nativeHandle_, dbHostId); + return this; + } + + @Override + public Options setEnforceSingleDelContracts(final boolean enforceSingleDelContracts) { + assert(isOwningHandle()); + setEnforceSingleDelContracts(nativeHandle_, enforceSingleDelContracts); + return this; + } + + @Override + public boolean enforceSingleDelContracts() { + assert(isOwningHandle()); + return enforceSingleDelContracts(nativeHandle_); + } + + @Override + public Options setFollowerRefreshCatchupPeriodMs(final long followerRefreshCatchupPeriodMs) { + assert(isOwningHandle()); + setFollowerRefreshCatchupPeriodMs(nativeHandle_, followerRefreshCatchupPeriodMs); + return this; + } + + @Override + public long followerRefreshCatchupPeriodMs() { + assert(isOwningHandle()); + return followerRefreshCatchupPeriodMs(nativeHandle_); + } + + @Override + public Options setFollowerRefreshCatchupRetryCount(final long followerRefreshCatchupRetryCount) { + assert(isOwningHandle()); + setFollowerRefreshCatchupRetryCount(nativeHandle_, followerRefreshCatchupRetryCount); + return this; + } + + @Override + public long followerRefreshCatchupRetryCount() { + assert(isOwningHandle()); + return followerRefreshCatchupRetryCount(nativeHandle_); + } + + @Override + public Options setFollowerCatchupRetryWaitMs(final long followerCatchupRetryWaitMs) { + assert(isOwningHandle()); + setFollowerCatchupRetryWaitMs(nativeHandle_, followerCatchupRetryWaitMs); + return this; + } + + @Override + public long followerCatchupRetryWaitMs() { + assert(isOwningHandle()); + return followerCatchupRetryWaitMs(nativeHandle_); + } + @Override public Options setSstPartitionerFactory(final SstPartitionerFactory sstPartitionerFactory) { setSstPartitionerFactory(nativeHandle_, sstPartitionerFactory.nativeHandle_); @@ -2150,6 +2348,16 @@ protected final void disposeInternal(final long handle) { private static native boolean errorIfExists(long handle); private static native void setParanoidChecks(long handle, boolean paranoidChecks); private static native boolean paranoidChecks(long handle); + private static native void setFlushVerifyMemtableCount(long handle, boolean flushVerifyMemtableCount); + private static native boolean flushVerifyMemtableCount(long handle); + private static native void setCompactionVerifyRecordCount(long handle, boolean compactionVerifyRecordCount); + private static native boolean compactionVerifyRecordCount(long handle); + private static native void setTrackAndVerifyWalsInManifest(long handle, boolean trackAndVerifyWalsInManifest); + private static native boolean trackAndVerifyWalsInManifest(long handle); + private static native void setTrackAndVerifyWals(long handle, boolean trackAndVerifyWals); + private static native boolean trackAndVerifyWals(long handle); + private static native void setVerifySstUniqueIdInManifest(long handle, boolean trackAndVerifyWals); + private static native boolean verifySstUniqueIdInManifest(long handle); private static native void setRateLimiter(long handle, long rateLimiterHandle); private static native void setSstFileManager(final long handle, final long sstFileManagerHandle); private static native void setLogger( @@ -2186,6 +2394,8 @@ private static native void dbPaths( private static native int maxBackgroundFlushes(long handle); private static native void setMaxBackgroundJobs(long handle, int maxMaxBackgroundJobs); private static native int maxBackgroundJobs(long handle); + private static native void setMaxManifestSpaceAmpPet(long handle, int maxManifestSpaceAmpPet); + private static native int maxManifestSpaceAmpPet(long handle); private static native void setMaxLogFileSize(long handle, long maxLogFileSize) throws IllegalArgumentException; private static native long maxLogFileSize(long handle); @@ -2288,13 +2498,12 @@ private static native void setSkipCheckingSstFileSizesOnDbOpen( private static native boolean skipCheckingSstFileSizesOnDbOpen(final long handle); private static native void setWalRecoveryMode(final long handle, final byte walRecoveryMode); private static native byte walRecoveryMode(final long handle); + private static native void setWalCompression(final long handle, final byte walCompression); + private static native byte walCompression(final long handle); private static native void setAllow2pc(final long handle, final boolean allow2pc); private static native boolean allow2pc(final long handle); private static native void setRowCache(final long handle, final long rowCacheHandle); private static native void setWalFilter(final long handle, final long walFilterHandle); - private static native void setFailIfOptionsFileError( - final long handle, final boolean failIfOptionsFileError); - private static native boolean failIfOptionsFileError(final long handle); private static native void setDumpMallocStats(final long handle, final boolean dumpMallocStats); private static native boolean dumpMallocStats(final long handle); private static native void setAvoidFlushDuringRecovery( @@ -2310,6 +2519,8 @@ private static native void setAllowIngestBehind( private static native boolean twoWriteQueues(final long handle); private static native void setManualWalFlush(final long handle, final boolean manualWalFlush); private static native boolean manualWalFlush(final long handle); + private static native void setBackgroundCloseInactiveWals(final long handle, final boolean manualWalFlush); + private static native boolean backgroundCloseInactiveWals(final long handle); // CF native handles private static native void oldDefaults( @@ -2457,12 +2668,18 @@ private static native void setCompactionThreadLimiter( private static native void setAvoidUnnecessaryBlockingIO( final long handle, final boolean avoidBlockingIO); private static native boolean avoidUnnecessaryBlockingIO(final long handle); + private static native void setPrefixSeekOptInOnly( + final long handle, final boolean prefixSeekOptInOnly); + private static native boolean prefixSeekOptInOnly(final long handle); private static native void setPersistStatsToDisk( final long handle, final boolean persistStatsToDisk); private static native boolean persistStatsToDisk(final long handle); private static native void setWriteDbidToManifest( final long handle, final boolean writeDbidToManifest); private static native boolean writeDbidToManifest(final long handle); + private static native void setWriteIdentityFile( + final long handle, final boolean writeDbidToManifest); + private static native boolean writeIdentityFile(final long handle); private static native void setLogReadaheadSize(final long handle, final long logReadaheadSize); private static native long logReadaheadSize(final long handle); private static native void setBestEffortsRecovery( @@ -2474,7 +2691,18 @@ private static native void setMaxBgErrorResumeCount( private static native void setBgerrorResumeRetryInterval( final long handle, final long bgerrorResumeRetryInterval); private static native long bgerrorResumeRetryInterval(final long handle); - + private static native void setAllowDataInErrors(final long handle, final boolean allowDataInErrors); + private static native boolean allowDataInErrors(final long handle); + private static native void setDbHostId(long handle, String dbLogDir); + private static native String dbHostId(long handle); + private static native void setEnforceSingleDelContracts(final long handle, final boolean enforceSingleDelContracts); + private static native boolean enforceSingleDelContracts(final long handle); + private static native void setFollowerRefreshCatchupPeriodMs(final long handle, final long followerRefreshCatchupPeriodMs); + private static native long followerRefreshCatchupPeriodMs(final long handle); + private static native void setFollowerRefreshCatchupRetryCount(final long handle, final long followerRefreshCatchupRetryCount); + private static native long followerRefreshCatchupRetryCount(final long handle); + private static native void setFollowerCatchupRetryWaitMs(final long handle, final long followerCatchupRetryWaitMs); + private static native long followerCatchupRetryWaitMs(final long handle); private static native void setEnableBlobFiles( final long nativeHandle_, final boolean enableBlobFiles); private static native boolean enableBlobFiles(final long nativeHandle_); diff --git a/java/src/test/java/org/rocksdb/DBOptionsTest.java b/java/src/test/java/org/rocksdb/DBOptionsTest.java index cf3ef22ddeb4..e6ec37425191 100644 --- a/java/src/test/java/org/rocksdb/DBOptionsTest.java +++ b/java/src/test/java/org/rocksdb/DBOptionsTest.java @@ -6,12 +6,19 @@ package org.rocksdb; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.BDDAssertions.then; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import java.nio.file.Paths; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.Random; import java.util.concurrent.atomic.AtomicBoolean; import org.junit.ClassRule; import org.junit.Test; @@ -42,7 +49,7 @@ public void getDBOptionsFromProps() { final Properties properties = new Properties(); properties.put("allow_mmap_reads", "true"); properties.put("bytes_per_sync", "13"); - try(final DBOptions opt = DBOptions.getDBOptionsFromProps(properties)) { + try (final DBOptions opt = DBOptions.getDBOptionsFromProps(properties)) { assertThat(opt).isNotNull(); assertThat(String.valueOf(opt.allowMmapReads())). isEqualTo(properties.get("allow_mmap_reads")); @@ -57,21 +64,21 @@ public void failDBOptionsFromPropsWithIllegalValue() { final Properties properties = new Properties(); properties.put("tomato", "1024"); properties.put("burger", "2"); - try(final DBOptions opt = DBOptions.getDBOptionsFromProps(properties)) { + try (final DBOptions opt = DBOptions.getDBOptionsFromProps(properties)) { assertThat(opt).isNull(); } } @Test(expected = IllegalArgumentException.class) public void failDBOptionsFromPropsWithNullValue() { - try(final DBOptions opt = DBOptions.getDBOptionsFromProps(null)) { + try (final DBOptions opt = DBOptions.getDBOptionsFromProps(null)) { //no-op } } @Test(expected = IllegalArgumentException.class) public void failDBOptionsFromPropsWithEmptyProps() { - try(final DBOptions opt = DBOptions.getDBOptionsFromProps( + try (final DBOptions opt = DBOptions.getDBOptionsFromProps( new Properties())) { //no-op } @@ -95,15 +102,16 @@ public void env() { @Test public void setIncreaseParallelism() { - try(final DBOptions opt = new DBOptions()) { - final int threads = Runtime.getRuntime().availableProcessors() * 2; + try (final DBOptions opt = new DBOptions()) { + final int threads = Runtime.getRuntime() + .availableProcessors() * 2; opt.setIncreaseParallelism(threads); } } @Test public void createIfMissing() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setCreateIfMissing(boolValue); assertThat(opt.createIfMissing()).isEqualTo(boolValue); @@ -112,7 +120,7 @@ public void createIfMissing() { @Test public void createMissingColumnFamilies() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setCreateMissingColumnFamilies(boolValue); assertThat(opt.createMissingColumnFamilies()).isEqualTo(boolValue); @@ -121,7 +129,7 @@ public void createMissingColumnFamilies() { @Test public void errorIfExists() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setErrorIfExists(boolValue); assertThat(opt.errorIfExists()).isEqualTo(boolValue); @@ -130,16 +138,61 @@ public void errorIfExists() { @Test public void paranoidChecks() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setParanoidChecks(boolValue); assertThat(opt.paranoidChecks()).isEqualTo(boolValue); } } + @Test + public void flushVerifyMemtableCount() { + try (final DBOptions opt = new DBOptions()) { + final boolean flushVerifyMemtableCount = rand.nextBoolean(); + opt.setFlushVerifyMemtableCount(flushVerifyMemtableCount); + then(opt.flushVerifyMemtableCount()).isEqualTo(flushVerifyMemtableCount); + } + } + + @Test + public void compactionVerifyRecordCount() { + try (final DBOptions opt = new DBOptions()) { + final boolean compactionVerifyRecordCount = rand.nextBoolean(); + opt.setCompactionVerifyRecordCount(compactionVerifyRecordCount); + then(opt.compactionVerifyRecordCount()).isEqualTo(compactionVerifyRecordCount); + } + } + + @Test + public void trackAndVerifyWalsInManifest() { + try (final DBOptions opt = new DBOptions()) { + final boolean trackAndVerifyWalsInManifest = rand.nextBoolean(); + opt.setTrackAndVerifyWalsInManifest(trackAndVerifyWalsInManifest); + then(opt.trackAndVerifyWalsInManifest()).isEqualTo(trackAndVerifyWalsInManifest); + } + } + + @Test + public void trackAndVerifyWals() { + try (final DBOptions opt = new DBOptions()) { + final boolean trackAndVerifyWals = rand.nextBoolean(); + opt.setTrackAndVerifyWals(trackAndVerifyWals); + then(opt.trackAndVerifyWals()).isEqualTo(trackAndVerifyWals); + } + } + + @Test + public void verifySstUniqueIdInManifest() { + try (final DBOptions opt = new DBOptions()) { + final boolean verifySstUniqueIdInManifest = rand.nextBoolean(); + opt.setVerifySstUniqueIdInManifest(verifySstUniqueIdInManifest); + then(opt.verifySstUniqueIdInManifest()).isEqualTo(verifySstUniqueIdInManifest); + } + } + @Test public void maxTotalWalSize() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setMaxTotalWalSize(longValue); assertThat(opt.maxTotalWalSize()).isEqualTo(longValue); @@ -148,7 +201,7 @@ public void maxTotalWalSize() { @Test public void maxOpenFiles() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final int intValue = rand.nextInt(); opt.setMaxOpenFiles(intValue); assertThat(opt.maxOpenFiles()).isEqualTo(intValue); @@ -157,7 +210,7 @@ public void maxOpenFiles() { @Test public void maxFileOpeningThreads() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final int intValue = rand.nextInt(); opt.setMaxFileOpeningThreads(intValue); assertThat(opt.maxFileOpeningThreads()).isEqualTo(intValue); @@ -166,7 +219,7 @@ public void maxFileOpeningThreads() { @Test public void useFsync() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setUseFsync(boolValue); assertThat(opt.useFsync()).isEqualTo(boolValue); @@ -180,7 +233,7 @@ public void dbPaths() { dbPaths.add(new DbPath(Paths.get("/b"), 100)); dbPaths.add(new DbPath(Paths.get("/c"), 1000)); - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { assertThat(opt.dbPaths()).isEqualTo(Collections.emptyList()); opt.setDbPaths(dbPaths); @@ -191,7 +244,7 @@ public void dbPaths() { @Test public void dbLogDir() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final String str = "path/to/DbLogDir"; opt.setDbLogDir(str); assertThat(opt.dbLogDir()).isEqualTo(str); @@ -200,7 +253,7 @@ public void dbLogDir() { @Test public void walDir() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final String str = "path/to/WalDir"; opt.setWalDir(str); assertThat(opt.walDir()).isEqualTo(str); @@ -209,7 +262,7 @@ public void walDir() { @Test public void deleteObsoleteFilesPeriodMicros() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setDeleteObsoleteFilesPeriodMicros(longValue); assertThat(opt.deleteObsoleteFilesPeriodMicros()).isEqualTo(longValue); @@ -219,7 +272,7 @@ public void deleteObsoleteFilesPeriodMicros() { @SuppressWarnings("deprecated") @Test public void maxBackgroundCompactions() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final int intValue = rand.nextInt(); opt.setMaxBackgroundCompactions(intValue); assertThat(opt.maxBackgroundCompactions()).isEqualTo(intValue); @@ -239,7 +292,7 @@ public void maxSubcompactions() { @SuppressWarnings("deprecated") @Test public void maxBackgroundFlushes() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final int intValue = rand.nextInt(); opt.setMaxBackgroundFlushes(intValue); assertThat(opt.maxBackgroundFlushes()).isEqualTo(intValue); @@ -256,8 +309,8 @@ public void maxBackgroundJobs() { } @Test - public void maxLogFileSize() throws RocksDBException { - try(final DBOptions opt = new DBOptions()) { + public void maxLogFileSize() { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setMaxLogFileSize(longValue); assertThat(opt.maxLogFileSize()).isEqualTo(longValue); @@ -265,8 +318,8 @@ public void maxLogFileSize() throws RocksDBException { } @Test - public void logFileTimeToRoll() throws RocksDBException { - try(final DBOptions opt = new DBOptions()) { + public void logFileTimeToRoll() { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setLogFileTimeToRoll(longValue); assertThat(opt.logFileTimeToRoll()).isEqualTo(longValue); @@ -274,8 +327,8 @@ public void logFileTimeToRoll() throws RocksDBException { } @Test - public void keepLogFileNum() throws RocksDBException { - try(final DBOptions opt = new DBOptions()) { + public void keepLogFileNum() { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setKeepLogFileNum(longValue); assertThat(opt.keepLogFileNum()).isEqualTo(longValue); @@ -283,8 +336,8 @@ public void keepLogFileNum() throws RocksDBException { } @Test - public void recycleLogFileNum() throws RocksDBException { - try(final DBOptions opt = new DBOptions()) { + public void recycleLogFileNum() { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setRecycleLogFileNum(longValue); assertThat(opt.recycleLogFileNum()).isEqualTo(longValue); @@ -293,7 +346,7 @@ public void recycleLogFileNum() throws RocksDBException { @Test public void maxManifestFileSize() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setMaxManifestFileSize(longValue); assertThat(opt.maxManifestFileSize()).isEqualTo(longValue); @@ -302,7 +355,7 @@ public void maxManifestFileSize() { @Test public void tableCacheNumshardbits() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final int intValue = rand.nextInt(); opt.setTableCacheNumshardbits(intValue); assertThat(opt.tableCacheNumshardbits()).isEqualTo(intValue); @@ -311,7 +364,7 @@ public void tableCacheNumshardbits() { @Test public void walSizeLimitMB() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setWalSizeLimitMB(longValue); assertThat(opt.walSizeLimitMB()).isEqualTo(longValue); @@ -320,7 +373,7 @@ public void walSizeLimitMB() { @Test public void walTtlSeconds() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setWalTtlSeconds(longValue); assertThat(opt.walTtlSeconds()).isEqualTo(longValue); @@ -328,8 +381,8 @@ public void walTtlSeconds() { } @Test - public void manifestPreallocationSize() throws RocksDBException { - try(final DBOptions opt = new DBOptions()) { + public void manifestPreallocationSize() { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setManifestPreallocationSize(longValue); assertThat(opt.manifestPreallocationSize()).isEqualTo(longValue); @@ -338,7 +391,7 @@ public void manifestPreallocationSize() throws RocksDBException { @Test public void useDirectReads() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setUseDirectReads(boolValue); assertThat(opt.useDirectReads()).isEqualTo(boolValue); @@ -347,7 +400,7 @@ public void useDirectReads() { @Test public void useDirectIoForFlushAndCompaction() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setUseDirectIoForFlushAndCompaction(boolValue); assertThat(opt.useDirectIoForFlushAndCompaction()).isEqualTo(boolValue); @@ -356,7 +409,7 @@ public void useDirectIoForFlushAndCompaction() { @Test public void allowFAllocate() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setAllowFAllocate(boolValue); assertThat(opt.allowFAllocate()).isEqualTo(boolValue); @@ -365,7 +418,7 @@ public void allowFAllocate() { @Test public void allowMmapReads() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setAllowMmapReads(boolValue); assertThat(opt.allowMmapReads()).isEqualTo(boolValue); @@ -374,7 +427,7 @@ public void allowMmapReads() { @Test public void allowMmapWrites() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setAllowMmapWrites(boolValue); assertThat(opt.allowMmapWrites()).isEqualTo(boolValue); @@ -383,7 +436,7 @@ public void allowMmapWrites() { @Test public void isFdCloseOnExec() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setIsFdCloseOnExec(boolValue); assertThat(opt.isFdCloseOnExec()).isEqualTo(boolValue); @@ -392,7 +445,7 @@ public void isFdCloseOnExec() { @Test public void statsDumpPeriodSec() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final int intValue = rand.nextInt(); opt.setStatsDumpPeriodSec(intValue); assertThat(opt.statsDumpPeriodSec()).isEqualTo(intValue); @@ -419,7 +472,7 @@ public void statsHistoryBufferSize() { @Test public void adviseRandomOnOpen() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setAdviseRandomOnOpen(boolValue); assertThat(opt.adviseRandomOnOpen()).isEqualTo(boolValue); @@ -428,7 +481,7 @@ public void adviseRandomOnOpen() { @Test public void dbWriteBufferSize() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setDbWriteBufferSize(longValue); assertThat(opt.dbWriteBufferSize()).isEqualTo(longValue); @@ -436,7 +489,7 @@ public void dbWriteBufferSize() { } @Test - public void setWriteBufferManager() throws RocksDBException { + public void setWriteBufferManager() { try (final DBOptions opt = new DBOptions(); final Cache cache = new LRUCache(1024 * 1024); final WriteBufferManager writeBufferManager = new WriteBufferManager(2000L, cache)) { opt.setWriteBufferManager(writeBufferManager); @@ -445,7 +498,7 @@ public void setWriteBufferManager() throws RocksDBException { } @Test - public void setWriteBufferManagerWithZeroBufferSize() throws RocksDBException { + public void setWriteBufferManagerWithZeroBufferSize() { try (final DBOptions opt = new DBOptions(); final Cache cache = new LRUCache(1024 * 1024); final WriteBufferManager writeBufferManager = new WriteBufferManager(0L, cache)) { opt.setWriteBufferManager(writeBufferManager); @@ -455,7 +508,7 @@ public void setWriteBufferManagerWithZeroBufferSize() throws RocksDBException { @Test public void compactionReadaheadSize() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setCompactionReadaheadSize(longValue); assertThat(opt.compactionReadaheadSize()).isEqualTo(longValue); @@ -464,7 +517,7 @@ public void compactionReadaheadSize() { @Test public void writableFileMaxBufferSize() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setWritableFileMaxBufferSize(longValue); assertThat(opt.writableFileMaxBufferSize()).isEqualTo(longValue); @@ -473,7 +526,7 @@ public void writableFileMaxBufferSize() { @Test public void useAdaptiveMutex() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final boolean boolValue = rand.nextBoolean(); opt.setUseAdaptiveMutex(boolValue); assertThat(opt.useAdaptiveMutex()).isEqualTo(boolValue); @@ -482,7 +535,7 @@ public void useAdaptiveMutex() { @Test public void bytesPerSync() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setBytesPerSync(longValue); assertThat(opt.bytesPerSync()).isEqualTo(longValue); @@ -491,7 +544,7 @@ public void bytesPerSync() { @Test public void walBytesPerSync() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setWalBytesPerSync(longValue); assertThat(opt.walBytesPerSync()).isEqualTo(longValue); @@ -518,7 +571,7 @@ public void enableThreadTracking() { @Test public void delayedWriteRate() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { final long longValue = rand.nextLong(); opt.setDelayedWriteRate(longValue); assertThat(opt.delayedWriteRate()).isEqualTo(longValue); @@ -527,7 +580,7 @@ public void delayedWriteRate() { @Test public void enablePipelinedWrite() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { assertThat(opt.enablePipelinedWrite()).isFalse(); opt.setEnablePipelinedWrite(true); assertThat(opt.enablePipelinedWrite()).isTrue(); @@ -536,7 +589,7 @@ public void enablePipelinedWrite() { @Test public void unordredWrite() { - try(final DBOptions opt = new DBOptions()) { + try (final DBOptions opt = new DBOptions()) { assertThat(opt.unorderedWrite()).isFalse(); opt.setUnorderedWrite(true); assertThat(opt.unorderedWrite()).isTrue(); @@ -598,6 +651,17 @@ public void walRecoveryMode() { } } + @Test + public void walCompression() { + try (final DBOptions opt = new DBOptions()) { + final CompressionType[] compressionTypes = CompressionType.values(); + for (final CompressionType compressionType : compressionTypes) { + opt.setWalCompression(compressionType); + then(opt.walCompression()).isEqualTo(compressionType); + } + } + } + @Test public void allow2pc() { try (final DBOptions opt = new DBOptions()) { @@ -612,12 +676,12 @@ public void rowCache() { try (final DBOptions opt = new DBOptions()) { assertThat(opt.rowCache()).isNull(); - try(final Cache lruCache = new LRUCache(1000)) { + try (final Cache lruCache = new LRUCache(1000)) { opt.setRowCache(lruCache); assertThat(opt.rowCache()).isEqualTo(lruCache); } - try(final Cache clockCache = new ClockCache(1000)) { + try (final Cache clockCache = new ClockCache(1000)) { opt.setRowCache(clockCache); assertThat(opt.rowCache()).isEqualTo(clockCache); } @@ -639,8 +703,8 @@ public void columnFamilyLogNumberMap( @Override public LogRecordFoundResult logRecordFound(final long logNumber, - final String logFileName, final WriteBatch batch, - final WriteBatch newBatch) { + final String logFileName, final WriteBatch batch, + final WriteBatch newBatch) { return new LogRecordFoundResult( WalProcessingOption.CONTINUE_PROCESSING, false); } @@ -710,6 +774,15 @@ public void manualWalFlush() { } } + @Test + public void backgroundCloseInactiveWals() { + try (final DBOptions opt = new DBOptions()) { + final boolean backgroundCloseInactiveWals = rand.nextBoolean(); + opt.setBackgroundCloseInactiveWals(backgroundCloseInactiveWals); + then(opt.backgroundCloseInactiveWals()).isEqualTo(backgroundCloseInactiveWals); + } + } + @Test public void atomicFlush() { try (final DBOptions opt = new DBOptions()) { @@ -721,9 +794,9 @@ public void atomicFlush() { @Test public void rateLimiter() { - try(final DBOptions options = new DBOptions(); - final DBOptions anotherOptions = new DBOptions(); - final RateLimiter rateLimiter = new RateLimiter(1000, 100 * 1000, 1)) { + try (final DBOptions options = new DBOptions(); + final DBOptions anotherOptions = new DBOptions(); + final RateLimiter rateLimiter = new RateLimiter(1000, 100 * 1000, 1)) { options.setRateLimiter(rateLimiter); // Test with parameter initialization anotherOptions.setRateLimiter( @@ -742,14 +815,14 @@ public void sstFileManager() throws RocksDBException { @Test public void statistics() { - try(final DBOptions options = new DBOptions()) { + try (final DBOptions options = new DBOptions()) { final Statistics statistics = options.statistics(); assertThat(statistics).isNull(); } - try(final Statistics statistics = new Statistics(); - final DBOptions options = new DBOptions().setStatistics(statistics); - final Statistics stats = options.statistics()) { + try (final Statistics statistics = new Statistics(); + final DBOptions options = new DBOptions().setStatistics(statistics); + final Statistics stats = options.statistics()) { assertThat(stats).isNotNull(); } } @@ -763,6 +836,15 @@ public void avoidUnnecessaryBlockingIO() { } } + @Test + public void prefixSeekOptInOnly() { + try (final DBOptions options = new DBOptions()) { + final boolean prefixSeekOptInOnly = rand.nextBoolean(); + options.setPrefixSeekOptInOnly(prefixSeekOptInOnly); + then(options.prefixSeekOptInOnly()).isEqualTo(prefixSeekOptInOnly); + } + } + @Test public void persistStatsToDisk() { try (final DBOptions options = new DBOptions()) { @@ -781,6 +863,15 @@ public void writeDbidToManifest() { } } + @Test + public void writeIdentityFile() { + try (final DBOptions options = new DBOptions()) { + final boolean writeIdentityFile = rand.nextBoolean(); + then(options.setWriteIdentityFile(writeIdentityFile)).isEqualTo(options); + then(options.writeIdentityFile()).isEqualTo(writeIdentityFile); + } + } + @Test public void logReadaheadSize() { try (final DBOptions options = new DBOptions()) { @@ -820,6 +911,60 @@ public void bgerrorResumeRetryInterval() { } } + @Test + public void allowDataInErrors() { + try (final DBOptions options = new DBOptions()) { + then(options.allowDataInErrors()).isFalse(); + then(options.setAllowDataInErrors(true)).isEqualTo(options); + then(options.allowDataInErrors()).isTrue(); + } + } + + @Test + public void dbHostId() { + try (final DBOptions options = new DBOptions()) { + final String hostId = "127.0.0.1"; + then(options.setDbHostId(hostId)).isEqualTo(options); + then(options.dbHostId()).isEqualTo(hostId); + } + } + + @Test + public void enforceSingleDelContracts() { + try (final DBOptions options = new DBOptions()) { + final boolean enforceSingleDelContracts = rand.nextBoolean(); + then(options.setEnforceSingleDelContracts(enforceSingleDelContracts)).isEqualTo(options); + then(options.enforceSingleDelContracts()).isEqualTo(enforceSingleDelContracts); + } + } + + @Test + public void followerRefreshCatchupPeriodMs() { + try (final DBOptions options = new DBOptions()) { + final long followerRefreshCatchupPeriodMs = rand.nextLong(); + then(options.setFollowerRefreshCatchupPeriodMs(followerRefreshCatchupPeriodMs)).isEqualTo(options); + then(options.followerRefreshCatchupPeriodMs()).isEqualTo(followerRefreshCatchupPeriodMs); + } + } + + @Test + public void followerRefreshCatchupRetryCount() { + try (final DBOptions options = new DBOptions()) { + final long followerRefreshCatchupRetryCount = rand.nextLong(); + then(options.setFollowerRefreshCatchupRetryCount(followerRefreshCatchupRetryCount)).isEqualTo(options); + then(options.followerRefreshCatchupRetryCount()).isEqualTo(followerRefreshCatchupRetryCount); + } + } + + @Test + public void followerCatchupRetryWaitMs() { + try (final DBOptions options = new DBOptions()) { + final long followerCatchupRetryWaitMs = rand.nextLong(); + then(options.setFollowerCatchupRetryWaitMs(followerCatchupRetryWaitMs)).isEqualTo(options); + then(options.followerCatchupRetryWaitMs()).isEqualTo(followerCatchupRetryWaitMs); + } + } + @Test public void maxWriteBatchGroupSizeBytes() { try (final DBOptions options = new DBOptions()) { @@ -830,6 +975,15 @@ public void maxWriteBatchGroupSizeBytes() { } } + @Test + public void maxManifestSpaceAmpPct() { + try (final DBOptions options = new DBOptions()) { + final int intValue = rand.nextInt(); + then(options.setMaxManifestSpaceAmpPet(intValue)).isEqualTo(options); + then(options.maxManifestSpaceAmpPet()).isEqualTo(intValue); + } + } + @Test public void skipCheckingSstFileSizesOnDbOpen() { try (final DBOptions options = new DBOptions()) { @@ -859,15 +1013,18 @@ public void onMemTableSealed(final MemTableInfo memTableInfo) { } }) { assertThat(options.setListeners(null)).isEqualTo(options); - assertThat(options.listeners().size()).isEqualTo(0); + assertThat(options.listeners() + .size()).isEqualTo(0); assertThat(options.setListeners(Arrays.asList(el1, el2))).isEqualTo(options); final List listeners = options.listeners(); assertEquals(el1, listeners.get(0)); assertEquals(el2, listeners.get(1)); options.setListeners(Collections.emptyList()); - listeners.get(0).onTableFileDeleted(null); + listeners.get(0) + .onTableFileDeleted(null); assertTrue(wasCalled1.get()); - listeners.get(1).onMemTableSealed(null); + listeners.get(1) + .onMemTableSealed(null); assertTrue(wasCalled2.get()); final List listeners2 = options.listeners(); assertNotNull(listeners2);