Mercurial > hg > Members > tatsuki > Alice
comparison src/alice/topology/node/IncomingConnectionInfo.java @ 28:98ab26e09a98
Configuration Manager work and implements reverseKey
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Jan 2012 08:41:34 +0900 |
parents | f54dcbebde3a |
children | 5c704b9a9a87 |
comparison
equal
deleted
inserted
replaced
27:f54dcbebde3a | 28:98ab26e09a98 |
---|---|
1 package alice.topology.node; | 1 package alice.topology.node; |
2 | 2 |
3 import java.io.IOException; | 3 import java.io.IOException; |
4 | 4 |
5 import org.msgpack.MessagePack; | 5 import org.msgpack.MessagePack; |
6 import org.msgpack.type.ValueFactory; | |
6 | 7 |
7 import alice.codesegment.CodeSegment; | 8 import alice.codesegment.CodeSegment; |
8 import alice.datasegment.CommandType; | 9 import alice.datasegment.CommandType; |
9 import alice.datasegment.DataSegment; | 10 import alice.datasegment.DataSegment; |
11 import alice.datasegment.DataSegmentManager; | |
10 import alice.datasegment.DataSegmentReceiver; | 12 import alice.datasegment.DataSegmentReceiver; |
11 import alice.topology.HostMessage; | 13 import alice.topology.HostMessage; |
12 | 14 |
13 public class IncomingConnectionInfo extends CodeSegment { | 15 public class IncomingConnectionInfo extends CodeSegment { |
14 | 16 |
15 public DataSegmentReceiver hostInfo = new DataSegmentReceiver(ids, CommandType.TAKE); | 17 public DataSegmentReceiver hostInfo = new DataSegmentReceiver(ids, CommandType.TAKE); |
16 private String absName; | 18 private String absName; |
17 private Class<CodeSegment> clazz; | 19 private int count; |
18 | 20 |
19 public IncomingConnectionInfo(String absName, Class<CodeSegment> clazz) { | 21 public IncomingConnectionInfo(String absName, int count) { |
20 this.absName = absName; | 22 this.absName = absName; |
21 this.clazz = clazz; | 23 this.count = count; |
22 } | 24 } |
23 | 25 |
24 @Override | 26 @Override |
25 public void run() { | 27 public void run() { |
26 if (this.hostInfo.val == null) { | 28 if (this.hostInfo.val == null) { |
27 System.out.println("Configuration finished"); | 29 ods.put("local", "configNodeNum", ValueFactory.createIntegerValue(count)); |
28 if (clazz == null) | 30 |
29 return; | |
30 try { | |
31 clazz.newInstance().execute(); | |
32 } catch (InstantiationException e) { | |
33 e.printStackTrace(); | |
34 } catch (IllegalAccessException e) { | |
35 e.printStackTrace(); | |
36 } | |
37 return; | 31 return; |
38 } | 32 } |
39 MessagePack msgpack = new MessagePack(); | 33 MessagePack msgpack = new MessagePack(); |
40 try { | 34 try { |
41 HostMessage hostInfo = msgpack.convert(this.hostInfo.val, HostMessage.class); | 35 HostMessage hostInfo = msgpack.convert(this.hostInfo.val, HostMessage.class); |
42 DataSegment.connect(hostInfo.connectionName, hostInfo.name, hostInfo.port); | 36 DataSegmentManager manager = DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port); |
37 manager.put("reverseKey", ValueFactory.createRawValue(hostInfo.reverseName)); | |
43 } catch (IOException e) { | 38 } catch (IOException e) { |
44 e.printStackTrace(); | 39 e.printStackTrace(); |
45 } | 40 } |
46 | 41 |
47 IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, clazz); | 42 IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, ++count); |
48 cs.hostInfo.setKey("manager", absName); | 43 cs.hostInfo.setKey("manager", absName); |
49 } | 44 } |
50 | 45 |
51 } | 46 } |