annotate src/alice/topology/node/StartTopologyNode.java @ 25:50c75cb3de60

implements TopologyNode
author kazz <kazz@cr.ie.u-ryukyu.ac.jp>
date Tue, 17 Jan 2012 02:40:27 +0900
parents
children 9c6b9e032338
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 package alice.topology.node;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 import java.io.IOException;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 import java.net.InetAddress;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 import java.net.UnknownHostException;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 import org.msgpack.MessagePack;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 import alice.codesegment.CodeSegment;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 import alice.datasegment.DataSegment;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 import alice.datasegment.DataSegmentManager;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 import alice.topology.HostMessage;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 public class StartTopologyNode extends CodeSegment {
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 TopologyNodeConfig conf;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 public StartTopologyNode(TopologyNodeConfig conf) {
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 this.conf = conf;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 }
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 @Override
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 public void run() {
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 DataSegmentManager manager = DataSegment.connect("topology_manager", conf.managerHostName, conf.managerPort);
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 try {
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 HostMessage host;
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 host = new HostMessage(InetAddress.getLocalHost().getHostName(), conf.localPort);
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 MessagePack msgpack = new MessagePack();
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 manager.put("host", msgpack.unconvert(host));
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 } catch (UnknownHostException e) {
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 e.printStackTrace();
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 } catch (IOException e) {
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 e.printStackTrace();
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 }
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 IncomingAbstractHostName cs = new IncomingAbstractHostName();
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 cs.absName.setKey("local", "host");
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 }
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39
50c75cb3de60 implements TopologyNode
kazz <kazz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 }