changeset 147:ae6ed9c35288 working

change share test
author sugi
date Tue, 09 Oct 2012 19:29:33 +0900
parents 36dc63d1bdcf
children 1a00e4d6b11d
files scripts/share_run.sh src/alice/test/topology/share/AutoIncrement.java src/alice/test/topology/share/CheckLocalIndex.java src/alice/test/topology/share/CheckMyName.java src/alice/test/topology/share/DataInfo.java src/alice/test/topology/share/LookUpData.java src/alice/test/topology/share/SendData.java
diffstat 7 files changed, 89 insertions(+), 44 deletions(-) [+]
line wrap: on
line diff
--- a/scripts/share_run.sh	Tue Sep 25 14:11:37 2012 +0900
+++ b/scripts/share_run.sh	Tue Oct 09 19:29:33 2012 +0900
@@ -4,12 +4,12 @@
 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 &
+java -cp ../Alice.jar alice.topology.manager.TopologyManager -p 10000 -conf ./topology/tree.dot &
 
 cnt=0
 while [ $cnt -lt $max ]
 do
-    java -cp ../Alice.jar alice.test.topology.share.ShareTopology -host `hostname` -port 10000 -p `expr 20000 + $cnt` -log ./output/share${cnt}.log -level debug > ./output/std_share${cnt}.log &
+    java -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/src/alice/test/topology/share/AutoIncrement.java	Tue Sep 25 14:11:37 2012 +0900
+++ b/src/alice/test/topology/share/AutoIncrement.java	Tue Oct 09 19:29:33 2012 +0900
@@ -16,9 +16,15 @@
 
 	@Override
 	public void run() {
-		DataInfo info = this.position.asClass(DataInfo.class);
-		info.setTime(System.currentTimeMillis());
-		ods.update("local", key, info);
+		synchronized(this){
+			try {
+				wait(50);
+			} catch (InterruptedException e) {
+				e.printStackTrace();
+			}
+		}
+		ods.update("local", key, new DataInfo(System.currentTimeMillis()));
+		new AutoIncrement(this.key ,this.position.index);
 	}
 	
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/share/CheckLocalIndex.java	Tue Oct 09 19:29:33 2012 +0900
@@ -0,0 +1,42 @@
+package alice.test.topology.share;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+import alice.test.topology.aquarium.Routing;
+import alice.test.topology.aquarium.RoutingTable;
+
+public class CheckLocalIndex extends CodeSegment {
+
+	private Receiver data = ids.create(CommandType.PEEK);
+	private Receiver list = ids.create(CommandType.PEEK);
+	private Receiver host = ids.create(CommandType.PEEK);
+	private String key;
+	
+	public CheckLocalIndex(String key, int index){
+		this.key = key;
+		this.host.setKey("local","host");
+		this.list.setKey("local", "list");
+		this.data.setKey("local", this.key, index);
+	}
+	
+	@Override
+	public void run() {
+		RoutingTable rt = this.list.asClass(RoutingTable.class);
+		int count = 0;
+		for (Routing r : rt.table) {
+			if (!r.name.equals(this.data.from)){
+				ods.update(r.name, this.key, this.data.val);
+				count++;
+			}
+			
+		}
+		System.out.println("count "+count+" host "+host.val);
+		if (count==0){
+			ods.put("parent", "data", this.data.val);
+		}
+		new CheckLocalIndex(this.key, this.data.index);
+		
+	}
+
+}
--- a/src/alice/test/topology/share/CheckMyName.java	Tue Sep 25 14:11:37 2012 +0900
+++ b/src/alice/test/topology/share/CheckMyName.java	Tue Oct 09 19:29:33 2012 +0900
@@ -7,7 +7,6 @@
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
 import alice.test.topology.aquarium.AddRoutingTable;
-import alice.test.topology.aquarium.CheckLocalIndex;
 import alice.test.topology.aquarium.Routing;
 import alice.test.topology.aquarium.RoutingTable;
 
@@ -16,14 +15,6 @@
 	Receiver host = ids.create(CommandType.PEEK);
 	Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
 	String key = "fish";
-	double a = Math.pow(2,1)-1; 
-	double b = Math.pow(2,2)-1; 
-	double c = Math.pow(2,3)-1; 
-	double d = Math.pow(2,4)-1;
-	double e = Math.pow(2,5)-1;
-	double f = Math.pow(2,6)-1;
-	double g = Math.pow(2,7)-1;
-	double h = Math.pow(2,8)-1;
 	
 	public CheckMyName(){
 		this.host.setKey("local","host");
@@ -48,40 +39,24 @@
 			
 			new AddRoutingTable(routing,0);
 			ods.put("parent", "member", name);
-				
+			new SendData(0);
 		}else if (type.equals("node")){
 			//System.out.println("node"+num);
 			if (num != 0){
 				routing.table.add(new Routing("parent"));
 				ods.put("parent", "member", name);
-				
+				new SendData(0);
+			}else{
+				new LookUpData("data",0);
 			}
 			ods.put("local", "list", routing);
 			new AddRoutingTable(routing,0);
 			
 		}
-		int depth = 0;
-		if (num == 0){
-			depth = 0;
-		}else if (a <= num && num < b){
-			depth = 1;
-		}else if (b <= num && num < c){
-			depth = 2;
-		}else if (c <= num && num < d){
-			depth = 3;
-		}else if (d <= num && num < e){
-			depth = 4;
-		}else if (e <= num && num < f){
-			depth = 5;
-		}else if (f <= num && num < g){
-			depth = 6;
-		}else if (g <= num && num < h){
-			depth = 7;
-		}
+		for (int i =0 ;i<1000000;i++){}
+		ods.update("local", key, new DataInfo());
 		
-		ods.update("local", key, new DataInfo());
-		for (long time=0;time<10000000;time++){}
-		new LookUpData(key,1,depth);
+		
 		new CheckLocalIndex(key,1);
 		if (num == 0) new AutoIncrement(key,0);
 				
--- a/src/alice/test/topology/share/DataInfo.java	Tue Sep 25 14:11:37 2012 +0900
+++ b/src/alice/test/topology/share/DataInfo.java	Tue Oct 09 19:29:33 2012 +0900
@@ -5,9 +5,7 @@
 @Message
 public class DataInfo {
 	public long setTime = 0;
-	public int a = 0;
-	public int b = 1;
-	
+		
 	public DataInfo(){}
 	
 	public DataInfo(long t){
--- a/src/alice/test/topology/share/LookUpData.java	Tue Sep 25 14:11:37 2012 +0900
+++ b/src/alice/test/topology/share/LookUpData.java	Tue Oct 09 19:29:33 2012 +0900
@@ -9,6 +9,12 @@
 	private Receiver data = ids.create(CommandType.PEEK);
 	String key;
 	int depth;
+	
+	public LookUpData(String key,int index){
+		this.key = key;
+		this.data.setKey("local", key, index);
+	}
+	
 	public LookUpData(String key,int index, int depth){
 		this.key = key;
 		this.depth = depth;
@@ -17,11 +23,9 @@
 
 	@Override
 	public void run(){
-		//System.out.println(data.val);
+		new LookUpData(this.key,this.data.index);
 		DataInfo di = data.asClass(DataInfo.class);
-		//System.out.println(System.currentTimeMillis());
-		System.out.println(depth+" "+(System.currentTimeMillis()-di.getTime()));
-		new LookUpData(this.key,this.data.index,depth);
+		System.out.println("Time "+(System.currentTimeMillis()-di.getTime())+" ms");
 
 	}
 	
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/alice/test/topology/share/SendData.java	Tue Oct 09 19:29:33 2012 +0900
@@ -0,0 +1,20 @@
+package alice.test.topology.share;
+
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class SendData extends CodeSegment{
+	private Receiver data = ids.create(CommandType.PEEK);
+	
+	public SendData(int index){
+		this.data.setKey("local", "data", index);
+	}
+	
+	@Override
+	public void run(){
+		new SendData(this.data.index);
+		ods.put("parent", "data", this.data.val);
+	}
+	
+}
\ No newline at end of file