Mercurial > hg > Database > Alice
annotate src/main/java/alice/topology/manager/StartTopologyManager.java @ 523:145c425db88d dispose
add CompressedLDSM
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 09 Apr 2015 18:36:26 +0900 |
parents | 6161dcd3da02 |
children | e91a574b69de 767d93626b88 3284428f525e 4027e55df60d |
rev | line source |
---|---|
401 | 1 package alice.topology.manager; |
2 | |
3 import java.io.File; | |
4 import java.io.FileNotFoundException; | |
5 import java.io.FileReader; | |
6 import java.util.ArrayList; | |
7 import java.util.HashMap; | |
8 import java.util.LinkedList; | |
9 | |
10 import org.apache.log4j.Logger; | |
11 | |
12 import alice.codesegment.CodeSegment; | |
403
539b7f5772c7
manager in extendTopology mode have parent Information at each node
sugi
parents:
402
diff
changeset
|
13 import alice.topology.HostMessage; |
478 | 14 import alice.topology.fix.ReceiveDisconnectMessage; |
401 | 15 |
16 import com.alexmerz.graphviz.ParseException; | |
17 import com.alexmerz.graphviz.Parser; | |
18 import com.alexmerz.graphviz.objects.Edge; | |
19 import com.alexmerz.graphviz.objects.Graph; | |
20 import com.alexmerz.graphviz.objects.Node; | |
21 | |
22 public class StartTopologyManager extends CodeSegment { | |
23 | |
419 | 24 TopologyManagerConfig conf; |
25 Logger logger = Logger.getLogger(StartTopologyManager.class); | |
401 | 26 |
419 | 27 public StartTopologyManager(TopologyManagerConfig conf) { |
28 this.conf = conf; | |
29 } | |
401 | 30 |
419 | 31 @Override |
32 public void run() { | |
438 | 33 new CheckComingHost(); |
34 ods.put("absCookieTable", new HashMap<String, String>()); | |
467 | 35 |
486
7be9054f7465
refactor. keepAlive has bug. if clear TaskType close , need to delete ResponsePing CodeSegment
sugi
parents:
478
diff
changeset
|
36 if (!conf.dynamic) { |
419 | 37 LinkedList<String> nodeNames = new LinkedList<String>(); |
38 HashMap<String, LinkedList<NodeInfo>> topology = new HashMap<String, LinkedList<NodeInfo>>(); | |
39 int nodeNum = 0; | |
40 try { | |
41 FileReader reader = new FileReader(new File(conf.confFilePath)); | |
42 Parser parser = new Parser(); | |
43 parser.parse(reader); | |
44 ArrayList<Graph> graphs = parser.getGraphs(); | |
45 for (Graph graph : graphs) { | |
46 ArrayList<Node> nodes = graph.getNodes(false); | |
47 nodeNum = nodes.size(); | |
48 for (Node node : nodes) { | |
49 String nodeName = node.getId().getId(); | |
50 nodeNames.add(nodeName); | |
51 topology.put(nodeName, new LinkedList<NodeInfo>()); | |
52 } | |
53 ArrayList<Edge> edges = graph.getEdges(); | |
54 HashMap<String, NodeInfo> hash = new HashMap<String, NodeInfo>(); | |
55 for (Edge edge : edges) { | |
56 String connection = edge.getAttribute("label"); | |
57 String source = edge.getSource().getNode().getId().getId(); | |
58 String target = edge.getTarget().getNode().getId().getId(); | |
59 LinkedList<NodeInfo> sources = topology.get(target); | |
60 NodeInfo nodeInfo = new NodeInfo(source, connection); | |
61 sources.add(nodeInfo); | |
62 hash.put(source + "," + target, nodeInfo); | |
63 } | |
64 for (Edge edge : edges) { | |
65 String connection = edge.getAttribute("label"); | |
66 String source = edge.getSource().getNode().getId().getId(); | |
67 String target = edge.getTarget().getNode().getId().getId(); | |
68 NodeInfo nodeInfo = hash.get(target + "," + source); | |
69 if (nodeInfo != null) { | |
70 nodeInfo.reverseName = connection; | |
71 } | |
72 } | |
73 } | |
402 | 74 |
419 | 75 } catch (FileNotFoundException e) { |
76 logger.error("File not found: " + conf.confFilePath); | |
77 e.printStackTrace(); | |
78 } catch (ParseException e) { | |
79 logger.error("File format error: " + conf.confFilePath); | |
80 e.printStackTrace(); | |
81 } | |
467 | 82 |
422 | 83 // for recode topology information |
423 | 84 // cookie List |
437 | 85 ods.put("running", false); |
86 ods.put("resultParse", topology); | |
87 ods.put("nodeNames", nodeNames); | |
467 | 88 |
437 | 89 new IncomingHosts(); |
402 | 90 |
419 | 91 ConfigWaiter cs3 = new ConfigWaiter(nodeNum); |
92 cs3.done.setKey("local", "done"); | |
467 | 93 |
419 | 94 } else { |
435 | 95 ods.put("running", true); |
467 | 96 |
475 | 97 HashMap<String, HostMessage> nameTable = new HashMap<String, HostMessage>(); |
523
145c425db88d
add CompressedLDSM
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
515
diff
changeset
|
98 |
514 | 99 if (conf.type == TopologyType.Tree) { |
100 int cominghostCount = 0; | |
101 ParentManager manager = new ParentManager(conf.hasChild); | |
102 ods.put("parentManager", manager); | |
103 ods.put("nameTable", nameTable); | |
104 ods.put("hostCount", cominghostCount); | |
105 new ComingServiceHosts(); | |
106 new ReceiveDisconnectMessage(); | |
107 } | |
419 | 108 } |
433 | 109 |
467 | 110 ods.put("topology", new HashMap<String, LinkedList<HostMessage>>()); |
435 | 111 ods.put("createdList", new LinkedList<String>()); |
433 | 112 new CreateHash(); |
468 | 113 |
114 TopologyFinish cs2 = new TopologyFinish(); | |
115 cs2.finish.setKey("local", "finish"); | |
419 | 116 } |
401 | 117 |
118 } |