Search in sources :

Example 1 with XidBinding

use of org.apache.qpid.server.store.berkeleydb.tuple.XidBinding in project qpid-broker-j by apache.

the class UpgradeFrom5To6Test method getXidKey.

protected DatabaseEntry getXidKey() {
    final DatabaseEntry value = new DatabaseEntry();
    byte[] globalId = { 1 };
    byte[] branchId = { 2 };
    Xid xid = new Xid(1l, globalId, branchId);
    XidBinding xidBinding = XidBinding.getInstance();
    xidBinding.objectToEntry(xid, value);
    return value;
}
Also used : Xid(org.apache.qpid.server.txn.Xid) XidBinding(org.apache.qpid.server.store.berkeleydb.tuple.XidBinding) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 2 with XidBinding

use of org.apache.qpid.server.store.berkeleydb.tuple.XidBinding in project qpid-broker-j by apache.

the class AbstractBDBMessageStore method removeXid.

private void removeXid(Transaction txn, long format, byte[] globalId, byte[] branchId) throws StoreException {
    DatabaseEntry key = new DatabaseEntry();
    Xid xid = new Xid(format, globalId, branchId);
    XidBinding keyBinding = XidBinding.getInstance();
    keyBinding.objectToEntry(xid, key);
    try {
        OperationStatus status = getXidDb().delete(txn, key);
        if (status == OperationStatus.NOTFOUND) {
            throw new StoreException("Unable to find xid");
        } else if (status != OperationStatus.SUCCESS) {
            throw new StoreException("Unable to remove xid");
        }
    } catch (RuntimeException e) {
        if (getLogger().isDebugEnabled()) {
            getLogger().error("Failed to remove xid in transaction {}", e);
        }
        throw getEnvironmentFacade().handleDatabaseException("Error accessing database while removing xid: " + e.getMessage(), e);
    }
}
Also used : Xid(org.apache.qpid.server.txn.Xid) ConnectionScopedRuntimeException(org.apache.qpid.server.util.ConnectionScopedRuntimeException) OperationStatus(com.sleepycat.je.OperationStatus) XidBinding(org.apache.qpid.server.store.berkeleydb.tuple.XidBinding) DatabaseEntry(com.sleepycat.je.DatabaseEntry) StoreException(org.apache.qpid.server.store.StoreException)

Example 3 with XidBinding

use of org.apache.qpid.server.store.berkeleydb.tuple.XidBinding 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

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