1 31 package org.objectweb.proactive.examples.garden; 32 33 import org.apache.log4j.Logger; 34 import org.objectweb.proactive.core.config.ProActiveConfiguration; 35 36 37 50 public class Flower { 51 52 static Logger logger = Logger.getLogger(Flower.class.getName()); 53 54 private String myName; 55 56 public Flower() { 57 super(); 58 } 59 60 61 public Flower(String name) { 62 this.myName = name; 63 logger.info("I am flower " + this.myName + " just been created"); 64 } 65 66 67 public String getName() { 68 return this.myName; 69 } 70 71 72 public void acceptReference(Flower f) { 73 logger.info("I am flower " + this.myName + " and I received a reference on flower " + f.getName()); 74 } 75 76 public int bob() { 77 return 90; 78 } 79 80 81 public static void main(String [] args) { 82 ProActiveConfiguration.load(); 83 try { 84 String nodeName1 = "///vm1"; 86 String nodeName2 = "///vm2"; 87 if (args.length >= 1) nodeName1 = args[0]; 88 if (args.length >= 2) nodeName2 = args[1]; 89 logger.info("Node 1 : "+nodeName1); 90 logger.info("Node 2 : "+nodeName2); 91 Flower a = (Flower)org.objectweb.proactive.ProActive.newActive(Flower.class.getName(), new Object []{"Amaryllis - LOCAL"}); 92 Flower b = (Flower)org.objectweb.proactive.ProActive.newActive(Flower.class.getName(), new Object []{"Bouton d'Or - LOCAL"}); 93 Flower c = (Flower)org.objectweb.proactive.ProActive.newActive(Flower.class.getName(), new Object []{"Coquelicot - vm1"}, nodeName1); 94 Flower d = (Flower)org.objectweb.proactive.ProActive.newActive(Flower.class.getName(), new Object []{"Daliah - vm1"}, nodeName1); 95 Flower e = (Flower)org.objectweb.proactive.ProActive.newActive(Flower.class.getName(), new Object []{"Eglantine - vm2"}, nodeName2); 96 Flower f = (Flower)org.objectweb.proactive.ProActive.newActive(Flower.class.getName(), new Object []{"Rose - vm2"}, nodeName2); 97 100 a.acceptReference(b); 102 103 d.acceptReference(b); 105 106 a.acceptReference(c); 108 109 e.acceptReference(c); 111 112 e.acceptReference(f); 116 } catch (Exception e) { 117 e.printStackTrace(); 118 } finally { 119 try { 120 Thread.sleep(1000); 121 } catch (InterruptedException e) { 122 } 123 System.exit(0); 124 } 125 } 126 } | Popular Tags |