Search in sources :

Example 46 with OperationStatus

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

the class BdbRevertPidScanToNewDup method transfer.

@Override
public void transfer() throws Exception {
    cursor = srcDB.openCursor(null, null);
    DatabaseEntry keyEntry = new DatabaseEntry();
    DatabaseEntry valueEntry = new DatabaseEntry();
    List<Versioned<byte[]>> vals;
    long startTime = System.currentTimeMillis();
    int scanCount = 0;
    int keyCount = 0;
    while (cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
        keyCount++;
        vals = StoreBinaryFormat.fromByteArray(valueEntry.getData());
        scanCount += vals.size();
        // pull out the real key
        byte[] stripedKey = StoreBinaryFormat.extractKey(keyEntry.getData());
        OperationStatus putStatus = dstDB.put(null, new DatabaseEntry(stripedKey), valueEntry);
        if (OperationStatus.SUCCESS != putStatus) {
            String errorStr = "Put failed with " + putStatus + " for key" + BdbConvertData.writeAsciiString(keyEntry.getData());
            logger.error(errorStr);
            throw new Exception(errorStr);
        }
        if (scanCount % 1000000 == 0)
            logger.info("Reverted " + scanCount + " entries in " + (System.currentTimeMillis() - startTime) / 1000 + " secs");
    }
    logger.info("Reverted " + scanCount + " entries and " + keyCount + " keys in " + (System.currentTimeMillis() - startTime) / 1000 + " secs");
}
Also used : Versioned(voldemort.versioning.Versioned) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 47 with OperationStatus

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

the class JEObjectDatabase method lookUpInternal.

@Override
protected List<ObjectId> lookUpInternal(final byte[] partialId) {
    checkOpen();
    DatabaseEntry key;
    {
        byte[] keyData = partialId.clone();
        key = new DatabaseEntry(keyData);
    }
    DatabaseEntry data = new DatabaseEntry();
    // do not retrieve data
    data.setPartial(0, 0, true);
    List<ObjectId> matches;
    CursorConfig cursorConfig = new CursorConfig();
    cursorConfig.setReadUncommitted(true);
    Transaction transaction = null;
    Cursor cursor = objectDb.openCursor(transaction, cursorConfig);
    try {
        // position cursor at the first closest key to the one looked up
        OperationStatus status = cursor.getSearchKeyRange(key, data, LockMode.READ_UNCOMMITTED);
        if (SUCCESS.equals(status)) {
            matches = new ArrayList<ObjectId>(2);
            final byte[] compKey = new byte[partialId.length];
            while (SUCCESS.equals(status)) {
                byte[] keyData = key.getData();
                System.arraycopy(keyData, 0, compKey, 0, compKey.length);
                if (Arrays.equals(partialId, compKey)) {
                    matches.add(new ObjectId(keyData));
                } else {
                    break;
                }
                status = cursor.getNext(key, data, LockMode.READ_UNCOMMITTED);
            }
        } else {
            matches = Collections.emptyList();
        }
        return matches;
    } finally {
        cursor.close();
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) ObjectId(org.locationtech.geogig.api.ObjectId) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) CursorConfig(com.sleepycat.je.CursorConfig) Cursor(com.sleepycat.je.Cursor)

Example 48 with OperationStatus

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

the class JEObjectDatabase method delete.

@Override
public boolean delete(final ObjectId id) {
    checkWritable();
    final byte[] rawKey = id.getRawValue();
    final DatabaseEntry key = new DatabaseEntry(rawKey);
    final Transaction transaction = newTransaction();
    final OperationStatus status;
    try {
        status = objectDb.delete(transaction, key);
        commit(transaction);
    } catch (RuntimeException e) {
        abort(transaction);
        throw e;
    }
    return SUCCESS.equals(status);
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 49 with OperationStatus

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

the class JEObjectDatabase method putInternal.

@Override
protected boolean putInternal(final ObjectId id, final byte[] rawData) {
    checkWritable();
    final Transaction transaction = newTransaction();
    final OperationStatus status;
    try {
        status = putInternal(id, rawData, transaction);
        commit(transaction);
    } catch (RuntimeException e) {
        abort(transaction);
        throw e;
    }
    final boolean didntExist = SUCCESS.equals(status);
    return didntExist;
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus)

Example 50 with OperationStatus

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

the class BerkeleyStorage method exists.

@Override
public boolean exists() throws SirixIOException {
    final DatabaseEntry valueEntry = new DatabaseEntry();
    final DatabaseEntry keyEntry = new DatabaseEntry();
    boolean returnVal = false;
    try {
        final Reader reader = new BerkeleyReader(mEnv, mDatabase, mByteHandler);
        TupleBinding.getPrimitiveBinding(Long.class).objectToEntry(-1l, keyEntry);
        final OperationStatus status = mDatabase.get(null, keyEntry, valueEntry, LockMode.DEFAULT);
        if (status == OperationStatus.SUCCESS) {
            returnVal = true;
        }
        reader.close();
    } catch (final DatabaseException exc) {
        throw new SirixIOException(exc);
    }
    return returnVal;
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) Reader(org.sirix.io.Reader) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DatabaseException(com.sleepycat.je.DatabaseException) SirixIOException(org.sirix.exception.SirixIOException)

Aggregations

OperationStatus (com.sleepycat.je.OperationStatus)76 DatabaseEntry (com.sleepycat.je.DatabaseEntry)70 Transaction (com.sleepycat.je.Transaction)23 DatabaseException (com.sleepycat.je.DatabaseException)21 Cursor (com.sleepycat.je.Cursor)15 StoreException (org.apache.qpid.server.store.StoreException)13 Versioned (voldemort.versioning.Versioned)9 Database (com.sleepycat.je.Database)8 ArrayList (java.util.ArrayList)7 LockConflictException (com.sleepycat.je.LockConflictException)6 UUIDTupleBinding (org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding)6 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)6 UUID (java.util.UUID)4 BimserverLockConflictException (org.bimserver.database.BimserverLockConflictException)4 SirixIOException (org.sirix.exception.SirixIOException)4 AsyncOperationStatus (voldemort.server.protocol.admin.AsyncOperationStatus)4 PersistenceFailureException (voldemort.store.PersistenceFailureException)4 DatabaseConfig (com.sleepycat.je.DatabaseConfig)3 LockMode (com.sleepycat.je.LockMode)3 VSystemException (io.vertigo.lang.VSystemException)3