Mercurial > hg > Database > Alice
annotate src/main/java/alice/topology/manager/RecodeTopology.java @ 472:116e0fde9233 dispose
change algotherm
author | sugi |
---|---|
date | Tue, 25 Nov 2014 16:17:33 +0900 |
parents | 268b1280dc18 |
children | fac27e395930 |
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 | |
466 | 14 private Receiver info1 = ids.create(CommandType.TAKE); // HashMap |
422 | 15 |
16 public RecodeTopology(){ | |
17 info.setKey("nodeInfo"); | |
472 | 18 |
422 | 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); | |
466 | 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); |
466 | 34 // need debug option |
35 // for (LinkedList<HostMessage> list :topology.values()){ | |
36 // System.out.print(list.get(0).remoteAbsName+" : "); | |
37 // for (HostMessage host : list){ | |
38 // System.out.print("[ "+host.absName+" "+host.name+" "+host.port+" "+host.connectionName+" "+host.reverseName+" "+host.remoteAbsName+" ]"); | |
39 // } | |
40 // System.out.println(); | |
41 // } | |
435 | 42 ods.update(info1.key, topology); |
422 | 43 } |
44 | |
45 } |