use of com.sleepycat.je.DatabaseConfig in project sessdb by ppdai.
the class BdbBenchmark method open.
@Override
public void open() {
try {
EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setAllowCreate(true);
envConfig.setCachePercent(90);
File file = new File(databaseDir_);
if (!file.exists()) {
file.mkdirs();
}
env_ = new Environment(file, envConfig);
DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setAllowCreate(true);
bdb_ = env_.openDatabase(null, BdbBenchmark.DATABASE_NAME, dbConfig);
} catch (DatabaseException e) {
e.printStackTrace();
}
}
use of com.sleepycat.je.DatabaseConfig in project vertigo by KleeGroup.
the class BerkeleyKVStorePlugin method start.
/**
* {@inheritDoc}
*/
@Override
public void start() {
final boolean readOnly = READONLY;
ramEnvironment = buildRamEnvironment(new File(dbFilePathTranslated + File.separator + "ram"), readOnly);
fsEnvironment = buildFsEnvironment(new File(dbFilePathTranslated), readOnly);
final DatabaseConfig databaseConfig = new DatabaseConfig().setReadOnly(readOnly).setAllowCreate(!readOnly).setTransactional(!readOnly);
for (final BerkeleyCollectionConfig collectionConfig : collectionConfigs) {
final BerkeleyDatabase berkeleyDatabase = new BerkeleyDatabase(// select environment (FS or RAM)
(collectionConfig.isInMemory() ? ramEnvironment : fsEnvironment).openDatabase(null, collectionConfig.getCollectionName(), // open database
databaseConfig), collectionConfig.getTimeToLiveSeconds(), transactionManager, codecManager);
databases.put(collectionConfig.getCollectionName(), berkeleyDatabase);
}
}
use of com.sleepycat.je.DatabaseConfig in project sirix by sirixdb.
the class BerkeleyStorageFactory method createStorage.
/**
* Create a new storage.
*
* @param resourceConfig the resource configuration
* @return the berkeley DB storage
* @throws NullPointerException if {@link ResourceConfiguration} is {@code null}
* @throws SirixIOException if the storage couldn't be created because of an I/O exception
*/
public BerkeleyStorage createStorage(final ResourceConfiguration resourceConfig) {
try {
final Path repoFile = resourceConfig.mPath.resolve(ResourceConfiguration.ResourcePaths.DATA.getFile());
if (!Files.exists(repoFile)) {
Files.createDirectories(repoFile);
}
final ByteHandlePipeline byteHandler = checkNotNull(resourceConfig.mByteHandler);
final DatabaseConfig conf = generateDBConf();
final EnvironmentConfig config = generateEnvConf();
final List<Path> path;
try (final Stream<Path> stream = Files.list(repoFile)) {
path = stream.collect(toList());
}
if (path.isEmpty() || (path.size() == 1 && "sirix.data".equals(path.get(0).getFileName().toString()))) {
conf.setAllowCreate(true);
config.setAllowCreate(true);
}
final Environment env = new Environment(repoFile.toFile(), config);
final Database database = env.openDatabase(null, NAME, conf);
return new BerkeleyStorage(env, database, byteHandler);
} catch (final DatabaseException | IOException e) {
throw new SirixIOException(e);
}
}
use of com.sleepycat.je.DatabaseConfig in project bboxdb by jnidzwetzki.
the class FileLineIndex method openDatabase.
/**
* Open the Berkeley DB
* @throws IOException
*/
protected void openDatabase() throws IOException {
final EnvironmentConfig envConfig = new EnvironmentConfig();
envConfig.setTransactional(false);
envConfig.setAllowCreate(true);
envConfig.setSharedCache(true);
tmpDatabaseDir = Files.createTempDirectory(null);
dbEnv = new Environment(tmpDatabaseDir.toFile(), envConfig);
logger.info("Database dir is {}", tmpDatabaseDir);
// Delete database on exit
FileUtil.deleteDirOnExit(tmpDatabaseDir);
final DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(false);
dbConfig.setAllowCreate(true);
dbConfig.setDeferredWrite(true);
database = dbEnv.openDatabase(null, "lines", dbConfig);
}
use of com.sleepycat.je.DatabaseConfig in project bboxdb by jnidzwetzki.
the class OSMBDBNodeStore method initNewBDBEnvironment.
/**
* Init a new BDB environment in the given folder
* @param folder
*/
@SuppressWarnings("unused")
protected void initNewBDBEnvironment(final File folder, final EnvironmentConfig envConfig) {
final Environment dbEnv = new Environment(folder, envConfig);
Transaction txn = null;
if (USE_TRANSACTIONS) {
txn = dbEnv.beginTransaction(null, null);
}
final DatabaseConfig dbConfig = new DatabaseConfig();
dbConfig.setTransactional(USE_TRANSACTIONS);
dbConfig.setAllowCreate(true);
dbConfig.setSortedDuplicates(true);
dbConfig.setDeferredWrite(true);
// dbConfig.setKeyPrefixing(true);
// dbConfig.setNodeMaxEntries(128);
final Database database = dbEnv.openDatabase(txn, "osm", dbConfig);
if (txn != null) {
txn.commit();
}
environments.add(dbEnv);
databases.add(database);
}
Aggregations