changeset 259:ccce30f84380

use "_CLIST" Key
author sugi
date Tue, 16 Jul 2013 16:00:41 +0900
parents 7f7b3506bff9
children 68f6e0fa4a89
files src/alice/test/topology/aquarium/AutoIncrement.java src/alice/test/topology/aquarium/CheckLocalIndex.java src/alice/test/topology/aquarium/CheckMyName.java
diffstat 3 files changed, 13 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/topology/aquarium/AutoIncrement.java	Sat Jul 13 20:55:32 2013 +0900
+++ b/src/alice/test/topology/aquarium/AutoIncrement.java	Tue Jul 16 16:00:41 2013 +0900
@@ -9,7 +9,6 @@
 	private Receiver position = ids.create(CommandType.PEEK);
 	private Receiver number = ids.create(CommandType.PEEK);
 	private float min = -1.3f;
-	private float max;
 	
 	public AutoIncrement(String key,int index){
 		this.number.setKey("maxsize");
@@ -18,7 +17,7 @@
 
 	@Override
 	public void run() {
-		max = this.number.asInteger()*2-1+0.3f;
+		float max = this.number.asInteger()*2-1+0.3f;
 		FishPoint fp = this.position.asClass(FishPoint.class);
 		if (fp.getX()+0.01>max){
 			fp.setXYZ(min, fp.getY(), fp.getZ());
--- a/src/alice/test/topology/aquarium/CheckLocalIndex.java	Sat Jul 13 20:55:32 2013 +0900
+++ b/src/alice/test/topology/aquarium/CheckLocalIndex.java	Tue Jul 16 16:00:41 2013 +0900
@@ -1,5 +1,8 @@
 package alice.test.topology.aquarium;
 
+import java.util.Iterator;
+import java.util.List;
+
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.Receiver;
@@ -10,21 +13,22 @@
 	private Receiver list = ids.create(CommandType.PEEK);
 	
 	public CheckLocalIndex(String key, int index){
-		
-		this.list.setKey("list");
+		this.list.setKey("_CLIST");
 		this.data.setKey(key, index);
 	}
 	
 	@Override
 	public void run() {
-		RoutingTable rt = this.list.asClass(RoutingTable.class);
-		for (Routing r : rt.table) {
-			if (!r.name.equals(this.data.from)){
-				ods.update(r.name, data.key, this.data.getVal());
+		@SuppressWarnings("unchecked")
+		List<String> r = list.asClass(List.class);
+		for (Iterator<String> ir = r.iterator();ir.hasNext();) {
+			String node = ir.next();
+			if (!node.equals(data.from)){
+				ods.update(node, data.key, data.getVal());
 			}
 			
 		}
-		new CheckLocalIndex(this.data.key, this.data.index);
+		new CheckLocalIndex(data.key, data.index);
 		
 	}
 
--- a/src/alice/test/topology/aquarium/CheckMyName.java	Sat Jul 13 20:55:32 2013 +0900
+++ b/src/alice/test/topology/aquarium/CheckMyName.java	Tue Jul 16 16:00:41 2013 +0900
@@ -1,6 +1,5 @@
 package alice.test.topology.aquarium;
 
-import java.util.List;
 import java.util.Random;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -12,19 +11,15 @@
 
 public class CheckMyName extends CodeSegment {
  	private Receiver host = ids.create(CommandType.PEEK);
- 	private Receiver clist = ids.create(CommandType.PEEK);
 	private Pattern pattern = Pattern.compile("^(node|cli)([0-9]+)$");
 	private String key = "fish";
 	
 	public CheckMyName(){
 		host.setKey("host");
-		clist.setKey("_CLIST");
 	}
 	
 	@Override
 	public void run(){
-		List<?> list = clist.asClass(List.class);
-		System.out.println(list);
 		String name = host.asString();
 		Matcher matcher = pattern.matcher(name);
 		
@@ -33,31 +28,18 @@
 		int num = new Integer(matcher.group(2));
 		ods.put("host_num", num*2);
 		MakeFrame frame =  new MakeFrame(name,num*2);
-		RoutingTable routing = new RoutingTable();
 		ods.put("num", 1);
 		
 		if (type.equals("cli")){
 			System.out.println("cli"+num);
-			routing.table.add(new Routing("parent"));
-			ods.put("list", routing);
-			
-			new AddRoutingTable(routing,0);
-			ods.put("parent", "member", name);
-			new TakeMynum();
-				
+			new TakeMynum();	
 		}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 TakeMynum();
-				
 			} else {
 				new SendMaxsize(0);
 			}
-			ods.put("list", routing);
-			new AddRoutingTable(routing,0);
-			
 		}
 		new CheckLocalIndex("maxsize",0);