Mercurial > hg > Database > Alice
annotate src/main/java/alice/topology/manager/IncomingHosts.java @ 547:e91a574b69de dispose
remove index
author | Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 18 Aug 2015 16:15:17 +0900 |
parents | 15eeb439830c |
children |
rev | line source |
---|---|
401 | 1 package alice.topology.manager; |
2 | |
3 import java.util.HashMap; | |
4 import java.util.LinkedList; | |
5 | |
6 import org.msgpack.type.ValueFactory; | |
7 | |
8 import alice.codesegment.CodeSegment; | |
9 import alice.datasegment.CommandType; | |
10 import alice.datasegment.Receiver; | |
11 import alice.topology.HostMessage; | |
12 | |
13 public class IncomingHosts extends CodeSegment { | |
410 | 14 |
437 | 15 private Receiver topology = ids.create(CommandType.TAKE); // Topology from parse file |
16 private Receiver nodeNames = ids.create(CommandType.TAKE); // nodeName list | |
17 private Receiver host = ids.create(CommandType.TAKE); // new coming host info | |
434 | 18 private Receiver absCookieTable = ids.create(CommandType.TAKE); // cookie, AbsName HashMap |
437 | 19 private Receiver cookie = ids.create(CommandType.TAKE); // MD5 |
410 | 20 |
437 | 21 public IncomingHosts() { |
547 | 22 this.topology.setKey("resultParse", this); |
23 this.nodeNames.setKey("nodeNames", this); | |
24 this.host.setKey("newHost", this); | |
25 this.absCookieTable.setKey("absCookieTable", this); | |
26 this.cookie.setKey("MD5", this); | |
410 | 27 } |
401 | 28 |
410 | 29 @Override |
30 public void run() { | |
31 HostMessage host = this.host.asClass(HostMessage.class); | |
431 | 32 @SuppressWarnings("unchecked") |
434 | 33 HashMap<String, String> absCookieTable = this.absCookieTable.asClass(HashMap.class); |
437 | 34 @SuppressWarnings("unchecked") |
35 HashMap<String, LinkedList<NodeInfo>> topology = this.topology.asClass(HashMap.class); | |
36 @SuppressWarnings("unchecked") | |
37 LinkedList<String> nodeNames = this.nodeNames.asClass(LinkedList.class); | |
38 | |
466 | 39 // not have or match cookie |
437 | 40 String nodeName = nodeNames.poll(); |
41 // Manager connect to Node | |
543
f3f7e256ee03
add AliceDaemon on paramater
Nozomi Teruya <e125769@ie.u-ryukyu.ac.jp>
parents:
539
diff
changeset
|
42 aliceDaemon.dataSegment.connect(nodeName, "", host.name, host.port); |
437 | 43 ods.put(nodeName, "host", nodeName); |
44 | |
45 String cookie = this.cookie.asString(); | |
46 absCookieTable.put(cookie, nodeName); | |
47 ods.put(this.absCookieTable.key, absCookieTable); | |
48 | |
49 ods.put(nodeName, "cookie", cookie); | |
50 | |
51 LinkedList<NodeInfo> nodes = topology.get(nodeName); | |
52 for (NodeInfo nodeInfo : nodes) { | |
53 HostMessage newHost = new HostMessage(host.name, host.port, | |
54 nodeInfo.connectionName, nodeInfo.reverseName); | |
55 newHost.absName = nodeName; | |
56 newHost.remoteAbsName = nodeInfo.sourceNodeName; | |
57 | |
58 ods.put("nodeInfo", newHost); | |
59 ods.put(nodeInfo.sourceNodeName, newHost); | |
60 new RecodeTopology(); | |
61 } | |
62 | |
63 if (nodeNames.isEmpty()) { | |
64 // configuration finish | |
65 for (String key : topology.keySet()) { | |
66 ods.put("local", key, ValueFactory.createNilValue()); | |
428
93995b7a9a05
change HostMessage field from parentAbsName to remoteAbsName
sugi
parents:
424
diff
changeset
|
67 } |
424
faae3e976cc1
change cookie LinkedLIst Type from String.class to HostMessage.class
sugi
parents:
423
diff
changeset
|
68 } |
466 | 69 |
437 | 70 ods.put(this.nodeNames.key, nodeNames); |
71 ods.put(this.topology.key, topology); | |
466 | 72 |
437 | 73 new IncomingHosts(); |
410 | 74 } |
401 | 75 } |