Search in sources :

Example 36 with XARecoveryModule

use of com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule in project narayana by jbosstm.

the class RecoveryShutdownTest method test.

/**
 * test that the call sequence
 *
 * XARecoveryModule#getNewXAResource()
 * RecoveryManager#terminate();
 * XARecoveryModule#removeXAResourceRecoveryHelper
 *
 * does not hang
 *
 * @throws InterruptedException if the test is interrupted
 */
@Test
public void test() throws InterruptedException {
    recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
    RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
    XARecoveryModule xarm = new XARecoveryModule();
    final SimpleResource testXAResource = new SimpleResource() {

        @Override
        public Xid[] recover(int i) throws XAException {
            return new Xid[] { new Xid() {

                @Override
                public int getFormatId() {
                    return 0;
                }

                @Override
                public byte[] getGlobalTransactionId() {
                    return new byte[0];
                }

                @Override
                public byte[] getBranchQualifier() {
                    return new byte[0];
                }
            } };
        }
    };
    final XAResourceRecoveryHelper xaResourceRecoveryHelper = new XAResourceRecoveryHelper() {

        @Override
        public boolean initialise(String p) throws Exception {
            return true;
        }

        @Override
        public XAResource[] getXAResources() throws Exception {
            return new XAResource[] { testXAResource };
        }
    };
    xarm.addXAResourceRecoveryHelper(xaResourceRecoveryHelper);
    manager.removeAllModules(false);
    manager.addModule(xarm);
    manager.scan();
    manager.terminate();
    xarm.getNewXAResource(new XAResourceRecord(null, null, new XidImple(), null));
    final boolean[] removedHelper = { false };
    Runnable r = () -> {
        // the next call will hang unless JBTM-2837 is fixed
        xarm.removeXAResourceRecoveryHelper(xaResourceRecoveryHelper);
        removedHelper[0] = true;
    };
    Thread t = new Thread(r);
    t.start();
    Thread.sleep(100);
    assertTrue("removal of an XAResourceRecoveryHelper hung", removedHelper[0]);
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) XidImple(com.arjuna.ats.jta.xa.XidImple) Xid(javax.transaction.xa.Xid) XAResource(javax.transaction.xa.XAResource) XAResourceRecord(com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord) XAResourceRecoveryHelper(com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) Test(org.junit.Test)

Example 37 with XARecoveryModule

use of com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule in project narayana by jbosstm.

the class InboundBridgeRecoveryManager method start.

/**
 * MC lifecycle callback, used to register components with the recovery manager.
 */
public void start() {
    txbridgeLogger.i18NLogger.info_ibrm_start();
    xtsATRecoveryManager.registerRecoveryModule(this);
    acRecoveryManager.addModule(this);
    XARecoveryModule xaRecoveryModule = getXARecoveryModule();
    xaRecoveryModule.addXAResourceOrphanFilter(this);
}
Also used : XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)

Aggregations

XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)37 Test (org.junit.Test)25 XAResourceRecoveryHelper (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)19 RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)18 XAResource (javax.transaction.xa.XAResource)17 Xid (javax.transaction.xa.Xid)14 Uid (com.arjuna.ats.arjuna.common.Uid)10 XidImple (com.arjuna.ats.jta.xa.XidImple)9 Enumeration (java.util.Enumeration)9 Vector (java.util.Vector)9 XAException (javax.transaction.xa.XAException)9 CommitMarkableResourceRecordRecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.CommitMarkableResourceRecordRecoveryModule)8 Connection (java.sql.Connection)8 InitialContext (javax.naming.InitialContext)7 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)7 RecoveryManager (com.arjuna.ats.arjuna.recovery.RecoveryManager)6 ExecuteException (org.jboss.byteman.rule.exception.ExecuteException)6 JTANodeNameXAResourceOrphanFilter (com.arjuna.ats.internal.jta.recovery.arjunacore.JTANodeNameXAResourceOrphanFilter)5 ArrayList (java.util.ArrayList)5 XAResourceRecord (com.arjuna.ats.internal.jta.resources.arjunacore.XAResourceRecord)4