Search in sources :

Example 11 with DatabaseConfig

use of com.sleepycat.je.DatabaseConfig in project voldemort by voldemort.

the class BdbSplitStorageEngineTest method testUnsharedCache.

@Test
public void testUnsharedCache() throws DatabaseException {
    EnvironmentConfig environmentConfig = new EnvironmentConfig();
    environmentConfig.setDurability(Durability.COMMIT_NO_SYNC);
    environmentConfig.setAllowCreate(true);
    environmentConfig.setTransactional(true);
    environmentConfig.setSharedCache(false);
    environmentConfig.setCacheSize(CACHE_SIZE);
    DatabaseConfig databaseConfig = new DatabaseConfig();
    databaseConfig.setAllowCreate(true);
    databaseConfig.setTransactional(true);
    databaseConfig.setSortedDuplicates(true);
    long maxCacheSize = getMaxCacheUsage(environmentConfig, databaseConfig);
    assertEquals("MaxCacheSize > CACHE_SIZE", true, maxCacheSize > CACHE_SIZE);
    assertEquals("MaxCacheSize < 2 * CACHE_SIZE", true, maxCacheSize < 2 * CACHE_SIZE);
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) DatabaseConfig(com.sleepycat.je.DatabaseConfig) Test(org.junit.Test)

Example 12 with DatabaseConfig

use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.

the class AbstractBDBPreferenceStore method getPreferencesVersionDb.

private Database getPreferencesVersionDb() {
    Database preferencesVersionDb;
    try {
        DatabaseConfig config = new DatabaseConfig().setTransactional(true).setAllowCreate(false);
        preferencesVersionDb = getEnvironmentFacade().openDatabase(PREFERENCES_VERSION_DB_NAME, config);
    } catch (DatabaseNotFoundException e) {
        preferencesVersionDb = updateVersion(null, BrokerModel.MODEL_VERSION);
    }
    return preferencesVersionDb;
}
Also used : DatabaseNotFoundException(com.sleepycat.je.DatabaseNotFoundException) Database(com.sleepycat.je.Database) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 13 with DatabaseConfig

use of com.sleepycat.je.DatabaseConfig in project qpid-broker-j by apache.

the class UpgradeFrom8To9 method performUpgrade.

@Override
public void performUpgrade(final Environment environment, final UpgradeInteractionHandler handler, final ConfiguredObject<?> parent) {
    reportStarting(environment, 8);
    DatabaseConfig dbConfig = new DatabaseConfig();
    dbConfig.setTransactional(true);
    dbConfig.setAllowCreate(true);
    final Transaction transaction = environment.beginTransaction(null, null);
    try {
        Database userPreferencesDb = environment.openDatabase(transaction, "USER_PREFERENCES", dbConfig);
        userPreferencesDb.close();
        try (Database userPreferencesVersionDb = environment.openDatabase(transaction, "USER_PREFERENCES_VERSION", dbConfig)) {
            if (userPreferencesVersionDb.count() == 0L) {
                DatabaseEntry key = new DatabaseEntry();
                DatabaseEntry value = new DatabaseEntry();
                StringBinding.stringToEntry(DEFAULT_VERSION, key);
                LongBinding.longToEntry(System.currentTimeMillis(), value);
                OperationStatus status = userPreferencesVersionDb.put(transaction, key, value);
                if (status != OperationStatus.SUCCESS) {
                    throw new StoreException("Error initialising user preference version: " + status);
                }
            }
        }
        transaction.commit();
        reportFinished(environment, 9);
    } catch (RuntimeException e) {
        try {
            if (transaction.isValid()) {
                transaction.abort();
            }
        } finally {
            throw e;
        }
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus) Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DatabaseConfig(com.sleepycat.je.DatabaseConfig) StoreException(org.apache.qpid.server.store.StoreException)

Example 14 with DatabaseConfig

use of com.sleepycat.je.DatabaseConfig in project sirix by sirixdb.

the class BerkeleyStorageFactory method generateDBConf.

/**
 * Generate {@link DatabaseConfig} reference.
 *
 * @return transactional database configuration
 */
private static DatabaseConfig generateDBConf() {
    final DatabaseConfig conf = new DatabaseConfig();
    conf.setTransactional(true);
    conf.setKeyPrefixing(true);
    return conf;
}
Also used : DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 15 with DatabaseConfig

use of com.sleepycat.je.DatabaseConfig in project vertigo by KleeGroup.

the class BerkeleyDatabase method clear.

/**
 * Clear this database.
 */
public void clear() {
    final String dataBaseName = database.getDatabaseName();
    final DatabaseConfig databaseConfig = database.getConfig();
    database.close();
    database.getEnvironment().truncateDatabase(null, dataBaseName, false);
    database = database.getEnvironment().openDatabase(null, dataBaseName, databaseConfig);
    database.getEnvironment().cleanLog();
}
Also used : DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Aggregations

DatabaseConfig (com.sleepycat.je.DatabaseConfig)56 Database (com.sleepycat.je.Database)30 Environment (com.sleepycat.je.Environment)26 EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)23 DatabaseEntry (com.sleepycat.je.DatabaseEntry)13 File (java.io.File)12 Transaction (com.sleepycat.je.Transaction)7 Test (org.junit.Test)7 Cursor (com.sleepycat.je.Cursor)6 DatabaseException (com.sleepycat.je.DatabaseException)6 IOException (java.io.IOException)4 Map (java.util.Map)4 StoreException (org.apache.qpid.server.store.StoreException)4 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)4 OperationStatus (com.sleepycat.je.OperationStatus)3 HashMap (java.util.HashMap)3 StoredClassCatalog (com.sleepycat.bind.serial.StoredClassCatalog)2 StringBinding (com.sleepycat.bind.tuple.StringBinding)2 TupleInput (com.sleepycat.bind.tuple.TupleInput)2 TupleOutput (com.sleepycat.bind.tuple.TupleOutput)2