Search in sources :

Example 16 with DatabaseException

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

the class BdbStorageEngine method get.

@Override
public List<Versioned<byte[]>> get(ByteArray key, byte[] transforms) throws PersistenceFailureException {
    StoreUtils.assertValidKey(key);
    DatabaseEntry keyEntry = new DatabaseEntry(key.get());
    DatabaseEntry valueEntry = new DatabaseEntry();
    long startTimeNs = -1;
    if (logger.isTraceEnabled())
        startTimeNs = System.nanoTime();
    try {
        // uncommitted reads are perfectly fine now, since we have no
        // je-delete() in put()
        OperationStatus status = getBdbDatabase().get(null, keyEntry, valueEntry, readLockMode);
        if (OperationStatus.SUCCESS == status) {
            return StoreBinaryFormat.fromByteArray(valueEntry.getData());
        } else {
            return Collections.emptyList();
        }
    } catch (DatabaseException e) {
        this.bdbEnvironmentStats.reportException(e);
        logger.error(e);
        throw new PersistenceFailureException(e);
    } finally {
        if (logger.isTraceEnabled()) {
            logger.trace("Completed GET (" + getName() + ") from key " + key + " (keyRef: " + System.identityHashCode(key) + ") in " + (System.nanoTime() - startTimeNs) + " ns at " + System.currentTimeMillis());
        }
    }
}
Also used : 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)

Example 17 with DatabaseException

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

the class BdbStorageEngine method putAndUnlock.

@Override
public void putAndUnlock(ByteArray key, KeyLockHandle<byte[]> handle) {
    long startTimeNs = -1;
    if (logger.isTraceEnabled())
        startTimeNs = System.nanoTime();
    StoreUtils.assertValidKey(key);
    DatabaseEntry keyEntry = new DatabaseEntry(key.get());
    DatabaseEntry valueEntry = new DatabaseEntry();
    boolean succeeded = false;
    Transaction transaction = null;
    try {
        transaction = (Transaction) handle.getKeyLock();
        valueEntry.setData(StoreBinaryFormat.toByteArray(handle.getValues()));
        OperationStatus status = getBdbDatabase().put(transaction, keyEntry, valueEntry);
        if (status != OperationStatus.SUCCESS)
            throw new PersistenceFailureException("putAndUnlock operation failed with status: " + status);
        succeeded = true;
    } catch (DatabaseException e) {
        this.bdbEnvironmentStats.reportException(e);
        logger.error("Error in putAndUnlock for store " + this.getName(), e);
        throw new PersistenceFailureException(e);
    } finally {
        if (succeeded)
            attemptCommit(transaction);
        else
            attemptAbort(transaction);
        if (logger.isTraceEnabled()) {
            logger.trace("Completed PUTANDUNLOCK (" + getName() + ") to key " + key + " (keyRef: " + System.identityHashCode(key) + " in " + (System.nanoTime() - startTimeNs) + " ns at " + System.currentTimeMillis());
        }
        handle.close();
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus) AsyncOperationStatus(voldemort.server.protocol.admin.AsyncOperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) PersistenceFailureException(voldemort.store.PersistenceFailureException) DatabaseException(com.sleepycat.je.DatabaseException)

Example 18 with DatabaseException

use of com.sleepycat.je.DatabaseException in project sessdb by ppdai.

the class BdbBenchmark method open.

@Override
public void open() {
    try {
        EnvironmentConfig envConfig = new EnvironmentConfig();
        envConfig.setAllowCreate(true);
        envConfig.setCachePercent(90);
        File file = new File(databaseDir_);
        if (!file.exists()) {
            file.mkdirs();
        }
        env_ = new Environment(file, envConfig);
        DatabaseConfig dbConfig = new DatabaseConfig();
        dbConfig.setAllowCreate(true);
        bdb_ = env_.openDatabase(null, BdbBenchmark.DATABASE_NAME, dbConfig);
    } catch (DatabaseException e) {
        e.printStackTrace();
    }
}
Also used : EnvironmentConfig(com.sleepycat.je.EnvironmentConfig) Environment(com.sleepycat.je.Environment) File(java.io.File) DatabaseException(com.sleepycat.je.DatabaseException) DatabaseConfig(com.sleepycat.je.DatabaseConfig)

Example 19 with DatabaseException

use of com.sleepycat.je.DatabaseException in project leopard by tanhaichao.

the class IdTransverterBdbImpl method transform.

@Override
public String transform(String tableName, String id) {
    try {
        Bdb database = bdb.getDatabase(tableName);
        // System.err.println("getString tableName:" + tableName + " id:" + id + " count:" + bdb.count());
        String newId = database.getString(id);
        return newId;
    } catch (DatabaseException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : Bdb(io.leopard.bdb.Bdb) DatabaseException(com.sleepycat.je.DatabaseException)

Example 20 with DatabaseException

use of com.sleepycat.je.DatabaseException in project leopard by tanhaichao.

the class IdTransverterBdbImpl method add.

@Override
public boolean add(String tableName, String id, String newId) {
    try {
        Bdb database = bdb.getDatabase(tableName);
        System.err.println("add tableName:" + tableName + " id:" + id);
        return database.putNoDupData(id, newId);
    } catch (DuplicateEntryException e) {
        logger.warn(e.getMessage());
        return false;
    } catch (DatabaseException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
}
Also used : Bdb(io.leopard.bdb.Bdb) DuplicateEntryException(com.sleepycat.je.tree.DuplicateEntryException) DatabaseException(com.sleepycat.je.DatabaseException)

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