public ExternalTransaction(Xid xid, TransactionManagerImpl txManager, Set<TransactionBranchInfo> resourceNames) { super(xid, txManager); for (TransactionBranchInfo info: resourceNames) { this.resourceNames.add(info.getResourceName()); } }
private boolean isNameInTransaction(XidBranchesPair xidBranchesPair, String name) { for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next(); if (name.equals(transactionBranchInfo.getResourceName())) { return true; } } return false; }
private boolean isNameInTransaction(XidBranchesPair xidBranchesPair, String name) { for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next(); if (name.equals(transactionBranchInfo.getResourceName())) { return true; } } return false; }
private boolean isNameInTransaction(XidBranchesPair xidBranchesPair, String name) { for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next(); if (name.equals(transactionBranchInfo.getResourceName())) { return true; } } return false; }
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; }
ps.setBytes(3, branchQualifier); ps.setBytes(4, branch.getBranchXid().getBranchQualifier()); ps.setString(5, branch.getResourceName()); ps.execute();
public Object prepare(Xid xid, List branches) throws LogException { int branchCount = branches.size(); byte[][] data = new byte[3 + 2 * branchCount][]; data[0] = intToBytes(xid.getFormatId()); data[1] = xid.getGlobalTransactionId(); data[2] = xid.getBranchQualifier(); int i = 3; for (Iterator iterator = branches.iterator(); iterator.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) iterator.next(); data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier(); data[i++] = transactionBranchInfo.getResourceName().getBytes(); } try { XACommittingTx committingTx = logger.putCommit(data); return committingTx; } catch (LogClosedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogRecordSizeException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogFileOverflowException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (InterruptedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (IOException e) { throw new LogException(e); } }
public Object prepare(Xid xid, List branches) throws LogException { int branchCount = branches.size(); byte[][] data = new byte[3 + 2 * branchCount][]; data[0] = intToBytes(xid.getFormatId()); data[1] = xid.getGlobalTransactionId(); data[2] = xid.getBranchQualifier(); int i = 3; for (Iterator iterator = branches.iterator(); iterator.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) iterator.next(); data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier(); data[i++] = transactionBranchInfo.getResourceName().getBytes(); } try { XACommittingTx committingTx = logger.putCommit(data); return committingTx; } catch (LogClosedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogRecordSizeException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogFileOverflowException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (InterruptedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (IOException e) { throw new LogException(e); } }
public Object prepare(Xid xid, List branches) throws LogException { int branchCount = branches.size(); byte[][] data = new byte[3 + 2 * branchCount][]; data[0] = intToBytes(xid.getFormatId()); data[1] = xid.getGlobalTransactionId(); data[2] = xid.getBranchQualifier(); int i = 3; for (Iterator iterator = branches.iterator(); iterator.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) iterator.next(); data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier(); data[i++] = transactionBranchInfo.getResourceName().getBytes(); } try { XACommittingTx committingTx = logger.putCommit(data); return committingTx; } catch (LogClosedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogRecordSizeException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogFileOverflowException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (InterruptedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (IOException e) { throw new LogException(e); } }
private void removeNameFromTransaction(XidBranchesPair xidBranchesPair, String name, boolean warn) { int removed = 0; for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next(); if (name.equals(transactionBranchInfo.getResourceName())) { branches.remove(); removed++; } } if (warn && removed == 0) { log.error("XAResource named: " + name + " returned branch xid for xid: " + xidBranchesPair.getXid() + " but was not registered with that transaction!"); } if (xidBranchesPair.getBranches().isEmpty() && 0 != removed ) { try { ourXids.remove(new ByteArrayWrapper(xidBranchesPair.getXid().getGlobalTransactionId())); txLog.commit(xidBranchesPair.getXid(), xidBranchesPair.getMark()); } catch (LogException e) { recoveryErrors.add(e); log.error("Could not commit", e); } } }
private void removeNameFromTransaction(XidBranchesPair xidBranchesPair, String name, boolean warn) { int removed = 0; for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next(); if (name.equals(transactionBranchInfo.getResourceName())) { branches.remove(); removed++; } } if (warn && removed == 0) { log.error("XAResource named: " + name + " returned branch xid for xid: " + xidBranchesPair.getXid() + " but was not registered with that transaction!"); } if (xidBranchesPair.getBranches().isEmpty() && 0 != removed ) { try { ourXids.remove(new ByteArrayWrapper(xidBranchesPair.getXid().getGlobalTransactionId())); txLog.commit(xidBranchesPair.getXid(), xidBranchesPair.getMark()); } catch (LogException e) { recoveryErrors.add(e); log.error(e); } } }
private void removeNameFromTransaction(XidBranchesPair xidBranchesPair, String name, boolean warn) { int removed = 0; for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next(); if (name.equals(transactionBranchInfo.getResourceName())) { branches.remove(); removed++; } } if (warn && removed == 0) { log.error("XAResource named: " + name + " returned branch xid for xid: " + xidBranchesPair.getXid() + " but was not registered with that transaction!"); } if (xidBranchesPair.getBranches().isEmpty() && 0 != removed ) { try { ourXids.remove(new ByteArrayWrapper(xidBranchesPair.getXid().getGlobalTransactionId())); txLog.commit(xidBranchesPair.getXid(), xidBranchesPair.getMark()); } catch (LogException e) { recoveryErrors.add(e); log.error("Could not commit", e); } } }
public Object prepare(Xid xid, List<? extends TransactionBranchInfo> branches) throws LogException { int branchCount = branches.size(); byte[][] data = new byte[3 + 2 * branchCount][]; data[0] = intToBytes(xid.getFormatId()); data[1] = xid.getGlobalTransactionId(); data[2] = xid.getBranchQualifier(); int i = 3; for (TransactionBranchInfo transactionBranchInfo : branches) { data[i++] = transactionBranchInfo.getBranchXid().getBranchQualifier(); data[i++] = transactionBranchInfo.getResourceName().getBytes(); } try { XACommittingTx committingTx = logger.putCommit(data); return committingTx; } catch (LogClosedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogRecordSizeException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (LogFileOverflowException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (InterruptedException e) { throw (IllegalStateException) new IllegalStateException().initCause(e); } catch (IOException e) { throw new LogException(e); } }
private void removeNameFromTransaction(XidBranchesPair xidBranchesPair, String name, boolean warn) { int removed = 0; for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { TransactionBranchInfo transactionBranchInfo = (TransactionBranchInfo) branches.next(); if (name.equals(transactionBranchInfo.getResourceName())) { branches.remove(); removed++; } } if (warn && removed == 0) { log.error("XAResource named: " + name + " returned branch xid for xid: " + xidBranchesPair.getXid() + " but was not registered with that transaction!"); } if (xidBranchesPair.getBranches().isEmpty() && 0 != removed ) { try { ourXids.remove(new ByteArrayWrapper(xidBranchesPair.getXid().getGlobalTransactionId())); txManager.getTransactionLog().commit(xidBranchesPair.getXid(), xidBranchesPair.getMark()); } catch (LogException e) { recoveryErrors.add(e); log.error("Could not commit", e); } } }
public synchronized void recoverLog() throws XAException { Collection preparedXids = null; try { preparedXids = txLog.recover(xidFactory); } catch (LogException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } for (Iterator iterator = preparedXids.iterator(); iterator.hasNext();) { XidBranchesPair xidBranchesPair = (Recovery.XidBranchesPair) iterator.next(); Xid xid = xidBranchesPair.getXid(); if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) { ourXids.put(new ByteArrayWrapper(xid.getGlobalTransactionId()), xidBranchesPair); for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { String name = ((TransactionBranchInfo) branches.next()).getResourceName(); Set transactionsForName = (Set)nameToOurTxMap.get(name); if (transactionsForName == null) { transactionsForName = new HashSet(); nameToOurTxMap.put(name, transactionsForName); } transactionsForName.add(xidBranchesPair); } } else { TransactionImpl externalTx = new ExternalTransaction(xid, txLog, xidBranchesPair.getBranches()); externalXids.put(xid, externalTx); externalGlobalIdMap.put(xid.getGlobalTransactionId(), externalTx); } } }
public synchronized void recoverLog() throws XAException { Collection preparedXids = null; try { preparedXids = txLog.recover(xidFactory); } catch (LogException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } for (Iterator iterator = preparedXids.iterator(); iterator.hasNext();) { XidBranchesPair xidBranchesPair = (Recovery.XidBranchesPair) iterator.next(); Xid xid = xidBranchesPair.getXid(); if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) { ourXids.put(new ByteArrayWrapper(xid.getGlobalTransactionId()), xidBranchesPair); for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { String name = ((TransactionBranchInfo) branches.next()).getResourceName(); Set transactionsForName = (Set)nameToOurTxMap.get(name); if (transactionsForName == null) { transactionsForName = new HashSet(); nameToOurTxMap.put(name, transactionsForName); } transactionsForName.add(xidBranchesPair); } } else { TransactionImpl externalTx = new ExternalTransaction(xid, txLog, xidBranchesPair.getBranches()); externalXids.put(xid, externalTx); externalGlobalIdMap.put(xid.getGlobalTransactionId(), externalTx); } } }
public synchronized void recoverLog() throws XAException { Collection preparedXids = null; try { preparedXids = txLog.recover(xidFactory); } catch (LogException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } for (Iterator iterator = preparedXids.iterator(); iterator.hasNext();) { XidBranchesPair xidBranchesPair = (Recovery.XidBranchesPair) iterator.next(); Xid xid = xidBranchesPair.getXid(); if (xidFactory.matchesGlobalId(xid.getGlobalTransactionId())) { ourXids.put(new ByteArrayWrapper(xid.getGlobalTransactionId()), xidBranchesPair); for (Iterator branches = xidBranchesPair.getBranches().iterator(); branches.hasNext();) { String name = ((TransactionBranchInfo) branches.next()).getResourceName(); Set transactionsForName = (Set)nameToOurTxMap.get(name); if (transactionsForName == null) { transactionsForName = new HashSet(); nameToOurTxMap.put(name, transactionsForName); } transactionsForName.add(xidBranchesPair); } } else { TransactionImpl externalTx = new ExternalTransaction(xid, txLog, xidBranchesPair.getBranches()); externalXids.put(xid, externalTx); externalGlobalIdMap.put(xid.getGlobalTransactionId(), externalTx); } } }
public synchronized void recoverLog() throws XAException { Collection<XidBranchesPair> preparedXids; try { preparedXids = txManager.getTransactionLog().recover(txManager.getXidFactory()); } catch (LogException e) { throw (XAException) new XAException(XAException.XAER_RMERR).initCause(e); } for (XidBranchesPair xidBranchesPair : preparedXids) { Xid xid = xidBranchesPair.getXid(); log.trace("read prepared global xid from log: " + toString(xid)); if (txManager.getXidFactory().matchesGlobalId(xid.getGlobalTransactionId())) { ourXids.put(new ByteArrayWrapper(xid.getGlobalTransactionId()), xidBranchesPair); for (TransactionBranchInfo transactionBranchInfo : xidBranchesPair.getBranches()) { log.trace("read branch from log: " + transactionBranchInfo.toString()); String name = transactionBranchInfo.getResourceName(); Set<XidBranchesPair> transactionsForName = nameToOurTxMap.get(name); if (transactionsForName == null) { transactionsForName = new HashSet<XidBranchesPair>(); nameToOurTxMap.put(name, transactionsForName); } transactionsForName.add(xidBranchesPair); } } else { log.trace("read external prepared xid from log: " + toString(xid)); TransactionImpl externalTx = new ExternalTransaction(xid, txManager, xidBranchesPair.getBranches()); externalXids.put(xid, externalTx); externalGlobalIdMap.put(xid.getGlobalTransactionId(), externalTx); } } }
log.info(NLS.MESSAGES.getMessage("tx.log.migrate.xid", xidBranchesPair.getXid())); for (TransactionBranchInfo branchInfo : xidBranchesPair.getBranches()) { log.info(NLS.MESSAGES.getMessage("tx.log.migrate.xid.branch", branchInfo.getBranchXid(), branchInfo.getResourceName()));