// Simple connection count stress test
PooledInvokerProxy.clearStats();
PooledInvokerProxy.clearPools();
for(int n = 0; n < 100; n ++)
{
StatefulSession tmp = (StatefulSession) homeHA.create();
tmp.remove();
tmp = (StatefulSession) homeHA.create();
StatelessSession tmp2 = home.create();
tmp.getNodeState();
tmp2.getCallCount();
tmp.getNodeState();
tmp2.getCallCount();
tmp.remove();
int totalCount = PooledInvokerProxy.getTotalPoolCount();
// N cluster nodes + 1 for unclustered
int expectedCount = urls.length + 1;
assertEquals("TotalPoolCount", expectedCount, totalCount);
long usedPooled = PooledInvokerProxy.getUsedPooled();
// iter * Ncalls - expectedCount (for the initial conn creation)
int expectedUsedPooled = (n+1) * 9 - expectedCount;
assertEquals("UsedPooled", expectedUsedPooled, usedPooled);
}
long inUseCount = PooledInvokerProxy.getInUseCount();
assertEquals("InUseCount", 0, inUseCount);
log.debug("Test Stateful Bean Failover");
log.debug("Looking up the home nextgen.StatefulSession...");
log.debug("Calling create on StatefulSessionHome...");
StatefulSession statefulSession =
(StatefulSession)homeHA.create("Bupple-Dupple");
assertTrue("statefulSessionHome.create() != null", statefulSession != null);
NodeAnswer node1 = statefulSession.getNodeState ();
getLog ().debug (node1);
// Now we switch to the other node, simulating a failure on node 1
System.setProperty ("JBossCluster-DoFail", "once");
NodeAnswer node2 = statefulSession.getNodeState ();
log.debug (node2);
assertEquals("Value is identical on replicated node1", "Bupple-Dupple", node1.answer);
assertEquals("Value is identical on replicated node2", "Bupple-Dupple", node2.answer);
// we change our name to see if it replicates to node 1
statefulSession.setName ("Changed");
// now we travel back on node 1
System.setProperty ("JBossCluster-DoFail", "once");
node1 = statefulSession.getNodeState ();
log.debug(node1);
assertEquals("Value is identical on replicated node1", "Changed", node1.answer);
node2 = statefulSession.getNodeState ();
log.debug(node2);
assertEquals("Value is identical on replicated node2", "Changed", node2.answer);
statefulSession.remove();
int totalCount = PooledInvokerProxy.getTotalPoolCount();
// N cluster nodes + 1 for unclustered
int expectedCount = urls.length + 1;
assertEquals("TotalPoolCount", expectedCount, totalCount);