diff --git a/java/rocksjni/options.cc b/java/rocksjni/options.cc index b56c50081..62ff1a3e1 100644 --- a/java/rocksjni/options.cc +++ b/java/rocksjni/options.cc @@ -1219,6 +1219,29 @@ void Java_org_rocksdb_Options_setWalSizeLimitMB( static_cast(WAL_size_limit_MB); } +/* + * Class: org_rocksdb_Options + * Method: setMaxWriteBatchGroupSizeBytes + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setMaxWriteBatchGroupSizeBytes( + JNIEnv*, jclass, jlong jhandle, jlong jmax_write_batch_group_size_bytes) { + auto* opt = reinterpret_cast(jhandle); + opt->max_write_batch_group_size_bytes = + static_cast(jmax_write_batch_group_size_bytes); +} + +/* + * Class: org_rocksdb_Options + * Method: maxWriteBatchGroupSizeBytes + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_maxWriteBatchGroupSizeBytes(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->max_write_batch_group_size_bytes); +} + /* * Class: org_rocksdb_Options * Method: manifestPreallocationSize @@ -1950,7 +1973,7 @@ jboolean Java_org_rocksdb_Options_skipStatsUpdateOnDbOpen( * Signature: (JZ)V */ void Java_org_rocksdb_Options_setSkipCheckingSstFileSizesOnDbOpen( - JNIEnv*, jobject, jlong jhandle, + JNIEnv*, jclass, jlong jhandle, jboolean jskip_checking_sst_file_sizes_on_db_open) { auto* opt = reinterpret_cast(jhandle); opt->skip_checking_sst_file_sizes_on_db_open = @@ -1963,7 +1986,7 @@ void Java_org_rocksdb_Options_setSkipCheckingSstFileSizesOnDbOpen( * Signature: (J)Z */ jboolean Java_org_rocksdb_Options_skipCheckingSstFileSizesOnDbOpen( - JNIEnv*, jobject, jlong jhandle) { + JNIEnv*, jclass, jlong jhandle) { auto* opt = reinterpret_cast(jhandle); return static_cast(opt->skip_checking_sst_file_sizes_on_db_open); } @@ -2112,6 +2135,162 @@ jboolean Java_org_rocksdb_Options_avoidFlushDuringRecovery( return static_cast(opt->avoid_flush_during_recovery); } +/* + * Class: org_rocksdb_Options + * Method: setAvoidUnnecessaryBlockingIO + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setAvoidUnnecessaryBlockingIO( + JNIEnv*, jclass, jlong jhandle, jboolean avoid_blocking_io) { + auto* opt = reinterpret_cast(jhandle); + opt->avoid_unnecessary_blocking_io = static_cast(avoid_blocking_io); +} + +/* + * Class: org_rocksdb_Options + * Method: avoidUnnecessaryBlockingIO + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_avoidUnnecessaryBlockingIO(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->avoid_unnecessary_blocking_io); +} + +/* + * Class: org_rocksdb_Options + * Method: setPersistStatsToDisk + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setPersistStatsToDisk( + JNIEnv*, jclass, jlong jhandle, jboolean persist_stats_to_disk) { + auto* opt = reinterpret_cast(jhandle); + opt->persist_stats_to_disk = static_cast(persist_stats_to_disk); +} + +/* + * Class: org_rocksdb_Options + * Method: persistStatsToDisk + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_persistStatsToDisk(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->persist_stats_to_disk); +} + +/* + * Class: org_rocksdb_Options + * Method: setWriteDbidToManifest + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setWriteDbidToManifest( + JNIEnv*, jclass, jlong jhandle, jboolean jwrite_dbid_to_manifest) { + auto* opt = reinterpret_cast(jhandle); + opt->write_dbid_to_manifest = static_cast(jwrite_dbid_to_manifest); +} + +/* + * Class: org_rocksdb_Options + * Method: writeDbidToManifest + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_writeDbidToManifest(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->write_dbid_to_manifest); +} + +/* + * Class: org_rocksdb_Options + * Method: setLogReadaheadSize + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setLogReadaheadSize(JNIEnv*, jclass, + jlong jhandle, + jlong jlog_readahead_size) { + auto* opt = reinterpret_cast(jhandle); + opt->log_readahead_size = static_cast(jlog_readahead_size); +} + +/* + * Class: org_rocksdb_Options + * Method: logReasaheadSize + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_logReadaheadSize(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->log_readahead_size); +} + +/* + * Class: org_rocksdb_Options + * Method: setBestEffortsRecovery + * Signature: (JZ)V + */ +void Java_org_rocksdb_Options_setBestEffortsRecovery( + JNIEnv*, jclass, jlong jhandle, jboolean jbest_efforts_recovery) { + auto* opt = reinterpret_cast(jhandle); + opt->best_efforts_recovery = static_cast(jbest_efforts_recovery); +} + +/* + * Class: org_rocksdb_Options + * Method: bestEffortsRecovery + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_Options_bestEffortsRecovery(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->best_efforts_recovery); +} + +/* + * Class: org_rocksdb_Options + * Method: setMaxBgErrorResumeCount + * Signature: (JI)V + */ +void Java_org_rocksdb_Options_setMaxBgErrorResumeCount( + JNIEnv*, jclass, jlong jhandle, jint jmax_bgerror_resume_count) { + auto* opt = reinterpret_cast(jhandle); + opt->max_bgerror_resume_count = static_cast(jmax_bgerror_resume_count); +} + +/* + * Class: org_rocksdb_Options + * Method: maxBgerrorResumeCount + * Signature: (J)I + */ +jint Java_org_rocksdb_Options_maxBgerrorResumeCount(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->max_bgerror_resume_count); +} + +/* + * Class: org_rocksdb_Options + * Method: setBgerrorResumeRetryInterval + * Signature: (JJ)V + */ +void Java_org_rocksdb_Options_setBgerrorResumeRetryInterval( + JNIEnv*, jclass, jlong jhandle, jlong jbgerror_resume_retry_interval) { + auto* opt = reinterpret_cast(jhandle); + opt->bgerror_resume_retry_interval = + static_cast(jbgerror_resume_retry_interval); +} + +/* + * Class: org_rocksdb_Options + * Method: bgerrorResumeRetryInterval + * Signature: (J)J + */ +jlong Java_org_rocksdb_Options_bgerrorResumeRetryInterval(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->bgerror_resume_retry_interval); +} + /* * Class: org_rocksdb_Options * Method: setAvoidFlushDuringShutdown @@ -5851,6 +6030,29 @@ jlong Java_org_rocksdb_DBOptions_walSizeLimitMB( ->WAL_size_limit_MB; } +/* + * Class: org_rocksdb_DBOptions + * Method: setMaxWriteBatchGroupSizeBytes + * Signature: (JJ)V + */ +void Java_org_rocksdb_DBOptions_setMaxWriteBatchGroupSizeBytes( + JNIEnv*, jclass, jlong jhandle, jlong jmax_write_batch_group_size_bytes) { + auto* opt = reinterpret_cast(jhandle); + opt->max_write_batch_group_size_bytes = + static_cast(jmax_write_batch_group_size_bytes); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: maxWriteBatchGroupSizeBytes + * Signature: (J)J + */ +jlong Java_org_rocksdb_DBOptions_maxWriteBatchGroupSizeBytes(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->max_write_batch_group_size_bytes); +} + /* * Class: org_rocksdb_DBOptions * Method: setManifestPreallocationSize @@ -6553,7 +6755,7 @@ jboolean Java_org_rocksdb_DBOptions_skipStatsUpdateOnDbOpen( * Signature: (JZ)V */ void Java_org_rocksdb_DBOptions_setSkipCheckingSstFileSizesOnDbOpen( - JNIEnv*, jobject, jlong jhandle, + JNIEnv*, jclass, jlong jhandle, jboolean jskip_checking_sst_file_sizes_on_db_open) { auto* opt = reinterpret_cast(jhandle); opt->skip_checking_sst_file_sizes_on_db_open = @@ -6566,7 +6768,7 @@ void Java_org_rocksdb_DBOptions_setSkipCheckingSstFileSizesOnDbOpen( * Signature: (J)Z */ jboolean Java_org_rocksdb_DBOptions_skipCheckingSstFileSizesOnDbOpen( - JNIEnv*, jobject, jlong jhandle) { + JNIEnv*, jclass, jlong jhandle) { auto* opt = reinterpret_cast(jhandle); return static_cast(opt->skip_checking_sst_file_sizes_on_db_open); } @@ -6846,6 +7048,162 @@ jboolean Java_org_rocksdb_DBOptions_avoidFlushDuringShutdown( return static_cast(opt->avoid_flush_during_shutdown); } +/* + * Class: org_rocksdb_DBOptions + * Method: setAvoidUnnecessaryBlockingIO + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setAvoidUnnecessaryBlockingIO( + JNIEnv*, jclass, jlong jhandle, jboolean avoid_blocking_io) { + auto* opt = reinterpret_cast(jhandle); + opt->avoid_unnecessary_blocking_io = static_cast(avoid_blocking_io); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: avoidUnnecessaryBlockingIO + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_avoidUnnecessaryBlockingIO(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->avoid_unnecessary_blocking_io); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setPersistStatsToDisk + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setPersistStatsToDisk( + JNIEnv*, jclass, jlong jhandle, jboolean persist_stats_to_disk) { + auto* opt = reinterpret_cast(jhandle); + opt->persist_stats_to_disk = static_cast(persist_stats_to_disk); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: persistStatsToDisk + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_persistStatsToDisk(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->persist_stats_to_disk); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setWriteDbidToManifest + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setWriteDbidToManifest( + JNIEnv*, jclass, jlong jhandle, jboolean jwrite_dbid_to_manifest) { + auto* opt = reinterpret_cast(jhandle); + opt->write_dbid_to_manifest = static_cast(jwrite_dbid_to_manifest); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: writeDbidToManifest + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_writeDbidToManifest(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->write_dbid_to_manifest); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setLogReadaheadSize + * Signature: (JJ)V + */ +void Java_org_rocksdb_DBOptions_setLogReadaheadSize(JNIEnv*, jclass, + jlong jhandle, + jlong jlog_readahead_size) { + auto* opt = reinterpret_cast(jhandle); + opt->log_readahead_size = static_cast(jlog_readahead_size); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: logReasaheadSize + * Signature: (J)J + */ +jlong Java_org_rocksdb_DBOptions_logReadaheadSize(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->log_readahead_size); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setBestEffortsRecovery + * Signature: (JZ)V + */ +void Java_org_rocksdb_DBOptions_setBestEffortsRecovery( + JNIEnv*, jclass, jlong jhandle, jboolean jbest_efforts_recovery) { + auto* opt = reinterpret_cast(jhandle); + opt->best_efforts_recovery = static_cast(jbest_efforts_recovery); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: bestEffortsRecovery + * Signature: (J)Z + */ +jboolean Java_org_rocksdb_DBOptions_bestEffortsRecovery(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->best_efforts_recovery); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setMaxBgErrorResumeCount + * Signature: (JI)V + */ +void Java_org_rocksdb_DBOptions_setMaxBgErrorResumeCount( + JNIEnv*, jclass, jlong jhandle, jint jmax_bgerror_resume_count) { + auto* opt = reinterpret_cast(jhandle); + opt->max_bgerror_resume_count = static_cast(jmax_bgerror_resume_count); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: maxBgerrorResumeCount + * Signature: (J)I + */ +jint Java_org_rocksdb_DBOptions_maxBgerrorResumeCount(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->max_bgerror_resume_count); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: setBgerrorResumeRetryInterval + * Signature: (JJ)V + */ +void Java_org_rocksdb_DBOptions_setBgerrorResumeRetryInterval( + JNIEnv*, jclass, jlong jhandle, jlong jbgerror_resume_retry_interval) { + auto* opt = reinterpret_cast(jhandle); + opt->bgerror_resume_retry_interval = + static_cast(jbgerror_resume_retry_interval); +} + +/* + * Class: org_rocksdb_DBOptions + * Method: bgerrorResumeRetryInterval + * Signature: (J)J + */ +jlong Java_org_rocksdb_DBOptions_bgerrorResumeRetryInterval(JNIEnv*, jclass, + jlong jhandle) { + auto* opt = reinterpret_cast(jhandle); + return static_cast(opt->bgerror_resume_retry_interval); +} + ////////////////////////////////////////////////////////////////////////////// // ROCKSDB_NAMESPACE::WriteOptions diff --git a/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java b/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java index ec4fc2155..5767b39be 100644 --- a/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java +++ b/java/src/main/java/org/rocksdb/ColumnFamilyOptionsInterface.java @@ -487,9 +487,13 @@ public interface ColumnFamilyOptionsInterface> { */ long walSizeLimitMB(); + /** + * The maximum limit of number of bytes that are written in a single batch + * of WAL or memtable write. It is followed when the leader write size + * is larger than 1/8 of this limit. + * + * Default: 1 MB + * + * @param maxWriteBatchGroupSizeBytes the maximum limit of number of bytes, see description. + * @return the instance of the current object. + */ + T setMaxWriteBatchGroupSizeBytes(final long maxWriteBatchGroupSizeBytes); + + /** + * The maximum limit of number of bytes that are written in a single batch + * of WAL or memtable write. It is followed when the leader write size + * is larger than 1/8 of this limit. + * + * Default: 1 MB + * + * @return the maximum limit of number of bytes, see description. + */ + long maxWriteBatchGroupSizeBytes(); + /** * Number of bytes to preallocate (via fallocate) the manifest * files. Default is 4mb, which is reasonable to reduce random IO @@ -1278,6 +1301,36 @@ public interface DBOptionsInterface> { */ boolean skipStatsUpdateOnDbOpen(); + /** + * If true, then {@link RocksDB#open(String)} will not fetch and check sizes of all sst files. + * This may significantly speed up startup if there are many sst files, + * especially when using non-default Env with expensive GetFileSize(). + * We'll still check that all required sst files exist. + * If {@code paranoid_checks} is false, this option is ignored, and sst files are + * not checked at all. + * + * Default: false + * + * @param skipCheckingSstFileSizesOnDbOpen if true, then SST file sizes will not be checked + * when calling {@link RocksDB#open(String)}. + * @return the reference to the current options. + */ + T setSkipCheckingSstFileSizesOnDbOpen(final boolean skipCheckingSstFileSizesOnDbOpen); + + /** + * If true, then {@link RocksDB#open(String)} will not fetch and check sizes of all sst files. + * This may significantly speed up startup if there are many sst files, + * especially when using non-default Env with expensive GetFileSize(). + * We'll still check that all required sst files exist. + * If {@code paranoid_checks} is false, this option is ignored, and sst files are + * not checked at all. + * + * Default: false + * + * @return true, if file sizes will not be checked when calling {@link RocksDB#open(String)}. + */ + boolean skipCheckingSstFileSizesOnDbOpen(); + /** * Recovery mode to control the consistency while replaying WAL * @@ -1561,4 +1614,199 @@ public interface DBOptionsInterface> { * @return true if atomic flush is enabled. */ boolean atomicFlush(); + + /** + * If true, working thread may avoid doing unnecessary and long-latency + * operation (such as deleting obsolete files directly or deleting memtable) + * and will instead schedule a background job to do it. + * Use it if you're latency-sensitive. + * If set to true, takes precedence over + * {@link ReadOptions#setBackgroundPurgeOnIteratorCleanup(boolean)}. + * + * @param avoidUnnecessaryBlockingIO If true, working thread may avoid doing unnecessary + * operation. + * @return the reference to the current options. + */ + T setAvoidUnnecessaryBlockingIO(final boolean avoidUnnecessaryBlockingIO); + + /** + * If true, working thread may avoid doing unnecessary and long-latency + * operation (such as deleting obsolete files directly or deleting memtable) + * and will instead schedule a background job to do it. + * Use it if you're latency-sensitive. + * If set to true, takes precedence over + * {@link ReadOptions#setBackgroundPurgeOnIteratorCleanup(boolean)}. + * + * @return true, if working thread may avoid doing unnecessary operation. + */ + boolean avoidUnnecessaryBlockingIO(); + + /** + * If true, automatically persist stats to a hidden column family (column + * family name: ___rocksdb_stats_history___) every + * stats_persist_period_sec seconds; otherwise, write to an in-memory + * struct. User can query through `GetStatsHistory` API. + * If user attempts to create a column family with the same name on a DB + * which have previously set persist_stats_to_disk to true, the column family + * creation will fail, but the hidden column family will survive, as well as + * the previously persisted statistics. + * When peristing stats to disk, the stat name will be limited at 100 bytes. + * Default: false + * + * @param persistStatsToDisk true if stats should be persisted to hidden column family. + * @return the instance of the current object. + */ + T setPersistStatsToDisk(final boolean persistStatsToDisk); + + /** + * If true, automatically persist stats to a hidden column family (column + * family name: ___rocksdb_stats_history___) every + * stats_persist_period_sec seconds; otherwise, write to an in-memory + * struct. User can query through `GetStatsHistory` API. + * If user attempts to create a column family with the same name on a DB + * which have previously set persist_stats_to_disk to true, the column family + * creation will fail, but the hidden column family will survive, as well as + * the previously persisted statistics. + * When peristing stats to disk, the stat name will be limited at 100 bytes. + * Default: false + * + * @return true if stats should be persisted to hidden column family. + */ + boolean persistStatsToDisk(); + + /** + * Historically DB ID has always been stored in Identity File in DB folder. + * If this flag is true, the DB ID is written to Manifest file in addition + * to the Identity file. By doing this 2 problems are solved + * 1. We don't checksum the Identity file where as Manifest file is. + * 2. Since the source of truth for DB is Manifest file DB ID will sit with + * the source of truth. Previously the Identity file could be copied + * independent of Manifest and that can result in wrong DB ID. + * We recommend setting this flag to true. + * Default: false + * + * @param writeDbidToManifest if true, then DB ID will be written to Manifest file. + * @return the instance of the current object. + */ + T setWriteDbidToManifest(final boolean writeDbidToManifest); + + /** + * Historically DB ID has always been stored in Identity File in DB folder. + * If this flag is true, the DB ID is written to Manifest file in addition + * to the Identity file. By doing this 2 problems are solved + * 1. We don't checksum the Identity file where as Manifest file is. + * 2. Since the source of truth for DB is Manifest file DB ID will sit with + * the source of truth. Previously the Identity file could be copied + * independent of Manifest and that can result in wrong DB ID. + * We recommend setting this flag to true. + * Default: false + * + * @return true, if DB ID will be written to Manifest file. + */ + boolean writeDbidToManifest(); + + /** + * 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 + * round-trips. If 0, then the prefetching is disabled. + * + * Default: 0 + * + * @param logReadaheadSize the number of bytes to prefetch when reading the log. + * @return the instance of the current object. + */ + T setLogReadaheadSize(final long logReadaheadSize); + + /** + * 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 + * round-trips. If 0, then the prefetching is disabled. + * + * Default: 0 + * + * @return the number of bytes to prefetch when reading the log. + */ + long logReadaheadSize(); + + /** + * By default, RocksDB recovery fails if any table file referenced in + * MANIFEST are missing after scanning the MANIFEST. + * Best-efforts recovery is another recovery mode that + * tries to restore the database to the most recent point in time without + * missing file. + * Currently not compatible with atomic flush. Furthermore, WAL files will + * not be used for recovery if best_efforts_recovery is true. + * Default: false + * + * @param bestEffortsRecovery if true, RocksDB will use best-efforts mode when recovering. + * @return the instance of the current object. + */ + T setBestEffortsRecovery(final boolean bestEffortsRecovery); + + /** + * By default, RocksDB recovery fails if any table file referenced in + * MANIFEST are missing after scanning the MANIFEST. + * Best-efforts recovery is another recovery mode that + * tries to restore the database to the most recent point in time without + * missing file. + * Currently not compatible with atomic flush. Furthermore, WAL files will + * not be used for recovery if best_efforts_recovery is true. + * Default: false + * + * @return true, if RocksDB uses best-efforts mode when recovering. + */ + boolean bestEffortsRecovery(); + + /** + * It defines how many times db resume is called by a separate thread when + * background retryable IO Error happens. When background retryable IO + * Error happens, SetBGError is called to deal with the error. If the error + * can be auto-recovered (e.g., retryable IO Error during Flush or WAL write), + * then db resume is called in background to recover from the error. If this + * value is 0 or negative, db resume will not be called. + * + * Default: INT_MAX + * + * @param maxBgerrorResumeCount maximum number of times db resume should be called when IO Error + * happens. + * @return the instance of the current object. + */ + T setMaxBgErrorResumeCount(final int maxBgerrorResumeCount); + + /** + * It defines how many times db resume is called by a separate thread when + * background retryable IO Error happens. When background retryable IO + * Error happens, SetBGError is called to deal with the error. If the error + * can be auto-recovered (e.g., retryable IO Error during Flush or WAL write), + * then db resume is called in background to recover from the error. If this + * value is 0 or negative, db resume will not be called. + * + * Default: INT_MAX + * + * @return maximum number of times db resume should be called when IO Error happens. + */ + int maxBgerrorResumeCount(); + + /** + * If max_bgerror_resume_count is ≥ 2, db resume is called multiple times. + * This option decides how long to wait to retry the next resume if the + * previous resume fails and satisfy redo resume conditions. + * + * Default: 1000000 (microseconds). + * + * @param bgerrorResumeRetryInterval how many microseconds to wait between DB resume attempts. + * @return the instance of the current object. + */ + T setBgerrorResumeRetryInterval(final long bgerrorResumeRetryInterval); + + /** + * If max_bgerror_resume_count is ≥ 2, db resume is called multiple times. + * This option decides how long to wait to retry the next resume if the + * previous resume fails and satisfy redo resume conditions. + * + * Default: 1000000 (microseconds). + * + * @return the instance of the current object. + */ + long bgerrorResumeRetryInterval(); } diff --git a/java/src/main/java/org/rocksdb/Options.java b/java/src/main/java/org/rocksdb/Options.java index 92df95c07..95d1daa80 100644 --- a/java/src/main/java/org/rocksdb/Options.java +++ b/java/src/main/java/org/rocksdb/Options.java @@ -661,6 +661,18 @@ public class Options extends RocksObject return walSizeLimitMB(nativeHandle_); } + @Override + public Options setMaxWriteBatchGroupSizeBytes(long maxWriteBatchGroupSizeBytes) { + setMaxWriteBatchGroupSizeBytes(nativeHandle_, maxWriteBatchGroupSizeBytes); + return this; + } + + @Override + public long maxWriteBatchGroupSizeBytes() { + assert (isOwningHandle()); + return maxWriteBatchGroupSizeBytes(nativeHandle_); + } + @Override public Options setWalSizeLimitMB(final long sizeLimitMB) { assert(isOwningHandle()); @@ -1066,6 +1078,18 @@ public class Options extends RocksObject return skipStatsUpdateOnDbOpen(nativeHandle_); } + @Override + public Options setSkipCheckingSstFileSizesOnDbOpen(boolean skipCheckingSstFileSizesOnDbOpen) { + setSkipCheckingSstFileSizesOnDbOpen(nativeHandle_, skipCheckingSstFileSizesOnDbOpen); + return this; + } + + @Override + public boolean skipCheckingSstFileSizesOnDbOpen() { + assert (isOwningHandle()); + return skipCheckingSstFileSizesOnDbOpen(nativeHandle_); + } + @Override public Options setWalRecoveryMode(final WALRecoveryMode walRecoveryMode) { assert(isOwningHandle()); @@ -1860,6 +1884,90 @@ public class Options extends RocksObject return atomicFlush(nativeHandle_); } + @Override + public Options setAvoidUnnecessaryBlockingIO(boolean avoidUnnecessaryBlockingIO) { + setAvoidUnnecessaryBlockingIO(nativeHandle_, avoidUnnecessaryBlockingIO); + return this; + } + + @Override + public boolean avoidUnnecessaryBlockingIO() { + assert (isOwningHandle()); + return avoidUnnecessaryBlockingIO(nativeHandle_); + } + + @Override + public Options setPersistStatsToDisk(boolean persistStatsToDisk) { + setPersistStatsToDisk(nativeHandle_, persistStatsToDisk); + return this; + } + + @Override + public boolean persistStatsToDisk() { + assert (isOwningHandle()); + return persistStatsToDisk(nativeHandle_); + } + + @Override + public Options setWriteDbidToManifest(boolean writeDbidToManifest) { + setWriteDbidToManifest(nativeHandle_, writeDbidToManifest); + return this; + } + + @Override + public boolean writeDbidToManifest() { + assert (isOwningHandle()); + return writeDbidToManifest(nativeHandle_); + } + + @Override + public Options setLogReadaheadSize(long logReadaheadSize) { + setLogReadaheadSize(nativeHandle_, logReadaheadSize); + return this; + } + + @Override + public long logReadaheadSize() { + assert (isOwningHandle()); + return logReadaheadSize(nativeHandle_); + } + + @Override + public Options setBestEffortsRecovery(boolean bestEffortsRecovery) { + setBestEffortsRecovery(nativeHandle_, bestEffortsRecovery); + return this; + } + + @Override + public boolean bestEffortsRecovery() { + assert (isOwningHandle()); + return bestEffortsRecovery(nativeHandle_); + } + + @Override + public Options setMaxBgErrorResumeCount(int maxBgerrorResumeCount) { + setMaxBgErrorResumeCount(nativeHandle_, maxBgerrorResumeCount); + return this; + } + + @Override + public int maxBgerrorResumeCount() { + assert (isOwningHandle()); + return maxBgerrorResumeCount(nativeHandle_); + } + + @Override + public Options setBgerrorResumeRetryInterval(long bgerrorResumeRetryInterval) { + setBgerrorResumeRetryInterval(nativeHandle_, bgerrorResumeRetryInterval); + return this; + } + + @Override + public long bgerrorResumeRetryInterval() { + assert (isOwningHandle()); + return bgerrorResumeRetryInterval(nativeHandle_); + } + @Override public Options setSstPartitionerFactory(SstPartitionerFactory sstPartitionerFactory) { setSstPartitionerFactory(nativeHandle_, sstPartitionerFactory.nativeHandle_); @@ -1974,6 +2082,9 @@ public class Options extends RocksObject private native long walTtlSeconds(long handle); private native void setWalSizeLimitMB(long handle, long sizeLimitMB); private native long walSizeLimitMB(long handle); + private static native void setMaxWriteBatchGroupSizeBytes( + final long handle, final long maxWriteBatchGroupSizeBytes); + private static native long maxWriteBatchGroupSizeBytes(final long handle); private native void setManifestPreallocationSize( long handle, long size) throws IllegalArgumentException; private native long manifestPreallocationSize(long handle); @@ -2066,6 +2177,9 @@ public class Options extends RocksObject private native void setSkipStatsUpdateOnDbOpen(final long handle, final boolean skipStatsUpdateOnDbOpen); private native boolean skipStatsUpdateOnDbOpen(final long handle); + private static native void setSkipCheckingSstFileSizesOnDbOpen( + final long handle, final boolean skipChecking); + private static native boolean skipCheckingSstFileSizesOnDbOpen(final long handle); private native void setWalRecoveryMode(final long handle, final byte walRecoveryMode); private native byte walRecoveryMode(final long handle); @@ -2266,6 +2380,26 @@ public class Options extends RocksObject private native void setSstPartitionerFactory(long nativeHandle_, long newFactoryHandle); private static native void setCompactionThreadLimiter( final long nativeHandle_, final long newLimiterHandle); + private static native void setAvoidUnnecessaryBlockingIO( + final long handle, final boolean avoidBlockingIO); + private static native boolean avoidUnnecessaryBlockingIO(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 setLogReadaheadSize(final long handle, final long logReadaheadSize); + private static native long logReadaheadSize(final long handle); + private static native void setBestEffortsRecovery( + final long handle, final boolean bestEffortsRecovery); + private static native boolean bestEffortsRecovery(final long handle); + private static native void setMaxBgErrorResumeCount( + final long handle, final int maxBgerrorRecumeCount); + private static native int maxBgerrorResumeCount(final long handle); + private static native void setBgerrorResumeRetryInterval( + final long handle, final long bgerrorResumeRetryInterval); + private static native long bgerrorResumeRetryInterval(final long handle); // instance variables // NOTE: If you add new member variables, please update the copy constructor above! diff --git a/java/src/test/java/org/rocksdb/DBOptionsTest.java b/java/src/test/java/org/rocksdb/DBOptionsTest.java index 71cada204..32e5aa21c 100644 --- a/java/src/test/java/org/rocksdb/DBOptionsTest.java +++ b/java/src/test/java/org/rocksdb/DBOptionsTest.java @@ -810,4 +810,89 @@ public class DBOptionsTest { assertThat(stats).isNotNull(); } } + + @Test + public void avoidUnnecessaryBlockingIO() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.avoidUnnecessaryBlockingIO()).isEqualTo(false); + assertThat(options.setAvoidUnnecessaryBlockingIO(true)).isEqualTo(options); + assertThat(options.avoidUnnecessaryBlockingIO()).isEqualTo(true); + } + } + + @Test + public void persistStatsToDisk() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.persistStatsToDisk()).isEqualTo(false); + assertThat(options.setPersistStatsToDisk(true)).isEqualTo(options); + assertThat(options.persistStatsToDisk()).isEqualTo(true); + } + } + + @Test + public void writeDbidToManifest() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.writeDbidToManifest()).isEqualTo(false); + assertThat(options.setWriteDbidToManifest(true)).isEqualTo(options); + assertThat(options.writeDbidToManifest()).isEqualTo(true); + } + } + + @Test + public void logReadaheadSize() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.logReadaheadSize()).isEqualTo(0); + final int size = 1024 * 1024 * 100; + assertThat(options.setLogReadaheadSize(size)).isEqualTo(options); + assertThat(options.logReadaheadSize()).isEqualTo(size); + } + } + + @Test + public void bestEffortsRecovery() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.bestEffortsRecovery()).isEqualTo(false); + assertThat(options.setBestEffortsRecovery(true)).isEqualTo(options); + assertThat(options.bestEffortsRecovery()).isEqualTo(true); + } + } + + @Test + public void maxBgerrorResumeCount() { + try (final DBOptions options = new DBOptions()) { + final int INT_MAX = 2147483647; + assertThat(options.maxBgerrorResumeCount()).isEqualTo(INT_MAX); + assertThat(options.setMaxBgErrorResumeCount(-1)).isEqualTo(options); + assertThat(options.maxBgerrorResumeCount()).isEqualTo(-1); + } + } + + @Test + public void bgerrorResumeRetryInterval() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.bgerrorResumeRetryInterval()).isEqualTo(1000000); + final long newRetryInterval = 24 * 3600 * 1000000L; + assertThat(options.setBgerrorResumeRetryInterval(newRetryInterval)).isEqualTo(options); + assertThat(options.bgerrorResumeRetryInterval()).isEqualTo(newRetryInterval); + } + } + + @Test + public void maxWriteBatchGroupSizeBytes() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.maxWriteBatchGroupSizeBytes()).isEqualTo(1024 * 1024); + final long size = 1024 * 1024 * 1024 * 10L; + assertThat(options.setMaxWriteBatchGroupSizeBytes(size)).isEqualTo(options); + assertThat(options.maxWriteBatchGroupSizeBytes()).isEqualTo(size); + } + } + + @Test + public void skipCheckingSstFileSizesOnDbOpen() { + try (final DBOptions options = new DBOptions()) { + assertThat(options.skipCheckingSstFileSizesOnDbOpen()).isEqualTo(false); + assertThat(options.setSkipCheckingSstFileSizesOnDbOpen(true)).isEqualTo(options); + assertThat(options.skipCheckingSstFileSizesOnDbOpen()).isEqualTo(true); + } + } } diff --git a/java/src/test/java/org/rocksdb/OptionsTest.java b/java/src/test/java/org/rocksdb/OptionsTest.java index 9c8f90093..043de032c 100644 --- a/java/src/test/java/org/rocksdb/OptionsTest.java +++ b/java/src/test/java/org/rocksdb/OptionsTest.java @@ -1342,7 +1342,7 @@ public class OptionsTest { } @Test - public void cfPaths() throws IOException { + public void cfPaths() { try (final Options options = new Options()) { final List paths = Arrays.asList( new DbPath(Paths.get("test1"), 2 << 25), new DbPath(Paths.get("/test2/path"), 2 << 25)); @@ -1351,4 +1351,89 @@ public class OptionsTest { assertThat(options.cfPaths()).isEqualTo(paths); } } + + @Test + public void avoidUnnecessaryBlockingIO() { + try (final Options options = new Options()) { + assertThat(options.avoidUnnecessaryBlockingIO()).isEqualTo(false); + assertThat(options.setAvoidUnnecessaryBlockingIO(true)).isEqualTo(options); + assertThat(options.avoidUnnecessaryBlockingIO()).isEqualTo(true); + } + } + + @Test + public void persistStatsToDisk() { + try (final Options options = new Options()) { + assertThat(options.persistStatsToDisk()).isEqualTo(false); + assertThat(options.setPersistStatsToDisk(true)).isEqualTo(options); + assertThat(options.persistStatsToDisk()).isEqualTo(true); + } + } + + @Test + public void writeDbidToManifest() { + try (final Options options = new Options()) { + assertThat(options.writeDbidToManifest()).isEqualTo(false); + assertThat(options.setWriteDbidToManifest(true)).isEqualTo(options); + assertThat(options.writeDbidToManifest()).isEqualTo(true); + } + } + + @Test + public void logReadaheadSize() { + try (final Options options = new Options()) { + assertThat(options.logReadaheadSize()).isEqualTo(0); + final int size = 1024 * 1024 * 100; + assertThat(options.setLogReadaheadSize(size)).isEqualTo(options); + assertThat(options.logReadaheadSize()).isEqualTo(size); + } + } + + @Test + public void bestEffortsRecovery() { + try (final Options options = new Options()) { + assertThat(options.bestEffortsRecovery()).isEqualTo(false); + assertThat(options.setBestEffortsRecovery(true)).isEqualTo(options); + assertThat(options.bestEffortsRecovery()).isEqualTo(true); + } + } + + @Test + public void maxBgerrorResumeCount() { + try (final Options options = new Options()) { + final int INT_MAX = 2147483647; + assertThat(options.maxBgerrorResumeCount()).isEqualTo(INT_MAX); + assertThat(options.setMaxBgErrorResumeCount(-1)).isEqualTo(options); + assertThat(options.maxBgerrorResumeCount()).isEqualTo(-1); + } + } + + @Test + public void bgerrorResumeRetryInterval() { + try (final Options options = new Options()) { + assertThat(options.bgerrorResumeRetryInterval()).isEqualTo(1000000); + final long newRetryInterval = 24 * 3600 * 1000000L; + assertThat(options.setBgerrorResumeRetryInterval(newRetryInterval)).isEqualTo(options); + assertThat(options.bgerrorResumeRetryInterval()).isEqualTo(newRetryInterval); + } + } + + @Test + public void maxWriteBatchGroupSizeBytes() { + try (final Options options = new Options()) { + assertThat(options.maxWriteBatchGroupSizeBytes()).isEqualTo(1024 * 1024); + final long size = 1024 * 1024 * 1024 * 10L; + assertThat(options.setMaxWriteBatchGroupSizeBytes(size)).isEqualTo(options); + assertThat(options.maxWriteBatchGroupSizeBytes()).isEqualTo(size); + } + } + + @Test + public void skipCheckingSstFileSizesOnDbOpen() { + try (final Options options = new Options()) { + assertThat(options.skipCheckingSstFileSizesOnDbOpen()).isEqualTo(false); + assertThat(options.setSkipCheckingSstFileSizesOnDbOpen(true)).isEqualTo(options); + assertThat(options.skipCheckingSstFileSizesOnDbOpen()).isEqualTo(true); + } + } }