Search in sources :

Example 6 with RecoveryModule

use of com.arjuna.ats.arjuna.recovery.RecoveryModule in project narayana by jbosstm.

the class RecoveryManagerService method addSerializableXAResourceDeserializer.

public void addSerializableXAResourceDeserializer(SerializableXAResourceDeserializer serializableXAResourceDeserializer) {
    XARecoveryModule xaRecoveryModule = null;
    for (RecoveryModule recoveryModule : ((Vector<RecoveryModule>) _recoveryManager.getModules())) {
        if (recoveryModule instanceof XARecoveryModule) {
            xaRecoveryModule = (XARecoveryModule) recoveryModule;
            break;
        }
    }
    if (xaRecoveryModule == null) {
        throw new IllegalStateException(jbossatxLogger.i18NLogger.get_jta_RecoveryManagerService_norecoverymodule());
    }
    xaRecoveryModule.addSerializableXAResourceDeserializer(serializableXAResourceDeserializer);
}
Also used : RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)

Example 7 with RecoveryModule

use of com.arjuna.ats.arjuna.recovery.RecoveryModule in project narayana by jbosstm.

the class RecoveryManagerService method removeXAResourceRecovery.

public void removeXAResourceRecovery(XAResourceRecovery xaResourceRecovery) {
    if (_recoveryManager == null) {
        throw new IllegalStateException(jbossatxLogger.i18NLogger.get_jta_RecoveryManagerService_norecoverysystem());
    }
    XARecoveryModule xaRecoveryModule = null;
    for (RecoveryModule recoveryModule : ((Vector<RecoveryModule>) _recoveryManager.getModules())) {
        if (recoveryModule instanceof XARecoveryModule) {
            xaRecoveryModule = (XARecoveryModule) recoveryModule;
            break;
        }
    }
    if (xaRecoveryModule == null) {
        throw new IllegalStateException(jbossatxLogger.i18NLogger.get_jta_RecoveryManagerService_norecoverymodule());
    }
    xaRecoveryModule.removeXAResourceRecoveryHelper(new XAResourceRecoveryHelperWrapper(xaResourceRecovery));
}
Also used : XAResourceRecoveryHelperWrapper(com.arjuna.ats.internal.jbossatx.jta.XAResourceRecoveryHelperWrapper) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)

Example 8 with RecoveryModule

use of com.arjuna.ats.arjuna.recovery.RecoveryModule in project narayana by jbosstm.

the class XAResourceRecord method getXAResourceDeserializers.

private List<SerializableXAResourceDeserializer> getXAResourceDeserializers() {
    if (serializableXAResourceDeserializers != null) {
        return serializableXAResourceDeserializers;
    }
    synchronized (this) {
        if (serializableXAResourceDeserializers != null) {
            return serializableXAResourceDeserializers;
        }
        serializableXAResourceDeserializers = new ArrayList<SerializableXAResourceDeserializer>();
        for (RecoveryModule recoveryModule : RecoveryManager.manager().getModules()) {
            if (recoveryModule instanceof XARecoveryModule) {
                XARecoveryModule xaRecoveryModule = (XARecoveryModule) recoveryModule;
                serializableXAResourceDeserializers.addAll(xaRecoveryModule.getSeriablizableXAResourceDeserializers());
                return serializableXAResourceDeserializers;
            }
        }
    }
    return serializableXAResourceDeserializers;
}
Also used : SerializableXAResourceDeserializer(com.arjuna.ats.jta.recovery.SerializableXAResourceDeserializer) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) XARecoveryModule(com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule)

Example 9 with RecoveryModule

use of com.arjuna.ats.arjuna.recovery.RecoveryModule in project narayana by jbosstm.

the class XARecoveryModule method getRegisteredXARecoveryModule.

public static XARecoveryModule getRegisteredXARecoveryModule() {
    if (registeredXARecoveryModule == null) {
        RecoveryManager recMan = RecoveryManager.manager();
        Vector recoveryModules = recMan.getModules();
        if (recoveryModules != null) {
            Enumeration modules = recoveryModules.elements();
            while (modules.hasMoreElements()) {
                RecoveryModule m = (RecoveryModule) modules.nextElement();
                if (m instanceof XARecoveryModule) {
                    registeredXARecoveryModule = (XARecoveryModule) m;
                    break;
                }
            }
        }
    }
    return registeredXARecoveryModule;
}
Also used : RecoveryManager(com.arjuna.ats.arjuna.recovery.RecoveryManager) Enumeration(java.util.Enumeration) RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule) Vector(java.util.Vector)

Example 10 with RecoveryModule

use of com.arjuna.ats.arjuna.recovery.RecoveryModule in project narayana by jbosstm.

the class SubordinateAtomicActionRecoveryModule method validatePosition.

/**
 * It is important to verify that the SubordinateAtomicActionRecoveryModule has been loaded before the XARecoveryModule
 * as otherwise when we check for an imported transaction it may not have been loaded by the  SubordinateAtomicActionRecoveryModule yet.
 *
 * @return true if and only if SubordinateAtomicActionRecoveryModule appears before XARecoveryModule in the modules
 */
private boolean validatePosition() {
    if (!this.validatePosition) {
        Vector<RecoveryModule> modules = RecoveryManager.manager().getModules();
        boolean foundSelf = false;
        for (RecoveryModule module : modules) {
            if (module instanceof SubordinateAtomicActionRecoveryModule) {
                foundSelf = true;
            } else if (module instanceof XARecoveryModule) {
                // configured to run before it
                if (!foundSelf) {
                    return false;
                } else {
                    this.validatePosition = true;
                    break;
                }
            }
        }
    }
    return this.validatePosition;
}
Also used : RecoveryModule(com.arjuna.ats.arjuna.recovery.RecoveryModule)

Aggregations

RecoveryModule (com.arjuna.ats.arjuna.recovery.RecoveryModule)27 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule)18 Enumeration (java.util.Enumeration)14 Vector (java.util.Vector)14 XAResource (javax.transaction.xa.XAResource)14 Test (org.junit.Test)12 CommitMarkableResourceRecordRecoveryModule (com.arjuna.ats.internal.jta.recovery.arjunacore.CommitMarkableResourceRecordRecoveryModule)11 XAResourceRecoveryHelper (com.arjuna.ats.jta.recovery.XAResourceRecoveryHelper)11 Connection (java.sql.Connection)10 Xid (javax.transaction.xa.Xid)10 InitialContext (javax.naming.InitialContext)9 JdbcDataSource (org.h2.jdbcx.JdbcDataSource)7 ExecuteException (org.jboss.byteman.rule.exception.ExecuteException)6 Uid (com.arjuna.ats.arjuna.common.Uid)5 RecoveryManager (com.arjuna.ats.arjuna.recovery.RecoveryManager)5 XAException (javax.transaction.xa.XAException)5 TransactionImple (com.arjuna.ats.internal.jta.transaction.arjunacore.TransactionImple)4 AtomicAction (com.arjuna.ats.arjuna.AtomicAction)3 InputObjectState (com.arjuna.ats.arjuna.state.InputObjectState)3 XARecoveryModule (com.arjuna.ats.internal.jta.recovery.jts.XARecoveryModule)3