本文整理汇总了Java中org.rocksdb.Options.setMaxWriteBufferNumber方法的典型用法代码示例。如果您正苦于以下问题:Java Options.setMaxWriteBufferNumber方法的具体用法?Java Options.setMaxWriteBufferNumber怎么用?Java Options.setMaxWriteBufferNumber使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.rocksdb.Options
的用法示例。
在下文中一共展示了Options.setMaxWriteBufferNumber方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: RocksDbCacheOperator
import org.rocksdb.Options; //导入方法依赖的package包/类
public RocksDbCacheOperator(TopologyContext context, String cacheDir) {
this.stormConf = context.getStormConf();
this.maxFlushSize = ConfigExtension.getTransactionCacheBatchFlushSize(stormConf);
Options rocksDbOpt = new Options();
rocksDbOpt.setCreateMissingColumnFamilies(true).setCreateIfMissing(true);
long bufferSize =
ConfigExtension.getTransactionCacheBlockSize(stormConf) != null ? ConfigExtension.getTransactionCacheBlockSize(stormConf) : (1 * SizeUnit.GB);
rocksDbOpt.setWriteBufferSize(bufferSize);
int maxBufferNum = ConfigExtension.getTransactionMaxCacheBlockNum(stormConf) != null ? ConfigExtension.getTransactionMaxCacheBlockNum(stormConf) : 3;
rocksDbOpt.setMaxWriteBufferNumber(maxBufferNum);
// Config for log of RocksDb
rocksDbOpt.setMaxLogFileSize(1073741824); // 1G
rocksDbOpt.setKeepLogFileNum(1);
rocksDbOpt.setInfoLogLevel(InfoLogLevel.WARN_LEVEL);
try {
Map<Object, Object> conf = new HashMap<Object, Object>();
conf.put(ROCKSDB_ROOT_DIR, cacheDir);
conf.put(ROCKSDB_RESET, true);
initDir(conf);
initDb(null, rocksDbOpt);
} catch (Exception e) {
throw new RuntimeException(e);
}
kryo = new Kryo();
output = new Output(200, 2000000000);
input = new Input(1);
LOG.info("Finished rocksDb cache init: maxFlushSize={}, bufferSize={}, maxBufferNum={}", maxFlushSize, bufferSize, maxBufferNum);
}
示例2: FeatureStoreRocksDb
import org.rocksdb.Options; //导入方法依赖的package包/类
FeatureStoreRocksDb(MetricsContext metricsContext, File dbPath) {
MetricRegistry metrics = metricsContext.metrics();
String context = metricsContext.context();
putTimer = metrics.timer(MetricRegistry.name(
context + "." + METRICS_PATH, "putTimer"));
putMeter = metrics.meter(MetricRegistry.name(
context + "." + METRICS_PATH, "putMeter"));
this.loadAllTimer = metrics.timer(MetricRegistry.name(
context + "." + METRICS_PATH, "loadAllTimer"));
this.loadAllMeter = metrics.meter(MetricRegistry.name(
context + "." + METRICS_PATH, "loadAllMeter"));
this.findAllTimer = metrics.timer(MetricRegistry.name(
context + "." + METRICS_PATH, "findAllTimer"));
this.findAllMeter = metrics.meter(MetricRegistry.name(
context + "." + METRICS_PATH, "findAllMeter"));
BlockBasedTableConfig tableConfig = new BlockBasedTableConfig();
tableConfig.setBlockCacheSize(BLOCK_CACHE_SIZE);
tableConfig.setBlockSize(BLOCK_SIZE);
options = new Options();
options.setTableFormatConfig(tableConfig);
options.setWriteBufferSize(WRITE_BUFFER_SIZE);
options.setCompressionType(COMPRESSION_TYPE);
options.setCompactionStyle(COMPACTION_STYLE);
options.setMaxWriteBufferNumber(MAX_WRITE_BUFFER_NUMBER);
options.setCreateIfMissing(CREATE_IF_MISSING);
options.setErrorIfExists(ERROR_IF_EXISTS);
writeOptions = new WriteOptions();
writeOptions.setDisableWAL(DISABLE_WAL);
writeOptions.setSync(true);
readOptions = new ReadOptions();
readOptions.setVerifyChecksums(true);
readOptions.setFillCache(true);
flushOptions = new FlushOptions();
flushOptions.setWaitForFlush(WAIT_FOR_FLUSH);
final File parent = new File("/tmp", "outland");
rocksDir = new File(dbPath, "feature-store");
//noinspection ResultOfMethodCallIgnored
rocksDir.getParentFile().mkdirs();
rocks = initializeRocksDb(); // todo: move this out?
}
示例3: openDB
import org.rocksdb.Options; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public void openDB(ProcessorContext context) {
// initialize the default rocksdb options
final BlockBasedTableConfig tableConfig = new BlockBasedTableConfig();
tableConfig.setBlockCacheSize(BLOCK_CACHE_SIZE);
tableConfig.setBlockSize(BLOCK_SIZE);
options = new Options();
options.setTableFormatConfig(tableConfig);
options.setWriteBufferSize(WRITE_BUFFER_SIZE);
options.setCompressionType(COMPRESSION_TYPE);
options.setCompactionStyle(COMPACTION_STYLE);
options.setMaxWriteBufferNumber(MAX_WRITE_BUFFERS);
options.setCreateIfMissing(true);
options.setErrorIfExists(false);
options.setInfoLogLevel(InfoLogLevel.ERROR_LEVEL);
// this is the recommended way to increase parallelism in RocksDb
// note that the current implementation of setIncreaseParallelism affects the number
// of compaction threads but not flush threads (the latter remains one). Also
// the parallelism value needs to be at least two because of the code in
// https://github.com/facebook/rocksdb/blob/62ad0a9b19f0be4cefa70b6b32876e764b7f3c11/util/options.cc#L580
// subtracts one from the value passed to determine the number of compaction threads
// (this could be a bug in the RocksDB code and their devs have been contacted).
options.setIncreaseParallelism(Math.max(Runtime.getRuntime().availableProcessors(), 2));
wOptions = new WriteOptions();
wOptions.setDisableWAL(true);
fOptions = new FlushOptions();
fOptions.setWaitForFlush(true);
final Map<String, Object> configs = context.appConfigs();
final Object configSetterValue = configs.get(StreamsConfig.ROCKSDB_CONFIG_SETTER_CLASS_CONFIG);
final Class<RocksDBConfigSetter> configSetterClass = (Class<RocksDBConfigSetter>) ConfigDef.parseType(
StreamsConfig.ROCKSDB_CONFIG_SETTER_CLASS_CONFIG,
configSetterValue,
ConfigDef.Type.CLASS);
if (configSetterClass != null) {
final RocksDBConfigSetter configSetter = Utils.newInstance(configSetterClass);
configSetter.setConfig(name, options, configs);
}
// we need to construct the serde while opening DB since
// it is also triggered by windowed DB segments without initialization
this.serdes = new StateSerdes<>(
ProcessorStateManager.storeChangelogTopic(context.applicationId(), name),
keySerde == null ? (Serde<K>) context.keySerde() : keySerde,
valueSerde == null ? (Serde<V>) context.valueSerde() : valueSerde);
this.dbDir = new File(new File(context.stateDir(), parentDir), this.name);
try {
this.db = openDB(this.dbDir, this.options, TTL_SECONDS);
} catch (IOException e) {
throw new StreamsException(e);
}
}