changeset 76:4a2ecd0a5e8f working

refactor test code segments
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Wed, 29 Feb 2012 22:02:31 +0900
parents 79a4f68cffb2
children 481f322b3206
files src/alice/codesegment/OutputDataSegment.java src/alice/test/topology/ring/CheckMyName.java src/alice/test/topology/ring/FirstRingMessagePassing.java src/alice/test/topology/ring/RingMessagePassing.java src/alice/test/topology/ring/RingTopologyConfig.java src/alice/test/topology/ring/StartRing.java
diffstat 6 files changed, 35 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/codesegment/OutputDataSegment.java	Mon Feb 27 17:05:54 2012 +0900
+++ b/src/alice/codesegment/OutputDataSegment.java	Wed Feb 29 22:02:31 2012 +0900
@@ -66,10 +66,22 @@
 		}
 	}
 	
+	/**
+	 * kill the Alice process after send other messages.
+	 * 
+	 * @param managerKey
+	 */
+	
 	public void finish(String managerKey) {
 		DataSegment.get(managerKey).finish();
 	}
 
+	/**
+	 * close socket for RemoteDataSegment after send other messages.
+	 * 
+	 * @param managerKey
+	 */
+	
 	public void close(String managerKey) {
 		DataSegment.get(managerKey).close();
 	}
--- a/src/alice/test/topology/ring/CheckMyName.java	Mon Feb 27 17:05:54 2012 +0900
+++ b/src/alice/test/topology/ring/CheckMyName.java	Wed Feb 29 22:02:31 2012 +0900
@@ -8,7 +8,7 @@
 
 public class CheckMyName extends CodeSegment {
 
-	public Receiver host = ids.create(CommandType.PEEK);
+	public Receiver ds1 = ids.create(CommandType.PEEK);
 	
 	private Logger logger = Logger.getLogger(CheckMyName.class);
 	private RingTopologyConfig conf;
@@ -19,18 +19,18 @@
 	
 	@Override
 	public void run() {
-		String host = this.host.asString();
+		String host = this.ds1.asString();
 		logger.debug(host);
 		if (host.equals("node0")) {
 			ods.put("local", "c", new byte[conf.size]);
-			FirstRingMessagePassing cs1 = new FirstRingMessagePassing(System.nanoTime(), conf.count, conf.nodeNum);
-			cs1.counter.setKey("c");
+			FirstRingMessagePassing cs1 = new FirstRingMessagePassing(conf.count, conf.nodeNum);
+			cs1.ds1.setKey("c");
 			RingFinish cs2 = new RingFinish("manager");
 			cs2.finish.setKey("finish");
 		} else {
 			ods.close("manager");
 			RingMessagePassing cs1 = new RingMessagePassing();
-			cs1.counter.setKey("c");
+			cs1.ds1.setKey("c");
 			RingFinish cs2 = new RingFinish("right");
 			cs2.finish.setKey("finish");
 		}
--- a/src/alice/test/topology/ring/FirstRingMessagePassing.java	Mon Feb 27 17:05:54 2012 +0900
+++ b/src/alice/test/topology/ring/FirstRingMessagePassing.java	Wed Feb 29 22:02:31 2012 +0900
@@ -8,10 +8,10 @@
 
 public class FirstRingMessagePassing extends CodeSegment {
 	
-	public Receiver counter = ids.create(CommandType.TAKE);
+	public Receiver ds1 = ids.create(CommandType.TAKE);
 	private long startTime;
 	private int count;
-	private int nodeNum; 
+	private int nodeNum;
 	
 	public FirstRingMessagePassing(long startTime, int count, int nodeNum) {
 		this.startTime = startTime;
@@ -19,10 +19,16 @@
 		this.nodeNum = nodeNum;
 	}
 	
+	public FirstRingMessagePassing(int count, int nodeNum) { // at first
+		this.startTime = System.nanoTime();
+		this.count = count;
+		this.nodeNum = nodeNum;
+	}
+	
 	@Override
 	public void run() {
-		ods.put("right", "c", counter.val);
-		if (counter.index > count) {
+		ods.put("right", "c", ds1.val); // copy whole DataSegment to the right
+		if (ds1.index > count) {        // after count time update of ds1
 			ods.put("right", "finish", ValueFactory.createNilValue());
 			long endTime = System.nanoTime();
 			long time = endTime - startTime;
@@ -31,7 +37,7 @@
 		}
 		
 		FirstRingMessagePassing cs = new FirstRingMessagePassing(startTime, count, nodeNum);
-		cs.counter.setKey("c");
+		cs.ds1.setKey("c");
 	}
 
 }
--- a/src/alice/test/topology/ring/RingMessagePassing.java	Mon Feb 27 17:05:54 2012 +0900
+++ b/src/alice/test/topology/ring/RingMessagePassing.java	Wed Feb 29 22:02:31 2012 +0900
@@ -6,13 +6,13 @@
 
 public class RingMessagePassing extends CodeSegment {
 
-	public Receiver counter = ids.create(CommandType.TAKE);
+	public Receiver ds1 = ids.create(CommandType.TAKE);
 
 	@Override
 	public void run() {
-		ods.put("right", "c", this.counter.val);
+		ods.put("right", "c", this.ds1.val);
 		RingMessagePassing cs = new RingMessagePassing();
-		cs.counter.setKey("c");
+		cs.ds1.setKey("c");
 	}
 
 }
--- a/src/alice/test/topology/ring/RingTopologyConfig.java	Mon Feb 27 17:05:54 2012 +0900
+++ b/src/alice/test/topology/ring/RingTopologyConfig.java	Wed Feb 29 22:02:31 2012 +0900
@@ -12,11 +12,11 @@
 		super(args);
 		for (int i = 0; i < args.length; i++) {
 			if ("-count".equals(args[i])) {
-				this.count = new Integer(args[++i]);
+				this.count = Integer.parseInt(args[i]);
 			} else if ("-size".equals(args[i])) {
-				this.size = new Integer(args[++i]);
+				this.size = Integer.parseInt(args[i]);
 			} else if ("-nodeNum".equals(args[i])) {
-				this.nodeNum = new Integer(args[++i]);
+				this.nodeNum = Integer.parseInt(args[i]);
 			}
 		}
 	}
--- a/src/alice/test/topology/ring/StartRing.java	Mon Feb 27 17:05:54 2012 +0900
+++ b/src/alice/test/topology/ring/StartRing.java	Wed Feb 29 22:02:31 2012 +0900
@@ -10,7 +10,7 @@
 	@Override
 	public void run() {
 		CheckMyName cs = new CheckMyName(conf);
-		cs.host.setKey("host");
+		cs.ds1.setKey("host");
 	}
 
 }