Mercurial > hg > Applications > TreeVNC
changeset 251:4a89a92becee
divide process about connectTo error
author | oc |
---|---|
date | Tue, 11 Nov 2014 05:30:56 +0900 |
parents | 45cb40bf0d74 |
children | eee9a8f53dbc |
files | src/main/java/com/glavsoft/rfb/client/ClientToServerMessage.java src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java |
diffstat | 2 files changed, 35 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/com/glavsoft/rfb/client/ClientToServerMessage.java Tue Nov 04 04:21:56 2014 +0900 +++ b/src/main/java/com/glavsoft/rfb/client/ClientToServerMessage.java Tue Nov 11 05:30:56 2014 +0900 @@ -35,7 +35,7 @@ byte POINTER_EVENT = 5; byte CLIENT_CUT_TEXT = 6; byte SERVER_CHANGE_REQUEST = (byte) 240; // TreeVNC extension - byte CHECK_DELAY_REPLY = 7; + byte CHECK_DELAY_REPLY = 70; void send(Writer writer) throws TransportException; }
--- a/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java Tue Nov 04 04:21:56 2014 +0900 +++ b/src/main/java/jp/ac/u_ryukyu/treevnc/TreeManagement.java Tue Nov 11 05:30:56 2014 +0900 @@ -84,7 +84,12 @@ me.setHostName(myHostName); if (deadParent.getTreeNum() == 0) { // if dead root, connect me. - connectTo(me, lostParentNode); + try { + connectTo(me, lostParentNode); + } catch (IOException e) { + System.out.println("root to lostParentNode Connection Faild (lostParent)"); + System.exit(0); + } return; } if (getChildNode(deadParent, 0) == null) return; @@ -102,12 +107,25 @@ TreeVNCNode newparent = nodeList.get(oldParent.getTreeNum()); TreeVNCNode grandfather = getParentNode(newparent.getTreeNum()); - connectTo(grandfather, newparent); + try { + connectTo(grandfather, newparent); + } catch (IOException e) { + System.out.println("grandfather to newparent Connection Faild (lostParent)"); + System.out.println("try lostNodeParent again."); + if(getChildNode(newparent, 0) == null) return; + moveLastNodeToLostNodePosition(newparent.getTreeNum()); + lostNodeConnection(newparent); + } for(int i=0; i < treebranch; i++) { TreeVNCNode child = getChildNode(newparent, i); if (child != null) { - connectTo(newparent, child); + try { + connectTo(newparent, child); + } catch (IOException e) { + System.out.println("newparent to child Connection Faild (lostParent)"); + System.exit(0); + } } } @@ -118,18 +136,10 @@ - public void connectTo(TreeVNCNode newparent, TreeVNCNode n) { + public void connectTo(TreeVNCNode newparent, TreeVNCNode n) throws IOException { TreeVncProtocol vc1 = new TreeVncProtocol(n.getHostname(),n.getPort()); - try { short nodeId = (short) n.getTreeNum(); vc1.connectTo(newparent.getHostname(), newparent.getPort(), isLeader(n), nodeId); - } catch (IOException e) { - // log - System.out.println("can't connectTo : port = " + n.getPort() + ", addr = " + n.getHostname()); - if (getChildNode(n, 0) == null) return; - moveLastNodeToLostNodePosition(n.getTreeNum()); - lostNodeConnection(n); - } } private int isLeader(TreeVNCNode n) { @@ -156,12 +166,22 @@ if (nodeList.size() >= treebranch + 1) { TreeVNCNode parent = getParentNode(node.getTreeNum()); checkParameter(parent.getTreeNum(), nodeList.size(), isLeader(node)); - connectTo(parent, node); + try { + connectTo(parent, node); + } catch (IOException e) { + System.out.println("parent : Connection Faild (decideWhereToConnect)"); + System.exit(0); + } } else { // connect to me TreeVNCNode me = nodeList.getFirst(); me.setHostName(localhostname); - connectTo(me, node); + try { + connectTo(me, node); + } catch (IOException e) { + System.out.println("root : Connection Faild (decideWhereToConnect)"); + System.exit(0); + } } if (showTreeNode) { showTreeNode();