Mercurial > hg > Database > Alice
diff src/main/java/alice/topology/manager/RecodeTopology.java @ 422:2c6f86320691 dispose
add topology state recoder
author | sugi |
---|---|
date | Mon, 21 Jul 2014 17:23:38 +0900 |
parents | |
children | 93995b7a9a05 |
line wrap: on
line diff
--- /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); + } + } + } + +}