geode-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bschucha...@apache.org
Subject [14/51] [partial] incubator-geode git commit: GEODE-77 removing the old jgroups subproject
Date Fri, 21 Aug 2015 21:22:38 GMT
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPING.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPING.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPING.java
deleted file mode 100644
index 53dcc66..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPING.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/** Notice of modification as required by the LGPL
- *  This file was modified by Gemstone Systems Inc. on
- *  $Date$
- **/
-// $Id: WANPING.java,v 1.10 2005/05/30 14:31:24 belaban Exp $
-
-package com.gemstone.org.jgroups.protocols;
-
-
-
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import com.gemstone.org.jgroups.Event;
-import com.gemstone.org.jgroups.Message;
-import com.gemstone.org.jgroups.util.ExternalStrings;
-import com.gemstone.org.jgroups.util.List;
-
-
-/**
- * Similar to TCPPING, except that the initial host list is specified as a list of logical pipe names.
- */
-public class WANPING extends Discovery  {
-//    int port_range=5;        // number of ports to be probed for initial membership GemStoneAddition(omitted)
-    List initial_hosts=null;  // hosts to be contacted for the initial membership
-
-
-    @Override // GemStoneAddition
-    public String getName() {
-        return "WANPING";
-    }
-
-
-    @Override // GemStoneAddition
-    public boolean setProperties(Properties props) {
-        String str;
-        str=props.getProperty("port_range");           // if member cannot be contacted on base port,
-        if(str != null) {                              // how many times can we increment the port
-//            port_range=Integer.parseInt(str); GemStoneAddition
-            props.remove("port_range");
-        }
-
-        str=props.getProperty("initial_hosts");
-        if(str != null) {
-            props.remove("initial_hosts");
-            initial_hosts=createInitialHosts(str);
-            if(log.isInfoEnabled()) log.info(ExternalStrings.WANPING_INITIAL_HOSTS__0, initial_hosts);
-        }
-
-        if(initial_hosts == null || initial_hosts.size() == 0) {
-            log.error("WANPING.setProperties(): hosts to contact for initial membership " +
-                               "not specified. Cannot determine coordinator !");
-            return false;
-        }
-        return super.setProperties(props);
-    }
-
-    @Override // GemStoneAddition
-    public void sendGetMembersRequest(AtomicBoolean waiter_sync) {
-        Message msg, copy;
-        PingHeader hdr;
-        String h;
-
-        hdr=new PingHeader(PingHeader.GET_MBRS_REQ, null);
-        msg=new Message(null, null, null);
-        msg.putHeader(getName(), hdr);
-        
-        wakeWaiter(waiter_sync);
-
-        for(Enumeration en=initial_hosts.elements(); en.hasMoreElements();) {
-            h=(String)en.nextElement();
-            copy=msg.copy();
-            copy.setDest(new WanPipeAddress(h));
-            passDown(new Event(Event.MSG, copy));
-        }
-    }
-
-
-
-    /* -------------------------- Private methods ---------------------------- */
-
-    /**
-     * Input is "pipe1,pipe2". Return List of Strings
-     */
-    private List createInitialHosts(String l) {
-        List tmp=new List();
-        StringTokenizer tok=new StringTokenizer(l, ",");
-        String t;
-
-        while(tok.hasMoreTokens()) {
-            try {
-                t=tok.nextToken();
-                tmp.add(t.trim());
-            }
-            catch(NumberFormatException e) {
-                log.error(ExternalStrings.WANPING_WANPINGCREATEINITIALHOSTS__0, e);
-            }
-        }
-        return tmp;
-    }
-
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPIPE.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPIPE.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPIPE.java
deleted file mode 100644
index 3de869b..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WANPIPE.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/** Notice of modification as required by the LGPL
- *  This file was modified by Gemstone Systems Inc. on
- *  $Date$
- **/
-// $Id: WANPIPE.java,v 1.7 2005/05/30 14:31:24 belaban Exp $
-
-package com.gemstone.org.jgroups.protocols;
-
-
-
-import com.gemstone.org.jgroups.*;
-import com.gemstone.org.jgroups.blocks.LogicalLink;
-import com.gemstone.org.jgroups.stack.Protocol;
-import com.gemstone.org.jgroups.util.ExternalStrings;
-import com.gemstone.org.jgroups.util.List;
-import com.gemstone.org.jgroups.util.Util;
-
-import java.io.IOException;
-import java.io.ObjectInput;
-import java.io.ObjectOutput;
-import java.net.InetAddress;
-import java.util.Enumeration;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-
-
-/**
-   Logical point-to-point link. Uses multiple physical links to provide a reliable transport. For example,
-   if there are 2 physical links over different networks, and one of them fails, the WAN pipe will still be
-   able to send traffic over the other link. Currently traffic is sent over the physical links round-robin,
-   but this will be made configurable in the future. Example: 70% over first link, 30% over second, or
-   packets are split and sent across both links (increasing the available bandwidth).
- */
-public class WANPIPE extends Protocol implements LogicalLink.Receiver {
-    LogicalLink    pipe=null;
-    String         name=null;         // logical name of WAN pipe
-    final List           links=new List();  // contains the parsed link descriptions
-
-    Address        local_addr=null;
-    String         group_addr=null;
-    final Properties     properties=null;
-    final Vector         members=new Vector();
-
-
-
-    public WANPIPE() {
-	pipe=new LogicalLink(this);
-    }
-
-
-    @Override // GemStoneAddition
-    public String toString() {
-	return "Protocol WANPIPE(local address: " + local_addr + ')';
-    }
-
-
-    @Override // GemStoneAddition
-    public String getName() {return "WANPIPE";}
-
-
-
-
-
-
-    /**
-       Sent to destination(s) using the WAN pipe. Send local messages directly back up the stack
-     */
-    @Override // GemStoneAddition
-    public void down(Event evt) {
-	Message      msg, /*rsp, GemStoneAddition*/ copy;
-	Address      dest_addr;
-
-	if(evt.getType() != Event.MSG) {
-	    handleDownEvent(evt);
-	    return;
-	}
-
-	msg=(Message)evt.getArg();
-	dest_addr=msg.getDest();
-	
-	if(dest_addr == null) {                 // send both local and remote
-	    for(int i=0; i < members.size(); i++) {
-		dest_addr=(Address)members.elementAt(i);
-
-		if(dest_addr.equals(local_addr)) {  // local or ...
-		    returnLocal(msg);
-		}
-		else {                              // remote
-		    copy=msg.copy();
-		    copy.setDest(dest_addr);
-		    copy.putHeader(getName(), new WanPipeHeader(group_addr));
-		    sendUnicastMessage(copy);
-		}
-	    }
-	}
-	else {
-	    if(dest_addr.equals(local_addr)) {  // destination can either be local ...
-		returnLocal(msg);
-	    }
-	    else {                              // or remote
-		msg.putHeader(getName(), new WanPipeHeader(group_addr));
-		sendUnicastMessage(msg);
-	    }
-	}	
-    }
-
-
-    /** Make a response and send back up the same stack it came down */
-    void returnLocal(Message msg) {
-	Message rsp=msg.copy();
-	rsp.setDest(local_addr);
-	rsp.setSrc(local_addr);
-	passUp(new Event(Event.MSG, rsp));
-    }
-
-
-
-
-    @Override // GemStoneAddition
-    public void start() throws Exception {
-	LinkInfo l;
-
-        for(Enumeration e=links.elements(); e.hasMoreElements();) {
-            l=(LinkInfo)e.nextElement();
-            pipe.addLink(l.local_addr, l.local_port, l.remote_addr, l.remote_port);
-        }
-        pipe.start();
-        local_addr=new WanPipeAddress(name);  // logical address for the WAN pipe
-        passUp(new Event(Event.SET_LOCAL_ADDRESS, local_addr));
-    }
-
-
-    @Override // GemStoneAddition
-    public void stop() {
-	pipe.stop();
-	pipe.removeAllLinks();
-    }
-
-
-
-
-
-
-
-    // LogicalLink.Receiver interface
-    public void receive(byte[] buf) {
-	WanPipeHeader    hdr=null;
-	Message          msg=null;
-
-	try {
-	    msg=(Message)Util.objectFromByteBuffer(buf);
-	}
-	catch(Exception e) {
-	    log.error(ExternalStrings.WANPIPE_WANPIPERECEIVE__0, e);
-	    return;
-	}
-	
-	 if(log.isInfoEnabled()) log.info(ExternalStrings.WANPIPE_RECEIVED_MSG__0, msg);
-	hdr=(WanPipeHeader)msg.removeHeader(getName());
-	
-	/* Discard all messages destined for a channel with a different name */
-	String ch_name=null;
-
-	if(hdr.group_addr != null)
-	    ch_name=hdr.group_addr;
-
-	if(group_addr == null) {
-	     log.error(ExternalStrings.WANPIPE_WANPIPERECEIVE_GROUP_ADDRESS_IN_HEADER_WAS_NULL_DISCARDED);
-	    return;
-	}
-
-	if(ch_name != null && !group_addr.equals(ch_name))
-	    return;
-
-	passUp(new Event(Event.MSG, msg));	
-    }
-
-
-
-
-
-    public void linkDown(InetAddress local, int local_port, InetAddress remote, int remote_port) {
-	Object p=getPeer();
-
-	passUp(new Event(Event.SUSPECT, new SuspectMember(local_addr, (Address)p)));
-    }
-
-
-    public void linkUp(InetAddress local, int local_port, InetAddress remote, int remote_port) {
-	
-    }
-
-
-    public void missedHeartbeat(InetAddress local, int local_port, InetAddress remote, int remote_port, int num_hbs) {
-	
-    }
-
-    public void receivedHeartbeatAgain(InetAddress local, int local_port, InetAddress remote, int remote_port) {
-	
-    }
-
-
-
-    /** Setup the Protocol instance acording to the configuration string */
-    @Override // GemStoneAddition
-    public boolean setProperties(Properties props) {super.setProperties(props);
-	String     str;
-
-	str=props.getProperty("name");
-	if(str != null) {
-	    name=str;
-	    props.remove("name");
-	}
-
-	str=props.getProperty("links");
-	if(str != null) {
-
-	    // parse links and put them in list (as LinkInfos)	    
-	    if(parseLinks(str) == false)
-		return false;
-	    props.remove("links");
-	}
-
-	if(name == null || name.length() == 0) {
-	    log.error(ExternalStrings.WANPIPE_WANPIPESETPROPERTIES_NAME_MUST_BE_SET);
-	    return false;
-	}
-	if(links.size() == 0) {
-	    log.error(ExternalStrings.WANPIPE_WANPIPESETPROPERTIES_NO_LINKS_SPECIFIED_AT_LEAST_1_LINK_MUST_BE_PRESENT);
-	    return false;
-	}
-
-	if(props.size() > 0) {
-	    log.error(ExternalStrings.WANPIPE_WANPIPESETPROPERTIES_THE_FOLLOWING_PROPERTIES_ARE_NOT_RECOGNIZED__0, props);
-
-	    return false;
-	}
-	return true;
-    }
-
-
-
-    /** Parse link spec and put each link into 'links' (as LinkInfo) <br>
-	Example: <pre> [daddy@6666,daddy@7777,daddy@7777,sindhu@6666] </pre>*/
-    boolean parseLinks(String s) {
-	LinkInfo        info;
-	StringTokenizer tok;
-	String          src, dst;
-	int             index=0; // holds position of '@'
-
-	s=s.replace('[', ' ');
-	s=s.replace(']', ' ');
-	s=s.trim();
-	tok=new StringTokenizer(s, ",");
-	while(tok.hasMoreElements()) {
-	    src=tok.nextToken().trim();
-	    dst=tok.nextToken().trim();
-	    info=new LinkInfo();
-
-	    index=src.indexOf('@');
-	    if(index == -1) {
-		log.error(ExternalStrings.WANPIPE_WANPIPEPARSELINKS_LOCAL_ADDRESS__0__MUST_HAVE_A__SEPARATOR, src);
-		return false;
-	    }
-	    info.local_addr=src.substring(0, index);
-	    info.local_port=Integer.parseInt(src.substring(index + 1, src.length()));
-
-	    index=dst.indexOf('@');
-	    if(index == -1) {
-		log.error(ExternalStrings.WANPIPE_WANPIPEPARSELINKS_REMOTE_ADDRESS__0__MUST_HAVE_A__SEPARATOR, dst);
-		return false;
-	    }
-	    info.remote_addr=dst.substring(0, index);
-	    info.remote_port=Integer.parseInt(dst.substring(index + 1, dst.length()));
-
-	    links.add(info);
-	}
-	
-	return true;
-    }
-
-
-    Object getPeer() {
-	Object ret=null;
-	if(members == null || members.size() == 0 || local_addr == null)
-	    return null;
-	for(int i=0; i < members.size(); i++)
-	    if(!members.elementAt(i).equals(local_addr))
-		return members.elementAt(i);
-	return ret;
-    }
-
-
-    
-
-
-    /**
-       If the sender is null, set our own address. We cannot just go ahead and set the address
-       anyway, as we might be sending a message on behalf of someone else ! E.g. in case of
-       retransmission, when the original sender has crashed, or in a FLUSH protocol when we
-       have to return all unstable messages with the FLUSH_OK response.
-     */
-    private void setSourceAddress(Message msg) {
-	if(msg.getSrc() == null)
-	    msg.setSrc(local_addr);
-    }
-
-
-
-
-    /** Send a message to the address specified in msg.dest */
-    private void sendUnicastMessage(Message msg) {
-	byte[] buf=null;
-
-	setSourceAddress(msg);	
-	try {
-	    buf=Util.objectToByteBuffer(msg);
-	}
-	catch(Exception e) {
-	    log.error(ExternalStrings.WANPIPE_WANPIPESENDUNICASTMESSAGE__0, e);
-	    return;
-	}
-	
-	try { 
-	    pipe.send(buf);
-	}
-	catch(LogicalLink.AllLinksDown links_down) {
-	    log.error("WANPIPE.sendUnicastMessage(): WAN pipe has no currently operational " +
-			       "link to send message. Discarding it.");
-	}
-	catch(LogicalLink.NoLinksAvailable no_links) {
-	    log.error("WANPIPE.sendUnicastMessage(): WAN pipe has no physical links configured;" +
-			       " cannot send message");
-	}
-	catch(Exception e) {
-	    log.error(ExternalStrings.WANPIPE_WANPIPESENDUNICASTMESSAGE__0, e);
-	}
-    }
-
-
-
-
-// Commented out GemStoneAddition
-//    private void handleUpEvent(Event evt) {
-//	switch(evt.getType()) {
-//	    
-//	case Event.SUSPECT:
-//	    break;
-//	}
-//    }
-
-
-
-    private void handleDownEvent(Event evt) {
-	switch(evt.getType()) {
-
-	case Event.TMP_VIEW:
-	case Event.VIEW_CHANGE:
-	    synchronized(members) {
-		members.removeAllElements();
-		Vector tmpvec=((View)evt.getArg()).getMembers();
-		for(int i=0; i < tmpvec.size(); i++)
-		    members.addElement(tmpvec.elementAt(i));
-	    }
-	    break;
-
-	case Event.SUSPECT:
-	    break;
-
-	case Event.GET_LOCAL_ADDRESS:   // return local address -> Event(SET_LOCAL_ADDRESS, local)
-	    passUp(new Event(Event.SET_LOCAL_ADDRESS, local_addr));
-	    break;
-
-	case Event.CONNECT:
-	    group_addr=(String)evt.getArg();
-	    passUp(new Event(Event.CONNECT_OK));
-	    break;
-
-	case Event.DISCONNECT:
-	    passUp(new Event(Event.DISCONNECT_OK));
-	    break;
-
-	}
-    }
-
-
-
-
-    protected/*GemStoneAddition*/ static class LinkInfo {
-	String local_addr=null, remote_addr=null;
-	int    local_port=0, remote_port=0;
-	
-	  @Override // GemStoneAddition
-	public String toString() {
-	    StringBuffer ret=new StringBuffer();
-	    
-	    ret.append("local_addr=" + (local_addr != null? local_addr : "null"));
-	    ret.append(":" + local_port);
-	    ret.append(", remote_addr=" + (remote_addr != null ? remote_addr : "null"));
-	    ret.append(":" + remote_port);
-	    return ret.toString();
-	}
-    }
-    
-    
-    static/*GemStoneAddition*/ public class WanPipeHeader extends Header {
-	public String group_addr=null;
-	
-	public WanPipeHeader() {} // used for externalization
-	
-	public WanPipeHeader(String n) {group_addr=n;}
-	
-        @Override // GemStoneAddition
-        public long size(short version) {
-	    return Header.HDR_OVERHEAD;
-	}
-	
-        @Override // GemStoneAddition
-	public String toString() {
-	    return "[WanPipe: group_addr=" + group_addr + ']';
-	}
-	
-	public void writeExternal(ObjectOutput out) throws IOException {
-	    out.writeObject(group_addr);
-	}
-	
-	
-	
-	public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-	    group_addr=(String)in.readObject();
-	}
-	
-    }
-    
-    
-}
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WanPipeAddress.java
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WanPipeAddress.java b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WanPipeAddress.java
deleted file mode 100644
index fbe79cd..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/WanPipeAddress.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/** Notice of modification as required by the LGPL
- *  This file was modified by Gemstone Systems Inc. on
- *  $Date$
- **/
-// $Id: WanPipeAddress.java,v 1.9 2005/08/08 12:45:46 belaban Exp $
-
-package com.gemstone.org.jgroups.protocols;
-
-import com.gemstone.org.jgroups.util.GemFireTracer;
-import com.gemstone.org.jgroups.util.ExternalStrings;
-import com.gemstone.org.jgroups.Address;
-import com.gemstone.org.jgroups.util.Util;
-
-import java.io.*;
-
-
-/**
- * Logical address for a WAN pipe (logical link)
- */
-public class WanPipeAddress implements Address {
-    String logical_name=null;
-    static final GemFireTracer log=GemFireTracer.getLog(WanPipeAddress.class);
-
-
-    // GemStoneAddition
-    public boolean preferredForCoordinator() {
-      return true;
-    }
-    public boolean splitBrainEnabled() {
-      return false;
-    }
-
-    @Override
-    public int getBirthViewId() {
-      return -1;
-    }
-    
-    @Override
-    public short getVersionOrdinal() {
-      return -1;
-    }
-
-    // Used only by Externalization
-    public WanPipeAddress() {
-    }
-
-
-    public WanPipeAddress(String logical_name) {
-        this.logical_name=logical_name;
-    }
-
-
-    public boolean isMulticastAddress() {
-        return true;
-    }
-
-    public int size(short version) {
-        return logical_name != null? logical_name.length()+2 : 22;
-    }
-
-
-    /**
-     * Establishes an order between 2 addresses. Assumes other contains non-null WanPipeAddress.
-     *
-     * @return 0 for equality, value less than 0 if smaller, greater than 0 if greater.
-     */
-    public int compareTo(Object other) throws ClassCastException {
-        if(other == null) {
-            log.error(ExternalStrings.WanPipeAddress_WANPIPEADDRESSCOMPARETO_OTHER_ADDRESS_IS_NULL_);
-            return -1;
-        }
-
-        if(!(other instanceof WanPipeAddress)) {
-            log.error(ExternalStrings.WanPipeAddress_WANPIPEADDRESSCOMPARETO_OTHER_ADDRESS_IS_NOT_OF_TYPE_WANPIPEADDRESS_);
-            return -1;
-        }
-
-        if(((WanPipeAddress)other).logical_name == null) {
-            log.error(ExternalStrings.WanPipeAddress_WANPIPEADDRESSCOMPARETO_OTHER_ADDRESS_IS_NULL_);
-            return -1;
-        }
-
-        return logical_name.compareTo(((WanPipeAddress)other).logical_name);
-    }
-
-
-    @Override // GemStoneAddition
-    public boolean equals(Object obj) {
-        if (obj == null || !(obj instanceof WanPipeAddress)) return false; // GemStoneAddition
-        return compareTo(obj) == 0;
-    }
-
-
-    @Override // GemStoneAddition
-    public int hashCode() {
-        return logical_name.hashCode();
-    }
-
-
-    @Override // GemStoneAddition
-    public String toString() {
-        return logical_name;
-    }
-
-
-    public void writeExternal(ObjectOutput out) throws IOException {
-        out.writeObject(logical_name);
-    }
-
-
-    public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-        logical_name=(String)in.readObject();
-    }
-
-
-
-//    public static void main(String args[]) {
-//
-//        WanPipeAddress a=new WanPipeAddress("daddy");
-//        System.out.println(a);
-//
-//        WanPipeAddress b=new WanPipeAddress("daddy.nms.fnc.fujitsu.com");
-//        System.out.println(b);
-//
-//
-//        if(a.equals(b))
-//            System.out.println("equals");
-//        else
-//            System.out.println("does not equal");
-//    }
-
-
-    public void writeTo(DataOutputStream outstream) throws IOException {
-        Util.writeString(logical_name, outstream);
-    }
-
-    public void readFrom(DataInputStream instream) throws IOException, IllegalAccessException, InstantiationException {
-        logical_name=Util.readString(instream);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/dump2.log
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/dump2.log b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/dump2.log
deleted file mode 100644
index e69de29..0000000

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/ENCRYPT.java.txt
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/ENCRYPT.java.txt b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/ENCRYPT.java.txt
deleted file mode 100644
index 1a53ace..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/ENCRYPT.java.txt
+++ /dev/null
@@ -1,408 +0,0 @@
-// $Id: ENCRYPT.java.txt,v 1.3 2005/05/30 14:31:05 belaban Exp $
-
-package org.jgroups.protocols;
-
-import java.io.Serializable;
-import java.security.*;
-import java.security.spec.KeySpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.Properties;
-import java.util.Vector;
-import org.jgroups.*;
-import org.jgroups.stack.*;
-import org.jgroups.log.Trace;
-
-
-
-class EncryptHeader implements Serializable {
-    int type;
-    static final int ENCRYPT         = 0;
-    static final int KEY_REQUEST     = 1;
-    static final int SERVER_PUBKEY   = 2;
-    static final int SECRETKEY       = 3;
-    static final int SECRETKEY_READY = 4;
-    public EncryptHeader(int type) {
-	this.type = type;
-    }
-    public String toString() {return "[ENCTYPT: <variables> ]";}
-}
-
-
-/**
- * ENCRYPT layer. Encrypt and decrypt the group communication in JGroups
- */
-public class ENCRYPT extends Protocol {
-    Address  local_addr=null;
-    Address  keyServerAddr = null;
-    boolean  keyServer=false;
-    String   asymAlgorithm="RSA";
-    String   symAlgorithm="DES/ECB/PKCS5Padding";
-    int      asymInit=512;					// initial public/private key length
-    int		 symInit=56;					// initial shared key length
-    // for public/private Key
-    KeyPair		Kpair;			// to store own's public/private Key
-    SecretKey	desKey=null;
-    PublicKey   pubKey = null;               // for server to store the temporary client public key
-    PublicKey   serverPubKey = null;         // for client to store server's public Key
-    Cipher		cipher;
-    Cipher		rsa;
-    Vector		members=new Vector();
-    Vector      notReady = new Vector();
-
-    public ENCRYPT(){
-	Security.addProvider(new ABAProvider());
-    }
-
-
-    public String  getName() {return "ENCRYPT";}
-
-
-    /*
-     * GetAlgorithm: Get the algorithm name from "algorithm/mode/padding"
-     */
-    private String getAlgorithm(String s)
-    {
-	int index = s.indexOf("/");
-	if (index==-1)
-	    return s;
-
-	return s.substring(0, index);
-    }
-
-
-    public boolean setProperties(Properties props) {super.setProperties(props);
-	String     str;
-	this.props=props;
-
-	// asymmetric key length
-	str=props.getProperty("asymInit");
-	if (str != null) {
-	    asymInit = new Integer(str).intValue();
-	    props.remove("asymInit");
-	    System.out.println("asymInit = "+asymInit);
-	}
-
-	// symmetric key length
-	str=props.getProperty("symInit");
-	if (str != null) {
-	    symInit = new Integer(str).intValue();
-	    props.remove("symInit");
-	    System.out.println("symInit = "+symInit);
-	}
-
-	// asymmetric algorithm name
-	str=props.getProperty("asymAlgorithm");
-	if (str != null) {
-	    asymAlgorithm = new String(str).toString();
-	    props.remove("asymAlgorithm");
-	}
-
-	// symmetric algorithm name
-	str=props.getProperty("symAlgorithm");
-	if (str != null) {
-	    symAlgorithm = new String(str).toString();
-	    props.remove("symAlgorithm");
-	}
-	if (props.size() > 0) {
-	    log.error("ENCRYPT.setProperties(): these properties are not recognized: " + props);
-
-	    return false;
-	}
-
-	// generate keys according to the specified algorithms
-	try{
-	    // generate publicKey and Private Key using RSA
-	    KeyPairGenerator KpairGen = KeyPairGenerator.getInstance(getAlgorithm(asymAlgorithm));
-	    KpairGen.initialize(asymInit, new SecureRandom());
-	    Kpair = KpairGen.generateKeyPair();
-
-	    // generate secret key
-	    KeyGenerator keyGen = KeyGenerator.getInstance(getAlgorithm(symAlgorithm));
-	    keyGen.init(symInit);
-	    desKey = keyGen.generateKey();
-
-	    // initialize for rsa, cipher encryption/decryption
-	    rsa = Cipher.getInstance(asymAlgorithm);
-	    cipher = Cipher.getInstance(symAlgorithm);
-	}
-	catch(Exception e){
-	    System.out.println(e+"at setProperties");
-	}
-	return true;
-    }
-
-
-    /** Just remove if you don't need to reset any state */
-    public void reset() {}
-
-    public void up(Event evt) {
-	Message msg;
-	Message newMsg;
-	EncryptHeader hdr;
-	switch(evt.getType()) {
-
-	case Event.SET_LOCAL_ADDRESS:
-	    local_addr=(Address)evt.getArg();
-	    break;
-	case Event.FIND_INITIAL_MBRS_OK:
-	    Vector member=(Vector)evt.getArg();
-	    keyServer = member.size() > 0 ? false : true;
-
-	    if (member != null && member.size() > 0)
-		keyServerAddr = (Address)((PingRsp)member.firstElement()).coord_addr;
-	    else keyServerAddr = local_addr;
-
-	    System.out.println("keyServer = " + keyServer + "  keyServerAddr : "+keyServerAddr.toString());
-	    if (!keyServer)
-		{
-		    desKey = null;
-		    // client send clien's public key to server and request server's public key
-		    newMsg = new Message(keyServerAddr,local_addr,Kpair.getPublic().getEncoded());
-		    newMsg.addHeader(new EncryptHeader(EncryptHeader.KEY_REQUEST));
-		    passDown(new Event(Event.MSG,newMsg));
-		}
-
-	    passUp(evt);
-	    return;
-
-	case Event.MSG:
-	    msg=(Message)evt.getArg();
-
-	    Object obj=msg.peekHeader();
-
-				// if not encrypted message, pass up
-	    if (obj == null || !(obj instanceof EncryptHeader)) {
-		passUp(evt);
-		return;
-	    }
-	    hdr = (EncryptHeader)msg.removeHeader();
-
-	    switch(hdr.type){
-
-		// key request from client and send server's public key to client
-	    case EncryptHeader.KEY_REQUEST:
-		try{
-		    // store the this client to notReady list using client's address
-		    notReady.addElement(msg.getSrc());
-		    // store the client's public key for temporary
-		    PublicKey pubKey = generatePubKey(msg.getBuffer());
-
-		    // send server's publicKey
-		    newMsg = new Message(msg.getSrc(), local_addr, Kpair.getPublic().getEncoded());
-		    newMsg.addHeader(new EncryptHeader(EncryptHeader.SERVER_PUBKEY));
-		    passDown(new Event(Event.MSG, newMsg));
-
-		    // send shared DesKey to client
-		    //   1. Decrypt desKey with server's own private Key
-		    //   2. Encrypt decrypted desKey with client's own public Key
-		    // encrypt encoded desKey using server's private key
-		    rsa.init(Cipher.ENCRYPT_MODE, Kpair.getPrivate());
-		    byte [] decryptedKey = rsa.doFinal(desKey.getEncoded());
-
-		    // encrypt decrypted key using client's public key
-		    rsa.init(Cipher.ENCRYPT_MODE, pubKey);
-		    byte [] encryptedKey = rsa.doFinal(decryptedKey);
-
-		    //send encrypted deskey to client
-		    newMsg = new Message(msg.getSrc(), local_addr, encryptedKey);
-		    newMsg.addHeader(new EncryptHeader(EncryptHeader.SECRETKEY));
-		    passDown(new Event(Event.MSG, newMsg));
-		}
-		catch(Exception e){
-		    System.out.println(e+"0");
-		}
-		return;
-
-	    case EncryptHeader.SECRETKEY_READY:
-		//server get client's public key and generate the secret key
-		notReady.removeElement(msg.getSrc());
-		return;
-	    case EncryptHeader.SERVER_PUBKEY:
-		serverPubKey = generatePubKey(msg.getBuffer());
-		return;
-
-	    case EncryptHeader.SECRETKEY:
-		try{
-		    // decrypt using client's private Key
-		    rsa.init(Cipher.DECRYPT_MODE,Kpair.getPrivate());
-		    byte[] decryptedKey = rsa.doFinal(msg.getBuffer());
-
-		    // decrypt using server's public Key
-		    rsa.init(Cipher.DECRYPT_MODE,serverPubKey);
-		    byte[] encodedKey = rsa.doFinal(decryptedKey);
-
-		    // decode secretKey
-		    desKey = decodedKey(encodedKey);
-		    System.out.println("Client generate shared secret key");
-		    // send ready message
-		    newMsg = new Message(msg.getSrc(), local_addr, null);
-		    newMsg.addHeader(new EncryptHeader(EncryptHeader.SECRETKEY_READY));
-		    passDown(new Event(Event.MSG, newMsg));
-		}
-		catch(Exception e){
-		    System.out.println(e+"5");
-		}
-		return;
-
-	    default: break;
-	    }
-
-	    if (hdr.type != 0) System.out.println("This is ERROR");
-
-				// not have shared key yet
-				// this encrypted message is of no use, drop it
-	    if (desKey == null) return;
-
-				// if both the shared key and incoming message are not null
-				// decrypt the message
-	    if (msg.getBuffer()!=null)
-		{
-		    try{
-			cipher.init(Cipher.DECRYPT_MODE, desKey);
-			msg.setBuffer(cipher.doFinal(msg.getBuffer()));
-		    }
-		    catch(Exception e){
-			System.out.println(e+"6");
-		    }
-		}
-
-	    break;
-	}
-	passUp(evt);            // Pass up to the layer above us
-    }
-
-    public void down(Event evt) {
-	Message msg;
-	Message newMsg;
-	SecretKey key;
-	boolean leave = false;
-
-	switch(evt.getType()) {
-	case Event.VIEW_CHANGE:
-	    Vector new_members=(Vector)((View)evt.getArg()).getMembers();
-
-				// member size decreases: member leaves, need a new key
-	    if (members.size() > new_members.size()) leave = true;
-
-				// copy member list
-	    synchronized(members) {
-		members.removeAllElements();
-		if (new_members != null && new_members.size() > 0)
-		    for (int i=0; i < new_members.size(); i++)
-			members.addElement(new_members.elementAt(i));
-	    }
-
-				// redistribute/regain the new key because old member leaves
-	    if (leave){
-		// get coordinator address
-		Object obj = members.firstElement();
-
-		// if I'm the coordinator/key-server
-		if (obj.equals(local_addr)){
-		    //create the new shared key and distribute
-		    keyServer = true;
-		    keyServerAddr = local_addr;
-
-		    // reset shared key
-		    desKey=null;
-
-		    try {
-			//generate new shared key
-			KeyGenerator keyGen = KeyGenerator.getInstance(getAlgorithm(symAlgorithm));
-			keyGen.init(symInit);
-			desKey = keyGen.generateKey();
-		    }
-		    catch (Exception e) {
-			System.out.println(e+"7");
-		    }
-
-		}//end of local_addr == obj
-		// if I'm not the coordinator/key-server
-		else {
-		    keyServer = false;
-		    keyServerAddr = (Address)obj;
-						
-		    // reset shared key
-		    desKey = null;
-
-		    // client send clien's public key to server and request server's public key
-		    newMsg = new Message(keyServerAddr, local_addr, Kpair.getPublic().getEncoded());
-		    newMsg.addHeader(new EncryptHeader(EncryptHeader.KEY_REQUEST));
-		    passDown(new Event(Event.MSG, newMsg));
-		    System.out.println("Request new key");
-		}
-	    }
-	    break;
-
-	case Event.MSG:
-	    msg=(Message)evt.getArg();
-	    int i;
-
-				// For Server:
-				// if some members don't have the shared key yet
-	    if (!notReady.isEmpty()){
-		System.out.println("not Ready list  :"+ notReady.toString());
-		if (msg.getDest() == null){
-		    for (i = 0; i < notReady.size();i++){
-			newMsg = new Message(notReady.elementAt(i), local_addr, msg.getBuffer());
-			passDown(new Event(Event.MSG, newMsg));
-		    }
-		    break;
-		}
-		else{
-		    for (i = 0; i < notReady.size();i++){
-			if (msg.getDest() == notReady.elementAt(i)){
-			    passDown(evt);
-			    return;
-			}
-		    }
-		}
-	    }
-
-				// I already know the shared key
-	    if (desKey != null) {
-		try {
-		    // if the message is not empty, encrypt it
-		    if (msg.getBuffer() != null)
-			{
-			    cipher.init(Cipher.ENCRYPT_MODE, desKey);
-			    msg.setBuffer(cipher.doFinal(msg.getBuffer()));
-			    msg.addHeader(new EncryptHeader(0));
-			}
-		}
-		catch (Exception e) {
-		    System.out.println(e+"8");
-		}
-	    }
-	    break;
-	}
-	//System.out.println("Pass Down: "+evt.toString());
-	passDown(evt);          // Pass on to the layer below us
-    }
-
-    private SecretKey decodedKey(byte[] encodedKey){
-	SecretKey key = null;
-	try{
-	    SecretKeyFactory KeyFac = SecretKeyFactory.getInstance(getAlgorithm(symAlgorithm));
-	    SecretKeySpec desKeySpec = new SecretKeySpec(encodedKey, getAlgorithm(symAlgorithm));
-	    key = KeyFac.generateSecret((KeySpec)desKeySpec);
-	}
-	catch(Exception e){
-	    log.error(e);
-	}
-	return key;
-    }
-
-    private PublicKey generatePubKey(byte [] encodedKey){
-	PublicKey pubKey = null;
-	try{
-	    KeyFactory KeyFac = KeyFactory.getInstance(getAlgorithm(asymAlgorithm));
-	    X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(encodedKey);
-	    pubKey = KeyFac.generatePublic((KeySpec)x509KeySpec);
-	}
-	catch(Exception e){
-	    log.error(e);
-	}
-	return pubKey;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FC.java.txt
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FC.java.txt b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FC.java.txt
deleted file mode 100644
index 78f7a1a..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FC.java.txt
+++ /dev/null
@@ -1,643 +0,0 @@
-// $Id: FC.java.txt,v 1.1 2005/08/16 12:58:58 belaban Exp $
-
-package org.jgroups.protocols;
-
-import EDU.oswego.cs.dl.util.concurrent.ConcurrentReaderHashMap;
-import org.jgroups.*;
-import org.jgroups.stack.Protocol;
-import org.jgroups.util.BoundedList;
-import org.jgroups.util.CondVar;
-import org.jgroups.util.Streamable;
-
-import java.io.*;
-import java.util.*;
-
-/**
- * Simple flow control protocol based on a credit system. Each sender has a number of credits (bytes
- * to send). When the credits have been exhausted, the sender blocks. Each receiver also keeps track of
- * how many credits it has received from a sender. When credits for a sender fall below a threshold,
- * the receiver sends more credits to the sender. Works for both unicast and multicast messages.
- * <p>
- * Note that this protocol must be located towards the top of the stack, or all down_threads from JChannel to this
- * protocol must be set to false ! This is in order to block JChannel.send()/JChannel.down().
- * @author Bela Ban
- * @version $Revision: 1.1 $
- */
-public class FC extends Protocol {
-
-    /** My own address */
-    Address local_addr=null;
-
-    /** HashMap<Address,Long>: keys are members, values are credits left. For each send, the
-     * number of credits is decremented by the message size */
-    final Map sent=new HashMap(11);
-    // final Map sent=new ConcurrentHashMap(11);
-
-    /** HashMap<Address,Long>: keys are members, values are credits left (in bytes).
-     * For each receive, the credits for the sender are decremented by the size of the received message.
-     * When the credits are 0, we refill and send a CREDIT message to the sender. Sender blocks until CREDIT
-     * is received after reaching <tt>min_credits</tt> credits. */
-    final Map received=new ConcurrentReaderHashMap(11);
-    // final Map received=new ConcurrentHashMap(11);
-
-    /** We cache the membership */
-    final Vector members=new Vector(11);
-
-    /** List of members from whom we expect credits */
-    final Vector creditors=new Vector(11);
-
-    /** Max number of bytes to send per receiver until an ack must
-     * be received before continuing sending */
-    private long max_credits=50000;
-
-    /** Max time (in milliseconds) to block. If credit hasn't been received after max_block_time, we send
-     * a REPLENISHMENT request to the members from which we expect credits. A value <= 0 means to
-     * wait forever.
-     */
-    private long max_block_time=5000;
-
-    /** If credits fall below this limit, we send more credits to the sender. (We also send when
-     * credits are exhausted (0 credits left)) */
-    double min_threshold=0.25;
-
-    /** Computed as <tt>max_credits</tt> times <tt>min_theshold</tt>. If explicitly set, this will
-     * override the above computation */
-    private long min_credits=0;
-
-    /** Current blocking. True if blocking, else false */
-    private final CondVar blocking=new CondVar("blocking", Boolean.FALSE);
-
-    static final String name="FC";
-
-    private long start_blocking=0, stop_blocking=0;
-
-    private int num_blockings=0, num_replenishments=0, num_credit_requests=0;
-    private long total_time_blocking=0;
-
-    final BoundedList last_blockings=new BoundedList(50);
-
-    final static FcHeader REPLENISH_HDR=new FcHeader(FcHeader.REPLENISH);
-    final static FcHeader CREDIT_REQUEST_HDR=new FcHeader(FcHeader.CREDIT_REQUEST);
-
-
-
-    public String getName() {
-        return name;
-    }
-
-    public void resetStats() {
-        super.resetStats();
-        num_blockings=num_replenishments=num_credit_requests=0;
-        total_time_blocking=0;
-        last_blockings.removeAll();
-    }
-
-    public long getMaxCredits() {
-        return max_credits;
-    }
-
-    public void setMaxCredits(long max_credits) {
-        this.max_credits=max_credits;
-    }
-
-    public double getMinThreshold() {
-        return min_threshold;
-    }
-
-    public void setMinThreshold(double min_threshold) {
-        this.min_threshold=min_threshold;
-    }
-
-    public long getMinCredits() {
-        return min_credits;
-    }
-
-    public void setMinCredits(long min_credits) {
-        this.min_credits=min_credits;
-    }
-
-    public boolean isBlocked() {
-        Object obj=blocking.get();
-        return obj != null && obj instanceof Boolean && ((Boolean)obj).booleanValue();
-    }
-
-    public int getNumberOfBlockings() {
-        return num_blockings;
-    }
-
-    public long getTotalTimeBlocked() {
-        return total_time_blocking;
-    }
-
-    public double getAverageTimeBlocked() {
-        return num_blockings == 0? num_blockings : total_time_blocking / num_blockings;
-    }
-
-    public int getNumberOfReplenishmentsReceived() {
-        return num_replenishments;
-    }
-
-    public int getNumberOfCreditRequests() {
-        return num_credit_requests;
-    }
-
-    public String printSenderCredits() {
-        return printMap(sent);
-    }
-
-    public String printReceiverCredits() {
-        return printMap(received);
-    }
-
-    public String printCredits() {
-        StringBuffer sb=new StringBuffer();
-        sb.append("senders:\n").append(printMap(sent)).append("\n\nreceivers:\n").append(printMap(received));
-        return sb.toString();
-    }
-
-    public Map dumpStats() {
-        Map retval=super.dumpStats();
-        if(retval == null)
-            retval=new HashMap();
-        retval.put("senders", printMap(sent));
-        retval.put("receivers", printMap(received));
-        retval.put("num_blockings", new Integer(this.num_blockings));
-        retval.put("avg_time_blocked", new Double(getAverageTimeBlocked()));
-        retval.put("num_replenishments", new Integer(this.num_replenishments));
-        return retval;
-    }
-
-    public String showLastBlockingTimes() {
-        return last_blockings.toString();
-    }
-
-
-
-    public void unblock() {
-        unblockSender();
-    }
-
-
-
-    public boolean setProperties(Properties props) {
-        String  str;
-        boolean min_credits_set=false;
-
-        super.setProperties(props);
-        str=props.getProperty("max_credits");
-        if(str != null) {
-            max_credits=Long.parseLong(str);
-            props.remove("max_credits");
-        }
-
-        str=props.getProperty("min_threshold");
-        if(str != null) {
-            min_threshold=Double.parseDouble(str);
-            props.remove("min_threshold");
-        }
-
-        str=props.getProperty("min_credits");
-        if(str != null) {
-            min_credits=Long.parseLong(str);
-            props.remove("min_credits");
-            min_credits_set=true;
-        }
-
-        if(!min_credits_set)
-            min_credits=(long)((double)max_credits * min_threshold);
-
-        str=props.getProperty("max_block_time");
-        if(str != null) {
-            max_block_time=Long.parseLong(str);
-            props.remove("max_block_time");
-        }
-
-        if(props.size() > 0) {
-            log.error("FC.setProperties(): the following properties are not recognized: " + props);
-
-            return false;
-        }
-        return true;
-    }
-
-    public void stop() {
-        super.stop();
-        unblock();
-    }
-
-
-    /**
-     * We need to receive view changes concurrent to messages on the down events: a message might blocks, e.g.
-     * because we don't have enough credits to send to member P. However, if member P crashed, we need to unblock !
-     * @param evt
-     */
-    protected void receiveDownEvent(Event evt) {
-        if(evt.getType() == Event.VIEW_CHANGE) {
-            View v=(View)evt.getArg();
-            Vector mbrs=v.getMembers();
-            handleViewChange(mbrs);
-        }
-        super.receiveDownEvent(evt);
-    }
-
-    public void down(Event evt) {
-        switch(evt.getType()) {
-        case Event.MSG:
-            handleDownMessage(evt);
-            return;
-        }
-        passDown(evt); // this could potentially use the lower protocol's thread which may block
-    }
-
-
-    private synchronized void handleDownMessage(Event evt) {
-        if(Boolean.TRUE.equals(blocking.get())) { // blocked
-            waitUntilEnoughCreditsAvailable();
-        }
-        else {
-            // not blocked
-            boolean rc;
-            synchronized(sent) { // 'sent' is the same lock as blocking.getLock()...
-                rc=decrMessage((Message)evt.getArg());
-                if(rc == false) {
-                    if(trace)
-                        log.trace("blocking due to insufficient credits");
-                    blocking.set(Boolean.TRUE);
-                    start_blocking=System.currentTimeMillis();
-                    num_blockings++;
-                }
-            }
-            if(rc == false) {
-                waitUntilEnoughCreditsAvailable();
-            }
-        }
-
-        passDown(evt);
-    }
-
-
-
-    public void up(Event evt) {
-        switch(evt.getType()) {
-            case Event.SET_LOCAL_ADDRESS:
-                local_addr=(Address)evt.getArg();
-                break;
-            case Event.VIEW_CHANGE:
-                handleViewChange(((View)evt.getArg()).getMembers());
-                break;
-            case Event.MSG:
-                Message msg=(Message)evt.getArg();
-                FcHeader hdr=(FcHeader)msg.removeHeader(name);
-                if(hdr != null) {
-                    switch(hdr.type) {
-                    case FcHeader.REPLENISH:
-                        num_replenishments++;
-                        handleCredit(msg.getSrc());
-                        break;
-                    case FcHeader.CREDIT_REQUEST:
-                        num_credit_requests++;
-                        Address sender=msg.getSrc();
-                        if(trace)
-                            log.trace("received credit request from " + sender + ": sending credits");
-                        received.put(sender, new Long(max_credits));
-                        sendCredit(sender);
-                        break;
-                    default:
-                        log.error("header type " + hdr.type + " not known");
-                        break;
-                    }
-                    return; // don't pass message up
-                }
-                else {
-                    adjustCredit(msg);
-                }
-                break;
-        }
-        passUp(evt);
-    }
-
-
-
-    private void handleCredit(Address sender) {
-        if(sender == null) return;
-        StringBuffer sb=null;
-        boolean unblock=false;
-
-        if(trace) {
-            Long old_credit=(Long)sent.get(sender);
-            sb=new StringBuffer();
-            sb.append("received credit from ").append(sender).append(", old credit was ").
-                    append(old_credit).append(", new credits are ").append(max_credits).
-                    append(".\nCreditors before are: ").append(creditors);
-        }
-
-        synchronized(sent) {
-            sent.put(sender, new Long(max_credits));
-            if(creditors.size() > 0) {  // we are blocked because we expect credit from one or more members
-                removeCreditor(sender);
-                if(trace) {
-                    sb.append("\nCreditors after removal of ").append(sender).append(" are: ").append(creditors);
-                    log.trace(sb.toString());
-                }
-                if(creditors.size() == 0) {
-                    unblock=true;
-                }
-            }
-            else {  // no creditors, but still blocking: we need to unblock
-                if(Boolean.TRUE.equals(blocking.get()))
-                    unblock=true;
-            }
-        }
-        if(unblock) // moved this outside of the 'sent' synchronized block
-            unblockSender();
-    }
-
-
-    /**
-     * Check whether sender has enough credits left. If not, send him some more
-     * @param msg
-     */
-    private void adjustCredit(Message msg) {
-        Address src=msg.getSrc();
-        long    size=Math.max(24, msg.getLength());
-
-        if(src == null) {
-            if(log.isErrorEnabled()) log.error("src is null");
-            return;
-        }
-
-        if(decrementCredit(received, src, size, min_credits) == false) {
-            received.put(src, new Long(max_credits));
-            if(trace) log.trace("sending replenishment message to " + src);
-            sendCredit(src);
-        }
-    }
-
-
-
-    private void sendCredit(Address dest) {
-        Message  msg=new Message(dest, null, null);
-        msg.putHeader(name, REPLENISH_HDR);
-        passDown(new Event(Event.MSG, msg));
-    }
-
-    private void sendCreditRequest(final Address dest) {
-        Message  msg=new Message(dest, null, null);
-        msg.putHeader(name, CREDIT_REQUEST_HDR);
-        passDown(new Event(Event.MSG, msg));
-    }
-
-
-
-    /**
-     * Checks whether enough credits are available to send message. If not, blocks until enough credits
-     * are available
-     * @param evt Guaranteed to be a Message
-     * @return
-     */
-    private void waitUntilEnoughCreditsAvailable() {
-        while(true) {
-            try {
-                blocking.waitUntilWithTimeout(Boolean.FALSE, max_block_time);  // waits on 'sent'
-                break;
-            }
-            catch(TimeoutException e) {
-                List tmp=new ArrayList(creditors);
-                if(trace)
-                    log.trace("timeout occurred waiting for credits; sending credit request to " + tmp +
-                              ", creditors are " + creditors);
-                Address mbr;
-                for(Iterator it=tmp.iterator(); it.hasNext();) {
-                    mbr=(Address)it.next();
-                    sendCreditRequest(mbr);
-                }
-            }
-        }
-    }
-
-
-    /**
-     * Try to decrement the credits needed for this message and return true if successful, or false otherwise.
-     * For unicast destinations, the credits required are subtracted from the unicast destination member, for
-     * multicast messages the credits are subtracted from all current members in the group.
-     * @param msg
-     * @return false: will block, true: will not block
-     */
-    private boolean decrMessage(Message msg) {
-        Address dest;
-        long    size;
-        boolean success=true;
-
-        // ******************************************************************************************************
-        // this method is called by waitUntilEnoughCredits() which syncs on 'sent', so we don't need to sync here
-        // ******************************************************************************************************
-
-        if(msg == null) {
-            if(log.isErrorEnabled()) log.error("msg is null");
-            return true; // don't block !
-        }
-        dest=msg.getDest();
-        size=Math.max(24, msg.getLength());
-        if(dest != null && !dest.isMulticastAddress()) { // unicast destination
-            if(decrementCredit(sent, dest, size, 0)) {
-                return true;
-            }
-            else {
-                addCreditor(dest);
-                return false;
-            }
-        }
-        else {                 // multicast destination
-            for(Iterator it=members.iterator(); it.hasNext();) {
-                dest=(Address)it.next();
-                if(decrementCredit(sent, dest, size, 0) == false) {
-                    addCreditor(dest);
-                    success=false;
-                }
-            }
-        }
-        return success;
-    }
-
-
-
-
-    /** If message queueing is enabled, sends queued messages and unlocks sender (if successful) */
-    private void unblockSender() {
-        if(start_blocking > 0) {
-            stop_blocking=System.currentTimeMillis();
-            long diff=stop_blocking - start_blocking;
-            total_time_blocking+=diff;
-            last_blockings.add(new Long(diff));
-            stop_blocking=start_blocking=0;
-            if(trace)
-                log.trace("setting blocking=false, blocking time was " + diff + "ms");
-        }
-        if(trace)
-            log.trace("setting blocking=false");
-        blocking.set(Boolean.FALSE);
-    }
-
-
-    private void addCreditor(Address mbr) {
-        if(mbr != null && !creditors.contains(mbr))
-            creditors.add(mbr);
-    }
-
-    private void removeCreditor(Address mbr) {
-        creditors.remove(mbr);
-    }
-
-
-
-
-    /**
-     * Find the credits associated with <tt>dest</tt> and decrement its credits by credits_required. If the remaining
-     * value is less than or equal to 0, return false, else return true. Note that we will always subtract the credits.
-     * @param map
-     * @param dest
-     * @param credits_required Number of bytes required
-     * @param minimal_credits For the receiver: add minimal credits to check whether credits need to be sent
-     * @return Whether the required credits could successfully be subtracted from the credits left
-     */
-    private boolean decrementCredit(Map map, Address dest, long credits_required, long minimal_credits) {
-        long    credits_left, new_credits_left;
-        Long    tmp=(Long)map.get(dest);
-        boolean success;
-
-        if(tmp == null)
-            return true;
-
-        credits_left=tmp.longValue();
-        success=credits_left > (credits_required + minimal_credits);
-        new_credits_left=Math.max(0, credits_left - credits_required);
-        map.put(dest, new Long(new_credits_left));
-
-        if(success) {
-            return true;
-        }
-        else {
-            if(trace) {
-                StringBuffer sb=new StringBuffer();
-                sb.append("not enough credits left for ").append(dest).append(": left=").append(new_credits_left);
-                sb.append(", required+min_credits=").append((credits_required +min_credits)).append(", required=");
-                sb.append(credits_required).append(", min_credits=").append(min_credits);
-                log.trace(sb.toString());
-            }
-            return false;
-        }
-    }
-
-
-    void handleViewChange(Vector mbrs) {
-        Address addr;
-        if(mbrs == null) return;
-
-        if(trace) log.trace("new membership: " + mbrs);
-        members.clear();
-        members.addAll(mbrs);
-
-        synchronized(received) {
-            // add members not in membership to received hashmap (with full credits)
-            for(int i=0; i < mbrs.size(); i++) {
-                addr=(Address) mbrs.elementAt(i);
-                if(!received.containsKey(addr))
-                    received.put(addr, new Long(max_credits));
-            }
-            // remove members that left
-            for(Iterator it=received.keySet().iterator(); it.hasNext();) {
-                addr=(Address) it.next();
-                if(!mbrs.contains(addr))
-                    it.remove();
-            }
-        }
-
-        boolean unblock=false;
-        synchronized(sent) {
-            // add members not in membership to sent hashmap (with full credits)
-            for(int i=0; i < mbrs.size(); i++) {
-                addr=(Address) mbrs.elementAt(i);
-                if(!sent.containsKey(addr))
-                    sent.put(addr, new Long(max_credits));
-            }
-            // remove members that left
-            for(Iterator it=sent.keySet().iterator(); it.hasNext();) {
-                addr=(Address)it.next();
-                if(!mbrs.contains(addr))
-                    it.remove(); // modified the underlying map
-            }
-
-            // remove all creditors which are not in the new view
-            for(int i=0; i < creditors.size(); i++) {
-                Address creditor=(Address)creditors.elementAt(i);
-                if(!mbrs.contains(creditor))
-                    creditors.remove(creditor);
-            }
-
-            if(trace) log.trace("creditors are " + creditors);
-            if(creditors.size() == 0)
-                unblock=true;
-        }
-        if(unblock)
-            unblockSender();
-    }
-
-    private static String printMap(Map m) {
-        Map.Entry entry;
-        StringBuffer sb=new StringBuffer();
-        for(Iterator it=m.entrySet().iterator(); it.hasNext();) {
-            entry=(Map.Entry)it.next();
-            sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
-        }
-        return sb.toString();
-    }
-
-
-
-
-
-    public static class FcHeader extends Header implements Streamable {
-        public static final byte REPLENISH      = 1;
-        public static final byte CREDIT_REQUEST = 2; // the sender of the message is the requester
-
-        byte  type = REPLENISH;
-
-        public FcHeader() {
-
-        }
-
-        public FcHeader(byte type) {
-            this.type=type;
-        }
-
-        public long size() {
-            return Global.BYTE_SIZE;
-        }
-
-        public void writeExternal(ObjectOutput out) throws IOException {
-            out.writeByte(type);
-        }
-
-        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
-            type=in.readByte();
-        }
-
-        public void writeTo(DataOutputStream out) throws IOException {
-            out.writeByte(type);
-        }
-
-        public void readFrom(DataInputStream in) throws IOException, IllegalAccessException, InstantiationException {
-            type=in.readByte();
-        }
-
-        public String toString() {
-            switch(type) {
-            case REPLENISH: return "REPLENISH";
-            case CREDIT_REQUEST: return "CREDIT_REQUEST";
-            default: return "<invalid type>";
-            }
-        }
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_RAND.java.txt
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_RAND.java.txt b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_RAND.java.txt
deleted file mode 100644
index c261cde..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_RAND.java.txt
+++ /dev/null
@@ -1,287 +0,0 @@
-// $Id: FD_RAND.java.txt,v 1.3 2005/05/30 14:31:05 belaban Exp $
-
-package org.jgroups.protocols;
-
-import java.util.Properties;
-import java.util.Vector;
-
-
-class FdRandHeader extends Header {
-    static final int HEARTBEAT     = 0;
-    static final int HEARTBEAT_ACK = 1;
-    static final int SUSPECT       = 2;
-    static final int REGULAR       = 3;
-
-
-    int     type=HEARTBEAT;
-    Object  suspected_mbr=null;
-
-    FdRandHeader(int type) {this.type=type;}
-
-
-    public String toString() {
-	switch(type) {
-	case HEARTBEAT:
-	    return "[FD_RAND: heartbeat]";
-	case HEARTBEAT_ACK:
-	    return "[FD_RAND: heartbeat ack]";
-	case SUSPECT:
-	    return "[FD_RAND: suspect]";
-	case REGULAR:
-	    return "[FD_RAND: regular message]";
-	default:
-	    return "[FD_RAND: unknown type (" + type + ")]";
-	}
-    }
-}
-
-
-
-
-/**
-   Failure detection based on simple heartbeat protocol. Regularly polls randomly
-   selected members for liveness. Passes SUSPECT message up the stack when a member is
-   not reachable. The simple algorithms works as follows: the membership is known.  Each
-   HB protocol periodically sends a 'are-you-alive' message to a randomly selected
-   member, except itself. When a response hasn't been received for n milliseconds and m
-   tries, the corresponding member is suspected (and eventually excluded if faulty).<p>
-   FD_RAND starts when it detects (in a view change notification) that there are at least
-   2 members in the group. It stops running when the membership drops below 2.  */
-
-public class FD_RAND extends Protocol implements Runnable {
-    boolean      trace=false;
-    Address      ping_dest=null;
-    Address      local_addr=null;
-    Thread       pinger=null;
-    long         timeout=1000;  // 1 second between heartbeats
-    boolean      ack_received=false;
-    Vector       members=null;
-    int          num_tries=0;
-    final int    max_tries=2;   // 3 tries before suspecting
-    Object       ack_mutex=new Object();
-
-
-    public String  getName() {return "FD_RAND";}
-
-
-    public boolean setProperties(Properties props) {super.setProperties(props);
-	String     str;
-
-	this.props=props;
-	str=props.getProperty("trace");
-	if(str != null) {
-	    trace=new Boolean(str).booleanValue();
-	    props.remove("trace");
-	}
-	
-	str=props.getProperty("timeout");
-	if(str != null) {
-	    timeout=new Long(str).longValue();
-	    props.remove("timeout");
-	}
-
-	
-	str=props.getProperty("num_tries");
-	if(str != null) {
-	    num_tries=new Integer(str).intValue();
-	    props.remove("num_tries");
-	    if(num_tries < 1) {
-		log.error("FD_RAND.setProperties(): propertiy 'num_tries' must be at least 1 ! " +
-				   "Setting it to 1");
-		num_tries=1;
-	    }
-	}
-
-
-	if(props.size() > 0) {
-	    log.error("FD_RAND.setProperties(): the following properties are not recognized: " + props);
-	    
-	    return false;
-	}
-	return true;
-    }
-
-
-
-
-    Address getPingDest() {
-	Address retval=null;
-	int     r, size;
-
-	if(members == null || members.size() < 2 || local_addr == null)
-	    return null;
-	size=members.size();
-	while(members.size() > 1) {
-	    r=((int)(Math.random() * (size+1))) % size;
-	    retval=(Address)members.elementAt(r);
-	    if(local_addr.equals(retval))
-		continue;
-	    else
-		break;
-	}	
-	return retval;
-    }
-
-
-
-    public void up(Event evt) {
-	Message       msg;
-	FdRandHeader  hdr=null;
-
-	switch(evt.getType()) {
-
-	case Event.SET_LOCAL_ADDRESS:
-	    local_addr=(Address)evt.getArg();
-	    break;
-	    
-	case Event.MSG:
-	    msg=(Message)evt.getArg();
-
-	    try {
-		hdr=(FdRandHeader)msg.removeHeader();
-	    }
-	    catch(Exception e) {
-		log.error("FD_RAND.up(): " + e);
-	    }
-
-	    switch(hdr.type) {
-	    case FdRandHeader.HEARTBEAT:                         // heartbeat request; send heartbeat ack
-		Message      hb_ack=new Message(msg.getSrc(), null, null);
-		FdRandHeader tmp_hdr=new FdRandHeader(FdRandHeader.HEARTBEAT_ACK);
-		tmp_hdr.suspected_mbr=local_addr;		
-		hb_ack.addHeader(tmp_hdr);
-		passDown(new Event(Event.MSG, hb_ack));
-		return;                                          // don't pass up !
-	    case FdRandHeader.HEARTBEAT_ACK:                     // heartbeat ack
-		Object suspect=hdr.suspected_mbr;
-		if(ping_dest != null && ping_dest.equals(suspect)) {
-		    synchronized(ack_mutex) {
-			ack_received=true;
-			ack_mutex.notify();
-		    }
-		}
-		return;
-	    case FdRandHeader.SUSPECT:
-		if(hdr.suspected_mbr != null) {
-		    System.out.println("FD_RAND: SUSPECT(" + hdr.suspected_mbr + ")");
-		    passUp(new Event(Event.SUSPECT, hdr.suspected_mbr));
-		}
-		return;
-	    default:
-		break;
-	    }	    
-	}
-	passUp(evt);                                        // pass up to the layer above us
-    }
-
-
-
-    public void down(Event evt) {
-	Message msg;
-	
-	switch(evt.getType()) {
-	case Event.STOP:
-	    stop();
-	    passDown(evt);
-	    break;
-	    
-	case Event.VIEW_CHANGE:
-	    synchronized(this) {
-		stop();
-		View v=(View)evt.getArg();
-		members=v != null ? v.getMembers() : null;		
-		passDown(evt);
-		start();
-	    }
-	    break;
-
-	case Event.MSG:
-	    msg=(Message)evt.getArg();
-	    msg.addHeader(new FdRandHeader(FdRandHeader.REGULAR));  // regular message
-	    passDown(evt);
-	    break;
-
-	default:
-	    passDown(evt);
-	    break;
-	}
-    }
-
-
-
-    /**
-       Loop while more than 1 member available. Choose a member randomly (not myself !) and send a
-       heartbeat. Wait for ack. If ack not received withing timeout, mcast SUSPECT message.
-     */
-    public void run() {
-	Message       suspect_msg, hb_req;
-	FdRandHeader  hdr;
-
-
-	while(members.size() > 1 && pinger != null) {
-	    ack_received=false;
-	    num_tries=0;
-
-	    ping_dest=getPingDest();
-
-	    while(!ack_received && num_tries <= max_tries && pinger != null) {
-		hb_req=new Message(ping_dest, null, null);
-		hb_req.addHeader(new FdRandHeader(FdRandHeader.HEARTBEAT));  // send heartbeat request
-		passDown(new Event(Event.MSG, hb_req));	    
-		
-		synchronized(ack_mutex) {                                    // wait for heartbeat ack
-		    try {ack_mutex.wait(timeout);}
-		    catch(Exception e) {}
-		}
-		if(pinger == null) return;
-		if(ack_received) {
-		    Util.sleep(timeout);
-		    break;
-		}
-		else {
-		    if(num_tries >= max_tries) {
-			System.out.println("FD_RAND(" + local_addr + "): received no heartbeat ack from " + 
-					   ping_dest + ", suspecting it");
-			hdr=new FdRandHeader(FdRandHeader.SUSPECT);
-			hdr.suspected_mbr=ping_dest;
-			suspect_msg=new Message(null, null, null);  // mcast SUSPECT to all members
-			suspect_msg.addHeader(hdr);
-			passDown(new Event(Event.MSG, suspect_msg));
-			break;
-		    }
-		    else {
-			num_tries++;
-			Util.sleep(timeout);
-		    }
-		}
-	    }
-	}
-    }
-
-
-
-
-
-    void start() {
-	if(pinger == null) {
-	    pinger=new Thread(this, "FD_RAND.PingerThread");
-	    pinger.start();
-	}
-    }
-
-
-    void stop() {
-	Thread tmp=null;
-	num_tries=0;
-	ack_received=false;
-	if(pinger != null && pinger.isAlive()) {
-	    tmp=pinger;
-	    pinger=null;
-	    tmp.interrupt();
-	    try {tmp.join(timeout);} catch(Exception ex) {}
-	}
-	pinger=null;
-    }
-
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/8b2ea77d/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_SHUN.java.txt
----------------------------------------------------------------------
diff --git a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_SHUN.java.txt b/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_SHUN.java.txt
deleted file mode 100644
index c21c0ac..0000000
--- a/gemfire-jgroups/src/main/java/com/gemstone/org/jgroups/protocols/obsolete/FD_SHUN.java.txt
+++ /dev/null
@@ -1,323 +0,0 @@
-// $Id: FD_SHUN.java.txt,v 1.3 2005/05/30 14:31:05 belaban Exp $
-
-package org.jgroups.protocols;
-
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.Vector;
-
-
-class FdHeaderShun extends Header {
-
-    static final int HEARTBEAT     = 0;
-    static final int HEARTBEAT_ACK = 1;
-    static final int SUSPECT       = 2;
-    static final int NOT_MEMBER    = 3;  // received as response by pinged mbr when we are not a member
-
-
-
-    int      type=HEARTBEAT;
-    Address  suspected_mbr=null;
-    Address  from=null;  // member who detected that suspected_mbr has failed
-
-    FdHeaderShun(int type) {this.type=type;}
-
-
-    public String toString() {
-	switch(type) {
-	case HEARTBEAT:
-	    return "[FD_SHUN: heartbeat]";
-	case HEARTBEAT_ACK:
-	    return "[FD_SHUN: heartbeat ack]";
-	case SUSPECT:
-	    return "[FD_SHUN: SUSPECT (suspected_mbr=" + suspected_mbr + ", from=" + from + ")]";
-	case NOT_MEMBER: return "[FD_SHUN: NOT_MEMBER]";
-	default:
-	    return "[FD_SHUN: unknown type (" + type + ")]";
-	}
-    }
-}
-
-
-
-
-/**
-   Failure detection based on simple heartbeat protocol. Regularly polls members for
-   liveness. Passes SUSPECT message up the stack when a member is not reachable. The simple
-   algorithms works as follows: the membership is known and ordered. Each HB protocol
-   periodically sends a 'are-you-alive' message to its *neighbor*. A neighbor is the next in
-   rank in the membership list. It is recomputed upon a view change. When a response hasn't
-   been received for n milliseconds and m tries, the corresponding member is suspected (and
-   eventually excluded if faulty).<p>
-   FD_SHUN starts when it detects (in a view change notification) that there are at least
-   2 members in the group. It stops running when the membership drops below 2.<p>
-   When a message is received from the monitored neighbor member, it causes the pinger thread to
-   'skip' sending the next are-you-alive message. Thus, traffic is reduced.<p>
-   When we receive a ping from a member that's not in the membership list, we shun it by sending it a 
-   NOT_MEMBER message. That member will then leave the group (and possibly rejoin).
-*/
-
-public class FD_SHUN extends Protocol implements Runnable {
-    boolean      trace=false;
-    Address      ping_dest=null;
-    Address      local_addr=null;
-    Thread       pinger=null;   // pinger thread
-    long         timeout=3000;  // number of millisecs to wait for an are-you-alive msg
-    boolean      ack_received=false, skip_heartbeat=false;
-    int          num_tries=0;
-    int          max_tries=2;   // number of times to send a are-you-alive msg (tot time= max_tries*timeout)
-    Vector       members=null;
-    Hashtable    invalid_pingers=new Hashtable();  // keys=Address, val=Integer (number of pings from suspected mbrs)
-
-
-
-    public String  getName() {return "FD_SHUN";}
-
-
-    public boolean setProperties(Properties props) {super.setProperties(props);
-	String     str;
-
-	this.props=props;
-	str=props.getProperty("trace");
-	if(str != null) {
-	    trace=new Boolean(str).booleanValue();
-	    props.remove("trace");
-	}
-
-	str=props.getProperty("timeout");
-	if(str != null) {
-	    timeout=new Long(str).longValue();
-	    props.remove("timeout");
-	}
-
-	str=props.getProperty("max_tries");  // before suspecting a member
-	if(str != null) {
-	    max_tries=new Integer(str).intValue();
-	    props.remove("max_tries");
-	}
-	if(props.size() > 0) {
-	    log.error("FD_SHUN.setProperties(): the following properties are not recognized: " + props);
-	    
-	    return false;
-	}
-	return true;
-    }
-
-
-
-    Address getPingDest(Vector members) {
-	Address tmp, retval=null;
-
-	if(members == null || members.size() < 2 || local_addr == null)
-	    return null;
-	for(int i=0; i < members.size(); i++) {
-	    tmp=(Address)members.elementAt(i);
-	    if(local_addr.equals(tmp)) {
-		if(i + 1 >= members.size())
-		    retval=(Address)members.elementAt(0);
-		else
-		    retval=(Address)members.elementAt(i+1);
-		break;
-	    }
-	}
-	return retval;
-    }
-
-
-
-    public void up(Event evt) {
-	Message       msg;
-	FdHeaderShun  hdr=null;
-	Address       sender;
-	Object        tmphdr;
-	int           num_pings=0;
-
-	switch(evt.getType()) {
-
-	case Event.SET_LOCAL_ADDRESS:
-	    local_addr=(Address)evt.getArg();
-	    break;
-
-	case Event.MSG:
-	    msg=(Message)evt.getArg();
-	    tmphdr=msg.peekHeader();
-	    if(tmphdr == null || !(tmphdr instanceof FdHeaderShun)) {
-		if(ping_dest != null && (sender=msg.getSrc()) != null) {
-		    if(ping_dest.equals(sender)) {
-			ack_received=true;
-			num_tries=0;
-			skip_heartbeat=true;
-		    }
-		}
-		break;  // message did not originate from FD_SHUN layer, just pass up
-	    }
-
-	    hdr=(FdHeaderShun)msg.removeHeader();
-
-	    switch(hdr.type) {
-	    case FdHeaderShun.HEARTBEAT:                       // heartbeat request; send heartbeat ack
-		Address      hb_sender=msg.getSrc();
-		Message      hb_ack=new Message(msg.getSrc(), null, null);
-		FdHeaderShun tmp_hdr=new FdHeaderShun(FdHeaderShun.HEARTBEAT_ACK);
-
-		// 1.  Send an ack
-		tmp_hdr.suspected_mbr=local_addr;
-		hb_ack.addHeader(tmp_hdr);
-		passDown(new Event(Event.MSG, hb_ack));
-
-		// 2. If sender is not a member, send a SUSPECT to sender (after n pings received)
-		if(hb_sender != null && members != null && !members.contains(hb_sender)) {
-		    if(invalid_pingers.containsKey(hb_sender)) {
-			num_pings=((Integer)invalid_pingers.get(hb_sender)).intValue();
-			if(num_pings >= max_tries) {
-			    log.error("** FD_SHUN.up(HEARTBEAT): sender " + hb_sender +
-					       " is not member in " + members + " ! Telling it to leave group");
-			    hb_ack=new Message(msg.getSrc(), null, null);
-			    tmp_hdr=new FdHeaderShun(FdHeaderShun.NOT_MEMBER);
-			    tmp_hdr.from=local_addr;
-			    tmp_hdr.suspected_mbr=hb_sender;
-			    hb_ack.addHeader(tmp_hdr);
-			    passDown(new Event(Event.MSG, hb_ack));
-			    invalid_pingers.remove(hb_sender);
-			}
-			else {
-			    num_pings++;
-			    invalid_pingers.put(hb_sender, new Integer(num_pings));
-			}
-		    }
-		    else {
-			num_pings++;
-			invalid_pingers.put(hb_sender, new Integer(num_pings));
-		    }
-		}
-		break;                                     // don't pass up !
-
-	    case FdHeaderShun.HEARTBEAT_ACK:                   // heartbeat ack
-		Object suspect=hdr.suspected_mbr;
-		if(ping_dest != null && ping_dest.equals(suspect)) {
-		    ack_received=true;
-		    num_tries=0;
-		}
-		else {
-		    stop();
-		    ping_dest=(Address)getPingDest(members);
-		    if(ping_dest != null)
-			start();
-		}
-		break;
-
-	    case FdHeaderShun.SUSPECT:
-		if(hdr.suspected_mbr != null) {
-		    if(trace)
-			System.out.println("FD_SHUN.up(SUSPECT): " + hdr);
-		    passUp(new Event(Event.SUSPECT, hdr.suspected_mbr));
-		    passDown(new Event(Event.SUSPECT, hdr.suspected_mbr));
-		}
-		break;
-
-	    case FdHeaderShun.NOT_MEMBER:
-		System.out.println("** FD_SHUN.up(NOT_MEMBER): I'm being shunned; exiting");
-		passUp(new Event(Event.EXIT));
-		break;
-	    }
-	    return;
-	}
-	passUp(evt);                                        // pass up to the layer above us
-    }
-
-
-
-    public void down(Event evt) {
-	Message msg;
-
-	switch(evt.getType()) {
-	case Event.STOP:
-	    stop();
-	    passDown(evt);
-	    break;
-
-	case Event.VIEW_CHANGE:
-	    synchronized(this) {
-		stop();
-		View v=(View)evt.getArg();
-		members=(v != null) ? v.getMembers() : null;
-		passDown(evt);
-		ping_dest=(Address)getPingDest(members);
-		if(ping_dest != null)
-		    start();
-	    }
-	    break;
-
-	default:
-	    passDown(evt);
-	    break;
-	}
-    }
-
-
-
-
-    public void run() {
-	Message       suspect_msg, hb_req;
-	FdHeaderShun  hdr;
-
-	while(ping_dest != null && pinger != null) {
-	    ack_received=false;
-	    if(!skip_heartbeat) {
-		hb_req=new Message(ping_dest, null, null);
-		hb_req.addHeader(new FdHeaderShun(FdHeaderShun.HEARTBEAT));  // send heartbeat request
-		if(trace) System.out.println("FD_SHUN: sending are-you-alive msg to " + ping_dest);
-		passDown(new Event(Event.MSG, hb_req));
-	    }
-	    skip_heartbeat=false;
-	    Util.sleep(timeout);
-	    if(pinger == null)
-		break;
-
-	    if(!ack_received && num_tries >= max_tries) {
-		if(trace)
-		    System.out.println("FD_SHUN(" + local_addr + "): received no heartbeat ack from " +
-				       ping_dest + ", suspecting it");
-		hdr=new FdHeaderShun(FdHeaderShun.SUSPECT);
-		hdr.suspected_mbr=ping_dest;
-		hdr.from=local_addr;
-		suspect_msg=new Message(null, null, null);       // mcast SUSPECT to all members
-		suspect_msg.addHeader(hdr);
-		passDown(new Event(Event.MSG, suspect_msg));
-		members.removeElement(ping_dest);                // try the next neighbor
-		ping_dest=(Address)getPingDest(members);
-	    }
-	    else {
-		if(trace && !skip_heartbeat)
-		    System.out.println("FD_SHUN: received heartbeat ack from " + ping_dest);
-		num_tries++;
-	    }
-	}
-    }
-
-
-
-
-
-    void start() {
-	if(pinger == null) {
-	    pinger=new Thread(this, "FD_SHUN.PingerThread");
-	    pinger.start();
-	}
-    }
-
-    void stop() {
-	Thread tmp=null;
-	if(pinger != null && pinger.isAlive()) {
-	    tmp=pinger;
-	    pinger=null;
-	    tmp.interrupt();
-	    try {tmp.join(timeout);} catch(Exception ex) {}
-	    if(tmp.isAlive())
-		log.error("**** FD_SHUN.stop(): interrupted pinger thread is still alive !");
-	}
-	pinger=null;
-    }
-
-
-}


Mime
View raw message