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;
}
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);
}
}
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);
}
}
Aggregations