use of com.sleepycat.je.EnvironmentConfig in project voldemort by voldemort.
the class BdbStorageEngineTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
this.envConfig = new EnvironmentConfig();
this.envConfig.setDurability(Durability.COMMIT_NO_SYNC);
this.envConfig.setAllowCreate(true);
this.envConfig.setTransactional(true);
this.tempDir = TestUtils.createTempDir();
this.environment = new Environment(this.tempDir, envConfig);
this.databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(true);
databaseConfig.setSortedDuplicates(false);
this.database = environment.openDatabase(null, "test", databaseConfig);
this.runtimeConfig = new BdbRuntimeConfig();
runtimeConfig.setLockMode(LOCK_MODE);
this.store = makeBdbStorageEngine("test", this.environment, this.database, runtimeConfig, this.prefixPartitionId);
}
use of com.sleepycat.je.EnvironmentConfig in project voldemort by voldemort.
the class BdbSplitStorageEngineTest method testSharedCache.
@Test
public void testSharedCache() throws DatabaseException {
EnvironmentConfig environmentConfig = new EnvironmentConfig();
environmentConfig.setDurability(Durability.COMMIT_NO_SYNC);
environmentConfig.setAllowCreate(true);
environmentConfig.setTransactional(true);
environmentConfig.setSharedCache(true);
environmentConfig.setCacheSize(CACHE_SIZE);
DatabaseConfig databaseConfig = new DatabaseConfig();
databaseConfig.setAllowCreate(true);
databaseConfig.setTransactional(true);
databaseConfig.setSortedDuplicates(true);
long maxCacheSize = getMaxCacheUsage(environmentConfig, databaseConfig);
// Include a buffer of 1mb.. since the actual cache usage can be a few
// bytes more
assertEquals("MaxCacheSize" + maxCacheSize + " <= CACHE_SIZE:" + CACHE_SIZE, true, maxCacheSize <= (CACHE_SIZE + ByteUtils.BYTES_PER_MB));
}
use of com.sleepycat.je.EnvironmentConfig in project GeoGig by boundlessgeo.
the class EnvironmentBuilder method get.
/**
* @return
* @see com.google.inject.Provider#get()
*/
@Override
public synchronized Environment get() {
final Optional<URL> repoUrl = new ResolveGeogigDir(platform).call();
if (!repoUrl.isPresent() && absolutePath == null) {
throw new IllegalStateException("Can't find geogig repository home");
}
final File storeDirectory;
if (absolutePath != null) {
storeDirectory = absolutePath;
} else {
File currDir;
try {
currDir = new File(repoUrl.get().toURI());
} catch (URISyntaxException e) {
throw Throwables.propagate(e);
}
File dir = currDir;
for (String subdir : path) {
dir = new File(dir, subdir);
}
storeDirectory = dir;
}
if (!storeDirectory.exists() && !storeDirectory.mkdirs()) {
throw new IllegalStateException("Unable to create Environment directory: '" + storeDirectory.getAbsolutePath() + "'");
}
EnvironmentConfig envCfg;
if (this.forceConfig == null) {
File conf = new File(storeDirectory, "je.properties");
if (!conf.exists()) {
String resource = stagingDatabase ? "je.properties.staging" : "je.properties.objectdb";
ByteSource from = Resources.asByteSource((getClass().getResource(resource)));
try {
from.copyTo(Files.asByteSink(conf));
} catch (IOException e) {
Throwables.propagate(e);
}
}
// use the default settings
envCfg = new EnvironmentConfig();
envCfg.setAllowCreate(true);
envCfg.setCacheMode(CacheMode.MAKE_COLD);
envCfg.setLockTimeout(5, TimeUnit.SECONDS);
envCfg.setDurability(Durability.COMMIT_SYNC);
// envCfg.setReadOnly(readOnly);
} else {
envCfg = this.forceConfig;
}
// // envCfg.setSharedCache(true);
// //
// final boolean transactional = false;
// envCfg.setTransactional(transactional);
// envCfg.setCachePercent(75);// Use up to 50% of the heap size for the shared db cache
// envCfg.setConfigParam(EnvironmentConfig.LOG_FILE_MAX, String.valueOf(256 * 1024 * 1024));
// // check <http://www.oracle.com/technetwork/database/berkeleydb/je-faq-096044.html#35>
// envCfg.setConfigParam("je.evictor.lruOnly", "false");
// envCfg.setConfigParam("je.evictor.nodesPerScan", "100");
//
// envCfg.setConfigParam(EnvironmentConfig.CLEANER_MIN_UTILIZATION, "25");
// envCfg.setConfigParam(EnvironmentConfig.CHECKPOINTER_HIGH_PRIORITY, "true");
//
// envCfg.setConfigParam(EnvironmentConfig.CLEANER_THREADS, "4");
// // TODO: check whether we can set is locking to false
// envCfg.setConfigParam(EnvironmentConfig.ENV_IS_LOCKING, String.valueOf(transactional));
//
// envCfg.setConfigParam(EnvironmentConfig.ENV_RUN_CHECKPOINTER,
// String.valueOf(!transactional));
// envCfg.setConfigParam(EnvironmentConfig.ENV_RUN_CLEANER, String.valueOf(!transactional));
//
// // envCfg.setConfigParam(EnvironmentConfig.ENV_RUN_EVICTOR, "false");
Environment env;
try {
env = new Environment(storeDirectory, envCfg);
} catch (RuntimeException lockedEx) {
// lockedEx.printStackTrace();
if (readOnly) {
// this happens when trying to open the env in read only mode when its already open
// in read/write mode inside the same process. So we re-open it read-write but the
// database itself will be open read-only by JEObjectDatabase.
envCfg.setReadOnly(true);
env = new Environment(storeDirectory, envCfg);
} else {
throw lockedEx;
}
}
return env;
}
Aggregations