diff src/alice/datasegment/RemoteDataSegmentManager.java @ 274:f866178f3018

success to reconnect
author sugi
date Sun, 29 Sep 2013 17:17:10 +0900
parents b4690114a0cd
children 99026285c5dc
line wrap: on
line diff
--- 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();
 	}