Kafka Streams:RocksDBConfigSetter参数化
Kafka Streams: RocksDBConfigSetter parameterization
如果我们有一个 class 实现 RocksDBConfigSetter,如何将参数值(例如 blockCache、blockSize、writeBufferSize、maxWriteBufer)传递给 class。
streamsConfig.put(StreamsConfig.ROCKSDB_CONFIG_SETTER_CLASS_CONFIG, MyRocksDBConfig.class);
此外,在 storeBuilder 上设置 withCachingDisabled() 与 withCachingEnabled() 但将 CACHE_MAX_BYTES_BUFFERING_CONFIG 设置为 0 之间有什么区别吗?
RocksDBConfigSetter
在文档中有描述:https://docs.confluent.io/current/streams/developer-guide/config-streams.html#rocksdb-config-setter
public static class CustomRocksDBConfig implements RocksDBConfigSetter {
@Override
public void setConfig(final String storeName, final Options options, final Map<String, Object> configs) {
BlockBasedTableConfig tableConfig = new org.rocksdb.BlockBasedTableConfig();
tableConfig.setBlockCacheSize(16 * 1024 * 1024L);
tableConfig.setBlockSize(16 * 1024L);
tableConfig.setCacheIndexAndFilterBlocks(true);
options.setTableFormatConfig(tableConfig);
options.setMaxWriteBufferNumber(2);
}
}
Also, is there any difference between setting the withCachingDisabled() on the storeBuilder versus withCachingEnabled() but setting the CACHE_MAX_BYTES_BUFFERING_CONFIG to 0?
从 Kafka 2.0 版(及更早版本)开始,是的。如果启用缓存,缓存层代码将被执行,而缓存禁用时,缓存层代码将被剥离,因此不会被执行。如果在启用缓存的情况下将缓冲区大小设置为零,这只会触发立即从缓存中逐出。因此,从实用的角度来看,并没有太大的区别。
请注意,这将在下一个版本中修复:https://issues.apache.org/jira/browse/KAFKA-6998
如果我们有一个 class 实现 RocksDBConfigSetter,如何将参数值(例如 blockCache、blockSize、writeBufferSize、maxWriteBufer)传递给 class。
streamsConfig.put(StreamsConfig.ROCKSDB_CONFIG_SETTER_CLASS_CONFIG, MyRocksDBConfig.class);
此外,在 storeBuilder 上设置 withCachingDisabled() 与 withCachingEnabled() 但将 CACHE_MAX_BYTES_BUFFERING_CONFIG 设置为 0 之间有什么区别吗?
RocksDBConfigSetter
在文档中有描述:https://docs.confluent.io/current/streams/developer-guide/config-streams.html#rocksdb-config-setter
public static class CustomRocksDBConfig implements RocksDBConfigSetter {
@Override
public void setConfig(final String storeName, final Options options, final Map<String, Object> configs) {
BlockBasedTableConfig tableConfig = new org.rocksdb.BlockBasedTableConfig();
tableConfig.setBlockCacheSize(16 * 1024 * 1024L);
tableConfig.setBlockSize(16 * 1024L);
tableConfig.setCacheIndexAndFilterBlocks(true);
options.setTableFormatConfig(tableConfig);
options.setMaxWriteBufferNumber(2);
}
}
Also, is there any difference between setting the withCachingDisabled() on the storeBuilder versus withCachingEnabled() but setting the CACHE_MAX_BYTES_BUFFERING_CONFIG to 0?
从 Kafka 2.0 版(及更早版本)开始,是的。如果启用缓存,缓存层代码将被执行,而缓存禁用时,缓存层代码将被剥离,因此不会被执行。如果在启用缓存的情况下将缓冲区大小设置为零,这只会触发立即从缓存中逐出。因此,从实用的角度来看,并没有太大的区别。
请注意,这将在下一个版本中修复:https://issues.apache.org/jira/browse/KAFKA-6998