1 3 package org.jgroups.protocols; 4 5 import org.jgroups.Event; 6 import org.jgroups.Message; 7 import org.jgroups.View; 8 import org.jgroups.stack.Protocol; 9 import org.jgroups.util.Util; 10 11 import java.util.Vector ; 12 13 14 17 18 public class LOSS extends Protocol { 19 final Vector members=new Vector (); 20 final long i=0; 21 boolean drop_next_msg=false; 22 23 24 public String getName() {return "LOSS";} 25 26 27 28 29 public void reset() {} 30 31 32 33 34 37 39 46 48 50 56 59 62 63 64 65 66 public void down(Event evt) { 67 Message msg; 68 69 switch(evt.getType()) { 70 71 case Event.TMP_VIEW: 72 case Event.VIEW_CHANGE: 73 Vector new_members=((View)evt.getArg()).getMembers(); 74 synchronized(members) { 75 members.removeAllElements(); 76 if(new_members != null && new_members.size() > 0) 77 for(int i=0; i < new_members.size(); i++) 78 members.addElement(new_members.elementAt(i)); 79 } 80 passDown(evt); 81 break; 82 83 case Event.MSG: 84 if(drop_next_msg) { 85 drop_next_msg=false; 86 msg=(Message)evt.getArg(); 87 88 if(msg.getDest() != null && !msg.getDest().isMulticastAddress()) { 89 break; 90 } 91 92 93 System.out.println("###### LOSS.down(): dropping msg " + Util.printMessage(msg)); 94 95 return; 96 } 97 break; 98 99 case Event.DROP_NEXT_MSG: 100 drop_next_msg=true; 101 break; 102 } 103 104 105 106 passDown(evt); } 108 109 110 111 } 112 | Popular Tags |