Mercurial > hg > Database > Alice
changeset 484:c00437e91db0 dispose
rename
author | sugi |
---|---|
date | Sat, 06 Dec 2014 20:52:52 +0900 |
parents | 86c45738dd9e |
children | 45b3fe2375ef |
files | src/main/java/alice/topology/fix/FixTopology.java |
diffstat | 1 files changed, 45 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/topology/fix/FixTopology.java Fri Dec 05 21:24:37 2014 +0900 +++ b/src/main/java/alice/topology/fix/FixTopology.java Sat Dec 06 20:52:52 2014 +0900 @@ -29,25 +29,26 @@ @SuppressWarnings("unchecked") @Override public void run() { - ConnectionInfo disconnect = info.asClass(ConnectionInfo.class); + ConnectionInfo lost = info.asClass(ConnectionInfo.class); + System.out.println(lost.port+" "+lost.nodeName); HashMap<String, HostMessage> nameTable = info3.asClass(HashMap.class); ParentManager manager = info4.asClass(ParentManager.class); HashMap<String, LinkedList<HostMessage>> topology = info1.asClass(HashMap.class); - HostMessage disconnectNode = null; - String disconnectNodeName = null; + HostMessage lostNode = null; + String lostNodeName = null; for (String name : nameTable.keySet()) { - disconnectNode = nameTable.get(name); - if ((disconnectNode.name.equals(disconnect.addr)||disconnectNode.name.equals(disconnect.hostname)) - && disconnectNode.port == disconnect.port) { - disconnectNodeName = name; + lostNode = nameTable.get(name); + if ((lostNode.name.equals(lost.addr)||lostNode.name.equals(lost.hostname)) + && lostNode.port == lost.port) { + lostNodeName = name; break; } - disconnectNode = null; + lostNode = null; } - if (disconnectNode!=null && disconnectNode.isAlive()) { + if (lostNode!=null && lostNode.isAlive()) { // change state not Alive - disconnectNode.alive = false; + lostNode.alive = false; // get lastJoinedNode int last = info2.asInteger()-1; String lastJoinNodeName = "node"+last; @@ -63,36 +64,52 @@ } } - if (!lastJoinNodeName.equals(disconnectNodeName)) { - // send close message to lastJoinedNode - ods.put(lastJoinNodeName, "_CLOSEMESSEAGE", parentNode.reverseName); - // send close message to lastJoinedNode's parent - ods.put(parentNode.absName, "_CLOSEMESSEAGE", parentNode.connectionName); + if (!lastJoinNodeName.equals(lostNodeName)) { + + if (lostNodeName.equals(parentNode.remoteAbsName)) { + + } else { + // send close message to lastJoinedNode + ods.put(lastJoinNodeName, "_CLOSEMESSEAGE", parentNode.reverseName); + // send close message to lastJoinedNode's parent + ods.put(parentNode.absName, "_CLOSEMESSEAGE", parentNode.connectionName); + } HostMessage lastJoinNode = nameTable.get(lastJoinNodeName); connectionList = topology.get(lastJoinNodeName); - LinkedList<HostMessage> disconnectionList = topology.get(disconnectNodeName); + LinkedList<HostMessage> disconnectionList = topology.get(lostNodeName); // remove NodeInformation from disconnection node's children and parent for (HostMessage node :disconnectionList) { LinkedList<HostMessage> list = topology.get(node.absName); - for (HostMessage node1 : list) { - if (node1.absName.equals(disconnectNodeName)) { - node1.name = lastJoinNode.name; - node1.port = lastJoinNode.port; - node1.absName = lastJoinNodeName; - ods.put(node1.remoteAbsName, node1); - break; + if (!node.absName.equals(lastJoinNodeName)) { + for (HostMessage node1 : list) { + if (node1.absName.equals(lostNodeName)) { + node1.name = lastJoinNode.name; + node1.port = lastJoinNode.port; + node1.absName = lastJoinNodeName; + ods.put(node1.remoteAbsName, node1); + break; + } + } + node.remoteAbsName = lastJoinNodeName; + ods.put(node.remoteAbsName, node); + connectionList.add(node); + } else { + for (HostMessage node1 :disconnectionList) { + if ("parent".equals(node1.connectionName)) { + node1.reverseName = lastJoinNodeName; + list.add(node1); + ods.put(node1.remoteAbsName, node1); + break; + } } } - node.remoteAbsName = lastJoinNodeName; - ods.put(node.remoteAbsName, node); - connectionList.add(node); } disconnectionList.clear(); - manager.replaceAndRemove(disconnectNodeName, lastJoinNodeName); + manager.replaceAndRemove(lostNodeName, lastJoinNodeName); } else { // disconnection node is lastJoinedNode - manager.remove(disconnectNodeName); + manager.remove(lostNodeName); } } else { // disconnect message already received.