Mercurial > hg > Database > Alice
changeset 422:2c6f86320691 dispose
add topology state recoder
author | sugi |
---|---|
date | Mon, 21 Jul 2014 17:23:38 +0900 |
parents | fdac53a9101f |
children | af343b2a7a8b |
files | src/main/java/alice/topology/manager/IncomingHosts.java src/main/java/alice/topology/manager/RecodeTopology.java src/main/java/alice/topology/manager/StartTopologyManager.java |
diffstat | 3 files changed, 53 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/topology/manager/IncomingHosts.java Fri Jul 18 23:47:49 2014 +0900 +++ b/src/main/java/alice/topology/manager/IncomingHosts.java Mon Jul 21 17:23:38 2014 +0900 @@ -15,13 +15,13 @@ HashMap<String, LinkedList<NodeInfo>> topology; LinkedList<String> nodeNames; - Receiver host = ids.create(CommandType.TAKE); + private Receiver host = ids.create(CommandType.TAKE); public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) { this.topology = topology; this.nodeNames = nodeNames; - this.host.setKey("local", "host"); + this.host.setKey("host"); } @Override @@ -35,7 +35,10 @@ for (NodeInfo nodeInfo : nodes) { HostMessage newHost = new HostMessage(host.name, host.port, nodeInfo.connectionName, nodeInfo.reverseName); - ods.put("local", nodeInfo.sourceNodeName, newHost); + newHost.parentAbsName = nodeInfo.sourceNodeName; + ods.put("nodeInfo", newHost); + ods.put(nodeInfo.sourceNodeName, newHost); + new RecodeTopology(); } if (nodeNames.isEmpty()) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/topology/manager/RecodeTopology.java Mon Jul 21 17:23:38 2014 +0900 @@ -0,0 +1,43 @@ +package alice.topology.manager; + +import java.util.HashMap; +import java.util.LinkedList; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; +import alice.topology.HostMessage; + +public class RecodeTopology extends CodeSegment { + + private Receiver info = ids.create(CommandType.TAKE); // NodeInfo + private Receiver info1 = ids.create(CommandType.TAKE); // HashMap + + public RecodeTopology(){ + info.setKey("nodeInfo"); + info1.setKey("topology"); + } + + @Override + public void run() { + HostMessage hostInfo = info.asClass(HostMessage.class); + @SuppressWarnings("unchecked") + HashMap<String, LinkedList<HostMessage>> topology = info1.asClass(HashMap.class); + LinkedList<HostMessage> connections; + if (!topology.containsKey(hostInfo.parentAbsName)) { + connections = new LinkedList<HostMessage>(); + } else { + connections = topology.get(hostInfo.parentAbsName); + } + connections.add(hostInfo); + topology.put(hostInfo.parentAbsName, connections); + ods.update(info1.key, topology); + + for (LinkedList<HostMessage> list :topology.values()){ + for (HostMessage host : list){ + System.out.println(host.parentAbsName+" : "+host.name+" "+host.port+" "+host.connectionName+" "+host.reverseName); + } + } + } + +}
--- a/src/main/java/alice/topology/manager/StartTopologyManager.java Fri Jul 18 23:47:49 2014 +0900 +++ b/src/main/java/alice/topology/manager/StartTopologyManager.java Mon Jul 21 17:23:38 2014 +0900 @@ -75,7 +75,10 @@ logger.error("File format error: " + conf.confFilePath); e.printStackTrace(); } - + + // for recode topology information + ods.put("topology", new HashMap<String, LinkedList<HostMessage>>()); + new IncomingHosts(topology, nodeNames); ConfigWaiter cs3 = new ConfigWaiter(nodeNum);