Mercurial > hg > Members > tatsuki > Alice
view src/alice/topology/manager/IncomingHosts.java @ 33:20c67f673224
change name of DataSegmentReceiver
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 18 Jan 2012 01:34:23 +0900 |
parents | 2bfb796b0fa1 |
children | ca079a730d0b |
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.Receiver; import alice.topology.HostMessage; public class IncomingHosts extends CodeSegment { HashMap<String, LinkedList<NodeInfo>> topology; LinkedList<String> nodeNames; Receiver host = ids.create(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(); // Manager connect to Node 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"); } } }