private void commit(NamedXAResource xaResource, Xid xid) { doCommitOrRollback(xaResource, xid, true); }
Xid xid = prepared[i]; if (xid.getGlobalTransactionId() == null || xid.getBranchQualifier() == null) { log.warn("Ignoring bad xid from\n name: " + xaResource.getName() + "\n " + toString(xid)); continue; log.trace("Considering recovered xid from\n name: " + xaResource.getName() + "\n " + toString(xid)); ByteArrayWrapper globalIdWrapper = new ByteArrayWrapper(xid.getGlobalTransactionId()); XidBranchesPair xidNamesPair = ourXids.get(globalIdWrapper); if (isNameInTransaction(xidNamesPair, name, xid)) { log.trace("This xid was prepared from this XAResource: committing"); commit(xaResource, xid); removeNameFromTransaction(xidNamesPair, name, true); } else { log.trace("This xid was prepared from another XAResource, ignoring"); rollback(xaResource, xid); } else if (txManager.getXidFactory().matchesBranchId(xid.getBranchQualifier())) { rollback(xaResource, xid); } else { log.trace("this xid is from an external transaction and was prepared in this tm. Waiting for instructions from transaction originator"); if (transactionsForName != null) { for (XidBranchesPair xidBranchesPair : transactionsForName) { removeNameFromTransaction(xidBranchesPair, name, false);
if (isNameInTransaction(xidNamesPair, name)) { try { xaResource.commit(xid, false); log.error("Recovery error", e); removeNameFromTransaction(xidNamesPair, name, true); for (Iterator transactions = transactionsForName.iterator(); transactions.hasNext();) { XidBranchesPair xidBranchesPair = (XidBranchesPair) transactions.next(); removeNameFromTransaction(xidBranchesPair, name, false);
public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException { if (defaultTransactionTimeoutSeconds <= 0) { throw new IllegalArgumentException("defaultTransactionTimeoutSeconds must be positive: attempted value: " + defaultTransactionTimeoutSeconds); } this.defaultTransactionTimeoutMilliseconds = defaultTransactionTimeoutSeconds * 1000; if (transactionLog == null) { this.transactionLog = new UnrecoverableLog(); } else { this.transactionLog = transactionLog; } if (xidFactory != null) { this.xidFactory = xidFactory; } else { this.xidFactory = new XidFactoryImpl(DEFAULT_TM_ID); } recovery = new RecoveryImpl(this); recovery.recoverLog(); }
private boolean isNameInTransaction(XidBranchesPair xidBranchesPair, String name, Xid xid) { for (TransactionBranchInfo transactionBranchInfo : xidBranchesPair.getBranches()) { if (name.equals(transactionBranchInfo.getResourceName()) && equals(xid, transactionBranchInfo.getBranchXid())) { return true; } } return false; }
if (isNameInTransaction(xidNamesPair, name)) { try { xaResource.commit(xid, false); log.error("Recovery error", e); removeNameFromTransaction(xidNamesPair, name, true); for (Iterator transactions = transactionsForName.iterator(); transactions.hasNext();) { XidBranchesPair xidBranchesPair = (XidBranchesPair) transactions.next(); removeNameFromTransaction(xidBranchesPair, name, false);
public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException { if (defaultTransactionTimeoutSeconds <= 0) { throw new IllegalArgumentException("defaultTransactionTimeoutSeconds must be positive: attempted value: " + defaultTransactionTimeoutSeconds); } this.defaultTransactionTimeoutMilliseconds = defaultTransactionTimeoutSeconds * 1000; if (transactionLog == null) { this.transactionLog = new UnrecoverableLog(); } else { this.transactionLog = transactionLog; } if (xidFactory != null) { this.xidFactory = xidFactory; } else { this.xidFactory = new XidFactoryImpl(DEFAULT_TM_ID); } recovery = new RecoveryImpl(this.transactionLog, this.xidFactory); recovery.recoverLog(); }
if (isNameInTransaction(xidNamesPair, name)) { try { xaResource.commit(xid, false); log.error(e); removeNameFromTransaction(xidNamesPair, name, true); for (Iterator transactions = transactionsForName.iterator(); transactions.hasNext();) { XidBranchesPair xidBranchesPair = (XidBranchesPair) transactions.next(); removeNameFromTransaction(xidBranchesPair, name, false);
public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException { if (defaultTransactionTimeoutSeconds <= 0) { throw new IllegalArgumentException("defaultTransactionTimeoutSeconds must be positive: attempted value: " + defaultTransactionTimeoutSeconds); } this.defaultTransactionTimeoutMilliseconds = defaultTransactionTimeoutSeconds * 1000; if (transactionLog == null) { this.transactionLog = new UnrecoverableLog(); } else { this.transactionLog = transactionLog; } if (xidFactory != null) { this.xidFactory = xidFactory; } else { this.xidFactory = new XidFactoryImpl(DEFAULT_TM_ID); } recovery = new RecoveryImpl(this.transactionLog, this.xidFactory); recovery.recoverLog(); }
private void rollback(NamedXAResource xaResource, Xid xid) { doCommitOrRollback(xaResource, xid, false); }
public TransactionManagerImpl(int defaultTransactionTimeoutSeconds, XidFactory xidFactory, TransactionLog transactionLog) throws XAException { if (defaultTransactionTimeoutSeconds <= 0) { throw new IllegalArgumentException("defaultTransactionTimeoutSeconds must be positive: attempted value: " + defaultTransactionTimeoutSeconds); } this.defaultTransactionTimeoutMilliseconds = defaultTransactionTimeoutSeconds * 1000; if (transactionLog == null) { this.transactionLog = new UnrecoverableLog(); } else { this.transactionLog = transactionLog; } if (xidFactory != null) { this.xidFactory = xidFactory; } else { this.xidFactory = new XidFactoryImpl(DEFAULT_TM_ID); } recovery = new RecoveryImpl(this.transactionLog, this.xidFactory); recovery.recoverLog(); }