diff src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java @ 384:56d4f93a3921 multicast

add RegisterList
author sugi
date Wed, 11 Jun 2014 15:49:59 +0900
parents 878d397904da
children 1cbac5818dca
line wrap: on
line diff
--- a/src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java	Tue Jun 10 19:36:46 2014 +0900
+++ b/src/main/java/alice/test/topology/aquarium/fx/CheckMyName.java	Wed Jun 11 15:49:59 2014 +0900
@@ -1,5 +1,6 @@
 package alice.test.topology.aquarium.fx;
 
+import java.util.ArrayList;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
@@ -8,9 +9,9 @@
 import alice.datasegment.Receiver;
 
 public class CheckMyName extends CodeSegment {
- 	private Receiver host = ids.create(CommandType.PEEK);
+	private Receiver host = ids.create(CommandType.PEEK);
 	private Pattern pattern = Pattern.compile("^(node|cli|local)([0-9]+)$");
-	
+
 	public CheckMyName(){
 		host.setKey("host");
 	}
@@ -20,19 +21,26 @@
 		String name = host.asString();
 		Matcher matcher = pattern.matcher(name);
 		matcher.find();
-		
+
 		// use view scope
 		//String type = matcher.group(1);
-		//int num = new Integer(matcher.group(2));
+		int num = new Integer(matcher.group(2));
 		
+		if (num == 0){ // root node
+			new RegisterList();
+			ods.put("registeredList", new ArrayList<FishInfo>());
+		} else {
+			new ReceiveRegisterList();
+		}
+
 		FishInfo fishInfo = new FishInfo(0,0,0);
 		fishInfo.setName(name);
-		
+
 		ods.put("fishData", fishInfo);
-		
+
 		new CreateObject();
 		new AddObject();
-		
+
 		String[] args = {name};
 		Aquarium.main(args);
 	}