changeset 258:7f7b3506bff9

client can get connection list setkey(_CLIST);
author sugi
date Sat, 13 Jul 2013 20:55:32 +0900
parents 16bfc302bff2
children ccce30f84380
files src/alice/test/topology/aquarium/CheckMyName.java src/alice/topology/manager/StartTopologyManager.java src/alice/topology/node/IncomingAbstractHostName.java src/alice/topology/node/IncomingConnectionInfo.java src/alice/topology/node/StartTopologyNode.java
diffstat 5 files changed, 23 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/alice/test/topology/aquarium/CheckMyName.java	Tue Jul 09 17:41:18 2013 +0900
+++ b/src/alice/test/topology/aquarium/CheckMyName.java	Sat Jul 13 20:55:32 2013 +0900
@@ -1,5 +1,6 @@
 package alice.test.topology.aquarium;
 
+import java.util.List;
 import java.util.Random;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -11,16 +12,19 @@
 
 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);
 		
--- a/src/alice/topology/manager/StartTopologyManager.java	Tue Jul 09 17:41:18 2013 +0900
+++ b/src/alice/topology/manager/StartTopologyManager.java	Sat Jul 13 20:55:32 2013 +0900
@@ -73,7 +73,7 @@
 			logger.error("File format error: " + conf.confFilePath);
 			e.printStackTrace();
 		}
-		
+
 		IncomingHosts cs1 = new IncomingHosts(topology, nodeNames);
 		cs1.host.setKey("local", "host");
 		
--- a/src/alice/topology/node/IncomingAbstractHostName.java	Tue Jul 09 17:41:18 2013 +0900
+++ b/src/alice/topology/node/IncomingAbstractHostName.java	Sat Jul 13 20:55:32 2013 +0900
@@ -6,11 +6,7 @@
 
 public class IncomingAbstractHostName extends CodeSegment {
 
-	private Receiver absName = ids.create(CommandType.PEEK);
-	
-	public IncomingAbstractHostName(){
-		absName.setKey("local", "host");
-	}
+	public Receiver absName = ids.create(CommandType.PEEK);
 
 	@Override
 	public void run() {
--- a/src/alice/topology/node/IncomingConnectionInfo.java	Tue Jul 09 17:41:18 2013 +0900
+++ b/src/alice/topology/node/IncomingConnectionInfo.java	Sat Jul 13 20:55:32 2013 +0900
@@ -1,5 +1,8 @@
 package alice.topology.node;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import alice.codesegment.CodeSegment;
 import alice.datasegment.CommandType;
 import alice.datasegment.DataSegment;
@@ -9,12 +12,20 @@
 public class IncomingConnectionInfo extends CodeSegment {
 
 	public Receiver hostInfo = ids.create(CommandType.TAKE);
+	private List<String> connectionList;
 	private String absName;
 	private int count;
 	
 	public IncomingConnectionInfo(String absName, int count) {
 		this.absName = absName;
 		this.count = count;
+		this.connectionList = new ArrayList<String>();
+	}
+	
+	public IncomingConnectionInfo(String absName, int count, List<String> connectionList) {
+		this.absName = absName;
+		this.count = count;
+		this.connectionList = connectionList;
 	}
 
 	@Override
@@ -27,8 +38,9 @@
 		HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class);
 		DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port);
 		ods.put(hostInfo.connectionName, "reverseKey", hostInfo.reverseName);
-
-		IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, ++count);
+		connectionList.add(hostInfo.connectionName);
+		ods.update("_CLIST", connectionList);
+		IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, ++count, connectionList);
 		cs.hostInfo.setKey("manager", absName);
 	}
 
--- a/src/alice/topology/node/StartTopologyNode.java	Tue Jul 09 17:41:18 2013 +0900
+++ b/src/alice/topology/node/StartTopologyNode.java	Sat Jul 13 20:55:32 2013 +0900
@@ -33,7 +33,8 @@
 		HostMessage host = new HostMessage(localHostName, conf.localPort);
 		ods.put("manager", "host", host);
 		
-		new IncomingAbstractHostName();
+		IncomingAbstractHostName cs = new IncomingAbstractHostName();
+		cs.absName.setKey("local", "host");
 		
 		IncomingReverseKey cs2 = new IncomingReverseKey();
 		cs2.reverseKey.setKey("local", "reverseKey");