CVS update: JGroups/src/org/jgroups/stack ProtocolStack.java

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

  Modified:    src/org/jgroups/stack ProtocolStack.java
  Log:
  added support for dumping of attr lists in probe.sh
  
  Revision  Changes    Path
  1.104     +28 -12    JGroups/src/org/jgroups/stack/ProtocolStack.java
  
  Index: ProtocolStack.java
  ===================================================================
  RCS file: /cvsroot/javagroups/JGroups/src/org/jgroups/stack/ProtocolStack.java,v
  retrieving revision 1.103
  retrieving revision 1.104
  diff -u -r1.103 -r1.104
  --- ProtocolStack.java	28 Jul 2010 12:43:22 -0000	1.103
  +++ ProtocolStack.java	13 Sep 2010 12:58:57 -0000	1.104
  @@ -29,7 +29,7 @@
    * stacks, and to destroy them again when not needed anymore
    *
    * @author Bela Ban
  - * @version $Id: ProtocolStack.java,v 1.103 2010/07/28 12:43:22 belaban Exp $
  + * @version $Id: ProtocolStack.java,v 1.104 2010/09/13 12:58:57 belaban Exp $
    */
   public class ProtocolStack extends Protocol implements Transport {
       public static final int ABOVE = 1; // used by insertProtocol()
  @@ -251,20 +251,36 @@
       }
   
       public Map<String,Object> dumpStats(String protocol_name) {
  -        Protocol p;
  -        Map<String,Object> retval=new HashMap<String,Object>(), tmp;
  -        String prot_name;
  +        return dumpStats(protocol_name, null);
  +    }
   
  -        p=top_prot;
  -        while(p != null) {
  -            prot_name=p.getName();
  -            if(prot_name.equals(protocol_name)) {
  -                tmp=p.dumpStats();
  -                if(tmp != null)
  -                    retval.put(prot_name, tmp);
  +
  +    public Map<String,Object> dumpStats(String protocol_name, List<String> attrs) {
  +        Protocol prot=findProtocol(protocol_name);
  +        if(prot == null)
  +            return null;
  +
  +        Map<String,Object> retval=new HashMap<String,Object>(), tmp;
  +        tmp=prot.dumpStats();
  +        if(tmp != null) {
  +            if(attrs != null && !attrs.isEmpty()) {
  +                // weed out attrs not in list
  +                for(Iterator<String> it=tmp.keySet().iterator(); it.hasNext();) {
  +                    String attrname=it.next();
  +                    boolean found=false;
  +                    for(String attr: attrs) {
  +                        if(attrname.startsWith(attr)) {
  +                            found=true;
  +                            break; // found
  +                        }
  +                    }
  +                    if(!found)
  +                        it.remove();
  +                }
               }
  -            p=p.getDownProtocol();
  +            retval.put(protocol_name, tmp);
           }
  +
           return retval;
       }
   
  
  
  

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