use of com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule 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));
}
use of com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule in project narayana by jbosstm.
the class RecoveryTest method directRecoverableConnection.
@Test
@BMRule(name = "throw rmfail xaexception", targetClass = "org.h2.jdbcx.JdbcXAConnection", targetMethod = "commit", action = "throw new javax.transaction.xa.XAException(javax.transaction.xa.XAException.XAER_RMFAIL)", targetLocation = "AT ENTRY")
public void directRecoverableConnection() throws Exception {
// jdbc:arjuna: <path to properties file>, path starting at System.getProperty("user.dir")
String url = TransactionalDriver.arjunaDriver + "ds-direct.properties";
Properties dbProperties = new Properties();
dbProperties.put(TransactionalDriver.dynamicClass, PropertyFileDynamicClass.class.getName());
dbProperties.put(TransactionalDriver.userName, "");
dbProperties.put(TransactionalDriver.password, "");
Properties p = System.getProperties();
p.put("jdbc.drivers", Driver.class.getName());
System.setProperties(p);
transactionalDriver = new TransactionalDriver();
DriverManager.registerDriver(transactionalDriver);
step0_setupTables(url, dbProperties);
// rmfail means the db connection was left to be recovered
step1_leaveXidsInDbTable(url, dbProperties);
step2_checkDbIsNotCommitted(url, dbProperties);
// 3. Perform recovery - checking only top down XARecoveryModule functionality
{
XARecoveryModule xarm = new XARecoveryModule();
RecoveryManager manager = RecoveryManager.manager();
manager.removeAllModules(true);
manager.addModule(xarm);
AtomicActionRecoveryModule aarm = new AtomicActionRecoveryModule();
aarm.periodicWorkFirstPass();
Transformer.disableTriggers(true);
aarm.periodicWorkSecondPass();
Transformer.enableTriggers(true);
}
step4_finalDbCommitCheck(url, dbProperties);
}
use of com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule in project narayana by jbosstm.
the class XAResourceRecord method getNewXAResource.
/**
* This routine finds the new XAResource for the transaction that used the
* old resource we couldn't serialize. It does this by looking up the
* XARecoveryModule in the recovery manager and asking it for the
* XAResource. The recovery manager will then look through its list of
* registered XARecoveryResource implementations for the appropriate
* instance. If the XARecoveryModule hasn't been initialised yet then this
* routine will fail, but on the next scan it should work.
*/
private final XAResource getNewXAResource() {
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) {
return ((XARecoveryModule) m).getNewXAResource(this);
}
}
}
return null;
}
use of com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule in project wildfly by wildfly.
the class InboundBridgeService method addDeserializerAndOrphanFilter.
private void addDeserializerAndOrphanFilter() {
final RecoveryManager recoveryManager = RecoveryManager.manager();
for (RecoveryModule recoveryModule : recoveryManager.getModules()) {
if (recoveryModule instanceof XARecoveryModule) {
orphanFilter = new InboundBridgeOrphanFilter();
((XARecoveryModule) recoveryModule).addXAResourceOrphanFilter(orphanFilter);
((XARecoveryModule) recoveryModule).addSerializableXAResourceDeserializer(new InboundBridge());
}
}
}
use of com.arjuna.ats.internal.jta.recovery.arjunacore.XARecoveryModule in project narayana by jbosstm.
the class RecoveryTest method test.
@Test
@BMRule(name = "throw lang error exception", targetClass = "org.h2.jdbcx.JdbcXAConnection", targetMethod = "commit", action = "throw new java.lang.Error()", targetLocation = "AT ENTRY")
public void test() throws Exception {
String url = "jdbc:arjuna:";
Properties p = System.getProperties();
p.put("jdbc.drivers", Driver.class.getName());
System.setProperties(p);
transactionalDriver = new TransactionalDriver();
DriverManager.registerDriver(transactionalDriver);
Properties dbProperties = new Properties();
final JdbcDataSource ds = new JdbcDataSource();
ds.setURL("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
dbProperties.put(TransactionalDriver.XADataSource, ds);
step0_setupTables(url, dbProperties);
// We need to do this in a different thread as otherwise the transaction would still be associated with the connection due to the java.lang.Error
// RMFAIL on it's own will cause H2 to close connection and that seems to discard the indoubt transactions
step1_leaveXidsInDbTable(url, dbProperties);
step2_checkDbIsNotCommitted(url, dbProperties);
// 3. Perform recovery
{
XARecoveryModule xarm = new XARecoveryModule();
xarm.addXAResourceRecoveryHelper(new XAResourceRecoveryHelper() {
@Override
public boolean initialise(String p) throws Exception {
return false;
}
@Override
public XAResource[] getXAResources() throws Exception {
return new XAResource[] { ds.getXAConnection().getXAResource() };
}
});
RecoveryManager manager = RecoveryManager.manager();
manager.removeAllModules(true);
manager.addModule(xarm);
AtomicActionRecoveryModule aarm = new AtomicActionRecoveryModule();
aarm.periodicWorkFirstPass();
Transformer.disableTriggers(true);
aarm.periodicWorkSecondPass();
Transformer.enableTriggers(true);
}
step4_finalDbCommitCheck(url, dbProperties);
}
Aggregations