Mercurial > hg > Database > Alice
annotate src/main/java/alice/topology/node/StartTopologyNode.java @ 647:e321c5ec9b58
fix toplogy manager; ring worked
author | suruga |
---|---|
date | Sun, 31 Dec 2017 19:32:27 +0900 |
parents | cb16036404ba |
children |
rev | line source |
---|---|
345 | 1 package alice.topology.node; |
2 | |
3 import java.net.InetAddress; | |
4 import java.net.UnknownHostException; | |
439 | 5 import java.util.ArrayList; |
6 | |
345 | 7 import alice.codesegment.CodeSegment; |
8 import alice.datasegment.DataSegment; | |
9 import alice.topology.HostMessage; | |
10 | |
11 public class StartTopologyNode extends CodeSegment { | |
12 | |
645
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
13 private final String manager; |
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
14 private final String local; |
419 | 15 private TopologyNodeConfig conf; |
16 private CodeSegment startCS; | |
17 | |
18 public StartTopologyNode(TopologyNodeConfig conf, CodeSegment startCS) { | |
19 this.conf = conf; | |
20 this.startCS = startCS; | |
645
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
21 this.manager = conf.getManagerKey(); |
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
22 this.local = conf.getLocalKey(); |
419 | 23 } |
24 | |
25 @Override | |
26 public void run() { | |
645
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
27 DataSegment.connect(manager, manager, conf.getManagerHostName(), conf.getManagerPort()); |
419 | 28 String localHostName = null; |
29 try { | |
562 | 30 localHostName = InetAddress.getLocalHost().getHostAddress(); |
419 | 31 } catch (UnknownHostException e) { |
32 e.printStackTrace(); | |
33 } | |
427 | 34 new SaveCookie(); |
647 | 35 if (conf.localPort == 0) { |
36 // local test mode | |
37 localHostName = conf.getLocalKey(); | |
38 } | |
39 ods.put("config" , conf ); | |
419 | 40 |
41 HostMessage host = new HostMessage(localHostName, conf.localPort); | |
427 | 42 host.cookie = conf.cookie; |
647 | 43 ods.put(manager, "hostMessage", host); |
419 | 44 |
645
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
45 ods.put(local,"_CLIST", new ArrayList<String>()); |
467 | 46 |
645
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
47 IncomingAbstractHostName cs = new IncomingAbstractHostName(conf); |
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
48 cs.absName.setKey(local, "host"); |
419 | 49 |
50 IncomingReverseKey cs2 = new IncomingReverseKey(); | |
645
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
51 cs2.reverseKey.setKey(local, "reverseKey"); |
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
52 cs2.reverseCount.setKey(local, "reverseCount"); |
419 | 53 |
645
cb16036404ba
fix local topology test
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
562
diff
changeset
|
54 ods.put(local, "reverseCount", 0); |
419 | 55 |
56 ConfigurationFinish cs3 = new ConfigurationFinish(startCS); | |
57 | |
58 } | |
59 | |
345 | 60 } |