// Extract the ObjectName, the rest is still marshalled
ObjectName mbean = (ObjectName) Registry.lookup(invocation.getObjectName());
long clientViewId = ((Long)invocation.getValue("CLUSTER_VIEW_ID")).longValue();
HATarget target = (HATarget)beanMap.get(invocation.getObjectName());
if (target == null)
{
// We could throw IllegalStateException but we have a race condition that could occur:
// when we undeploy a bean, the cluster takes some time to converge
// and to recalculate a new viewId and list of replicant for each HATarget.
// Consequently, a client could own an up-to-date list of the replicants
// (before the cluster has converged) and try to perform an invocation
// on this node where the HATarget no more exist, thus receiving a
// wrong exception and no failover is performed with an IllegalStateException
//
throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
"target is not/no more registered on this node");
}
if (!target.invocationsAllowed ())
throw new GenericClusteringException(GenericClusteringException.COMPLETED_NO,
"invocations are currently not allowed on this target");
// The cl on the thread should be set in another interceptor
Object rtn = support.getServer().invoke(mbean,
"invoke",
new Object[] { invocation },
Invocation.INVOKE_SIGNATURE);
HARMIResponse rsp = new HARMIResponse();
if (clientViewId != target.getCurrentViewId())
{
rsp.newReplicants = new ArrayList(target.getReplicants());
rsp.currentViewId = target.getCurrentViewId();
}
rsp.response = rtn;
return new MarshalledObject(rsp);
}