diff src/alice/test/topology/share/CheckMyName.java @ 135:2f401fd70311 working

create No Graphic aquarium
author sugi
date Thu, 16 Aug 2012 19:57:10 +0900
parents 53aff28cde6b
children bb023f060f2f
line wrap: on
line diff
--- 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);
+		}
+		
+		
+		
 	}
 }