1 3 package org.jgroups.protocols.pbcast; 4 5 import org.apache.commons.logging.Log; 6 import org.apache.commons.logging.LogFactory; 7 import org.jgroups.Address; 8 import org.jgroups.Event; 9 import org.jgroups.Membership; 10 import org.jgroups.View; 11 12 import java.util.Vector ; 13 14 15 16 17 18 public abstract class GmsImpl { 19 protected GMS gms=null; 20 protected final Log log=LogFactory.getLog(getClass()); 21 boolean leaving=false; 22 23 public abstract void join(Address mbr); 24 public abstract void leave(Address mbr); 25 26 public abstract void handleJoinResponse(JoinRsp join_rsp); 27 public abstract void handleLeaveResponse(); 28 29 public abstract void suspect(Address mbr); 30 public abstract void unsuspect(Address mbr); 31 32 public void merge(Vector other_coords) {;} public void handleMergeRequest(Address sender, Object merge_id) {;} public void handleMergeResponse(MergeData data, Object merge_id) {;} public void handleMergeView(MergeData data, Object merge_id) {;} public void handleMergeCancelled(Object merge_id) {;} 38 public abstract JoinRsp handleJoin(Address mbr); 39 public abstract void handleLeave(Address mbr, boolean suspected); 40 public abstract void handleViewChange(View new_view, Digest digest); 41 public abstract void handleSuspect(Address mbr); 42 public void handleExit() {;} 43 44 public boolean handleUpEvent(Event evt) {return true;} 45 public boolean handleDownEvent(Event evt) {return true;} 46 47 public void init() throws Exception {leaving=false;} 48 public void start() throws Exception {leaving=false;} 49 public void stop() {leaving=true;} 50 51 52 53 54 protected void wrongMethod(String method_name) { 55 if(log.isErrorEnabled()) 56 log.error(method_name + "() should not be invoked on an instance of " + getClass().getName()); 57 } 58 59 60 61 66 protected boolean iWouldBeCoordinator(Vector new_mbrs) { 67 Membership tmp_mbrs=gms.members.copy(); 68 tmp_mbrs.merge(new_mbrs, null); 69 tmp_mbrs.sort(); 70 if(tmp_mbrs.size() <= 0 || gms.local_addr == null) 71 return false; 72 return gms.local_addr.equals(tmp_mbrs.elementAt(0)); 73 } 74 75 } 76 | Popular Tags |