Mercurial > hg > Database > Alice
changeset 274:f866178f3018
success to reconnect
line wrap: on
line diff
--- a/src/alice/datasegment/DataSegment.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/datasegment/DataSegment.java Sun Sep 29 17:17:10 2013 +0900 @@ -27,8 +27,8 @@ dataSegment.dataSegmentManageres.put(key, manager); } - public static RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port) { - RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port); + public static RemoteDataSegmentManager connect(String connectionKey, String reverseKey, String hostName, int port, boolean rFlag) { + RemoteDataSegmentManager manager = new RemoteDataSegmentManager(connectionKey, reverseKey, hostName, port, rFlag); regist(connectionKey, manager); return manager; }
--- a/src/alice/datasegment/RemoteDataSegmentManager.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/datasegment/RemoteDataSegmentManager.java Sun Sep 29 17:17:10 2013 +0900 @@ -9,13 +9,15 @@ import alice.daemon.Connection; import alice.daemon.IncomingTcpConnection; import alice.daemon.OutboundTcpConnection; +import alice.topology.HostMessage; +import alice.topology.manager.reconnection.SendError; public class RemoteDataSegmentManager extends DataSegmentManager { Connection connection; Logger logger; - public RemoteDataSegmentManager(String connectionKey, final String reverseKey, final String hostName, final int port) { + public RemoteDataSegmentManager(String connectionKey, final String reverseKey, final String hostName, final int port, final boolean rFlag) { logger = Logger.getLogger(connectionKey); connection = new Connection(); final RemoteDataSegmentManager manager = this; @@ -32,14 +34,20 @@ logger.info("Connect to " + connection.getInfoString()); } catch (IOException e) { try { + //System.out.println("WAITING"); Thread.sleep(50); } catch (InterruptedException e1) { e1.printStackTrace(); } } - } while (connect); + } while (connect&&!rFlag); new IncomingTcpConnection(connection, manager, reverseKey).start(); new OutboundTcpConnection(connection).start(); + // if connection failed need to stop these thread + if (connect){ + System.out.println("send error"); + new SendError(new HostMessage(hostName, port)).execute(); + } } }.start(); }
--- a/src/alice/test/codesegment/remote/TestRemoteAlice.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/test/codesegment/remote/TestRemoteAlice.java Sun Sep 29 17:17:10 2013 +0900 @@ -9,7 +9,7 @@ TestRemoteConfig conf = new TestRemoteConfig(args); new AliceDaemon(conf).listen(); - DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort); + DataSegment.connect(conf.key, "", conf.hostname, conf.connectPort, false); new RemoteStartCodeSegment().execute(); }
--- a/src/alice/topology/HostMessage.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/HostMessage.java Sun Sep 29 17:17:10 2013 +0900 @@ -10,6 +10,7 @@ public String connectionName; public String reverseName; public String absName; + public boolean reconnectFlag = false; public HostMessage() { } public HostMessage(String name, int port) { @@ -32,4 +33,8 @@ return absName; } + public void setFlag(){ + this.reconnectFlag = true; + } + }
--- a/src/alice/topology/manager/IncomingHosts.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/manager/IncomingHosts.java Sun Sep 29 17:17:10 2013 +0900 @@ -32,8 +32,8 @@ String nodeName = nodeNames.poll(); // Manager connect to Node - // this connection must disconnect - DataSegment.connect(nodeName, "", host.name, host.port); + + DataSegment.connect(nodeName, "", host.name, host.port, host.reconnectFlag); ods.put(nodeName, "host", nodeName); LinkedList<NodeInfo> nodes = topology.get(nodeName); ArrayList<HostMessage> list;
--- a/src/alice/topology/manager/reconnection/CheckABSName.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/manager/reconnection/CheckABSName.java Sun Sep 29 17:17:10 2013 +0900 @@ -21,13 +21,14 @@ @Override public void run() { + System.out.println("CheckABSName"); @SuppressWarnings("unchecked") List<HostMessage> ABSIPList = abs.asClass(List.class); HostMessage hostInfo = host.asClass(HostMessage.class); for (HostMessage mes : ABSIPList){ if (mes.name.equals(message.name)&&mes.port == message.port){ DataSegment.remove(mes.getABSName()); - DataSegment.connect(mes.getABSName(), "", hostInfo.name, hostInfo.port); + DataSegment.connect(mes.getABSName(), "", hostInfo.name, hostInfo.port, hostInfo.reconnectFlag); ods.put(mes.getABSName(), "host", mes.getABSName()); ods.put("_RECABSNAME", mes.getABSName()); ods.put("_HMCLONE", new HostMessage(mes.name, mes.port)); @@ -40,7 +41,7 @@ } ods.put("host", hostInfo); new ReceiveError(); - + System.out.println("not match"); } }
--- a/src/alice/topology/manager/reconnection/CheckConnectionList.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/manager/reconnection/CheckConnectionList.java Sun Sep 29 17:17:10 2013 +0900 @@ -52,6 +52,7 @@ if (mes3.name.equals(oldInfo.name)&&mes3.port == oldInfo.port){ mes3.name = newInfo.name; mes3.port = newInfo.port; + mes3.setFlag(); ods.put(absName2, "_RECODATA", mes3); break; } @@ -60,9 +61,9 @@ } } } + System.out.println("SendHost Data"); ods.put(absName, ValueFactory.createNilValue()); ods.update("connection", connectionList); new ReceiveError(); } -} - \ No newline at end of file +} \ No newline at end of file
--- a/src/alice/topology/manager/reconnection/ReceiveError.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/manager/reconnection/ReceiveError.java Sun Sep 29 17:17:10 2013 +0900 @@ -18,9 +18,12 @@ public void run() { HostMessage message = reportInfo.asClass(HostMessage.class); try { + System.out.println("Receive Error "+ message.port); Socket socket = new Socket(message.name, message.port); socket.close(); + System.out.println("alive "+message.port); } catch (IOException e) { + System.out.println("Receive Error "+ message.port); new CheckABSName(message); return; }
--- a/src/alice/topology/manager/reconnection/ReceiveReconnectData.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/manager/reconnection/ReceiveReconnectData.java Sun Sep 29 17:17:10 2013 +0900 @@ -17,7 +17,7 @@ public void run() { HostMessage host = hostData.asClass(HostMessage.class); DataSegment.remove(host.connectionName); - DataSegment.connect(host.connectionName, host.reverseName, host.name, host.port); + DataSegment.connect(host.connectionName, host.reverseName, host.name, host.port, host.reconnectFlag); ods.put(host.connectionName, "reverseKey", host.reverseName); new ReceiveReconnectData(); }
--- a/src/alice/topology/node/IncomingConnectionInfo.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/node/IncomingConnectionInfo.java Sun Sep 29 17:17:10 2013 +0900 @@ -36,7 +36,8 @@ } HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class); - DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port); + System.out.println(hostInfo.reconnectFlag); + DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port, hostInfo.reconnectFlag); ods.put(hostInfo.connectionName, "reverseKey", hostInfo.reverseName); connectionList.add(hostInfo.connectionName); ods.update("_CLIST", connectionList);
--- a/src/alice/topology/node/StartTopologyNode.java Thu Sep 26 12:10:49 2013 +0900 +++ b/src/alice/topology/node/StartTopologyNode.java Sun Sep 29 17:17:10 2013 +0900 @@ -22,7 +22,7 @@ @Override public void run() { - DataSegment.connect("manager", "", conf.managerHostName, conf.managerPort); + DataSegment.connect("manager", "", conf.managerHostName, conf.managerPort, false); String localHostName = null; try { localHostName = InetAddress.getLocalHost().getHostName();