changeset 46:1a498f436332

bug fix for time calculate
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Sat, 04 Feb 2012 16:03:05 +0900
parents ae24d5d40c10
children 5b6624b2f055
files scripts/ring_manager_run.sh src/alice/test/topology/fish/DistributedFish.java src/alice/test/topology/ring/CheckMyName.java src/alice/test/topology/ring/FirstRingMessagePassing.java src/alice/test/topology/ring/RingTopology.java src/alice/test/topology/ring/RingTopologyConfig.java src/alice/test/topology/ring/StartRing.java src/alice/topology/node/ConfigurationFinish.java src/alice/topology/node/Start.java src/alice/topology/node/StartTopologyNode.java src/alice/topology/node/TopologyNode.java
diffstat 11 files changed, 42 insertions(+), 38 deletions(-) [+]
line wrap: on
line diff
--- 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
--- 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());
 
 	}
 
--- 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");
--- 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");
 	}
 
--- 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));
 	}
 	
 }
--- 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]);
 			}
--- 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");
 	}
 
--- 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<? extends CodeSegment> clazz;
+	private CodeSegment startCS;
 	
-	public ConfigurationFinish(Class<? extends CodeSegment> 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");
 	}
--- 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<? extends CodeSegment> clazz;
+	private CodeSegment startCS;
 	
-	public Start(Class<? extends CodeSegment> 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();
 	}
 
 }
--- 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<? extends CodeSegment> clazz;
+	private CodeSegment startCS;
 	
-	public StartTopologyNode(TopologyNodeConfig conf, Class<? extends CodeSegment> 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");
 	}
--- 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<? extends CodeSegment> 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) {