Mercurial > hg > Members > tatsuki > Alice
annotate src/topology/manager/IncomingHosts.java @ 23:54bf607118ae
change method to create RemoteDSM
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Jan 2012 01:10:29 +0900 |
parents | 2ca2d961a8d2 |
children | ebd91e607b63 |
rev | line source |
---|---|
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
1 package topology.manager; |
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.io.IOException; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
4 import java.util.HashMap; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
5 import java.util.LinkedList; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
6 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
7 import org.apache.log4j.Logger; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
8 import org.msgpack.MessagePack; |
23
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
9 import org.msgpack.type.ValueFactory; |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
10 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
11 import alice.codesegment.CodeSegment; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
12 import alice.datasegment.CommandType; |
23
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
13 import alice.datasegment.DataSegment; |
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
14 import alice.datasegment.DataSegmentManager; |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
15 import alice.datasegment.DataSegmentReceiver; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
16 import alice.topology.HostMessage; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
17 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
18 public class IncomingHosts extends CodeSegment { |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
19 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
20 HashMap<String, NodeInfo> topology; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
21 LinkedList<String> nodeNames; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
22 DataSegmentReceiver host = new DataSegmentReceiver(ids, CommandType.TAKE); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
23 Logger logger = Logger.getLogger(IncomingHosts.class); |
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 public IncomingHosts(HashMap<String, NodeInfo> topology, LinkedList<String> nodeNames) { |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
26 this.topology = topology; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
27 this.nodeNames = nodeNames; |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
28 } |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
29 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
30 @Override |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
31 public void run() { |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
32 MessagePack msgpack = new MessagePack(); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
33 try { |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
34 HostMessage host = msgpack.convert(this.host.val, HostMessage.class); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
35 String nodeName = nodeNames.poll(); |
23
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
36 DataSegmentManager manager = DataSegment.connect(nodeName, host.name, host.port); |
54bf607118ae
change method to create RemoteDSM
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
22
diff
changeset
|
37 manager.put("host", ValueFactory.createRawValue(nodeName)); |
22
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
38 } catch (IOException e) { |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
39 logger.error("HostMessage format error"); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
40 e.printStackTrace(); |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
41 } |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
42 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
43 if (!nodeNames.isEmpty()) { |
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 |
2ca2d961a8d2
implements outline of TopologyManager
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff
changeset
|
50 } |