[jboss-cvs] JBossCache/src/org/jboss/cache/buddyreplication ...
Manik Surtani
msurtani at jboss.com
Fri Feb 9 12:23:58 EST 2007
User: msurtani
Date: 07/02/09 12:23:58
Modified: src/org/jboss/cache/buddyreplication BuddyGroup.java
NextMemberBuddyLocator.java
Log:
annotations
Revision Changes Path
1.11 +13 -23 JBossCache/src/org/jboss/cache/buddyreplication/BuddyGroup.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: BuddyGroup.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/buddyreplication/BuddyGroup.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- BuddyGroup.java 30 Dec 2006 19:48:45 -0000 1.10
+++ BuddyGroup.java 9 Feb 2007 17:23:58 -0000 1.11
@@ -6,9 +6,12 @@
*/
package org.jboss.cache.buddyreplication;
+import net.jcip.annotations.ThreadSafe;
import org.jgroups.Address;
import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Vector;
@@ -17,7 +20,8 @@
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
-public class BuddyGroup implements Serializable //Externalizable
+ at ThreadSafe
+public class BuddyGroup implements Serializable//Externalizable
{
/**
* Serial version.
@@ -35,50 +39,36 @@
// List buddies = new ArrayList();
- public String getGroupName()
+ public synchronized String getGroupName()
{
return groupName;
}
- public void setGroupName(String groupName)
+ public synchronized void setGroupName(String groupName)
{
this.groupName = groupName;
}
- public Address getDataOwner()
+ public synchronized Address getDataOwner()
{
return dataOwner;
}
- public void setDataOwner(Address dataOwner)
+ public synchronized void setDataOwner(Address dataOwner)
{
this.dataOwner = dataOwner;
}
- public List<Address> getBuddies()
+ public synchronized List<Address> getBuddies()
{
- return buddies;
+ return Collections.unmodifiableList(buddies);
}
- public void setBuddies(List<Address> buddies)
+ public synchronized void setBuddies(List<Address> buddies)
{
- this.buddies = buddies;
+ this.buddies = new ArrayList(buddies);
}
- // public void writeExternal(ObjectOutput out) throws IOException
- // {
- // out.writeObject(groupName);
- // out.writeObject(dataOwner);
- // out.writeObject(buddies);
- // }
- //
- // public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
- // {
- // groupName = (String) in.readObject();
- // dataOwner = (IpAddress) in.readObject();
- // buddies = (List) in.readObject();
- // }
-
public String toString()
{
StringBuffer b = new StringBuffer("BuddyGroup: (");
1.10 +10 -2 JBossCache/src/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: NextMemberBuddyLocator.java
===================================================================
RCS file: /cvsroot/jboss/JBossCache/src/org/jboss/cache/buddyreplication/NextMemberBuddyLocator.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- NextMemberBuddyLocator.java 30 Dec 2006 19:48:45 -0000 1.9
+++ NextMemberBuddyLocator.java 9 Feb 2007 17:23:58 -0000 1.10
@@ -6,6 +6,7 @@
*/
package org.jboss.cache.buddyreplication;
+import net.jcip.annotations.ThreadSafe;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jboss.cache.config.BuddyReplicationConfig.BuddyLocatorConfig;
@@ -34,6 +35,7 @@
*
* @author <a href="mailto:manik at jboss.org">Manik Surtani (manik at jboss.org)</a>
*/
+ at ThreadSafe
public class NextMemberBuddyLocator implements BuddyLocator
{
private Log log = LogFactory.getLog(NextMemberBuddyLocator.class);
@@ -86,7 +88,9 @@
ignoreColocatedBuddiesForSession = false;
i = 0;
if (log.isInfoEnabled())
+ {
log.info("Expected to look for " + numBuddiesToFind + " buddies but could only find " + buddies.size() + " suitable candidates - trying with colocated buddies as well.");
+ }
continue;
}
@@ -95,10 +99,12 @@
if (subscript >= currentMembership.size() && buddyPoolMap != null)
{
buddyPoolMap = null;
- ignoreColocatedBuddiesForSession = config.isIgnoreColocatedBuddies(); // reset this flag
+ ignoreColocatedBuddiesForSession = config.isIgnoreColocatedBuddies();// reset this flag
i = 0;
if (log.isInfoEnabled())
+ {
log.info("Expected to look for " + numBuddiesToFind + " buddies but could only find " + buddies.size() + " suitable candidates - trying again, ignoring buddy pool hints.");
+ }
continue;
}
@@ -107,7 +113,9 @@
if (subscript >= currentMembership.size())
{
if (log.isInfoEnabled())
+ {
log.info("Expected to look for " + numBuddiesToFind + " buddies but could only find " + buddies.size() + " suitable candidates!");
+ }
break;
}
@@ -116,7 +124,7 @@
!candidate.equals(dataOwner) && // ignore self from selection as buddy
!buddies.contains(candidate) && // havent already considered this candidate
(!ignoreColocatedBuddiesForSession || !isColocated(candidate, dataOwner)) && // ignore colocated buddies
- (isInSameBuddyPool(buddyPoolMap, candidate, dataOwner)) // try and find buddies in the same buddy pool first
+ (isInSameBuddyPool(buddyPoolMap, candidate, dataOwner))// try and find buddies in the same buddy pool first
)
{
buddies.add(candidate);
More information about the jboss-cvs-commits
mailing list