}
}
protected void failureCall(InvokerHaFailureType failureType, boolean injectFailureIn1stCall, Class<? extends LoadBalancePolicy> policyClass, boolean newProxiesInBetweenFailures) throws Exception
{
Invocation inv;
if (injectFailureIn1stCall)
{
/* When failure must happen in the very 1st call, we create a 1st
* invocation with the failure injected */
inv = infrastructure.createDateTimeTellerInvocation(null, failureType, timeTellerProxy);
}
else
{
/* When failure is not in first call, we do a call to each bean before
* injecting the faliure */
performTransactionalStickyCalls(1, null, policyClass, newProxiesInBetweenFailures);
/* Now we create the invocation with the failure injected */
inv = infrastructure.createDateTimeTellerInvocation(null, failureType, timeTellerProxy);
}
try
{
log.debug(invokeTimeTellerProxy(inv));
if (failureType.isRecoverable(injectFailureIn1stCall))
{
failureType.assertFailoverCounter(injectFailureIn1stCall, inv.getAsIsValue("FAILOVER_COUNTER"));
inv = infrastructure.createDateTimeTellerInvocation(null, null, timeTellerProxy);
log.debug(invokeTimeTellerProxy(inv));
}
else
{
fail("should have failed, failover is not allowed for " + failureType);
}
}
catch (Exception e)
{
log.debug("Exception (could be expected) during failure call testing", e);
if (failureType.isRecoverable(injectFailureIn1stCall))
{
fail("should have failed, failover is not allowed for " + failureType);
}
else
{
assertNull("transaction on the client side should be null", inv.getTransaction());
failureType.assertFailoverCounter(injectFailureIn1stCall, inv.getAsIsValue("FAILOVER_COUNTER"));
failureType.assertException(e.getCause());
}
}
}