[jboss-dev-forums] [Design of Messaging on JBoss (Messaging/JBoss)] - Re: JBMESSAGING-674 - Propagating changes on ClusteredConnec

clebert.suconic@jboss.com do-not-reply at jboss.com
Tue Jan 16 19:06:49 EST 2007


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#4002524

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4002524



More information about the jboss-dev-forums mailing list