CVS update: JGroups/src/org/jgroups/util Util.java
"Bela Ban" <[email protected]> Fri, 17 Sep 2010 13:03:55 +0000
| Newsgroups | gmane.comp.java.javagroups.cvs |
|---|---|
| Message-ID | <[email protected]> |
User: belaban
Date: 10/09/17 13:03:55
Modified: src/org/jgroups/util Util.java
Log:
method to get the rank of a member with respect to a view
Revision Changes Path
1.274 +13 -1 JGroups/src/org/jgroups/util/Util.java
Index: Util.java
===================================================================
RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/util/Util.java,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -r1.273 -r1.274
--- Util.java 17 Sep 2010 11:50:07 -0000 1.273
+++ Util.java 17 Sep 2010 13:03:55 -0000 1.274
@@ -37,7 +37,7 @@
/**
* Collection of various utility routines that can not be assigned to other classes.
* @author Bela Ban
- * @version $Id: Util.java,v 1.273 2010/09/17 11:50:07 belaban Exp $
+ * @version $Id: Util.java,v 1.274 2010/09/17 13:03:55 belaban Exp $
*/
public class Util {
@@ -2115,6 +2115,18 @@
}
+ public static int getRank(View view, Address addr) {
+ if(view == null || addr == null)
+ return 0;
+ List<Address> members=view.getMembers();
+ for(int i=0; i < members.size(); i++) {
+ Address mbr=members.get(i);
+ if(mbr.equals(addr))
+ return i+1;
+ }
+ return 0;
+ }
+
public static Object pickRandomElement(List list) {
if(list == null) return null;
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev