Mercurial > hg > Members > tatsuki > Alice
annotate src/alice/topology/manager/IncomingHosts.java @ 34:ca079a730d0b
added method to OutputDataSegment and Receiver, to convert type from Value to Class<?> without MessagePack
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 19 Jan 2012 16:01:50 +0900 |
parents | 20c67f673224 |
children | 2afbb6404840 |
rev | line source |
---|---|
27 | 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 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 import org.apache.log4j.Logger; |
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
|
7 |
23
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
8 import org.msgpack.type.ValueFactory; |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
9 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 import alice.codesegment.CodeSegment; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 import alice.datasegment.CommandType; |
23
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
12 import alice.datasegment.DataSegment; |
33
20c67f673224
change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
13 import alice.datasegment.Receiver; |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
14 import alice.topology.HostMessage; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 public class IncomingHosts extends CodeSegment { |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 |
24 | 18 HashMap<String, LinkedList<NodeInfo>> topology; |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 LinkedList<String> nodeNames; |
33
20c67f673224
change name of DataSegmentReceiver
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
32
diff
changeset
|
20 Receiver host = ids.create(CommandType.TAKE); |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 Logger logger = Logger.getLogger(IncomingHosts.class); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 |
24 | 23 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
|
24 this.topology = topology; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
25 this.nodeNames = nodeNames; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 } |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 @Override |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 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
|
30 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
|
31 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
|
32 // 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
|
33 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
|
34 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
|
35 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
|
36 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
|
37 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
|
38 ods.put("local", nodeInfo.sourceNodeName, newHost); |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 } |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 |
26 | 41 if (nodeNames.isEmpty()) { |
42 // configuration finish | |
43 for (String key : topology.keySet()) { | |
44 ods.put("local", key, ValueFactory.createNilValue()); | |
45 } | |
46 } else { | |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
47 IncomingHosts cs = new IncomingHosts(topology, nodeNames); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
48 cs.host.setKey("local", "host"); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
49 } |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 } |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
51 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
52 } |