/** * Gets the RocksDB {@link DBOptions} to be used for all RocksDB instances. */ public DBOptions getDbOptions() { // initial options from pre-defined profile DBOptions opt = predefinedOptions.createDBOptions(); // add user-defined options, if specified if (optionsFactory != null) { opt = optionsFactory.createDBOptions(opt); } // add necessary default options opt = opt.setCreateIfMissing(true); return opt; }
public void initDb(List<Integer> list) throws Exception { LOG.info("Begin to init rocksDB of {}", rootDir); DBOptions dbOptions = null; List<ColumnFamilyDescriptor> columnFamilyNames = new ArrayList<>(); columnFamilyNames.add(new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY)); for (Integer timeout : list) { columnFamilyNames.add(new ColumnFamilyDescriptor(String.valueOf(timeout).getBytes())); } List<Integer> ttlValues = new ArrayList<>(); // Default column family with infinite TTL // NOTE that the first must be 0, RocksDB.java API has this limitation ttlValues.add(0); // new column family with list second ttl ttlValues.addAll(list); try { dbOptions = new DBOptions().setCreateMissingColumnFamilies(true).setCreateIfMissing(true); List<ColumnFamilyHandle> columnFamilyHandleList = new ArrayList<>(); ttlDB = TtlDB.open(dbOptions, rootDir, columnFamilyNames, columnFamilyHandleList, ttlValues, false); for (int i = 0; i < ttlValues.size(); i++) { windowHandlers.put(ttlValues.get(i), columnFamilyHandleList.get(i)); } LOG.info("Successfully init rocksDB of {}", rootDir); } finally { if (dbOptions != null) { dbOptions.dispose(); } } }
.setCreateIfMissing(true) .setCreateMissingColumnFamilies(true);
} else { final DBOptions options = new DBOptions() .setCreateIfMissing(true) .setCreateMissingColumnFamilies(true) .setIncreaseParallelism(rocksThreads)
.setCreateIfMissing(true) .setCreateMissingColumnFamilies(true);
dbOptions.setCreateIfMissing(true); dbOptions.setMaxBackgroundFlushes(2); dbOptions.setMaxBackgroundCompactions(2);
throw new StorageInitializationException("Unable to parse Data Base Options."); dbOptions.setCreateIfMissing(true); dbOptions.setCreateMissingColumnFamilies(true); dbOptions.createStatistics();
@Override public DBOptions createDbOptions(DBOptions currentOptions) { if (currentOptions == null) currentOptions = new DBOptions(); currentOptions.setCreateIfMissing(true); currentOptions.setCreateMissingColumnFamilies(true); //currentOptions.setMemTableConfig(new HashLinkedListMemTableConfig()); //currentOptions.setStatsDumpPeriodSec(300); //currentOptions.createStatistics(); currentOptions.setAllowOsBuffer(true); currentOptions.setMaxOpenFiles(-1); currentOptions.setMaxBackgroundFlushes(2); currentOptions.setMaxBackgroundCompactions(2); currentOptions.setAllowOsBuffer(false); return currentOptions; }
dbOptions.setCreateIfMissing(true); ColumnFamilyOptions columnFamilyOptions = PredefinedOptions.DEFAULT.createColumnOptions(); final RocksDBKeyedStateBackend<Long> longHeapKeyedStateBackend =
dbOptions.setCreateIfMissing(true); ColumnFamilyOptions columnFamilyOptions = PredefinedOptions.DEFAULT.createColumnOptions(); final RocksDBKeyedStateBackend<Long> longHeapKeyedStateBackend =
@Override public DBOptions setCreateIfMissing(final boolean flag) { assert(isOwningHandle()); setCreateIfMissing(nativeHandle_, flag); return this; }
/** * Gets the RocksDB {@link DBOptions} to be used for all RocksDB instances. */ public DBOptions getDbOptions() { // initial options from pre-defined profile DBOptions opt = predefinedOptions.createDBOptions(); // add user-defined options, if specified if (optionsFactory != null) { opt = optionsFactory.createDBOptions(opt); } // add necessary default options opt = opt.setCreateIfMissing(true); return opt; }
/** * Gets the RocksDB {@link DBOptions} to be used for all RocksDB instances. */ public DBOptions getDbOptions() { // initial options from pre-defined profile DBOptions opt = predefinedOptions.createDBOptions(); // add user-defined options, if specified if (optionsFactory != null) { opt = optionsFactory.createDBOptions(opt); } // add necessary default options opt = opt.setCreateIfMissing(true); return opt; }
/** * Gets the RocksDB {@link DBOptions} to be used for all RocksDB instances. */ public DBOptions getDbOptions() { // initial options from pre-defined profile DBOptions opt = predefinedOptions.createDBOptions(); // add user-defined options, if specified if (optionsFactory != null) { opt = optionsFactory.createDBOptions(opt); } // add necessary default options opt = opt.setCreateIfMissing(true); return opt; }
public void initDb(List<Integer> list) throws Exception { LOG.info("Begin to init rocksDB of {}", rootDir); DBOptions dbOptions = null; List<ColumnFamilyDescriptor> columnFamilyNames = new ArrayList<ColumnFamilyDescriptor>(); columnFamilyNames.add(new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY)); for (Integer timeout : list) { columnFamilyNames.add(new ColumnFamilyDescriptor(String.valueOf(timeout).getBytes())); } List<Integer> ttlValues = new ArrayList<Integer>(); // Default column family with infinite lifetime // ATTENSION, the first must be 0, RocksDB.java API has this limitation ttlValues.add(0); // new column family with list second ttl ttlValues.addAll(list); try { dbOptions = new DBOptions().setCreateMissingColumnFamilies(true).setCreateIfMissing(true); List<ColumnFamilyHandle> columnFamilyHandleList = new ArrayList<ColumnFamilyHandle>(); ttlDB = TtlDB.open(dbOptions, rootDir, columnFamilyNames, columnFamilyHandleList, ttlValues, false); for (int i = 0; i < ttlValues.size(); i++) { windowHandlers.put(ttlValues.get(i), columnFamilyHandleList.get(i)); } LOG.info("Successfully init rocksDB of {}", rootDir); } finally { if (dbOptions != null) { dbOptions.dispose(); } } }
protected ZeebeRocksDb<ColumnFamilyType> open( final File dbDirectory, List<byte[]> columnFamilyNames) { final ZeebeRocksDb<ColumnFamilyType> db; try { final List<AutoCloseable> closeables = new ArrayList<>(); final ColumnFamilyOptions columnFamilyOptions = createColumnFamilyOptions(); closeables.add(columnFamilyOptions); final List<ColumnFamilyDescriptor> columnFamilyDescriptors = createFamilyDescriptors(columnFamilyNames, columnFamilyOptions); final DBOptions dbOptions = new DBOptions() .setCreateMissingColumnFamilies(true) .setErrorIfExists(false) .setCreateIfMissing(true); closeables.add(dbOptions); db = ZeebeRocksDb.openZbDb( dbOptions, dbDirectory.getAbsolutePath(), columnFamilyDescriptors, closeables, columnFamilyTypeClass); } catch (final RocksDBException e) { throw new RuntimeException("Unexpected error occurred trying to open the database", e); } return db; }
private DBOptions dataDbOptions() { DBOptions dbOptions; if (databaseProperties != null) { dbOptions = DBOptions.getDBOptionsFromProps(databaseProperties); if (dbOptions == null) { throw log.rocksDBUnknownPropertiesSupplied(databaseProperties.toString()); } } else { dbOptions = new DBOptions(); } return dbOptions .setCreateIfMissing(true) // We have to create missing column families on open. // Otherwise when we start we won't know what column families this database had if any - thus // we must specify all of them and later remove them. .setCreateMissingColumnFamilies(true); }
public static RocksDbKeyValueService create(String dataDir, Map<String, String> dbOptions, Map<String, String> cfOptions, WriteOpts writeOpts, String comparator) { DBOptions dbOpts = new DBOptions().setCreateIfMissing(true); setReflectionOpts(dbOpts, dbOptions); ColumnFamilyOptions cfMetadataOpts = new ColumnFamilyOptions(); setReflectionOpts(cfMetadataOpts, cfOptions); ColumnFamilyOptions cfCommonOpts; switch (comparator) { case "atlasdb-v2": cfCommonOpts = new ColumnFamilyOptions().setComparator(RocksComparator.INSTANCE); break; case "atlasdb": cfCommonOpts = new ColumnFamilyOptions().setComparator(RocksOldComparator.INSTANCE); break; default: throw new IllegalArgumentException("Unknown comparator " + comparator); } setReflectionOpts(cfCommonOpts, cfOptions); return create(dataDir, dbOpts, cfMetadataOpts, cfCommonOpts, writeOpts); }
dbOpts.setCreateIfMissing(true); dbOpts.setErrorIfExists(false); dbOpts.setInfoLogLevel(DEFAULT_LOG_LEVEL);
/** * Builds RocksDb {@link DBOptions}. * * @param maxBackgroundFlushes * high priority threads, usually 1 or 2 would be enough * @param maxBackgroundCompactions * low priority threads, between 1 - num_cpu_cores * @param maxBackgroundThreads * {@code >= maxBackgroundFlushes, maxBackgroundCompactions} * @param maxLogFileSize * if equal to {@code 0}, write all logs to one file and roll by time * @return */ public static DBOptions buildDbOptions(int maxBackgroundFlushes, int maxBackgroundCompactions, int maxBackgroundThreads, long maxLogFileSize) { DBOptions dbOptions = new DBOptions(); dbOptions.setCreateIfMissing(true).setCreateMissingColumnFamilies(true) .setErrorIfExists(false); dbOptions.setMaxBackgroundFlushes(maxBackgroundFlushes) .setMaxBackgroundCompactions(maxBackgroundCompactions) .setIncreaseParallelism(maxBackgroundThreads); dbOptions.setAllowMmapReads(true).setAllowMmapWrites(true); dbOptions.setMaxOpenFiles(-1); dbOptions.setKeepLogFileNum(100).setLogFileTimeToRoll(3600) .setMaxLogFileSize(maxLogFileSize); return dbOptions; }