Mercurial > hg > Database > Alice
view src/main/java/alice/topology/manager/IncomingHosts.java @ 558:0259a8aba18c dispose
add ip to HostMessage.class, delete System.out in ReceiveData, some TopM class change using ip connection
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 21 Nov 2015 18:23:51 +0900 |
parents | 1a860019b2fe |
children |
line wrap: on
line source
package alice.topology.manager; import java.net.InetAddress; import java.net.UnknownHostException; 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 { private Receiver topology = ids.create(CommandType.TAKE); // Topology from parse file private Receiver nodeNames = ids.create(CommandType.TAKE); // nodeName list private Receiver host = ids.create(CommandType.TAKE); // new coming host info private Receiver absCookieTable = ids.create(CommandType.TAKE); // cookie, AbsName HashMap private Receiver cookie = ids.create(CommandType.TAKE); // MD5 public IncomingHosts() { this.topology.setKey("resultParse"); this.nodeNames.setKey("nodeNames"); this.host.setKey("newHost"); this.absCookieTable.setKey("absCookieTable"); this.cookie.setKey("MD5"); } @Override public void run() { HostMessage host = this.host.asClass(HostMessage.class); @SuppressWarnings("unchecked") HashMap<String, String> absCookieTable = this.absCookieTable.asClass(HashMap.class); @SuppressWarnings("unchecked") HashMap<String, LinkedList<NodeInfo>> topology = this.topology.asClass(HashMap.class); @SuppressWarnings("unchecked") LinkedList<String> nodeNames = this.nodeNames.asClass(LinkedList.class); // not have or match cookie String nodeName = nodeNames.poll(); // Manager connect to Node DataSegment.connect(nodeName, "", host.ip, host.port); ods.put(nodeName, "host", nodeName); String cookie = this.cookie.asString(); absCookieTable.put(cookie, nodeName); ods.put(this.absCookieTable.key, absCookieTable); ods.put(nodeName, "cookie", cookie); LinkedList<NodeInfo> nodes = topology.get(nodeName); for (NodeInfo nodeInfo : nodes) { HostMessage newHost = new HostMessage(host.name, host.ip, host.port, nodeInfo.connectionName, nodeInfo.reverseName); newHost.absName = nodeName; newHost.remoteAbsName = 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()); } } ods.put(this.nodeNames.key, nodeNames); ods.put(this.topology.key, topology); new IncomingHosts(); } }