1 24 25 package utobcast.draw; 26 27 import java.net.InetAddress ; 28 import java.util.HashMap ; 29 import java.util.Map ; 30 31 import org.objectweb.dream.adl.FactoryFactory; 32 import org.objectweb.dream.protocol.utobcast.ProcessMembership; 33 import org.objectweb.dream.util.Util; 34 import org.objectweb.fractal.adl.Factory; 35 import org.objectweb.fractal.api.Component; 36 import org.objectweb.fractal.api.control.ContentController; 37 import org.objectweb.fractal.rmi.registry.Registry; 38 import org.objectweb.fractal.util.Fractal; 39 40 import utobcast.TCPProcess; 41 42 45 public class Main 46 { 47 48 54 public static void main(String [] args) throws Exception 55 { 56 Factory f = FactoryFactory.getFactory(); 57 Map ctx = new HashMap (); 58 59 ctx.put("naming-service", Registry.getRegistry("zirconium.inrialpes.fr")); 61 Component composite = (Component) f.newComponent("utobcast.draw.Draw", ctx); 62 63 Fractal.getLifeCycleController(composite).startFc(); 65 66 68 70 TCPProcess[] tcpProcesses = new TCPProcess[3]; 71 tcpProcesses[0] = new TCPProcess((short) 0, InetAddress.getLocalHost(), 72 30000); 73 tcpProcesses[1] = new TCPProcess((short) 1, InetAddress.getLocalHost(), 74 30001); 75 tcpProcesses[2] = new TCPProcess((short) 2, InetAddress.getLocalHost(), 76 30002); 77 82 ContentController contentController = Fractal 83 .getContentController(composite); 84 85 for (int i = 0; i < tcpProcesses.length; i++) 86 { 87 Component node = Util.getComponentByName(contentController, Integer 88 .toString(i)); 89 ContentController cc = Fractal.getContentController(node); 90 ProcessMembership processMembershipItf = (ProcessMembership) Util 91 .getComponentByName(cc, "UTOBcastProtocol/ProcessMembership") 92 .getFcInterface(ProcessMembership.ITF_NAME); 93 processMembershipItf.setLeader(tcpProcesses[0]); 94 processMembershipItf.setBackup(tcpProcesses[1]); 95 processMembershipItf.setMyself(tcpProcesses[i]); 96 } 97 98 ProcessMembership leaderProcessMembershipItf = (ProcessMembership) Util 100 .getComponentByName(contentController, 101 "0/UTOBcastProtocol/ProcessMembership").getFcInterface( 102 ProcessMembership.ITF_NAME); 103 104 ProcessMembership backupMembershipItf = (ProcessMembership) Util 106 .getComponentByName(contentController, 107 "1/UTOBcastProtocol/ProcessMembership").getFcInterface( 108 ProcessMembership.ITF_NAME); 109 110 for (int i = 0; i < tcpProcesses.length; i++) 111 { 112 leaderProcessMembershipItf.addProcess(tcpProcesses[i]); 113 backupMembershipItf.addProcess(tcpProcesses[i]); 114 } 115 116 } 117 } | Popular Tags |