Mercurial > hg > Members > tatsuki > Alice
view src/alice/topology/manager/IncomingHosts.java @ 28:98ab26e09a98
Configuration Manager work and implements reverseKey
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Jan 2012 08:41:34 +0900 |
parents | f54dcbebde3a |
children | 5c704b9a9a87 |
line wrap: on
line source
package alice.topology.manager; import java.io.IOException; import java.util.HashMap; import java.util.LinkedList; import org.apache.log4j.Logger; import org.msgpack.MessagePack; import org.msgpack.type.ValueFactory; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.DataSegmentManager; import alice.datasegment.DataSegmentReceiver; import alice.topology.HostMessage; public class IncomingHosts extends CodeSegment { HashMap<String, LinkedList<NodeInfo>> topology; LinkedList<String> nodeNames; DataSegmentReceiver host = new DataSegmentReceiver(ids, CommandType.TAKE); Logger logger = Logger.getLogger(IncomingHosts.class); public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) { this.topology = topology; this.nodeNames = nodeNames; } @Override public void run() { MessagePack msgpack = new MessagePack(); try { HostMessage host = msgpack.convert(this.host.val, HostMessage.class); String nodeName = nodeNames.poll(); DataSegmentManager manager = DataSegment.connect(nodeName, "", host.name, host.port); manager.put("host", ValueFactory.createRawValue(nodeName)); LinkedList<NodeInfo> nodes = topology.get(nodeName); for (NodeInfo nodeInfo : nodes) { HostMessage newHost = new HostMessage(host.name, host.port, nodeInfo.connectionName, nodeInfo.reverseName); ods.put("local", nodeInfo.sourceNodeName, msgpack.unconvert(newHost)); } } catch (IOException e) { logger.error("HostMessage format error"); e.printStackTrace(); } 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"); } } }