changeset 18:4e5507afb41f

"MAXSIZE" change automatically
author e095732
date Mon, 04 Feb 2013 01:23:24 +0900
parents 9bacc8b30c4b
children a1e4a3aafdd1
files scripts/share_run.sh scripts/topology/tree.dot scripts/topology/tree.png src/alice/test/topology/aquarium/fx/CalculateMaxSize.java src/alice/test/topology/aquarium/fx/CheckMyName.java src/alice/test/topology/aquarium/fx/CountMessage.java src/alice/test/topology/aquarium/fx/OtherNode.java src/alice/test/topology/aquarium/fx/PositionController.java src/alice/test/topology/aquarium/fx/RegistRoutingTable.java src/alice/test/topology/aquarium/fx/SendMessage.java src/alice/test/topology/aquarium/fx/SetTranslation.java src/alice/test/topology/aquarium/fx/TopNode.java
diffstat 12 files changed, 107 insertions(+), 31 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/share_run.sh	Sun Feb 03 18:34:16 2013 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,15 +0,0 @@
-#!/bin/bash
-max=$1
-child_num=$2
-ruby ./topology/treen.rb $1 $2 > ./topology/tree.dot
-dot -Tpng ./topology/tree.dot > ./topology/tree.png
-#open ./topology/tree.png
-java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/tree.dot &
-
-cnt=0
-while [ $cnt -lt $max ]
-do
-    java -version:1.6 -showversion -cp ../Alice.jar alice.test.topology.share.ShareTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` > ./output/std_share${cnt}.log &
-    cnt=`expr $cnt + 1`
-done
-wait
--- a/scripts/topology/tree.dot	Sun Feb 03 18:34:16 2013 +0900
+++ b/scripts/topology/tree.dot	Mon Feb 04 01:23:24 2013 +0900
@@ -1,4 +1,6 @@
 digraph test {
 	node0 -> cli1 [label="child0"]
+	node0 -> cli2 [label="child1"]
 	cli1 -> node0 [label="parent"]
+	cli2 -> node0 [label="parent"]
 }
Binary file scripts/topology/tree.png has changed
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/CalculateMaxSize.java	Mon Feb 04 01:23:24 2013 +0900
@@ -0,0 +1,31 @@
+package alice.test.topology.aquarium.fx;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CalculateMaxSize extends CodeSegment{
+	
+	private Receiver data1 = ids.create(CommandType.PEEK);
+	private Receiver data2 = ids.create(CommandType.PEEK);
+
+	public CalculateMaxSize(){
+		data1.setKey("CHILDNUM");
+		data2.setKey("width");
+	}
+	
+	public CalculateMaxSize(int index){
+		data1.setKey("CHILDNUM", index);
+		data2.setKey("width");
+	}
+	
+	@Override
+	public void run() {
+		int childnum = data1.asInteger();
+		int width = data2.asInteger();
+		int maxsize = childnum * width + width;
+		ods.update("local", "MAXSIZE", maxsize);
+		System.out.println(maxsize);
+		new CalculateMaxSize(data1.index);
+	}
+}
--- a/src/alice/test/topology/aquarium/fx/CheckMyName.java	Sun Feb 03 18:34:16 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/CheckMyName.java	Mon Feb 04 01:23:24 2013 +0900
@@ -20,7 +20,8 @@
 		String name = host.asString();
 		Matcher matcher = pattern.matcher(name);
 		matcher.find();
-		
+		System.out.println(name);
+		new Share("MAXSIZE");
 		int num = new Integer(matcher.group(2));
 		
 		ods.put("local", "mynum", num);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/CountMessage.java	Mon Feb 04 01:23:24 2013 +0900
@@ -0,0 +1,26 @@
+package alice.test.topology.aquarium.fx;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class CountMessage extends CodeSegment{
+
+	private Receiver data1 = ids.create(CommandType.TAKE);
+	private Receiver data2 = ids.create(CommandType.PEEK);
+	
+
+	public CountMessage(){
+		data1.setKey("CHILD");
+		data2.setKey("CHILDNUM");
+	}
+	
+	@Override
+	public void run() {
+		int childnum = data2.asInteger();
+		ods.update("local", "CHILDNUM", childnum+1);
+		new CountMessage();
+		
+	}
+	
+}
--- a/src/alice/test/topology/aquarium/fx/OtherNode.java	Sun Feb 03 18:34:16 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/OtherNode.java	Mon Feb 04 01:23:24 2013 +0900
@@ -18,11 +18,13 @@
 	public void run() {
 		ods.put("local", "list", new RoutingTable("parent"));
 		new RegistRoutingTable();
+		ods.put("local", "MAXSIZE", 800);
 		ods.put("parent", "member", "ADD_MEM");
-		
+		ods.put("parent", "CHILD", "ADD");
 		int startX = data1.asInteger() * data2.asInteger(); 
 		ods.put("local", "startX", startX);
-		
+		new SendMessage();
+		new Share("MAXSIZE");
 		Aquarium aqua = new Aquarium();
 		aqua.run();
 	}
--- a/src/alice/test/topology/aquarium/fx/PositionController.java	Sun Feb 03 18:34:16 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/PositionController.java	Mon Feb 04 01:23:24 2013 +0900
@@ -6,19 +6,22 @@
 
 public class PositionController extends CodeSegment{
 	
-	private Receiver data = ids.create(CommandType.PEEK);
-	private double max = 1600; // should be DS
+	private Receiver data1 = ids.create(CommandType.PEEK);
+	private Receiver data2 = ids.create(CommandType.PEEK);
 	
 	public PositionController(String key){
-		this.data.setKey(key);
+		data1.setKey(key);
+		data2.setKey("MAXSIZE");
 	}
 	
 	public PositionController(String key ,int index){
-		this.data.setKey(key, index);
+		data1.setKey(key, index);
+		data2.setKey("MAXSIZE");
 	}
 
 	@Override
 	public void run() {
+		int maxsize = data2.asInteger();
 		//System.out.println(data.val);
 		synchronized(this){
 			try {
@@ -28,16 +31,16 @@
 			 
 				wait(20);
 		
-		FishData fd = data.asClass(FishData.class);
-		if(fd.getX()+2.0>max){
+		FishData fd = data1.asClass(FishData.class);
+		if(fd.getX()+2.0>maxsize){
 			fd.SetXYZ(0, fd.getY(), fd.getZ());
 			
 		} else {
 			fd.SetXYZ(fd.getX()+3.0, fd.getY(), fd.getZ());
 		}
 
-		new PositionController(data.key, data.index);
-		ods.update("local", data.key, fd);
+		new PositionController(data1.key, data1.index);
+		ods.update("local", data1.key, fd);
 			} catch (InterruptedException e) {
 				e.printStackTrace();
 			}
--- a/src/alice/test/topology/aquarium/fx/RegistRoutingTable.java	Sun Feb 03 18:34:16 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/RegistRoutingTable.java	Mon Feb 04 01:23:24 2013 +0900
@@ -18,11 +18,9 @@
 	public void run() {
 		RoutingTable routing = rdata.asClass(RoutingTable.class);
 		routing.table.add(new RoutingData(data.from));
-		System.out.println(routing.toString());
 		ods.update("local", "list", routing);
 		new RegistRoutingTable();
 		
-		
 	}
 
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/aquarium/fx/SendMessage.java	Mon Feb 04 01:23:24 2013 +0900
@@ -0,0 +1,21 @@
+package alice.test.topology.aquarium.fx;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SendMessage extends CodeSegment{
+
+	private Receiver data1 = ids.create(CommandType.TAKE);
+	
+	public SendMessage(){
+		data1.setKey("CHILD");
+	}
+	
+	@Override
+	public void run() {
+		ods.put("parent", "CHILD", "ADD");
+		new SendMessage();
+	}
+
+}
--- a/src/alice/test/topology/aquarium/fx/SetTranslation.java	Sun Feb 03 18:34:16 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/SetTranslation.java	Mon Feb 04 01:23:24 2013 +0900
@@ -34,11 +34,11 @@
 		int startX = data2.asInteger();
 		int width = data3.asInteger();
 		FishData fd = data1.asClass(FishData.class);
-		if (startX<=fd.getX()&& fd.getX()<=startX+width){
+		//if (startX<=fd.getX()&& fd.getX()<=startX+width){
 			iv.setTranslateX(fd.getX() - startX);
 			iv.setTranslateY(fd.getY());
 			iv.setTranslateZ(fd.getZ());
-		}
+		//}
 		new SetTranslation(iv, data1.key, data1.index);
 	}
 
--- a/src/alice/test/topology/aquarium/fx/TopNode.java	Sun Feb 03 18:34:16 2013 +0900
+++ b/src/alice/test/topology/aquarium/fx/TopNode.java	Mon Feb 04 01:23:24 2013 +0900
@@ -17,11 +17,18 @@
 	@Override
 	public void run() {
 		ods.put("local", "list", new RoutingTable());
+		ods.put("local", "MAXSIZE", 800);
+		
 		new RegistRoutingTable();
 		
+		
+		
 		int startX = data1.asInteger() * data2.asInteger(); 
 		ods.put("local", "startX", startX);
-		
+		ods.put("local", "CHILDNUM", 0);
+		new CalculateMaxSize();
+		new CountMessage();
+		new Share("MAXSIZE");
 		Aquarium aqua = new Aquarium();
 		aqua.run();
 	}