Mercurial > hg > Members > tatsuki > Alice
view src/alice/topology/node/IncomingConnectionInfo.java @ 27:f54dcbebde3a
topology manager work!
author | kazz <kazz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 17 Jan 2012 03:52:39 +0900 |
parents | 9c6b9e032338 |
children | 98ab26e09a98 |
line wrap: on
line source
package alice.topology.node; import java.io.IOException; import org.msgpack.MessagePack; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.DataSegmentReceiver; import alice.topology.HostMessage; public class IncomingConnectionInfo extends CodeSegment { public DataSegmentReceiver hostInfo = new DataSegmentReceiver(ids, CommandType.TAKE); 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 == null) { 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); DataSegment.connect(hostInfo.connectionName, hostInfo.name, hostInfo.port); } catch (IOException e) { e.printStackTrace(); } IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, clazz); cs.hostInfo.setKey("manager", absName); } }