Search in sources :

Example 1 with PreparedTransaction

use of org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction in project qpid-broker-j by apache.

the class PreparedTransactionBinding method entryToObject.

public static PreparedTransaction entryToObject(final CachingUUIDFactory uuidFactory, final DatabaseEntry value) {
    TupleInput input = TupleBinding.entryToInput(value);
    Transaction.EnqueueRecord[] enqueues = readEnqueueRecords(uuidFactory, input);
    Transaction.DequeueRecord[] dequeues = readDequeueRecords(uuidFactory, input);
    return new PreparedTransaction(enqueues, dequeues);
}
Also used : PreparedTransaction(org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction) TupleInput(com.sleepycat.bind.tuple.TupleInput) MessageEnqueueRecord(org.apache.qpid.server.store.MessageEnqueueRecord)

Example 2 with PreparedTransaction

use of org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction in project qpid-broker-j by apache.

the class AbstractBDBMessageStore method recordXid.

private List<Runnable> recordXid(Transaction txn, long format, byte[] globalId, byte[] branchId, org.apache.qpid.server.store.Transaction.EnqueueRecord[] enqueues, org.apache.qpid.server.store.Transaction.DequeueRecord[] dequeues) throws StoreException {
    DatabaseEntry key = new DatabaseEntry();
    Xid xid = new Xid(format, globalId, branchId);
    XidBinding keyBinding = XidBinding.getInstance();
    keyBinding.objectToEntry(xid, key);
    DatabaseEntry value = new DatabaseEntry();
    PreparedTransaction preparedTransaction = new PreparedTransaction(enqueues, dequeues);
    PreparedTransactionBinding.objectToEntry(preparedTransaction, value);
    for (org.apache.qpid.server.store.Transaction.EnqueueRecord enqueue : enqueues) {
        StoredMessage storedMessage = enqueue.getMessage().getStoredMessage();
        if (storedMessage instanceof StoredBDBMessage) {
            ((StoredBDBMessage) storedMessage).store(txn);
        }
    }
    try {
        getXidDb().put(txn, key, value);
        return Collections.emptyList();
    } catch (RuntimeException e) {
        if (getLogger().isDebugEnabled()) {
            getLogger().debug("Failed to write xid: {}", e.getMessage(), e);
        }
        throw getEnvironmentFacade().handleDatabaseException("Error writing xid to database", e);
    }
}
Also used : Xid(org.apache.qpid.server.txn.Xid) PreparedTransaction(org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) PreparedTransaction(org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction) Transaction(com.sleepycat.je.Transaction) StoredMessage(org.apache.qpid.server.store.StoredMessage) XidBinding(org.apache.qpid.server.store.berkeleydb.tuple.XidBinding) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Aggregations

PreparedTransaction (org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction)2 TupleInput (com.sleepycat.bind.tuple.TupleInput)1 DatabaseEntry (com.sleepycat.je.DatabaseEntry)1 Transaction (com.sleepycat.je.Transaction)1 MessageEnqueueRecord (org.apache.qpid.server.store.MessageEnqueueRecord)1 StoredMessage (org.apache.qpid.server.store.StoredMessage)1 XidBinding (org.apache.qpid.server.store.berkeleydb.tuple.XidBinding)1 Xid (org.apache.qpid.server.txn.Xid)1 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)1