1 3 package org.jgroups.protocols; 4 5 import org.apache.commons.logging.Log; 6 import org.apache.commons.logging.LogFactory; 7 import org.jgroups.*; 8 9 import java.util.Vector ; 10 11 12 13 public abstract class GmsImpl { 14 protected GMS gms=null; 15 16 protected final Log log=LogFactory.getLog(getClass()); 17 18 public abstract void init(); 20 public abstract void join(Address mbr); 21 public abstract void leave(Address mbr); 22 public abstract void suspect(Address mbr); 23 public abstract void merge(Vector coords); 24 25 public abstract boolean handleJoin(Address mbr); 26 public abstract void handleLeave(Address mbr, boolean suspected); 27 public abstract void handleViewChange(ViewId new_view, Vector mbrs); 28 public abstract View handleMerge(ViewId other_view,Vector other_members); 29 public abstract void handleSuspect(Address mbr); 30 31 public boolean handleUpEvent(Event evt) {return true;} 32 public boolean handleDownEvent(Event evt) {return true;} 33 34 35 36 37 protected void wrongMethod(String method_name) { 38 if(log.isErrorEnabled()) log.error("method " + method_name + 39 "() should not be sent to an instance of " + getClass().getName()); 40 } 41 42 43 44 49 protected boolean iWouldBeCoordinator(Vector new_mbrs) { 50 Membership tmp_mbrs=gms.members.copy(); 51 tmp_mbrs.merge(new_mbrs, null); 52 tmp_mbrs.sort(); 53 if(tmp_mbrs.size() <= 0 || gms.local_addr == null) 54 return false; 55 return gms.local_addr.equals(tmp_mbrs.elementAt(0)); 56 } 57 58 } 59 | Popular Tags |