public int prepare(Xid xid) throws XAException { System.out.println("**prepare " + xid); xids.add(xid); xarm.periodicWorkFirstPass(); return XAResource.XA_OK; }
/** * @param xid The transaction to commit/rollback. * * @return the XAResource than can be used to commit/rollback the specified * transaction. */ private XAResource getNewXAResource(Xid xid) { // JBTM-1354 JCA needs to be able to recover XAResources associated with a subordinate transaction so we have to do at least // the start scan to make sure that we have loaded all the XAResources we possibly can to assist subordinate transactions recovering // the reason we can't do bottom up recovery is if this server has an XAResource which tries to recover a remote server (e.g. distributed JTA) // then we get deadlock on the secondpass periodicWorkFirstPass(); if (_xidScans != null) { Enumeration<XAResource> keys = _xidScans.keys(); while (keys.hasMoreElements()) { XAResource theKey = keys.nextElement(); RecoveryXids xids = _xidScans.get(theKey); // JBTM-1255 moved stale check back to bottomUpRecovery if (xids.contains(xid)) { // This Xid is going to be recovered by the AtomicAction xids.remove(xid); return theKey; } } } return null; }
/** * @param xid The transaction to commit/rollback. * * @return the XAResource than can be used to commit/rollback the specified * transaction. */ private XAResource getNewXAResource(Xid xid) { XAResource toReturn = getTheKey(xid); if (toReturn == null) { synchronized (this) { /* * run an xid scan with the lock held to avoid _xidScans being changed * after the call to periodicWorkFirstPass but before the call to getTheKey */ periodicWorkFirstPass(ScanStates.IDLE); toReturn = getTheKey(xid); } } return toReturn; }
/** * @param xid The transaction to commit/rollback. * * @return the XAResource than can be used to commit/rollback the specified * transaction. */ private XAResource getNewXAResource(Xid xid) { XAResource toReturn = getTheKey(xid); if (toReturn == null) { synchronized (this) { /* * run an xid scan with the lock held to avoid _xidScans being changed * after the call to periodicWorkFirstPass but before the call to getTheKey */ periodicWorkFirstPass(ScanStates.IDLE); toReturn = getTheKey(xid); } } return toReturn; }
/** * @param xid The transaction to commit/rollback. * * @return the XAResource than can be used to commit/rollback the specified * transaction. */ private XAResource getNewXAResource(Xid xid) { XAResource toReturn = getTheKey(xid); if (toReturn == null) { synchronized (this) { /* * run an xid scan with the lock held to avoid _xidScans being changed * after the call to periodicWorkFirstPass but before the call to getTheKey */ periodicWorkFirstPass(ScanStates.IDLE); toReturn = getTheKey(xid); } } return toReturn; }
/** * @param xid The transaction to commit/rollback. * * @return the XAResource than can be used to commit/rollback the specified * transaction. */ private XAResource getNewXAResource(Xid xid) { XAResource toReturn = getTheKey(xid); if (toReturn == null) { synchronized (this) { /* * run an xid scan with the lock held to avoid _xidScans being changed * after the call to periodicWorkFirstPass but before the call to getTheKey */ periodicWorkFirstPass(ScanStates.IDLE); toReturn = getTheKey(xid); } } return toReturn; }
public void run() { xaRecoveryModule.periodicWorkFirstPass(); try { Thread.sleep(100); } catch (InterruptedException e) { } xaRecoveryModule.periodicWorkSecondPass(); } }.start();
_recoveryStarted = true; if (XARecoveryModule.getRegisteredXARecoveryModule() != null) { XARecoveryModule.getRegisteredXARecoveryModule().periodicWorkFirstPass();
@Test public void testNull () { XARecoveryModule xarm = new XARecoveryModule(); xarm.periodicWorkFirstPass(); xarm.periodicWorkSecondPass(); assertNotNull(xarm.id()); }
xarm.periodicWorkFirstPass(); assertEquals(recoverCalled, 1); xarm.periodicWorkSecondPass(); assertEquals(recoverCalled, 2); xarm.periodicWorkFirstPass(); assertEquals(recoverCalled, 3); xarm.periodicWorkFirstPass(); assertEquals(recoverCalled, 5); xarm.periodicWorkSecondPass();
private synchronized void periodicWorkFirstPass(ScanStates endState) { // JBTM-1354 JCA needs to be able to recover XAResources associated with a subordinate transaction so we have to do at least // the start scan to make sure that we have loaded all the XAResources we possibly can to assist subordinate transactions recovering // the reason we can't do bottom up recovery is if this server has an XAResource which tries to recover a remote server (e.g. distributed JTA) // then we get deadlock on the secondpass if (getScanState() == ScanStates.BETWEEN_PASSES) { periodicWorkSecondPass(); endState = ScanStates.BETWEEN_PASSES; // Ensure if originally we are between periodic recovery scans we continue in that state and leave XAResource in STARTRSCAN } setScanState(ScanStates.FIRST_PASS); // synchronized uses a reentrant lock if(jtaLogger.logger.isDebugEnabled()) { jtaLogger.logger.debugv("{0} - first pass", _logName); } contactedJndiNames.clear(); jtaLogger.setRecoveryProblems(false); _uids = new InputObjectState(); /* * Scan for resources in the object store. */ try { if (!_recoveryStore.allObjUids(_recoveryManagerClass.type(), _uids)) {
private synchronized void periodicWorkFirstPass(ScanStates endState) { // JBTM-1354 JCA needs to be able to recover XAResources associated with a subordinate transaction so we have to do at least // the start scan to make sure that we have loaded all the XAResources we possibly can to assist subordinate transactions recovering // the reason we can't do bottom up recovery is if this server has an XAResource which tries to recover a remote server (e.g. distributed JTA) // then we get deadlock on the secondpass if (getScanState() == ScanStates.BETWEEN_PASSES) { periodicWorkSecondPass(); endState = ScanStates.BETWEEN_PASSES; // Ensure if originally we are between periodic recovery scans we continue in that state and leave XAResource in STARTRSCAN } setScanState(ScanStates.FIRST_PASS); // synchronized uses a reentrant lock if(jtaLogger.logger.isDebugEnabled()) { jtaLogger.logger.debugv("{0} - first pass", _logName); } contactedJndiNames.clear(); jtaLogger.setRecoveryProblems(false); _uids = new InputObjectState(); /* * Scan for resources in the object store. */ try { if (!_recoveryStore.allObjUids(_recoveryManagerClass.type(), _uids)) {
_recoveryStarted = true; if (XARecoveryModule.getRegisteredXARecoveryModule() != null) { XARecoveryModule.getRegisteredXARecoveryModule().periodicWorkFirstPass();
private synchronized void periodicWorkFirstPass(ScanStates endState) { // JBTM-1354 JCA needs to be able to recover XAResources associated with a subordinate transaction so we have to do at least // the start scan to make sure that we have loaded all the XAResources we possibly can to assist subordinate transactions recovering // the reason we can't do bottom up recovery is if this server has an XAResource which tries to recover a remote server (e.g. distributed JTA) // then we get deadlock on the secondpass if (getScanState() == ScanStates.BETWEEN_PASSES) { periodicWorkSecondPass(); endState = ScanStates.BETWEEN_PASSES; // Ensure if originally we are between periodic recovery scans we continue in that state and leave XAResource in STARTRSCAN } setScanState(ScanStates.FIRST_PASS); // synchronized uses a reentrant lock if(jtaLogger.logger.isDebugEnabled()) { jtaLogger.logger.debugv("{0} - first pass", _logName); } contactedJndiNames.clear(); jtaLogger.setRecoveryProblems(false); _uids = new InputObjectState(); /* * Scan for resources in the object store. */ try { if (!_recoveryStore.allObjUids(_recoveryManagerClass.type(), _uids)) {
private synchronized void periodicWorkFirstPass(ScanStates endState) { // JBTM-1354 JCA needs to be able to recover XAResources associated with a subordinate transaction so we have to do at least // the start scan to make sure that we have loaded all the XAResources we possibly can to assist subordinate transactions recovering // the reason we can't do bottom up recovery is if this server has an XAResource which tries to recover a remote server (e.g. distributed JTA) // then we get deadlock on the secondpass if (getScanState() == ScanStates.BETWEEN_PASSES) { periodicWorkSecondPass(); endState = ScanStates.BETWEEN_PASSES; // Ensure if originally we are between periodic recovery scans we continue in that state and leave XAResource in STARTRSCAN } setScanState(ScanStates.FIRST_PASS); // synchronized uses a reentrant lock if(jtaLogger.logger.isDebugEnabled()) { jtaLogger.logger.debugv("{0} - first pass", _logName); } contactedJndiNames.clear(); jtaLogger.setRecoveryProblems(false); _uids = new InputObjectState(); /* * Scan for resources in the object store. */ try { if (!_recoveryStore.allObjUids(_recoveryManagerClass.type(), _uids)) {
_recoveryStarted = true; if (XARecoveryModule.getRegisteredXARecoveryModule() != null) { XARecoveryModule.getRegisteredXARecoveryModule().periodicWorkFirstPass();
_recoveryStarted = true; if (XARecoveryModule.getRegisteredXARecoveryModule() != null) { XARecoveryModule.getRegisteredXARecoveryModule().periodicWorkFirstPass();
_recoveryStarted = true; if (XARecoveryModule.getRegisteredXARecoveryModule() != null) { XARecoveryModule.getRegisteredXARecoveryModule().periodicWorkFirstPass();
xaRecoveryModule.periodicWorkFirstPass(); xaRecoveryModule.periodicWorkSecondPass();
@Test public void testRecover () throws Exception { ArrayList<String> r = new ArrayList<String>(); TransactionImple tx = new TransactionImple(0); assertTrue(tx.enlistResource(new RecoveryXAResource())); assertEquals(tx.doPrepare(), TwoPhaseOutcome.PREPARE_OK); r.add("com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource"); jtaPropertyManager.getJTAEnvironmentBean().setXaResourceRecoveryClassNames(r); XARecoveryModule xarm = new XARecoveryModule(); assertNull(xarm.getNewXAResource( new XAResourceRecord(null, null, new XidImple(), null) )); for (int i = 0; i < 11; i++) { xarm.periodicWorkFirstPass(); xarm.periodicWorkSecondPass(); } assertTrue(xarm.getNewXAResource( new XAResourceRecord(null, null, new XidImple(new Uid()), null) ) == null); assertNull(xarm.getNewXAResource( new XAResourceRecord(null, null, new XidImple(), null) )); }