changeset 135:2f401fd70311 working

create No Graphic aquarium
author sugi
date Thu, 16 Aug 2012 19:57:10 +0900
parents 53aff28cde6b
children bb023f060f2f
files scripts/aquarium.sh scripts/fishBeta_run.sh scripts/share_run.sh src/alice/test/topology/aquarium/CheckMyName.java src/alice/test/topology/aquarium/StartFishMovement.java src/alice/test/topology/share/CheckLocalIndex.java src/alice/test/topology/share/CheckMyName.java src/alice/test/topology/share/CheckNeedLocalUpdate.java src/alice/test/topology/share/CheckNeedParentUpdate.java src/alice/test/topology/share/CheckParentIndex.java src/alice/test/topology/share/LookUpData.java src/alice/test/topology/share/StartFishMovement.java
diffstat 12 files changed, 84 insertions(+), 175 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/aquarium.sh	Thu Aug 16 19:57:10 2012 +0900
@@ -0,0 +1,15 @@
+#!/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 -log ./output/manager.log -level debug > ./output/std_manager.log &
+
+cnt=0
+while [ $cnt -lt $max ]
+do
+    java -cp  ../Alice.jar alice.test.topology.aquarium.FishMovementTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/modelbeta${cnt}.log -level debug > ./output/std_modelbeta${cnt}.log &
+    cnt=`expr $cnt + 1`
+done
+wait
--- a/scripts/fishBeta_run.sh	Wed Aug 15 17:11:57 2012 +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 -log ./output/manager.log -level debug > ./output/std_manager.log &
-
-cnt=0
-while [ $cnt -lt $max ]
-do
-    java -cp  ../Alice.jar alice.test.topology.fishmodel.beta.FishMovementTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/modelbeta${cnt}.log -level debug > ./output/std_modelbeta${cnt}.log &
-    cnt=`expr $cnt + 1`
-done
-wait
--- a/scripts/share_run.sh	Wed Aug 15 17:11:57 2012 +0900
+++ b/scripts/share_run.sh	Thu Aug 16 19:57:10 2012 +0900
@@ -3,7 +3,7 @@
 child_num=$2
 ruby ./topology/treen.rb $1 $2 > ./topology/tree.dot
 dot -Tpng ./topology/tree.dot > ./topology/tree.png
-open ./topology/tree.png
+#open ./topology/tree.png
 java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/tree.dot -log ./output/manager.log -level debug > ./output/std_manager.log &
 
 cnt=0
--- a/src/alice/test/topology/aquarium/CheckMyName.java	Wed Aug 15 17:11:57 2012 +0900
+++ b/src/alice/test/topology/aquarium/CheckMyName.java	Thu Aug 16 19:57:10 2012 +0900
@@ -13,6 +13,10 @@
 	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
 	String key = "fish";
 	
+	public CheckMyName(){
+		host.setKey("local","host");
+	}
+	
 	@Override
 	public void run(){
 		
@@ -22,25 +26,10 @@
 		matcher.find();
 		String type = matcher.group(1);
 		int num = new Integer(matcher.group(2));
-		/*
-		ods.put("local", "myMax", num);
-		if (type.equals("cli")){
-			ods.put("parent", "check", num);
-		}else if (type.equals("node")){
-			if (num !=0){
-				ods.put("parent", "check", num);
-			} else {
-				
-			}
-		}
-		*/
 		
 		MakeFrame frame =  new MakeFrame(name);
 		RoutingTable routing = new RoutingTable();
-		/*
-		ods.put("local", "max", num);
-		new CheckLocalIndex(key,1);
-		*/
+		
 		if (type.equals("cli")){
 			System.out.println("cli"+num);
 			routing.table.add(new Routing("parent"));
--- a/src/alice/test/topology/aquarium/StartFishMovement.java	Wed Aug 15 17:11:57 2012 +0900
+++ b/src/alice/test/topology/aquarium/StartFishMovement.java	Thu Aug 16 19:57:10 2012 +0900
@@ -5,8 +5,7 @@
 public class StartFishMovement extends CodeSegment{
 	@Override
 	public void run(){
-		CheckMyName cs = new CheckMyName();
-		cs.host.setKey("local","host");
+		new CheckMyName();
 	}
 	
 
--- a/src/alice/test/topology/share/CheckLocalIndex.java	Wed Aug 15 17:11:57 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CheckLocalIndex extends CodeSegment {
-
-	private Receiver local = ids.create(CommandType.PEEK);
-	String key;
-	
-	public CheckLocalIndex(String key, int index){
-		this.key = key;
-		this.local.setKey("local", this.key, index);
-	}
-	
-	@Override
-	public void run() {
-		System.out.println("index: "+this.local.index + " value: "+this.local.val);
-		new CheckNeedParentUpdate(this.key, local);
-						
-	}
-
-}
--- a/src/alice/test/topology/share/CheckMyName.java	Wed Aug 15 17:11:57 2012 +0900
+++ b/src/alice/test/topology/share/CheckMyName.java	Thu Aug 16 19:57:10 2012 +0900
@@ -6,58 +6,67 @@
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
+import alice.test.topology.aquarium.AddRoutingTable;
+import alice.test.topology.aquarium.AutoIncrement;
+import alice.test.topology.aquarium.CheckLocalIndex;
 import alice.test.topology.aquarium.FishPoint;
+import alice.test.topology.aquarium.Routing;
+import alice.test.topology.aquarium.RoutingTable;
+
 
 public class CheckMyName extends CodeSegment {
 	Receiver host = ids.create(CommandType.PEEK);
 	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
-	
 	String key = "fish";
 	
 	public CheckMyName(){
-		host.setKey("local","host");
+		this.host.setKey("local","host");
 	}
 	
-	
 	@Override
-	public synchronized void run(){
+	public void run(){
 		
 		String name = host.asString();
 		Matcher matcher = pattern.matcher(name);
 		
 		matcher.find();
 		String type = matcher.group(1);
-		int cliNum = new Integer(matcher.group(2));
+		int num = new Integer(matcher.group(2));
+		
+		RoutingTable routing = new RoutingTable();
 		
 		if (type.equals("cli")){
-			System.out.println("cli"+cliNum);
-			ods.update("local", this.key, new FishPoint(0.0f,0.0f));
-			new CheckLocalIndex(this.key,0);
-			new CheckParentIndex(this.key,0);
-			
-			
-									
-		}else if(type.equals("node")){
+			System.out.println("cli"+num);
+			routing.table.add(new Routing("parent"));
+			ods.put("local", "list", routing);
 			
-			System.out.println("node"+cliNum);
-			if (cliNum == 0){
-				try {
-					for (float i = 0.0f; i < 2.0f; i +=0.1f) {
-						System.out.println("i = " + i);
-						ods.update("local", "fish", new FishPoint(i,i));
-						wait(500);
-					} 
-				}catch (InterruptedException e) {
-					
-					e.printStackTrace();
-				}
-			}else{
-				ods.update("local", this.key, new FishPoint(0.0f,0.0f));
-				new CheckLocalIndex(this.key,0);
-				new CheckParentIndex(this.key,0);
+			new AddRoutingTable(routing,0);
+			ods.put("parent", "member", name);
+				
+		}else if (type.equals("node")){
+			System.out.println("node"+num);
+			if (num != 0){
+				routing.table.add(new Routing("parent"));
+				ods.put("parent", "member", name);
 				
 			}
-						
+			ods.put("local", "list", routing);
+			new AddRoutingTable(routing,0);
+			
 		}
+		
+		ods.update("local", key, new FishPoint(-0.1f,-0.1f));
+		new CheckLocalIndex(key,1);
+		
+		for (int i = 0;i < 3 ; i++){
+			key = "fish"+i;
+			if (num == 0) new AutoIncrement(key,0);
+			ods.update("local", key, new FishPoint(0.2f*i,0.2f*i));
+			new CheckLocalIndex(key,1);
+			new LookUpData(key,1);
+		}
+		
+		
+		
 	}
 }
--- a/src/alice/test/topology/share/CheckNeedLocalUpdate.java	Wed Aug 15 17:11:57 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.test.topology.aquarium.FishPoint;
-
-public class CheckNeedLocalUpdate extends CodeSegment {
-
-	private Receiver local = ids.create(CommandType.PEEK);
-	private Receiver parent;
-	String key;
-	
-	public CheckNeedLocalUpdate(String key, Receiver parent) {
-		this.key = key;
-		this.parent = parent;
-		this.local.setKey("local", this.key);
-	}
-
-	@Override
-	public void run() {
-		System.out.println(this.local.from);
-		if (this.parent.index > this.local.index){
-			System.out.println("local is updated");
-			ods.update("local", this.key, this.parent.asClass(FishPoint.class));
-	
-		}
-		new CheckParentIndex(this.key ,this.parent.index);
-		
-	}
-
-}
--- a/src/alice/test/topology/share/CheckNeedParentUpdate.java	Wed Aug 15 17:11:57 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-import alice.test.topology.aquarium.FishPoint;
-
-public class CheckNeedParentUpdate extends CodeSegment {
-
-	private Receiver parent = ids.create(CommandType.PEEK);
-	private Receiver local;
-	String key;
-	
-	public CheckNeedParentUpdate(String key ,Receiver local){
-		this.key = key;
-		this.local = local;
-		this.parent.setKey("parent", this.key);
-	}
-
-	@Override
-	public void run() {
-		if (this.local.index > this.parent.index){
-			System.out.println("parent is updated");
-			ods.update("parent", this.key, this.local.asClass(FishPoint.class));
-		}
-		new CheckLocalIndex(this.key,this.local.index);
-		
-	}
-
-}
--- a/src/alice/test/topology/share/CheckParentIndex.java	Wed Aug 15 17:11:57 2012 +0900
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,23 +0,0 @@
-package alice.test.topology.share;
-
-import alice.codesegment.CodeSegment;
-import alice.datasegment.CommandType;
-import alice.datasegment.Receiver;
-
-public class CheckParentIndex extends CodeSegment {
-
-	public Receiver parent = ids.create(CommandType.PEEK);
-	String key;
-		
-	public CheckParentIndex(String key ,int index){
-		this.key = key;
-		this.parent.setKey("parent", this.key, index);
-	}
-	
-	@Override
-	public void run() {
-		//System.out.println(this.parent.from);
-		new CheckNeedLocalUpdate(this.key, parent);
-	}
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/share/LookUpData.java	Thu Aug 16 19:57:10 2012 +0900
@@ -0,0 +1,23 @@
+package alice.test.topology.share;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class LookUpData extends CodeSegment{
+
+	private Receiver data = ids.create(CommandType.PEEK);
+	String key;
+	public LookUpData(String key,int index){
+		this.key = key;
+		this.data.setKey("local", key, index);
+	}
+
+	@Override
+	public void run(){
+		System.out.println(data.val);
+		new LookUpData(this.key,this.data.index);
+
+	}
+	
+}
\ No newline at end of file
--- a/src/alice/test/topology/share/StartFishMovement.java	Wed Aug 15 17:11:57 2012 +0900
+++ b/src/alice/test/topology/share/StartFishMovement.java	Thu Aug 16 19:57:10 2012 +0900
@@ -5,8 +5,6 @@
 public class StartFishMovement extends CodeSegment{
 	@Override
 	public void run(){
-		//new Client();
-		//new Node();
 		new CheckMyName();
 	}