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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
422
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
1 package alice.topology.manager;
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
2
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
3 import java.util.HashMap;
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
4 import java.util.LinkedList;
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
5
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
6 import alice.codesegment.CodeSegment;
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
7 import alice.datasegment.CommandType;
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
8 import alice.datasegment.Receiver;
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
9 import alice.topology.HostMessage;
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
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
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
15 public class RecodeTopology extends CodeSegment {
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
16
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
17 private Receiver info = ids.create(CommandType.TAKE); // NodeInfo
466
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
18 private Receiver info1 = ids.create(CommandType.TAKE); // HashMap
422
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
19
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
20 public RecodeTopology(){
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
21 info.setKey("nodeInfo");
475
fac27e395930 change decide children algorithm
sugi
parents: 472
diff changeset
22 info1.setKey("topology");
422
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
23 }
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
24
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
25 @Override
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
26 public void run() {
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
27 HostMessage hostInfo = info.asClass(HostMessage.class);
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
28 @SuppressWarnings("unchecked")
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
29 HashMap<String, LinkedList<HostMessage>> topology = info1.asClass(HashMap.class);
466
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
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
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
32 connections = new LinkedList<HostMessage>();
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
33 } else {
428
93995b7a9a05 change HostMessage field from parentAbsName to remoteAbsName
sugi
parents: 422
diff changeset
34 connections = topology.get(hostInfo.remoteAbsName);
422
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
35 }
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
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
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
38 // need debug option
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
39 // for (LinkedList<HostMessage> list :topology.values()){
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
40 // System.out.print(list.get(0).remoteAbsName+" : ");
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
41 // for (HostMessage host : list){
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
42 // System.out.print("[ "+host.absName+" "+host.name+" "+host.port+" "+host.connectionName+" "+host.reverseName+" "+host.remoteAbsName+" ]");
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
43 // }
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
44 // System.out.println();
268b1280dc18 remove debug message
sugi
parents: 435
diff changeset
45 // }
435
41bb86275910 send MD5 "mode -t"
sugi
parents: 429
diff changeset
46 ods.update(info1.key, topology);
422
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
47 }
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
48
2c6f86320691 add topology state recoder
sugi
parents:
diff changeset
49 }