Search in sources :

Example 66 with OperationStatus

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

the class AbstractBDBMessageStore method getAllContent.

QpidByteBuffer getAllContent(long messageId) throws StoreException {
    DatabaseEntry contentKeyEntry = new DatabaseEntry();
    LongBinding.longToEntry(messageId, contentKeyEntry);
    DatabaseEntry value = new DatabaseEntry();
    getLogger().debug("Message Id: {} Getting content body", messageId);
    try {
        OperationStatus status = getMessageContentDb().get(null, contentKeyEntry, value, LockMode.READ_UNCOMMITTED);
        if (status == OperationStatus.SUCCESS) {
            byte[] data = value.getData();
            int offset = value.getOffset();
            int length = value.getSize();
            QpidByteBuffer buf = QpidByteBuffer.allocateDirect(length);
            buf.put(data, offset, length);
            buf.flip();
            return buf;
        } else {
            throw new StoreException("Unable to find message with id " + messageId);
        }
    } catch (RuntimeException e) {
        throw getEnvironmentFacade().handleDatabaseException("Error getting AMQMessage with id " + messageId + " to database: " + e.getMessage(), e);
    }
}
Also used : ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) OperationStatus(com.sleepycat.je.OperationStatus) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer) DatabaseEntry(com.sleepycat.je.DatabaseEntry) StoreException(org.apache.qpid.server.store.StoreException)

Example 67 with OperationStatus

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

the class BDBConfigurationStore method update.

private void update(boolean createIfNecessary, ConfiguredObjectRecord record, com.sleepycat.je.Transaction txn) throws StoreException {
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Updating, creating " + createIfNecessary + " : " + record);
    }
    DatabaseEntry key = new DatabaseEntry();
    UUIDTupleBinding keyBinding = UUIDTupleBinding.getInstance();
    keyBinding.objectToEntry(record.getId(), key);
    DatabaseEntry value = new DatabaseEntry();
    DatabaseEntry newValue = new DatabaseEntry();
    ConfiguredObjectBinding configuredObjectBinding = ConfiguredObjectBinding.getInstance();
    OperationStatus status = getConfiguredObjectsDb().get(txn, key, value, LockMode.DEFAULT);
    final boolean isNewRecord = status == OperationStatus.NOTFOUND;
    if (status == OperationStatus.SUCCESS || (createIfNecessary && isNewRecord)) {
        // write the updated entry to the store
        configuredObjectBinding.objectToEntry(record, newValue);
        status = getConfiguredObjectsDb().put(txn, key, newValue);
        if (status != OperationStatus.SUCCESS) {
            throw new StoreException("Error updating configuration details within the store: " + status);
        }
        if (isNewRecord) {
            writeHierarchyRecords(txn, record);
        }
    } else if (status != OperationStatus.NOTFOUND) {
        throw new StoreException("Error finding configuration details within the store: " + status);
    }
}
Also used : ConfiguredObjectBinding(org.apache.qpid.server.store.berkeleydb.tuple.ConfiguredObjectBinding) OperationStatus(com.sleepycat.je.OperationStatus) UUIDTupleBinding(org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding) DatabaseEntry(com.sleepycat.je.DatabaseEntry) StoreException(org.apache.qpid.server.store.StoreException)

Example 68 with OperationStatus

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

the class BDBConfigurationStore method removeConfiguredObject.

private OperationStatus removeConfiguredObject(Transaction tx, ConfiguredObjectRecord record) throws StoreException {
    UUID id = record.getId();
    Map<String, UUID> parents = record.getParents();
    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Removing configured object: " + id);
    }
    DatabaseEntry key = new DatabaseEntry();
    UUIDTupleBinding uuidBinding = UUIDTupleBinding.getInstance();
    uuidBinding.objectToEntry(id, key);
    OperationStatus status = getConfiguredObjectsDb().delete(tx, key);
    if (status == OperationStatus.SUCCESS) {
        for (String parentType : parents.keySet()) {
            DatabaseEntry hierarchyKey = new DatabaseEntry();
            HierarchyKeyBinding keyBinding = HierarchyKeyBinding.getInstance();
            keyBinding.objectToEntry(new HierarchyKey(record.getId(), parentType), hierarchyKey);
            getConfiguredObjectHierarchyDb().delete(tx, hierarchyKey);
        }
    }
    return status;
}
Also used : HierarchyKeyBinding(org.apache.qpid.server.store.berkeleydb.tuple.HierarchyKeyBinding) OperationStatus(com.sleepycat.je.OperationStatus) UUIDTupleBinding(org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding) HierarchyKey(org.apache.qpid.server.store.berkeleydb.entry.HierarchyKey) DatabaseEntry(com.sleepycat.je.DatabaseEntry) UUID(java.util.UUID)

Example 69 with OperationStatus

use of com.sleepycat.je.OperationStatus in project bboxdb by jnidzwetzki.

the class FileLineIndex method locateLine.

/**
 * Get the content of the line
 * @param lineNumber
 * @return
 */
public long locateLine(final long line) {
    if (database == null) {
        throw new IllegalArgumentException("No database is open, please index file first");
    }
    if (line >= indexedLines) {
        throw new IllegalArgumentException("Line " + line + " is higher then indexedLines: " + (indexedLines - 1));
    }
    final DatabaseEntry key = buildDatabaseEntry(line);
    final DatabaseEntry value = new DatabaseEntry();
    final OperationStatus result = database.get(null, key, value, LockMode.DEFAULT);
    if (result != OperationStatus.SUCCESS) {
        throw new RuntimeException("Data fetch got status " + result + " for " + line);
    }
    final long bytePos = DataEncoderHelper.readLongFromByte(value.getData());
    return bytePos;
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 70 with OperationStatus

use of com.sleepycat.je.OperationStatus in project bboxdb by jnidzwetzki.

the class FileLineIndex method registerLine.

/**
 * Register a new line in the index file
 * @param line
 * @param pos
 */
protected void registerLine(final long line, final long bytePos) {
    final DatabaseEntry key = buildDatabaseEntry(line);
    final DatabaseEntry value = buildDatabaseEntry(bytePos);
    final OperationStatus status = database.put(null, key, value);
    if (status != OperationStatus.SUCCESS) {
        throw new RuntimeException("Data insertion, got status " + status);
    }
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

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