public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { connection.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (SQLException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { connection.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (SQLException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
@Override public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) { log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { connection.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (SQLException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
@Override public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) { log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { connection.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (SQLException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
public void rollback(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to rollback, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot roll it back on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { this.state = NO_TX; throw new BitronixXAException("resource committed during prepare on XID " + this.xid, XAException.XA_HEURCOM); } try { session.rollback(); } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } finally { this.state = NO_TX; this.xid = null; } }
public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { session.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
@Override public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) { log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { session.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { session.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
@Override public int prepare(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) { log.debug("OK to prepare, old state=" + xlatedState() + ", XID=" + xid); } } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot prepare it on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { throw new BitronixXAException("resource already prepared on XID " + this.xid, XAException.XAER_PROTO); } try { session.commit(); this.state = PREPARED; return XAResource.XA_OK; } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } }
@Override public void rollback(Xid xid) throws XAException { if (xid == null) throw new BitronixXAException("XID cannot be null", XAException.XAER_INVAL); if (state == NO_TX) { throw new BitronixXAException("resource never started on XID " + xid, XAException.XAER_PROTO); } else if (state == STARTED) { throw new BitronixXAException("resource never ended on XID " + xid, XAException.XAER_PROTO); } else if (state == ENDED) { if (this.xid.equals(xid)) { if (log.isDebugEnabled()) { log.debug("OK to rollback, old state=" + xlatedState() + ", XID=" + xid); } } else throw new BitronixXAException("resource already started on XID " + this.xid + " - cannot roll it back on another XID " + xid, XAException.XAER_PROTO); } else if (state == PREPARED) { this.state = NO_TX; throw new BitronixXAException("resource committed during prepare on XID " + this.xid, XAException.XA_HEURCOM); } try { session.rollback(); } catch (JMSException ex) { throw new BitronixXAException("error preparing non-XA resource", XAException.XAER_RMERR, ex); } finally { this.state = NO_TX; this.xid = null; } }
/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) { log.debug("resuming " + xaResourceHolderState); } // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) { log.debug("re-enlisting resource " + xaResourceHolderState); } try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) log.debug("resuming " + xaResourceHolderState); // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) log.debug("re-enlisting resource " + xaResourceHolderState); try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) { log.debug("resuming " + xaResourceHolderState); } // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) { log.debug("re-enlisting resource " + xaResourceHolderState); } try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
/** * Resume all enlisted resources in the current transaction context. * @throws XAException if the resource threw an exception during resume. */ public void resume() throws XAException { // all XAResource needs to be re-enlisted but this must happen // outside the Scheduler's iteration as enlist() can change the // collection's content and confuse the iterator. List<XAResourceHolderState> toBeReEnlisted = new ArrayList<XAResourceHolderState>(); for (XAResourceHolderState xaResourceHolderState : resources) { if (log.isDebugEnabled()) log.debug("resuming " + xaResourceHolderState); // If a prepared statement is (re-)used after suspend/resume is performed its XAResource needs to be // re-enlisted. This must be done outside this loop or that will confuse the iterator! toBeReEnlisted.add(new XAResourceHolderState(xaResourceHolderState)); } if (toBeReEnlisted.size() > 0 && log.isDebugEnabled()) log.debug("re-enlisting " + toBeReEnlisted.size() + " resource(s)"); for (XAResourceHolderState xaResourceHolderState : toBeReEnlisted) { if (log.isDebugEnabled()) log.debug("re-enlisting resource " + xaResourceHolderState); try { enlist(xaResourceHolderState); xaResourceHolderState.getXAResourceHolder().putXAResourceHolderState(xaResourceHolderState.getXid(), xaResourceHolderState); } catch (BitronixSystemException ex) { throw new BitronixXAException("error re-enlisting resource during resume: " + xaResourceHolderState, XAException.XAER_RMERR, ex); } } }
throw new BitronixXAException("unknown heuristic termination, global state of this transaction is unknown - guilty: " + failedResourceHolder, XAException.XA_HEURHAZ, xaException);
throw new BitronixXAException("unknown heuristic termination, global state of this transaction is unknown - guilty: " + failedResourceHolder, XAException.XA_HEURHAZ, xaException);
public void forget(Xid xid) throws XAException { getEventRecorder().addEvent(new XAResourceForgetEvent(this, xid)); boolean found = xads.removeInDoubtXid(xid); if (!found) throw new BitronixXAException("unknown XID: " + xid, XAException.XAER_INVAL); }
public void forget(Xid xid) throws XAException { getEventRecorder().addEvent(new XAResourceForgetEvent(this, xid)); boolean found = xads.removeInDoubtXid(xid); if (!found) throw new BitronixXAException("unknown XID: " + xid, XAException.XAER_INVAL); }
public void testExtract() throws Exception { DefaultExceptionAnalyzer analyzer = new DefaultExceptionAnalyzer(); assertNull(analyzer.extractExtraXAExceptionDetails(new BitronixXAException("XA error", XAException.XA_HEURCOM))); assertEquals("ORA-1234", analyzer.extractExtraXAExceptionDetails(new OracleXAException(1234))); } }
public void testExtract() throws Exception { DefaultExceptionAnalyzer analyzer = new DefaultExceptionAnalyzer(); assertNull(analyzer.extractExtraXAExceptionDetails(new BitronixXAException("XA error", XAException.XA_HEURCOM))); assertEquals("ORA-1234", analyzer.extractExtraXAExceptionDetails(new OracleXAException(1234))); } }