[jboss-cvs] JBossCache/src/org/jboss/cache/buddyreplication ...

Manik Surtani msurtani at jboss.com
Thu Dec 21 10:42:18 EST 2006


  User: msurtani
  Date: 06/12/21 10:42:18

  Modified:    src/org/jboss/cache/buddyreplication  Tag:
                        Branch_JBossCache_1_4_0 BuddyManager.java
  Log:
  refactored
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.33.2.9  +19 -10    JBossCache/src/org/jboss/cache/buddyreplication/BuddyManager.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: BuddyManager.java
  ===================================================================
  RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/buddyreplication/BuddyManager.java,v
  retrieving revision 1.33.2.8
  retrieving revision 1.33.2.9
  diff -u -b -r1.33.2.8 -r1.33.2.9
  --- BuddyManager.java	9 Dec 2006 15:14:46 -0000	1.33.2.8
  +++ BuddyManager.java	21 Dec 2006 15:42:17 -0000	1.33.2.9
  @@ -72,11 +72,11 @@
      /**
       * Map of buddy pools received from broadcasts
       */
  -   Map buddyPool;
  +   Map buddyPool = new ConcurrentReaderHashMap();
      /**
       * The nullBuddyPool is a set of addresses that have not specified buddy pools.
       */
  -   Set nullBuddyPool;
  +   final Set nullBuddyPool = new HashSet();
      /**
       * Name of the buddy pool for current instance.  May be null if buddy pooling is not used.
       */
  @@ -153,10 +153,6 @@
         buddyPoolName = XmlHelper.readStringContents(element, "buddyPoolName");
         if (buddyPoolName != null && buddyPoolName.equals("")) buddyPoolName = null;
   
  -      // initialise buddy pool map
  -      buddyPool = new ConcurrentReaderHashMap();
  -      nullBuddyPool = new HashSet();
  -
         // now read the buddy locator details and create accordingly.
         String buddyLocatorClass = null;
         Properties buddyLocatorProperties = null;
  @@ -396,9 +392,17 @@
            log.debug(buddyGroup.getDataOwner() + ": received announcement that cache instance " + address + " is in buddy pool " + poolName);
         }
         if (poolName != null)
  +      {
            buddyPool.put(address, poolName);
  +      }
         else
  -         nullBuddyPool.add(address);
  +      {
  +         synchronized(nullBuddyPool)
  +         {
  +            // writes to this concurrent set are expensive.  Don't write unnecessarily.
  +            if (!nullBuddyPool.contains(address)) nullBuddyPool.add(address);
  +         }
  +      }
   
         // notify any waiting view change threads that buddy pool info has been received.
         synchronized (poolInfoNotifierLock)
  @@ -936,10 +940,15 @@
            while (i.hasNext())
            {
               Object address = i.next();
  +
  +            // make sure no one is concurrently writing to nullBuddyPool.
  +            synchronized(nullBuddyPool)
  +            {
               infoReceived = infoReceived && (address.equals(cache.getLocalAddress()) || buddyPool.keySet().contains(address) || nullBuddyPool.contains(address));
            }
  +         }
   
  -         log.trace(buddyGroup.getDataOwner() + " received buddy pool info for new members " + newMembers + "?  " + infoReceived);
  +         if (log.isTraceEnabled()) log.trace(buddyGroup.getDataOwner() + " received buddy pool info for new members " + newMembers + "?  " + infoReceived);
   
            return infoReceived;
         }
  
  
  



More information about the jboss-cvs-commits mailing list