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
|
|
11 public class RecodeTopology extends CodeSegment {
|
|
12
|
|
13 private Receiver info = ids.create(CommandType.TAKE); // NodeInfo
|
|
14 private Receiver info1 = ids.create(CommandType.TAKE); // HashMap
|
|
15
|
|
16 public RecodeTopology(){
|
|
17 info.setKey("nodeInfo");
|
|
18 info1.setKey("topology");
|
|
19 }
|
|
20
|
|
21 @Override
|
|
22 public void run() {
|
|
23 HostMessage hostInfo = info.asClass(HostMessage.class);
|
|
24 @SuppressWarnings("unchecked")
|
|
25 HashMap<String, LinkedList<HostMessage>> topology = info1.asClass(HashMap.class);
|
|
26 LinkedList<HostMessage> connections;
|
|
27 if (!topology.containsKey(hostInfo.parentAbsName)) {
|
|
28 connections = new LinkedList<HostMessage>();
|
|
29 } else {
|
|
30 connections = topology.get(hostInfo.parentAbsName);
|
|
31 }
|
|
32 connections.add(hostInfo);
|
|
33 topology.put(hostInfo.parentAbsName, connections);
|
|
34 ods.update(info1.key, topology);
|
|
35
|
|
36 for (LinkedList<HostMessage> list :topology.values()){
|
|
37 for (HostMessage host : list){
|
|
38 System.out.println(host.parentAbsName+" : "+host.name+" "+host.port+" "+host.connectionName+" "+host.reverseName);
|
|
39 }
|
|
40 }
|
|
41 }
|
|
42
|
|
43 }
|