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);
rocksDbOpt.setMaxLogFileSize(1073741824);
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);
}