This is an automated email from the ASF dual-hosted git repository. tangyun pushed a commit to branch release-1.13 in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.13 by this push: new 097f717 [FLINK-23198][docs] Fix the demo of ConfigurableRocksDBOptionsFactory 097f717 is described below commit 097f717b28cfdc2ba77ccffbd0b3da850eebdb1c Author: yanchenyun <yanchen...@126.com> AuthorDate: Mon Jul 5 16:35:09 2021 +0800 [FLINK-23198][docs] Fix the demo of ConfigurableRocksDBOptionsFactory this fix #16371. --- .../docs/ops/state/large_state_tuning.md | 2 +- docs/content.zh/docs/ops/state/state_backends.md | 32 +++++++++++--------- docs/content/docs/ops/state/large_state_tuning.md | 2 +- docs/content/docs/ops/state/state_backends.md | 34 ++++++++++++---------- 4 files changed, 39 insertions(+), 31 deletions(-) diff --git a/docs/content.zh/docs/ops/state/large_state_tuning.md b/docs/content.zh/docs/ops/state/large_state_tuning.md index 7e5f301..0853619 100644 --- a/docs/content.zh/docs/ops/state/large_state_tuning.md +++ b/docs/content.zh/docs/ops/state/large_state_tuning.md @@ -160,7 +160,7 @@ public class MyOptionsFactory implements ConfigurableRocksDBOptionsFactory { } @Override - public OptionsFactory configure(Configuration configuration) { + public OptionsFactory configure(ReadableConfig configuration) { return this; } } diff --git a/docs/content.zh/docs/ops/state/state_backends.md b/docs/content.zh/docs/ops/state/state_backends.md index ec72281..ee36333 100644 --- a/docs/content.zh/docs/ops/state/state_backends.md +++ b/docs/content.zh/docs/ops/state/state_backends.md @@ -269,31 +269,35 @@ Flink还提供了两个参数来控制*写路径*(MemTable)和*读路径*( 下面是自定义 `ConfigurableRocksDBOptionsFactory` 的一个示例 (开发完成后,请将您的实现类全名设置到 `state.backend.rocksdb.options-factory`). ```java - public class MyOptionsFactory implements ConfigurableRocksDBOptionsFactory { + public static final ConfigOption<Integer> BLOCK_RESTART_INTERVAL = ConfigOptions + .key("my.custom.rocksdb.block.restart-interval") + .intType() + .defaultValue(16) + .withDescription( + " Block restart interval. RocksDB has default block restart interval as 16. "); - private static final long DEFAULT_SIZE = 256 * 1024 * 1024; // 256 MB - private long blockCacheSize = DEFAULT_SIZE; + private int blockRestartInterval = BLOCK_RESTART_INTERVAL.defaultValue(); @Override - public DBOptions createDBOptions(DBOptions currentOptions, Collection<AutoCloseable> handlesToClose) { - return currentOptions.setIncreaseParallelism(4) - .setUseFsync(false); + public DBOptions createDBOptions(DBOptions currentOptions, + Collection<AutoCloseable> handlesToClose) { + return currentOptions + .setIncreaseParallelism(4) + .setUseFsync(false); } @Override - public ColumnFamilyOptions createColumnOptions( - ColumnFamilyOptions currentOptions, Collection<AutoCloseable> handlesToClose) { + public ColumnFamilyOptions createColumnOptions(ColumnFamilyOptions currentOptions, + Collection<AutoCloseable> handlesToClose) { return currentOptions.setTableFormatConfig( - new BlockBasedTableConfig() - .setBlockCacheSize(blockCacheSize) - .setBlockSize(128 * 1024)); // 128 KB + new BlockBasedTableConfig() + .setBlockRestartInterval(blockRestartInterval)); } @Override - public RocksDBOptionsFactory configure(Configuration configuration) { - this.blockCacheSize = - configuration.getLong("my.custom.rocksdb.block.cache.size", DEFAULT_SIZE); + public RocksDBOptionsFactory configure(ReadableConfig configuration) { + this.blockRestartInterval = configuration.get(BLOCK_RESTART_INTERVAL); return this; } } diff --git a/docs/content/docs/ops/state/large_state_tuning.md b/docs/content/docs/ops/state/large_state_tuning.md index 998ec1a..21639d0 100644 --- a/docs/content/docs/ops/state/large_state_tuning.md +++ b/docs/content/docs/ops/state/large_state_tuning.md @@ -160,7 +160,7 @@ public class MyOptionsFactory implements ConfigurableRocksDBOptionsFactory { } @Override - public OptionsFactory configure(Configuration configuration) { + public OptionsFactory configure(ReadableConfig configuration) { return this; } } diff --git a/docs/content/docs/ops/state/state_backends.md b/docs/content/docs/ops/state/state_backends.md index 9bcb6953..fafdf2f 100644 --- a/docs/content/docs/ops/state/state_backends.md +++ b/docs/content/docs/ops/state/state_backends.md @@ -291,31 +291,35 @@ The default value for `state.backend.rocksdb.options-factory` is in fact `org.ap Below is an example how to define a custom ConfigurableOptionsFactory (set class name under `state.backend.rocksdb.options-factory`). ```java - public class MyOptionsFactory implements ConfigurableRocksDBOptionsFactory { + public static final ConfigOption<Integer> BLOCK_RESTART_INTERVAL = ConfigOptions + .key("my.custom.rocksdb.block.restart-interval") + .intType() + .defaultValue(16) + .withDescription( + " Block restart interval. RocksDB has default block restart interval as 16. "); - private static final long DEFAULT_SIZE = 256 * 1024 * 1024; // 256 MB - private long blockCacheSize = DEFAULT_SIZE; + private int blockRestartInterval = BLOCK_RESTART_INTERVAL.defaultValue(); @Override - public DBOptions createDBOptions(DBOptions currentOptions, Collection<AutoCloseable> handlesToClose) { - return currentOptions.setIncreaseParallelism(4) - .setUseFsync(false); + public DBOptions createDBOptions(DBOptions currentOptions, + Collection<AutoCloseable> handlesToClose) { + return currentOptions + .setIncreaseParallelism(4) + .setUseFsync(false); } @Override - public ColumnFamilyOptions createColumnOptions( - ColumnFamilyOptions currentOptions, Collection<AutoCloseable> handlesToClose) { + public ColumnFamilyOptions createColumnOptions(ColumnFamilyOptions currentOptions, + Collection<AutoCloseable> handlesToClose) { return currentOptions.setTableFormatConfig( - new BlockBasedTableConfig() - .setBlockCacheSize(blockCacheSize) - .setBlockSize(128 * 1024)); // 128 KB + new BlockBasedTableConfig() + .setBlockRestartInterval(blockRestartInterval)); } @Override - public RocksDBOptionsFactory configure(Configuration configuration) { - this.blockCacheSize = - configuration.getLong("my.custom.rocksdb.block.cache.size", DEFAULT_SIZE); + public RocksDBOptionsFactory configure(ReadableConfig configuration) { + this.blockRestartInterval = configuration.get(BLOCK_RESTART_INTERVAL); return this; } } @@ -450,4 +454,4 @@ env.getCheckpointConfig().setCheckpointStorage("file:///checkpoint-dir") env.getCheckpointConfig().setCheckpointStorage(new FileSystemCheckpointStorage("file:///checkpoint-dir")) ``` {{< /tab >}} -{{< /tabs>}} \ No newline at end of file +{{< /tabs>}}