comparison src/topology/manager/StartTopologyManager.java @ 24:ebd91e607b63

implements TopologyManager
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2012 01:32:35 +0900
parents 2ca2d961a8d2
children
comparison
equal deleted inserted replaced
23:54bf607118ae 24:ebd91e607b63
27 } 27 }
28 28
29 @Override 29 @Override
30 public void run() { 30 public void run() {
31 LinkedList<String> nodeNames = new LinkedList<String>(); 31 LinkedList<String> nodeNames = new LinkedList<String>();
32 HashMap<String, NodeInfo> topology = new HashMap<String, NodeInfo>(); 32 HashMap<String, LinkedList<NodeInfo>> topology = new HashMap<String, LinkedList<NodeInfo>>();
33 try { 33 try {
34 FileReader reader = new FileReader(new File(conf.confFilePath)); 34 FileReader reader = new FileReader(new File(conf.confFilePath));
35 Parser parser = new Parser(); 35 Parser parser = new Parser();
36 parser.parse(reader); 36 parser.parse(reader);
37 ArrayList<Graph> graphs = parser.getGraphs(); 37 ArrayList<Graph> graphs = parser.getGraphs();
38 for (Graph graph : graphs) { 38 for (Graph graph : graphs) {
39 ArrayList<Node> nodes = graph.getNodes(false); 39 ArrayList<Node> nodes = graph.getNodes(false);
40 for (Node node : nodes) { 40 for (Node node : nodes) {
41 nodeNames.add(node.getId().getId()); 41 String nodeName = node.getId().getId();
42 nodeNames.add(nodeName);
43 topology.put(nodeName, new LinkedList<NodeInfo>());
42 } 44 }
43 ArrayList<Edge> edges = graph.getEdges(); 45 ArrayList<Edge> edges = graph.getEdges();
44 for (Edge edge : edges) { 46 for (Edge edge : edges) {
45 String connection = edge.getAttribute("label"); 47 String connection = edge.getAttribute("label");
46 String source = edge.getSource().getNode().getId().getId(); 48 String source = edge.getSource().getNode().getId().getId();
47 String target = edge.getSource().getNode().getId().getId(); 49 String target = edge.getSource().getNode().getId().getId();
48 topology.put(target, new NodeInfo(source, connection)); 50 LinkedList<NodeInfo> sources = topology.get(target);
51 sources.add(new NodeInfo(source, connection));
49 } 52 }
50 } 53 }
51 54
52 } catch (FileNotFoundException e) { 55 } catch (FileNotFoundException e) {
53 logger.error("File not found: " + conf.confFilePath); 56 logger.error("File not found: " + conf.confFilePath);