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(); } } }
final DBOptions options = new DBOptions() .setCreateIfMissing(true) .setCreateMissingColumnFamilies(true) .setIncreaseParallelism(rocksThreads) .setMaxBackgroundCompactions(rocksThreads)
.setMaxOpenFiles(-1) .setCreateIfMissing(true) .setCreateMissingColumnFamilies(true);
dbOptions.setCreateMissingColumnFamilies(true); dbOptions.setCreateIfMissing(true); dbOptions.setMaxBackgroundFlushes(2);
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; }
@Override public DBOptions setCreateMissingColumnFamilies( final boolean flag) { assert(isOwningHandle()); setCreateMissingColumnFamilies(nativeHandle_, flag); return this; }
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); }
.setCreateMissingColumnFamilies(true) .setIncreaseParallelism(parallelism) .setMaxBackgroundCompactions(maxBackgroundCompactions)
colFamily.add(new ColumnFamilyDescriptor(RocksDB.DEFAULT_COLUMN_FAMILY, coptions1)); options.setCreateMissingColumnFamilies(true); db = RocksDB.open(options, "c:/temp", colFamily, colFamilyHandles); byte[] k = "6442".getBytes();
dbOpts.setInfoLogLevel(DEFAULT_LOG_LEVEL); dbOpts.setIncreaseParallelism(DEFAULT_PARALLELISM); dbOpts.setCreateMissingColumnFamilies(true);
/** * 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; }