Mercurial > hg > Database > Alice
annotate src/main/java/alice/topology/manager/RecodeTopology.java @ 428:93995b7a9a05 dispose
change HostMessage field from parentAbsName to remoteAbsName
author | sugi |
---|---|
date | Tue, 22 Jul 2014 12:56:25 +0900 |
parents | 2c6f86320691 |
children | 1b32ea1263f3 |
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 | |
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; | |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
27 if (!topology.containsKey(hostInfo.remoteAbsName)) { |
422 | 28 connections = new LinkedList<HostMessage>(); |
29 } else { | |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
30 connections = topology.get(hostInfo.remoteAbsName); |
422 | 31 } |
32 connections.add(hostInfo); | |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
33 topology.put(hostInfo.remoteAbsName, connections); |
422 | 34 ods.update(info1.key, topology); |
35 | |
36 for (LinkedList<HostMessage> list :topology.values()){ | |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
37 System.out.print(list.get(0).remoteAbsName+" : "); |
422 | 38 for (HostMessage host : list){ |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
39 System.out.print("[ "+host.absName+" "+host.name+" "+host.port+" "+host.connectionName+" "+host.reverseName+" ]"); |
422 | 40 } |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
422
diff
changeset
|
41 System.out.println(); |
422 | 42 } |
43 } | |
44 | |
45 } |