Search in sources :

Example 6 with DatabaseException

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

the class BdbStorageConfiguration method checkPointAllEnvironments.

/**
     * Forceful checkpointing
     */
@JmxOperation(description = "Forcefully checkpoint all the environments")
public void checkPointAllEnvironments() {
    synchronized (lock) {
        try {
            for (Environment environment : environments.values()) {
                CheckpointConfig checkPointConfig = new CheckpointConfig();
                checkPointConfig.setForce(true);
                environment.checkpoint(checkPointConfig);
            }
        } catch (DatabaseException e) {
            throw new VoldemortException(e);
        }
    }
}
Also used : CheckpointConfig(com.sleepycat.je.CheckpointConfig) Environment(com.sleepycat.je.Environment) DatabaseException(com.sleepycat.je.DatabaseException) VoldemortException(voldemort.VoldemortException) JmxOperation(voldemort.annotations.jmx.JmxOperation)

Example 7 with DatabaseException

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

the class BdbStorageConfiguration method getStore.

public StorageEngine<ByteArray, byte[], byte[]> getStore(StoreDefinition storeDef, RoutingStrategy strategy) {
    synchronized (lock) {
        try {
            String storeName = storeDef.getName();
            Environment environment = getEnvironment(storeDef);
            Database db = environment.openDatabase(null, storeName, databaseConfig);
            BdbRuntimeConfig runtimeConfig = new BdbRuntimeConfig(voldemortConfig);
            BdbStorageEngine engine = null;
            if (voldemortConfig.getBdbPrefixKeysWithPartitionId()) {
                engine = new PartitionPrefixedBdbStorageEngine(storeName, environment, db, runtimeConfig, strategy);
            } else {
                engine = new BdbStorageEngine(storeName, environment, db, runtimeConfig);
            }
            if (voldemortConfig.isJmxEnabled()) {
                // register the environment stats mbean
                JmxUtils.registerMbean(storeName, engine.getBdbEnvironmentStats());
                // aggregated stats
                if (useOneEnvPerStore) {
                    aggBdbStats.trackEnvironment(engine.getBdbEnvironmentStats());
                }
            }
            return engine;
        } catch (DatabaseException d) {
            throw new StorageInitializationException(d);
        }
    }
}
Also used : StorageInitializationException(voldemort.store.StorageInitializationException) Database(com.sleepycat.je.Database) Environment(com.sleepycat.je.Environment) DatabaseException(com.sleepycat.je.DatabaseException)

Example 8 with DatabaseException

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

the class BdbStorageEngine method getStats.

public DatabaseStats getStats(boolean setFast) {
    try {
        StatsConfig config = new StatsConfig();
        config.setFast(setFast);
        return this.getBdbDatabase().getStats(config);
    } catch (DatabaseException e) {
        this.bdbEnvironmentStats.reportException(e);
        logger.error(e);
        throw new VoldemortException(e);
    }
}
Also used : StatsConfig(com.sleepycat.je.StatsConfig) DatabaseException(com.sleepycat.je.DatabaseException) VoldemortException(voldemort.VoldemortException)

Example 9 with DatabaseException

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

the class BdbStorageEngine method truncate.

@Override
public void truncate() {
    if (isTruncating.compareAndSet(false, true)) {
        Transaction transaction = null;
        boolean succeeded = false;
        try {
            transaction = this.environment.beginTransaction(null, null);
            // close current bdbDatabase first
            bdbDatabase.close();
            // truncate the database
            environment.truncateDatabase(transaction, this.getName(), false);
            succeeded = true;
        } catch (DatabaseException e) {
            this.bdbEnvironmentStats.reportException(e);
            logger.error(e);
            throw new VoldemortException("Failed to truncate Bdb store " + getName(), e);
        } finally {
            commitOrAbort(succeeded, transaction);
            // reopen the bdb database for future queries.
            if (reopenBdbDatabase()) {
                isTruncating.compareAndSet(true, false);
            } else {
                throw new VoldemortException("Failed to reopen Bdb Database after truncation, All request will fail on store " + getName());
            }
        }
    } else {
        throw new VoldemortException("Store " + getName() + " is already truncating, cannot start another one.");
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) DatabaseException(com.sleepycat.je.DatabaseException) VoldemortException(voldemort.VoldemortException)

Example 10 with DatabaseException

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

the class BdbStorageEngine method getAndLock.

@Override
public KeyLockHandle<byte[]> getAndLock(ByteArray key) {
    long startTimeNs = -1;
    if (logger.isTraceEnabled())
        startTimeNs = System.nanoTime();
    StoreUtils.assertValidKey(key);
    DatabaseEntry keyEntry = new DatabaseEntry(key.get());
    DatabaseEntry valueEntry = new DatabaseEntry();
    Transaction transaction = null;
    List<Versioned<byte[]>> vals = null;
    KeyLockHandle<byte[]> handle;
    try {
        transaction = environment.beginTransaction(null, null);
        // do a get for the existing values
        OperationStatus status = getBdbDatabase().get(transaction, keyEntry, valueEntry, LockMode.RMW);
        if (OperationStatus.SUCCESS == status) {
            vals = StoreBinaryFormat.fromByteArray(valueEntry.getData());
        } else {
            vals = new ArrayList<Versioned<byte[]>>(0);
        }
        handle = new KeyLockHandle<byte[]>(vals, transaction);
    } catch (DatabaseException e) {
        this.bdbEnvironmentStats.reportException(e);
        // Unless we return out properly from this method, we need to ensure
        // the transaction handle is closed on exception..
        attemptAbort(transaction);
        logger.error("Error in getAndLock for store " + this.getName(), e);
        throw new PersistenceFailureException(e);
    } finally {
        if (logger.isTraceEnabled()) {
            logger.trace("Completed getAndLock (" + getName() + ") to key " + key + " (keyRef: " + System.identityHashCode(key) + " in " + (System.nanoTime() - startTimeNs) + " ns at " + System.currentTimeMillis());
        }
    }
    return handle;
}
Also used : Transaction(com.sleepycat.je.Transaction) Versioned(voldemort.versioning.Versioned) OperationStatus(com.sleepycat.je.OperationStatus) AsyncOperationStatus(voldemort.server.protocol.admin.AsyncOperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DatabaseException(com.sleepycat.je.DatabaseException) PersistenceFailureException(voldemort.store.PersistenceFailureException)

Aggregations

DatabaseException (com.sleepycat.je.DatabaseException)21 DatabaseEntry (com.sleepycat.je.DatabaseEntry)5 Environment (com.sleepycat.je.Environment)5 OperationStatus (com.sleepycat.je.OperationStatus)5 Transaction (com.sleepycat.je.Transaction)5 VoldemortException (voldemort.VoldemortException)5 AsyncOperationStatus (voldemort.server.protocol.admin.AsyncOperationStatus)5 PersistenceFailureException (voldemort.store.PersistenceFailureException)5 Versioned (voldemort.versioning.Versioned)3 StatsConfig (com.sleepycat.je.StatsConfig)2 PermanentBackendException (com.thinkaurelius.titan.diskstorage.PermanentBackendException)2 WebURL (edu.uci.ics.crawler4j.url.WebURL)2 Bdb (io.leopard.bdb.Bdb)2 File (java.io.File)2 PermanentBackendException (org.janusgraph.diskstorage.PermanentBackendException)2 CheckpointConfig (com.sleepycat.je.CheckpointConfig)1 Database (com.sleepycat.je.Database)1 DatabaseConfig (com.sleepycat.je.DatabaseConfig)1 EnvironmentConfig (com.sleepycat.je.EnvironmentConfig)1 DuplicateEntryException (com.sleepycat.je.tree.DuplicateEntryException)1