# HG changeset patch # User kazz # Date 1328338985 -32400 # Node ID 1a498f436332eba8ae491a0c4c25c2318821ec93 # Parent ae24d5d40c107dad5081d57b7e14e6a392022629 bug fix for time calculate diff -r ae24d5d40c10 -r 1a498f436332 scripts/ring_manager_run.sh --- a/scripts/ring_manager_run.sh Sat Feb 04 14:31:07 2012 +0900 +++ b/scripts/ring_manager_run.sh Sat Feb 04 16:03:05 2012 +0900 @@ -5,15 +5,16 @@ fi max=$1 +count=$2 ruby ./topology/ring.rb $1 > ./topology/ring.dot dot -Tpng ./topology/ring.dot > ./topology/ring.png open ./topology/ring.png -java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/ring.dot -log ./output/manager.log -level debug & +java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/ring.dot -log ./output/manager.log -level info & cnt=0 while [ $cnt -lt $max ] do - java -cp ../Alice.jar alice.test.topology.ring.RingTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/ring${cnt}.log -level debug & + java -cp ../Alice.jar alice.test.topology.ring.RingTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/ring${cnt}.log -level info -count $count & cnt=`expr $cnt + 1` done wait diff -r ae24d5d40c10 -r 1a498f436332 src/alice/test/topology/fish/DistributedFish.java --- a/src/alice/test/topology/fish/DistributedFish.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/test/topology/fish/DistributedFish.java Sat Feb 04 16:03:05 2012 +0900 @@ -6,7 +6,7 @@ public static void main(String[] args) { FishConfig conf = new FishConfig(args); - new TopologyNode(conf, StartFish.class); + new TopologyNode(conf, new StartFish()); } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/test/topology/ring/CheckMyName.java --- a/src/alice/test/topology/ring/CheckMyName.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/test/topology/ring/CheckMyName.java Sat Feb 04 16:03:05 2012 +0900 @@ -10,15 +10,20 @@ public class CheckMyName extends CodeSegment { - Receiver host = ids.create(CommandType.PEEK); - Logger logger = Logger.getLogger(CheckMyName.class); + public Receiver host = ids.create(CommandType.PEEK); + + private Logger logger = Logger.getLogger(CheckMyName.class); + private RingTopologyConfig conf; + public CheckMyName(RingTopologyConfig conf) { + this.conf = conf; + } @Override public void run() { String host = this.host.asString(); logger.debug(host); if (host.equals("node0")) { ods.put("local", "counter", 0); - FirstRingMessagePassing cs1 = new FirstRingMessagePassing(new Date()); + FirstRingMessagePassing cs1 = new FirstRingMessagePassing(new Date(), conf.count); cs1.counter.setKey("local", "counter"); RingFinish cs2 = new RingFinish("manager"); cs2.finish.setKey("local", "finish"); diff -r ae24d5d40c10 -r 1a498f436332 src/alice/test/topology/ring/FirstRingMessagePassing.java --- a/src/alice/test/topology/ring/FirstRingMessagePassing.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/test/topology/ring/FirstRingMessagePassing.java Sat Feb 04 16:03:05 2012 +0900 @@ -11,10 +11,12 @@ public class FirstRingMessagePassing extends CodeSegment { public Receiver counter = ids.create(CommandType.TAKE); - public Date startTime; + private Date startTime; + private int count; - public FirstRingMessagePassing(Date startTime) { + public FirstRingMessagePassing(Date startTime, int count) { this.startTime = startTime; + this.count = count; } @Override @@ -22,8 +24,8 @@ int counter = this.counter.asInteger(); ++counter; ods.put("right", "counter", counter); - - if (counter >= 10) { + System.out.println(count); + if (counter >= count) { ods.put("right", "finish", ValueFactory.createNilValue()); Date endTime = new Date(); long time = endTime.getTime() - startTime.getTime(); @@ -31,7 +33,7 @@ return; } - FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime); + FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count); cs.counter.setKey("local", "counter"); } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/test/topology/ring/RingTopology.java --- a/src/alice/test/topology/ring/RingTopology.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/test/topology/ring/RingTopology.java Sat Feb 04 16:03:05 2012 +0900 @@ -6,7 +6,7 @@ public static void main(String[] args) { RingTopologyConfig conf = new RingTopologyConfig(args); - new TopologyNode(conf, StartRing.class); + new TopologyNode(conf, new StartRing(conf)); } } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/test/topology/ring/RingTopologyConfig.java --- a/src/alice/test/topology/ring/RingTopologyConfig.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/test/topology/ring/RingTopologyConfig.java Sat Feb 04 16:03:05 2012 +0900 @@ -6,7 +6,7 @@ public int count = 10; public RingTopologyConfig(String[] args) { super(args); - for (int i = 0; i< args.length; i++) { + for (int i = 0; i < args.length; i++) { if ("-count".equals(args[i])) { this.count = new Integer(args[++i]); } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/test/topology/ring/StartRing.java --- a/src/alice/test/topology/ring/StartRing.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/test/topology/ring/StartRing.java Sat Feb 04 16:03:05 2012 +0900 @@ -3,10 +3,13 @@ import alice.codesegment.CodeSegment; public class StartRing extends CodeSegment { - + private RingTopologyConfig conf; + public StartRing(RingTopologyConfig conf) { + this.conf = conf; + } @Override public void run() { - CheckMyName cs = new CheckMyName(); + CheckMyName cs = new CheckMyName(conf); cs.host.setKey("local", "host"); } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/topology/node/ConfigurationFinish.java --- a/src/alice/topology/node/ConfigurationFinish.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/topology/node/ConfigurationFinish.java Sat Feb 04 16:03:05 2012 +0900 @@ -10,10 +10,10 @@ public Receiver reverseCount = ids.create(CommandType.PEEK); public Receiver configNodeNum = ids.create(CommandType.PEEK); - private Class clazz; + private CodeSegment startCS; - public ConfigurationFinish(Class clazz) { - this.clazz = clazz; + public ConfigurationFinish(CodeSegment startCS) { + this.startCS = startCS; } @Override @@ -21,13 +21,13 @@ if (reverseCount.val.equals(configNodeNum.val)) { ods.put("manager", "done", ValueFactory.createNilValue()); - Start cs = new Start(clazz); + Start cs = new Start(startCS); cs.done.setKey("manager", "start"); return; } - ConfigurationFinish cs3 = new ConfigurationFinish(clazz); + ConfigurationFinish cs3 = new ConfigurationFinish(startCS); cs3.reverseCount.setKey("local", "reverseCount", this.reverseCount.index); cs3.configNodeNum.setKey("local", "configNodeNum"); } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/topology/node/Start.java --- a/src/alice/topology/node/Start.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/topology/node/Start.java Sat Feb 04 16:03:05 2012 +0900 @@ -10,25 +10,18 @@ public Receiver done = ids.create(CommandType.PEEK); private Logger logger = Logger.getLogger(Start.class); - private Class clazz; + private CodeSegment startCS; - public Start(Class clazz) { - this.clazz = clazz; + public Start(CodeSegment startCS) { + this.startCS = startCS; } @Override public void run() { logger.info("Configuration finished."); - if (clazz == null) + if (startCS == null) return; - try { - clazz.newInstance().execute(); - } catch (InstantiationException e) { - e.printStackTrace(); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - + startCS.execute(); } } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/topology/node/StartTopologyNode.java --- a/src/alice/topology/node/StartTopologyNode.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/topology/node/StartTopologyNode.java Sat Feb 04 16:03:05 2012 +0900 @@ -10,11 +10,11 @@ public class StartTopologyNode extends CodeSegment { private TopologyNodeConfig conf; - private Class clazz; + private CodeSegment startCS; - public StartTopologyNode(TopologyNodeConfig conf, Class clazz) { + public StartTopologyNode(TopologyNodeConfig conf, CodeSegment startCS) { this.conf = conf; - this.clazz = clazz; + this.startCS = startCS; } @Override @@ -39,7 +39,7 @@ ods.put("local", "reverseCount", 0); - ConfigurationFinish cs3 = new ConfigurationFinish(clazz); + ConfigurationFinish cs3 = new ConfigurationFinish(startCS); cs3.reverseCount.setKey("local", "reverseCount"); cs3.configNodeNum.setKey("local", "configNodeNum"); } diff -r ae24d5d40c10 -r 1a498f436332 src/alice/topology/node/TopologyNode.java --- a/src/alice/topology/node/TopologyNode.java Sat Feb 04 14:31:07 2012 +0900 +++ b/src/alice/topology/node/TopologyNode.java Sat Feb 04 16:03:05 2012 +0900 @@ -5,9 +5,9 @@ public class TopologyNode { - public TopologyNode(TopologyNodeConfig conf, Class clazz) { + public TopologyNode(TopologyNodeConfig conf, CodeSegment startCS) { new AliceDaemon(conf).listen(); - new StartTopologyNode(conf, clazz).execute(); + new StartTopologyNode(conf, startCS).execute(); } public static void main(String[] args) {