Mercurial > hg > Database > Alice
annotate src/main/java/alice/topology/manager/RecodeTopology.java @ 584:8f765e3eed24 dispose
add Topology Manager Number to Topology Node Key
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Wed, 27 Jan 2016 18:10:50 +0900 |
parents | fac27e395930 |
children | 3284428f525e |
rev | line source |
---|---|
422 | 1 package alice.topology.manager; |
2 | |
3 import java.util.HashMap; | |
4 import java.util.LinkedList; | |
5 | |
6 import alice.codesegment.CodeSegment; | |
7 import alice.datasegment.CommandType; | |
8 import alice.datasegment.Receiver; | |
9 import alice.topology.HostMessage; | |
10 | |
584
8f765e3eed24
add Topology Manager Number to Topology Node Key
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
11 /** |
8f765e3eed24
add Topology Manager Number to Topology Node Key
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
12 * This class update "topology"(topology info). |
8f765e3eed24
add Topology Manager Number to Topology Node Key
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
13 * "topology" has HashMap<String:nodeName, LinkedList<HostMessage>> |
8f765e3eed24
add Topology Manager Number to Topology Node Key
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
475
diff
changeset
|
14 */ |
422 | 15 public class RecodeTopology extends CodeSegment { |
16 | |
17 private Receiver info = ids.create(CommandType.TAKE); // NodeInfo | |
466 | 18 private Receiver info1 = ids.create(CommandType.TAKE); // HashMap |
422 | 19 |
20 public RecodeTopology(){ | |
21 info.setKey("nodeInfo"); | |
475 | 22 info1.setKey("topology"); |
422 | 23 } |
24 | |
25 @Override | |
26 public void run() { | |
27 HostMessage hostInfo = info.asClass(HostMessage.class); | |
28 @SuppressWarnings("unchecked") | |
29 HashMap<String, LinkedList<HostMessage>> topology = info1.asClass(HashMap.class); | |
466 | 30 LinkedList<HostMessage> connections; |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
31 if (!topology.containsKey(hostInfo.remoteAbsName)) { |
422 | 32 connections = new LinkedList<HostMessage>(); |
33 } else { | |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
34 connections = topology.get(hostInfo.remoteAbsName); |
422 | 35 } |
36 connections.add(hostInfo); | |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
37 topology.put(hostInfo.remoteAbsName, connections); |
466 | 38 // need debug option |
39 // for (LinkedList<HostMessage> list :topology.values()){ | |
40 // System.out.print(list.get(0).remoteAbsName+" : "); | |
41 // for (HostMessage host : list){ | |
42 // System.out.print("[ "+host.absName+" "+host.name+" "+host.port+" "+host.connectionName+" "+host.reverseName+" "+host.remoteAbsName+" ]"); | |
43 // } | |
44 // System.out.println(); | |
45 // } | |
435 | 46 ods.update(info1.key, topology); |
422 | 47 } |
48 | |
49 } |