The way I found to skip the race condition was to guess the failoverId based on the order
on the failoverMap.
So, in case we can't find the nodeID on failoverMap (meaning the CF was already
updated) I will use a method that I'm calling guessFailoverId:
|
| class ClusteringAspect...
|
|
| public static Integer guessFailoverID(Map failoverMap, Integer nodeID)
| {
| Integer failoverNodeID = null;
| Integer[] nodes = (Integer[])failoverMap.keySet().toArray(new
Integer[failoverMap.size()]);
| // We need to sort the array first
| Arrays.sort(nodes);
| for (int i = 0; i < nodes.length; i++)
| {
| if (nodeID.intValue() < nodes.intValue())
| {
| failoverNodeID = nodes;
| break;
| }
| }
| // if still null use the first node...
| if (failoverNodeID==null)
| {
| failoverNodeID = nodes[0];
| }
| return failoverNodeID;
| }
|
|
I want to keep this method as public static just because on the process of writing it I
wrote a testcase for it... I haven't committed it yet:
org.jboss.test.messaging.jms.clustering.ClusteringAspectInternalTest
Any objections on a test for internal methods (not part of the API)?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4002524#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...