annotate src/alice/topology/manager/IncomingHosts.java @ 90:75aa139d46eb working

minor change
author sugi
date Tue, 05 Jun 2012 00:26:13 +0900
parents d4c7f7b1096b
children b5daccf36104
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27
f54dcbebde3a topology manager work!
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 26
diff changeset
1 package alice.topology.manager;
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 import java.util.HashMap;
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 import java.util.LinkedList;
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
23
54bf607118ae change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
6 import org.msgpack.type.ValueFactory;
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 import alice.codesegment.CodeSegment;
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 import alice.datasegment.CommandType;
23
54bf607118ae change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 22
diff changeset
10 import alice.datasegment.DataSegment;
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
11 import alice.datasegment.Receiver;
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 import alice.topology.HostMessage;
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 public class IncomingHosts extends CodeSegment {
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
24
ebd91e607b63 implements TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
16 HashMap<String, LinkedList<NodeInfo>> topology;
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 LinkedList<String> nodeNames;
33
20c67f673224 change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 32
diff changeset
18 Receiver host = ids.create(CommandType.TAKE);
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
24
ebd91e607b63 implements TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 23
diff changeset
20 public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology, LinkedList<String> nodeNames) {
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 this.topology = topology;
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 this.nodeNames = nodeNames;
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 }
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 @Override
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 public void run() {
34
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
27 HostMessage host = this.host.asClass(HostMessage.class);
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
28 String nodeName = nodeNames.poll();
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
29 // Manager connect to Node
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
30 DataSegment.connect(nodeName, "", host.name, host.port);
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
31 ods.put(nodeName, "host", nodeName);
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
32 LinkedList<NodeInfo> nodes = topology.get(nodeName);
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
33 for (NodeInfo nodeInfo : nodes) {
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
34 HostMessage newHost = new HostMessage(host.name, host.port, nodeInfo.connectionName, nodeInfo.reverseName);
ca079a730d0b added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 33
diff changeset
35 ods.put("local", nodeInfo.sourceNodeName, newHost);
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 }
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
26
9c6b9e032338 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 25
diff changeset
38 if (nodeNames.isEmpty()) {
9c6b9e032338 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 25
diff changeset
39 // configuration finish
9c6b9e032338 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 25
diff changeset
40 for (String key : topology.keySet()) {
9c6b9e032338 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 25
diff changeset
41 ods.put("local", key, ValueFactory.createNilValue());
9c6b9e032338 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 25
diff changeset
42 }
9c6b9e032338 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents: 25
diff changeset
43 } else {
22
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 IncomingHosts cs = new IncomingHosts(topology, nodeNames);
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 cs.host.setKey("local", "host");
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 }
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 }
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
2ca2d961a8d2 implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 }