Mercurial > hg > Database > Alice
view src/alice/topology/manager/IncomingHosts.java @ 274:f866178f3018
success to reconnect
author | sugi |
---|---|
date | Sun, 29 Sep 2013 17:17:10 +0900 |
parents | 3667ab045530 |
children |
line wrap: on
line source
package alice.topology.manager; import java.util.ArrayList; 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; Receiver host = ids.create(CommandType.TAKE); Receiver connection = ids.create(CommandType.TAKE); public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) { this.topology = topology; this.nodeNames = nodeNames; } @Override public void run() { HostMessage host = this.host.asClass(HostMessage.class); @SuppressWarnings("unchecked") HashMap<String, ArrayList<HostMessage>> connectionList = this.connection.asClass(HashMap.class); String nodeName = nodeNames.poll(); // Manager connect to Node DataSegment.connect(nodeName, "", host.name, host.port, host.reconnectFlag); ods.put(nodeName, "host", nodeName); LinkedList<NodeInfo> nodes = topology.get(nodeName); ArrayList<HostMessage> list; for (NodeInfo nodeInfo : nodes) { HostMessage newHost = new HostMessage(host.name, host.port, nodeInfo.connectionName, nodeInfo.reverseName); ods.put("local", nodeInfo.sourceNodeName, newHost); if (connectionList.containsKey(nodeInfo.sourceNodeName)){ list = connectionList.get(nodeInfo.sourceNodeName); } else { list = new ArrayList<HostMessage>(); connectionList.put(nodeInfo.sourceNodeName, list); } list.add(newHost); } ods.update("local", "connection", connectionList); if (nodeNames.isEmpty()) { // configuration finish for (String key : topology.keySet()) { ods.put("local", key, ValueFactory.createNilValue()); } } else { IncomingHosts cs = new IncomingHosts(topology, nodeNames); cs.host.setKey("local", "host"); cs.connection.setKey("local", "connection"); } } }