annotate src/main/java/alice/topology/manager/RecodeTopology.java @ 422:2c6f86320691 dispose

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