Search in sources :

Example 6 with EnvironmentConfig

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);
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment) DatabaseConfig(com.sleepycat.je.DatabaseConfig) Before(org.junit.Before)

Example 7 with EnvironmentConfig

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));
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) DatabaseConfig(com.sleepycat.je.DatabaseConfig) Test(org.junit.Test)

Example 8 with EnvironmentConfig

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;
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) ByteSource(com.google.common.io.ByteSource) Environment(com.sleepycat.je.Environment) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) ResolveGeogigDir(org.locationtech.geogig.api.plumbing.ResolveGeogigDir) File(java.io.File) URL(java.net.URL)

Aggregations

EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)8 DatabaseConfig (com.sleepycat.je.DatabaseConfig)6 Environment (com.sleepycat.je.Environment)6 File (java.io.File)5 Database (com.sleepycat.je.Database)2 Test (org.junit.Test)2 ByteSource (com.google.common.io.ByteSource)1 CheckpointConfig (com.sleepycat.je.CheckpointConfig)1 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1 DatabaseException (com.sleepycat.je.DatabaseException)1 EntityStore (com.sleepycat.persist.EntityStore)1 StoreConfig (com.sleepycat.persist.StoreConfig)1 IOException (java.io.IOException)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Random (java.util.Random)1 Timer (java.util.Timer)1 Callable (java.util.concurrent.Callable)1 ExecutorService (java.util.concurrent.ExecutorService)1