use of com.arjuna.ats.arjuna.recovery.RecoveryManager in project narayana by jbosstm.
the class EmbeddedRecoveryTest method test.
@Test
public void test() {
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
DummyRecoveryModule module = new DummyRecoveryModule();
// make sure no other modules registered for this test
manager.removeAllModules(false);
manager.addModule(module);
manager.scan();
assertTrue(module.finished());
}
use of com.arjuna.ats.arjuna.recovery.RecoveryManager in project narayana by jbosstm.
the class RecoveryDriverUnitTest method testValid.
@Test
public void testValid() throws Exception {
recoveryPropertyManager.getRecoveryEnvironmentBean().setPeriodicRecoveryPeriod(1);
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
RecoveryManager rm = RecoveryManager.manager();
rm.scan(null);
RecoveryDriver rd = new RecoveryDriver(RecoveryManager.getRecoveryManagerPort(), recoveryPropertyManager.getRecoveryEnvironmentBean().getRecoveryAddress(), 100000);
assertTrue(rd.asynchronousScan());
assertTrue(rd.synchronousScan());
}
use of com.arjuna.ats.arjuna.recovery.RecoveryManager in project narayana by jbosstm.
the class RecoveryManagerUnitTest method testSuspendResume.
@Test
public void testSuspendResume() throws Exception {
recoveryPropertyManager.getRecoveryEnvironmentBean().setPeriodicRecoveryPeriod(1);
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryBackoffPeriod(1);
RecoveryManager rm = RecoveryManager.manager();
rm.scan(null);
rm.suspend(false);
rm.resume();
assertTrue(rm.getModules() != null);
rm.removeModule(null, true);
rm.removeAllModules(true);
rm.terminate(false);
}
use of com.arjuna.ats.arjuna.recovery.RecoveryManager 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.arjuna.recovery.RecoveryManager 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;
}
Aggregations