Mercurial > hg > Members > tatsuki > Alice
changeset 268:709936c00c89
creating reconnect manager
author | sugi |
---|---|
date | Sun, 18 Aug 2013 02:13:52 +0900 |
parents | fac206b7849c |
children | 9982e1c4f099 |
files | src/alice/topology/HostMessage.java src/alice/topology/manager/IncomingHosts.java src/alice/topology/manager/TopologyFinish.java src/alice/topology/manager/reconnection/CheckABSName.java src/alice/topology/manager/reconnection/ReceiveConnectionError.java src/alice/topology/manager/reconnection/ReceiveError.java src/alice/topology/node/ConfigurationFinish.java src/alice/topology/node/IncomingAbstractHostName.java |
diffstat | 8 files changed, 75 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/alice/topology/HostMessage.java Sat Aug 17 18:55:19 2013 +0900 +++ b/src/alice/topology/HostMessage.java Sun Aug 18 02:13:52 2013 +0900 @@ -28,4 +28,8 @@ absName = name; } + public String getABSName(){ + return absName; + } + }
--- a/src/alice/topology/manager/IncomingHosts.java Sat Aug 17 18:55:19 2013 +0900 +++ b/src/alice/topology/manager/IncomingHosts.java Sun Aug 18 02:13:52 2013 +0900 @@ -32,7 +32,9 @@ String nodeName = nodeNames.poll(); // Manager connect to Node + // this connection must disconnect DataSegment.connect(nodeName, "", host.name, host.port); + System.out.println(nodeName); ods.put(nodeName, "host", nodeName); LinkedList<NodeInfo> nodes = topology.get(nodeName); ArrayList<HostMessage> list; @@ -62,6 +64,8 @@ cs.host.setKey("local", "host"); cs.connection.setKey("local", "connection"); } + + // for Debug if (connectionList.containsKey("node0")){ ArrayList<HostMessage> maplist = connectionList.get("node0"); for (HostMessage i : maplist){
--- a/src/alice/topology/manager/TopologyFinish.java Sat Aug 17 18:55:19 2013 +0900 +++ b/src/alice/topology/manager/TopologyFinish.java Sun Aug 18 02:13:52 2013 +0900 @@ -3,13 +3,13 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; -import alice.topology.manager.reconnection.ReceiveConnectionError; +import alice.topology.manager.reconnection.ReceiveError; public class TopologyFinish extends CodeSegment { public Receiver finish = ids.create(CommandType.TAKE); @Override public void run() { - new ReceiveConnectionError(); + new ReceiveError(); } }
--- a/src/alice/topology/manager/reconnection/CheckABSName.java Sat Aug 17 18:55:19 2013 +0900 +++ b/src/alice/topology/manager/reconnection/CheckABSName.java Sun Aug 18 02:13:52 2013 +0900 @@ -1,5 +1,37 @@ package alice.topology.manager.reconnection; -public class CheckABSName { +import java.util.List; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.DataSegment; +import alice.datasegment.Receiver; +import alice.topology.HostMessage; + +public class CheckABSName extends CodeSegment{ + private Receiver abs = ids.create(CommandType.PEEK); + private Receiver host = ids.create(CommandType.TAKE); + private HostMessage message; + + public CheckABSName(HostMessage mes) { + message = mes; + abs.setKey("_ABSTABLE"); + host.setKey("host"); + } + + @Override + public void run() { + @SuppressWarnings("unchecked") + List<HostMessage> absList = abs.asClass(List.class); + for (HostMessage mes : absList){ + if (mes.name.equals(message.name)&&mes.port == message.port){ + HostMessage hostInfo = host.asClass(HostMessage.class); + DataSegment.connect(mes.getABSName(), "", hostInfo.name, hostInfo.port); + ods.put(mes.getABSName(), "host", mes.getABSName()); + + } + + } + } }
--- a/src/alice/topology/manager/reconnection/ReceiveConnectionError.java Sat Aug 17 18:55:19 2013 +0900 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,33 +0,0 @@ -package alice.topology.manager.reconnection; - -import java.io.IOException; -import java.net.Socket; -import java.net.UnknownHostException; - -import alice.codesegment.CodeSegment; -import alice.datasegment.CommandType; -import alice.datasegment.Receiver; -import alice.topology.HostMessage; - -public class ReceiveConnectionError extends CodeSegment { - public Receiver reportInfo = ids.create(CommandType.TAKE); - - public ReceiveConnectionError(){ - reportInfo.setKey("_ERROR"); - } - - @Override - public void run() { - HostMessage message = reportInfo.asClass(HostMessage.class); - try { - Socket socket = new Socket(message.name, message.port); - socket.close(); - } catch (UnknownHostException e) { - e.printStackTrace(); - } catch (IOException e) { - new CheckABSName(); - } - new ReceiveConnectionError(); - } - -}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/alice/topology/manager/reconnection/ReceiveError.java Sun Aug 18 02:13:52 2013 +0900 @@ -0,0 +1,30 @@ +package alice.topology.manager.reconnection; + +import java.io.IOException; +import java.net.Socket; +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; +import alice.topology.HostMessage; + +public class ReceiveError extends CodeSegment { + public Receiver reportInfo = ids.create(CommandType.TAKE); + + public ReceiveError(){ + reportInfo.setKey("_ERROR"); + } + + @Override + public void run() { + HostMessage message = reportInfo.asClass(HostMessage.class); + try { + Socket socket = new Socket(message.name, message.port); + socket.close(); + } catch (IOException e) { + new CheckABSName(message); + return; + } + new ReceiveError(); + } + +}
--- a/src/alice/topology/node/ConfigurationFinish.java Sat Aug 17 18:55:19 2013 +0900 +++ b/src/alice/topology/node/ConfigurationFinish.java Sun Aug 18 02:13:52 2013 +0900 @@ -20,10 +20,8 @@ public void run() { if (reverseCount.getVal().equals(configNodeNum.getVal())) { ods.put("manager", "done", ValueFactory.createNilValue()); - Start cs = new Start(startCS); cs.done.setKey("manager", "start"); - return; }
--- a/src/alice/topology/node/IncomingAbstractHostName.java Sat Aug 17 18:55:19 2013 +0900 +++ b/src/alice/topology/node/IncomingAbstractHostName.java Sun Aug 18 02:13:52 2013 +0900 @@ -19,7 +19,9 @@ String absName = this.absName.asString(); IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, 0); cs.hostInfo.setKey("manager", absName); + System.out.println(absName); host.setABSName(absName); + // need create list on manager ods.put("manager","_ABS_IP", host); }