CVS update: JGroups/src/org/jgroups/protocols Discovery.java

"Bela Ban" <[email protected]> Fri, 17 Sep 2010 13:26:41 +0000
Newsgroups gmane.comp.java.javagroups.cvs
Message-ID <[email protected]>
  User: belaban 
  Date: 10/09/17 13:26:41

  Modified:    src/org/jgroups/protocols Discovery.java
  Log:
  added max_rank to limit discovery responses (https://jira.jboss.org/browse/JGRP-1181)
  
  Revision  Changes    Path
  1.76      +14 -1     JGroups/src/org/jgroups/protocols/Discovery.java
  
  Index: Discovery.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/protocols/Discovery.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- Discovery.java	28 Jul 2010 09:49:57 -0000	1.75
  +++ Discovery.java	17 Sep 2010 13:26:40 -0000	1.76
  @@ -39,7 +39,7 @@
    * </ul>
    * 
    * @author Bela Ban
  - * @version $Id: Discovery.java,v 1.75 2010/07/28 09:49:57 belaban Exp $
  + * @version $Id: Discovery.java,v 1.76 2010/09/17 13:26:40 belaban Exp $
    */
   @MBean
   public abstract class Discovery extends Protocol {   
  @@ -67,6 +67,10 @@
               "discovery request, or not. Default is false, except for TCPPING")
       boolean return_entire_cache=false;
   
  +    @Property(description="Only members with a rank <= max_rank will send a discovery response. 1 means only the " +
  +            "coordinator will reply. 0 disables this; everyone replies. JIRA: https://jira.jboss.org/browse/JGRP-1181")
  +    int max_rank=0;
  +
       
       /* ---------------------------------------------   JMX      ------------------------------------------------------ */
   
  @@ -78,6 +82,9 @@
       @ManagedAttribute
       private volatile int max_found_members=0;
   
  +    @ManagedAttribute
  +    protected int rank=0;
  +
       
       /* --------------------------------------------- Fields ------------------------------------------------------ */
   
  @@ -97,6 +104,8 @@
           timer=getTransport().getTimer();
           if(timer == null)
               throw new Exception("timer cannot be retrieved from protocol stack");
  +        if(max_rank > 0)
  +            return_entire_cache=true;
       }
   
   
  @@ -286,6 +295,9 @@
                   switch(hdr.type) {
   
                       case PingHeader.GET_MBRS_REQ:   // return Rsp(local_addr, coord)
  +                        if(max_rank > 0 && rank > 0 && rank > max_rank) // https://jira.jboss.org/browse/JGRP-1181
  +                            return null;
  +
                           if(group_addr == null || hdr.cluster_name == null) {
                               if(log.isWarnEnabled())
                                   log.warn("group_addr (" + group_addr + ") or cluster_name of header (" + hdr.cluster_name
  @@ -425,6 +437,7 @@
                           members.addAll(tmp);
                       }
                   }
  +                rank=Util.getRank(view, local_addr);
                   return down_prot.down(evt);
   
               case Event.BECOME_SERVER: // called after client has joined and is fully working group member
  
  
  

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