Search in sources :

Example 1 with Database

use of com.sleepycat.je.Database in project GeoGig by boundlessgeo.

the class BDBJEDeduplicationService method createDeduplicator.

@Override
public Deduplicator createDeduplicator() {
    Database database = createDatabase();
    BDBJEDeduplicator deduplicator = new BDBJEDeduplicator(database, this);
    this.openDeduplicators.add(deduplicator);
    return deduplicator;
}
Also used : Database(com.sleepycat.je.Database)

Example 2 with Database

use of com.sleepycat.je.Database in project GeoGig by boundlessgeo.

the class JEObjectDatabase method createDatabase.

protected Database createDatabase() {
    final String databaseName = "ObjectDatabase";
    Environment environment;
    try {
        environment = createEnvironment(readOnly);
    } catch (EnvironmentLockedException e) {
        throw new IllegalStateException("The repository is already open by another process for writing", e);
    }
    if (!environment.getDatabaseNames().contains(databaseName)) {
        if (readOnly) {
            environment.close();
            try {
                environment = createEnvironment(false);
            } catch (EnvironmentLockedException e) {
                throw new IllegalStateException(String.format("Environment open readonly but database %s does not exist.", databaseName));
            }
        }
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        Database openDatabase = environment.openDatabase(null, databaseName, dbConfig);
        openDatabase.close();
        environment.flushLog(true);
        environment.close();
        environment = createEnvironment(readOnly);
    }
    // System.err.println("Opened ObjectDatabase at " + env.getHome()
    // + ". Environment read-only: " + environment.getConfig().getReadOnly()
    // + " database read only: " + this.readOnly);
    Database database;
    try {
        LOGGER.debug("Opening ObjectDatabase at {}", environment.getHome());
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setCacheMode(CacheMode.MAKE_COLD);
        // can result in a slightly smaller db size
        dbConfig.setKeyPrefixing(false);
        dbConfig.setReadOnly(readOnly);
        boolean transactional = environment.getConfig().getTransactional();
        dbConfig.setTransactional(transactional);
        dbConfig.setDeferredWrite(!transactional);
        database = environment.openDatabase(null, databaseName, dbConfig);
    } catch (RuntimeException e) {
        if (environment != null) {
            environment.close();
        }
        throw e;
    }
    this.env = environment;
    return database;
}
Also used : EnvironmentLockedException(com.sleepycat.je.EnvironmentLockedException) AbstractObjectDatabase(org.locationtech.geogig.storage.AbstractObjectDatabase) ConfigDatabase(org.locationtech.geogig.storage.ConfigDatabase) ObjectDatabase(org.locationtech.geogig.storage.ObjectDatabase) Database(com.sleepycat.je.Database) Environment(com.sleepycat.je.Environment) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 3 with Database

use of com.sleepycat.je.Database in project BIMserver by opensourceBIM.

the class BerkeleyKeyValueStore method openTable.

public boolean openTable(DatabaseSession databaseSession, String tableName, boolean transactional) throws BimserverDatabaseException {
    if (tables.containsKey(tableName)) {
        throw new BimserverDatabaseException("Table " + tableName + " already opened");
    }
    DatabaseConfig databaseConfig = new DatabaseConfig();
    databaseConfig.setKeyPrefixing(keyPrefixing);
    databaseConfig.setAllowCreate(false);
    boolean finalTransactional = transactional && useTransactions;
    // if (!transactional) {
    // databaseConfig.setCacheMode(CacheMode.EVICT_BIN);
    // }
    databaseConfig.setDeferredWrite(!finalTransactional);
    databaseConfig.setTransactional(finalTransactional);
    databaseConfig.setSortedDuplicates(false);
    Database database = environment.openDatabase(null, tableName, databaseConfig);
    if (database == null) {
        throw new BimserverDatabaseException("Table " + tableName + " not found in database");
    }
    tables.put(tableName, new TableWrapper(database, finalTransactional));
    return true;
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) Database(com.sleepycat.je.Database) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 4 with Database

use of com.sleepycat.je.Database in project BIMserver by opensourceBIM.

the class BerkeleyKeyValueStore method createTable.

public boolean createTable(String tableName, DatabaseSession databaseSession, boolean transactional) throws BimserverDatabaseException {
    if (tables.containsKey(tableName)) {
        throw new BimserverDatabaseException("Table " + tableName + " already created");
    }
    DatabaseConfig databaseConfig = new DatabaseConfig();
    databaseConfig.setKeyPrefixing(keyPrefixing);
    databaseConfig.setAllowCreate(true);
    boolean finalTransactional = transactional && useTransactions;
    databaseConfig.setDeferredWrite(!finalTransactional);
    // if (!transactional) {
    // databaseConfig.setCacheMode(CacheMode.EVICT_BIN);
    // }
    databaseConfig.setTransactional(finalTransactional);
    databaseConfig.setSortedDuplicates(false);
    Database database = environment.openDatabase(null, tableName, databaseConfig);
    if (database == null) {
        return false;
    }
    tables.put(tableName, new TableWrapper(database, finalTransactional));
    return true;
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) Database(com.sleepycat.je.Database) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 5 with Database

use of com.sleepycat.je.Database in project timbuctoo by HuygensING.

the class BdbNonPersistentEnvironmentCreator method close.

public void close() throws DatabaseException, IOException {
    for (Database database : databases.values()) {
        database.close();
    }
    boolean wasDeleted = false;
    int tries = 0;
    while (!wasDeleted) {
        try {
            FileUtils.cleanDirectory(dbHome);
            wasDeleted = true;
        } catch (IOException e) {
            tries++;
            if (tries >= 10) {
                wasDeleted = true;
            } else {
                try {
                    Thread.sleep(1);
                } catch (InterruptedException e1) {
                    LOG.error("Trying to clean up and delete directory, but it failed the first time around and then the " + "thread was interrupted");
                    wasDeleted = true;
                }
            }
        }
    }
}
Also used : Database(com.sleepycat.je.Database) IOException(java.io.IOException)

Aggregations

Database (com.sleepycat.je.Database)73 DatabaseEntry (com.sleepycat.je.DatabaseEntry)46 Transaction (com.sleepycat.je.Transaction)35 DatabaseConfig (com.sleepycat.je.DatabaseConfig)27 UUID (java.util.UUID)12 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)11 Environment (com.sleepycat.je.Environment)10 OperationStatus (com.sleepycat.je.OperationStatus)8 Cursor (com.sleepycat.je.Cursor)7 HashSet (java.util.HashSet)7 StoreException (org.apache.qpid.server.store.StoreException)7 HashMap (java.util.HashMap)6 EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)5 File (java.io.File)5 ArrayList (java.util.ArrayList)5 FieldTable (org.apache.qpid.server.protocol.v0_8.FieldTable)5 NewPreparedTransaction (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.NewPreparedTransaction)5 OldPreparedTransaction (org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.OldPreparedTransaction)5 Test (org.junit.Test)5 TupleOutput (com.sleepycat.bind.tuple.TupleOutput)4