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