Mercurial > hg > Database > Alice
changeset 26:9c6b9e032338
implements TopologyNode
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Jan 2012 03:11:23 +0900 |
parents | 50c75cb3de60 |
children | f54dcbebde3a |
files | src/alice/topology/node/IncomingAbstractHostName.java src/alice/topology/node/IncomingConnectionInfo.java src/alice/topology/node/StartTopologyNode.java src/alice/topology/node/TopologyNode.java src/topology/manager/IncomingHosts.java |
diffstat | 5 files changed, 42 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/topology/node/IncomingAbstractHostName.java Tue Jan 17 02:40:27 2012 +0900 +++ b/src/alice/topology/node/IncomingAbstractHostName.java Tue Jan 17 03:11:23 2012 +0900 @@ -7,11 +7,16 @@ public class IncomingAbstractHostName extends CodeSegment { public DataSegmentReceiver absName = new DataSegmentReceiver(ids, CommandType.PEEK); + private Class<CodeSegment> clazz; + public IncomingAbstractHostName(Class<CodeSegment> clazz) { + this.clazz = clazz; + } + @Override public void run() { String absName = this.absName.val.asRawValue().getString(); - IncomingConnectionInfo cs = new IncomingConnectionInfo(absName); + IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, clazz); cs.hostInfo.setKey("manager", absName); }
--- a/src/alice/topology/node/IncomingConnectionInfo.java Tue Jan 17 02:40:27 2012 +0900 +++ b/src/alice/topology/node/IncomingConnectionInfo.java Tue Jan 17 03:11:23 2012 +0900 @@ -13,13 +13,29 @@ public class IncomingConnectionInfo extends CodeSegment { public DataSegmentReceiver hostInfo = new DataSegmentReceiver(ids, CommandType.TAKE); - public String absName; - public IncomingConnectionInfo(String absName) { + private String absName; + private Class<CodeSegment> clazz; + + public IncomingConnectionInfo(String absName, Class<CodeSegment> clazz) { this.absName = absName; + this.clazz = clazz; } @Override public void run() { + if (this.hostInfo.val.isNilValue()) { + System.out.println("Configuration finished"); + if (clazz == null) + return; + try { + clazz.newInstance().execute(); + } catch (InstantiationException e) { + e.printStackTrace(); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } + return; + } MessagePack msgpack = new MessagePack(); try { HostMessage hostInfo = msgpack.convert(this.hostInfo.val, HostMessage.class); @@ -27,6 +43,9 @@ } catch (IOException e) { e.printStackTrace(); } + + IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, clazz); + cs.hostInfo.setKey("manager", absName); } }
--- a/src/alice/topology/node/StartTopologyNode.java Tue Jan 17 02:40:27 2012 +0900 +++ b/src/alice/topology/node/StartTopologyNode.java Tue Jan 17 03:11:23 2012 +0900 @@ -13,10 +13,12 @@ public class StartTopologyNode extends CodeSegment { - TopologyNodeConfig conf; + private TopologyNodeConfig conf; + private Class<CodeSegment> clazz; - public StartTopologyNode(TopologyNodeConfig conf) { + public StartTopologyNode(TopologyNodeConfig conf, Class<CodeSegment> clazz) { this.conf = conf; + this.clazz = clazz; } @Override @@ -33,7 +35,7 @@ e.printStackTrace(); } - IncomingAbstractHostName cs = new IncomingAbstractHostName(); + IncomingAbstractHostName cs = new IncomingAbstractHostName(clazz); cs.absName.setKey("local", "host"); }
--- a/src/alice/topology/node/TopologyNode.java Tue Jan 17 02:40:27 2012 +0900 +++ b/src/alice/topology/node/TopologyNode.java Tue Jan 17 03:11:23 2012 +0900 @@ -1,17 +1,18 @@ package alice.topology.node; +import alice.codesegment.CodeSegment; import alice.daemon.AliceDaemon; public class TopologyNode { - public TopologyNode(String[] args, TopologyNodeConfig conf) { + public TopologyNode(String[] args, TopologyNodeConfig conf, Class<CodeSegment> clazz) { new AliceDaemon(conf).listen(); - new StartTopologyNode(conf).execute(); + new StartTopologyNode(conf, clazz).execute(); } public static void main(String[] args) { TopologyNodeConfig conf = new TopologyNodeConfig(args); - TopologyNode node = new TopologyNode(args, conf); + TopologyNode node = new TopologyNode(args, conf, null); } }
--- a/src/topology/manager/IncomingHosts.java Tue Jan 17 02:40:27 2012 +0900 +++ b/src/topology/manager/IncomingHosts.java Tue Jan 17 03:11:23 2012 +0900 @@ -45,7 +45,12 @@ e.printStackTrace(); } - if (!nodeNames.isEmpty()) { + if (nodeNames.isEmpty()) { + // configuration finish + for (String key : topology.keySet()) { + ods.put("local", key, ValueFactory.createNilValue()); + } + } else { IncomingHosts cs = new IncomingHosts(topology, nodeNames); cs.host.setKey("local", "host"); }