use of com.arjuna.ats.arjuna.recovery.RecoveryManager 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]);
}
use of com.arjuna.ats.arjuna.recovery.RecoveryManager in project narayana by jbosstm.
the class Test01 method main.
public static void main(String[] args) {
System.setProperty("com.arjuna.ats.jta.xaRecoveryNode", "1");
System.setProperty("XAResourceRecovery1", "com.hp.mwtests.ts.jta.recovery.DummyXARecoveryResource");
try {
RecoveryManager manager = RecoveryManager.manager(RecoveryManager.DIRECT_MANAGEMENT);
manager.scan();
manager.scan();
System.out.println("Passed.");
} catch (Exception ex) {
System.out.println("Failed.");
}
System.clearProperty("com.arjuna.ats.jta.xaRecoveryNode");
System.clearProperty("XAResourceRecovery1");
}
use of com.arjuna.ats.arjuna.recovery.RecoveryManager in project narayana by jbosstm.
the class ExecutionWrapper method main.
public static void main(String[] args) throws Exception {
String className = args[0];
String[] subArgs = new String[args.length - 1];
System.arraycopy(args, 1, subArgs, 0, args.length - 1);
if (className.equals("com.arjuna.ats.arjuna.recovery.RecoveryManager")) {
if (!recMgrFile.createNewFile()) {
System.err.println("Recovery manager already running?");
System.exit(-1);
}
recMgrFile.deleteOnExit();
System.out.println("Ready");
Thread.sleep(Long.MAX_VALUE);
} else if (className.equals("org.jboss.jbossts.qa.Utils.EmptyObjectStore")) {
String objectStoreBaseDirBaseName = System.getProperty("ObjectStoreBaseDir");
// strip off the trailing '/emptyObjectStore' to get the test rather than task dir
objectStoreBaseDirBaseName = objectStoreBaseDirBaseName.substring(0, objectStoreBaseDirBaseName.lastIndexOf(System.getProperty("file.separator")));
File directory = new File(objectStoreBaseDirBaseName);
for (File candidateFile : directory.listFiles()) {
if (candidateFile.isDirectory()) {
System.err.println("emptying " + candidateFile.getCanonicalPath());
EmptyObjectStore.removeContents(candidateFile);
}
}
System.out.println("Passed");
} else {
int portOffset = Integer.valueOf(System.getProperty("portOffsetId")) * 20;
int recoveryOrbPortBase = jtsPropertyManager.getJTSEnvironmentBean().getRecoveryManagerPort();
int recoveryOrbPort = recoveryOrbPortBase + portOffset;
jtsPropertyManager.getJTSEnvironmentBean().setRecoveryManagerPort(recoveryOrbPort);
int recoveryManagerPortBase = recoveryPropertyManager.getRecoveryEnvironmentBean().getRecoveryPort();
int recoveryManagerPort = recoveryManagerPortBase + portOffset;
recoveryPropertyManager.getRecoveryEnvironmentBean().setRecoveryPort(recoveryManagerPort);
System.out.println("using ports " + recoveryOrbPort + " and " + recoveryManagerPort);
String objectStoreBaseDirBaseName = System.getProperty("ObjectStoreBaseDir");
// full path incl taskName, see TestGroupBase
File directory = new File(objectStoreBaseDirBaseName);
File hornetqStoreDir = new File(directory, "HornetQStore");
// additionalCommandLineElements.add("-DHornetqJournalEnvironmentBean.storeDir="+hornetqStoreDir);
BeanPopulator.getDefaultInstance(HornetqJournalEnvironmentBean.class).setStoreDir(hornetqStoreDir.getCanonicalPath());
BeanPopulator.getDefaultInstance(ObjectStoreEnvironmentBean.class).setObjectStoreType("com.arjuna.ats.internal.arjuna.objectstore.hornetq.HornetqObjectStoreAdaptor");
/*
[junit] Running org.jboss.jbossts.qa.junit.testgroup.TestGroup_txcore_recovery
[junit] Tests run: 36, Failures: 24, Errors: 0, Time elapsed: 971.637 sec
[junit] Test org.jboss.jbossts.qa.junit.testgroup.TestGroup_txcore_recovery FAILED
*/
File ostoreDir = new File(directory, "ObjectStore");
BeanPopulator.getDefaultInstance(ObjectStoreEnvironmentBean.class).setObjectStoreDir(ostoreDir.getCanonicalPath());
BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "communicationStore").setObjectStoreDir(ostoreDir.getCanonicalPath());
BeanPopulator.getNamedInstance(ObjectStoreEnvironmentBean.class, "stateStore").setObjectStoreDir(ostoreDir.getCanonicalPath());
final Properties p = new Properties();
p.setProperty("OAPort", "" + recoveryOrbPort);
// for persistent servers the JavaIdl orb requires you to explicitly define which port the
// server will run on and to provide a unique id per server per machine:
p.setProperty("com.sun.CORBA.POA.ORBPersistentServerPort", "" + recoveryOrbPort);
p.setProperty("com.sun.CORBA.POA.ORBServerId", "" + recoveryOrbPort);
initOrb(p, 10, recoveryOrbPort, args);
RecoveryManager manager = RecoveryManager.manager();
Class clazz = Class.forName(className);
Method mainMethod = clazz.getMethod("main", new Class[] { subArgs.getClass() });
before();
mainMethod.invoke(null, new Object[] { subArgs });
after();
manager.terminate();
System.exit(0);
}
}
Aggregations