@SuppressWarnings("unused") public void initDb(List<Integer> list, Options dbOptions) throws Exception { LOG.info("Begin to init rocksDB of {}", rootDir); try { //List<ColumnFamilyHandle> columnFamilyHandleList = new ArrayList<ColumnFamilyHandle>(); db = RocksDB.open(dbOptions, rootDir); LOG.info("Successfully init rocksDB of {}", rootDir); } finally { if (dbOptions != null) { dbOptions.dispose(); } } }
@Override public void open() throws FailStoreException { try { db = RocksDB.open(options, dbPath.getPath()); } catch (Exception e) { throw new FailStoreException(e); } }
@Override public void open() throws FailStoreException { try { db = RocksDB.open(options, dbPath.getPath()); } catch (Exception e) { throw new FailStoreException(e); } }
public static RocksDB create(Map conf, String rocksDbDir, int ttlTimeSec) throws IOException { Options options = getOptions(conf); try { RocksDB rocksDb = ttlTimeSec > 0 ? TtlDB.open(options, rocksDbDir, ttlTimeSec, false) : RocksDB.open(options, rocksDbDir); LOG.info("Finished loading RocksDB"); // enable compaction rocksDb.compactRange(); return rocksDb; } catch (RocksDBException e) { throw new IOException("Failed to initialize RocksDb.", e); } }
public static RocksDB createWithColumnFamily(Map conf, String rocksDbDir, final Map<String, ColumnFamilyHandle> columnFamilyHandleMap, int ttlTimeSec) throws IOException { List<ColumnFamilyDescriptor> columnFamilyDescriptors = getExistingColumnFamilyDesc(conf, rocksDbDir); List<ColumnFamilyHandle> columnFamilyHandles = new ArrayList<>(); DBOptions dbOptions = getDBOptions(conf); try { RocksDB rocksDb = ttlTimeSec > 0 ? TtlDB.open( dbOptions, rocksDbDir, columnFamilyDescriptors, columnFamilyHandles, getTtlValues(ttlTimeSec, columnFamilyDescriptors), false) : RocksDB.open(dbOptions, rocksDbDir, columnFamilyDescriptors, columnFamilyHandles); int n = Math.min(columnFamilyDescriptors.size(), columnFamilyHandles.size()); // skip default column columnFamilyHandleMap.put(DEFAULT_COLUMN_FAMILY, rocksDb.getDefaultColumnFamily()); for (int i = 1; i < n; i++) { ColumnFamilyDescriptor descriptor = columnFamilyDescriptors.get(i); columnFamilyHandleMap.put(new String(descriptor.columnFamilyName()), columnFamilyHandles.get(i)); } LOG.info("Finished loading RocksDB with existing column family={}, dbPath={}, ttlSec={}", columnFamilyHandleMap.keySet(), rocksDbDir, ttlTimeSec); // enable compaction rocksDb.compactRange(); return rocksDb; } catch (RocksDBException e) { throw new IOException("Failed to initialize RocksDb.", e); } }
dbRef = RocksDB.open( Preconditions.checkNotNull(dbOptions), Preconditions.checkNotNull(path),
public void build(ILookupTable srcLookupTable) { File dbFolder = new File(dbPath); if (dbFolder.exists()) { logger.info("remove rocksdb folder:{} to rebuild table cache:{}", dbPath, tableDesc.getIdentity()); FileUtils.deleteQuietly(dbFolder); } else { logger.info("create new rocksdb folder:{} for table cache:{}", dbPath, tableDesc.getIdentity()); dbFolder.mkdirs(); } logger.info("start to build lookup table:{} to rocks db:{}", tableDesc.getIdentity(), dbPath); try (RocksDB rocksDB = RocksDB.open(options, dbPath)) { // todo use batch may improve write performance for (String[] row : srcLookupTable) { KV kv = encoder.encode(row); rocksDB.put(kv.getKey(), kv.getValue()); } } catch (RocksDBException e) { logger.error("error when put data to rocksDB", e); throw new RuntimeException("error when write data to rocks db", e); } logger.info("source table:{} has been written to rocks db:{}", tableDesc.getIdentity(), dbPath); } }
db = RocksDB.open(options, path); } catch (RocksDBException e) { String message = "Error opening RockDB database";
mDb = RocksDB.open(options, mDbPath, cfDescriptors, columns); mDefaultColumn = columns.get(0); mBlockMetaColumn = columns.get(1);
.setInfoLogLevel(InfoLogLevel.INFO_LEVEL); dbOptions = options; return RocksDB.open(options, rocksDbDir.toAbsolutePath().toString()); } else { final DBOptions options = new DBOptions() final RocksDB db = RocksDB.open(options, rocksDbDir.toAbsolutePath().toString(), cfDescriptors, cfHandles); for(int i = 0; i < cfNames.size(); i++) { COLUMN_FAMILIES.put(cfNames.get(i), new ColumnFamily(cfHandles.get(i), cfOptionss.get(i)));
mDb = RocksDB.open(options, mDbPath, cfDescriptors, columns); mDefaultColumn = columns.get(0); mInodesColumn = columns.get(1);
RocksDB rdbStore = RocksDB.open(dbOptions, dataDir, descriptors, handles);
db = RocksDB.open(options, dbPath.toString()); } catch (RocksDBException e) { logger.error(e.getMessage(), e);
public RocksDBStdSessions(HugeConfig config, String dataPath, String walPath, String database, String store) throws RocksDBException { super(database, store); this.conf = config; // Init options Options options = new Options(); RocksDBStdSessions.initOptions(this.conf, options, options, options); options.setWalDir(walPath); /* * Open RocksDB at the first time * Don't merge old CFs, we expect a clear DB when using this one */ this.rocksdb = RocksDB.open(options, dataPath); }
this.rocksdb = RocksDB.open(options, dataPath, cfds, cfhs); E.checkState(cfhs.size() == cfs.size(), "Expect same size of cf-handles and cf-names");
public RocksdbMap() { dbDir = Files.createTempDir(); try { this.db = RocksDB.open(dbDir.getAbsolutePath()); } catch (RocksDBException e) { Throwables.propagate(e); } }
private RocksDB openDatabase() { try { return RocksDB.open(this.databaseOptions, this.dbDir); } catch (RocksDBException ex) { throw convert(ex, "initialize RocksDB instance"); } }
@BeforeClass static public void createRocksDb() throws IOException, RocksDBException { if (Files.exists(dirPath)) { removeRecursiveDirectory(dirPath); } Files.createDirectories(dirPath); Options options = new Options().setCreateIfMissing(true); db = RocksDB.open(options, dirPath.toString()); db.put("testString".getBytes(), "this is string".getBytes()); db.put(ByteBuffer.allocate(4).putInt(123).array(), ByteBuffer.allocate(4).putInt(456).array()); }
public DBSharder(String dbpath, Long timestamp) throws RocksDBException { log = LoggerFactory.getLogger(DBSharder.class); RocksDB.loadLibrary(); options = new Options(); env = options.getEnv(); env.setBackgroundThreads(2); options.setEnv(env); options.setCreateIfMissing(true); options.setDbLogDir(dbpath + "/logs/"); options.setMergeOperator(new StringAppendOperator()); db = RocksDB.open(options, dbpath + "/" + timestamp); }