Mercurial > hg > Database > Alice
view src/main/java/alice/topology/manager/IncomingHosts.java @ 422:2c6f86320691 dispose
add topology state recoder
author | sugi |
---|---|
date | Mon, 21 Jul 2014 17:23:38 +0900 |
parents | 74e13553e3e3 |
children | af343b2a7a8b |
line wrap: on
line source
package alice.topology.manager; import java.util.HashMap; import java.util.LinkedList; import org.msgpack.type.ValueFactory; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.Receiver; import alice.topology.HostMessage; public class IncomingHosts extends CodeSegment { HashMap<String, LinkedList<NodeInfo>> topology; LinkedList<String> nodeNames; 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("host"); } @Override public void run() { HostMessage host = this.host.asClass(HostMessage.class); String nodeName = nodeNames.poll(); // Manager connect to Node DataSegment.connect(nodeName, "", host.name, host.port); ods.put(nodeName, "host", nodeName); LinkedList<NodeInfo> nodes = topology.get(nodeName); for (NodeInfo nodeInfo : nodes) { HostMessage newHost = new HostMessage(host.name, host.port, nodeInfo.connectionName, nodeInfo.reverseName); newHost.parentAbsName = nodeInfo.sourceNodeName; ods.put("nodeInfo", newHost); ods.put(nodeInfo.sourceNodeName, newHost); new RecodeTopology(); } if (nodeNames.isEmpty()) { // configuration finish for (String key : topology.keySet()) { ods.put("local", key, ValueFactory.createNilValue()); } } else { new IncomingHosts(topology, nodeNames); } } }