Mercurial > hg > Database > Alice
changeset 24:ebd91e607b63
implements TopologyManager
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Jan 2012 01:32:35 +0900 |
parents | 54bf607118ae |
children | 50c75cb3de60 |
files | src/topology/manager/IncomingHosts.java src/topology/manager/StartTopologyManager.java |
diffstat | 2 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/topology/manager/IncomingHosts.java Tue Jan 17 01:10:29 2012 +0900 +++ b/src/topology/manager/IncomingHosts.java Tue Jan 17 01:32:35 2012 +0900 @@ -17,12 +17,12 @@ public class IncomingHosts extends CodeSegment { - HashMap<String, NodeInfo> topology; + 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, NodeInfo> topology, LinkedList<String> nodeNames) { + public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) { this.topology = topology; this.nodeNames = nodeNames; } @@ -35,6 +35,11 @@ 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); + ods.put("local", nodeInfo.sourceNodeName, msgpack.unconvert(newHost)); + } } catch (IOException e) { logger.error("HostMessage format error"); e.printStackTrace();
--- a/src/topology/manager/StartTopologyManager.java Tue Jan 17 01:10:29 2012 +0900 +++ b/src/topology/manager/StartTopologyManager.java Tue Jan 17 01:32:35 2012 +0900 @@ -29,7 +29,7 @@ @Override public void run() { LinkedList<String> nodeNames = new LinkedList<String>(); - HashMap<String, NodeInfo> topology = new HashMap<String, NodeInfo>(); + HashMap<String, LinkedList<NodeInfo>> topology = new HashMap<String, LinkedList<NodeInfo>>(); try { FileReader reader = new FileReader(new File(conf.confFilePath)); Parser parser = new Parser(); @@ -38,14 +38,17 @@ for (Graph graph : graphs) { ArrayList<Node> nodes = graph.getNodes(false); for (Node node : nodes) { - nodeNames.add(node.getId().getId()); + String nodeName = node.getId().getId(); + nodeNames.add(nodeName); + topology.put(nodeName, new LinkedList<NodeInfo>()); } ArrayList<Edge> edges = graph.getEdges(); for (Edge edge : edges) { String connection = edge.getAttribute("label"); String source = edge.getSource().getNode().getId().getId(); String target = edge.getSource().getNode().getId().getId(); - topology.put(target, new NodeInfo(source, connection)); + LinkedList<NodeInfo> sources = topology.get(target); + sources.add(new NodeInfo(source, connection)); } }