@Override public DBOptions setErrorIfExists( final boolean errorIfExists) { assert(isOwningHandle()); setErrorIfExists(nativeHandle_, errorIfExists); return this; }
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; }
dbOpts.setErrorIfExists(false); dbOpts.setInfoLogLevel(DEFAULT_LOG_LEVEL); dbOpts.setIncreaseParallelism(DEFAULT_PARALLELISM);
/** * 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; }