changeset 114:ce96f375f369

fix topologyManager
author akahori
date Fri, 30 Nov 2018 11:17:06 +0900
parents d2f1c7e3cf01
children e1e919f12ed9
files src/main/java/christie/topology/manager/CreateTreeTopology.java src/main/java/christie/topology/manager/FileParser.java src/main/java/christie/topology/manager/RecordTopology.java
diffstat 3 files changed, 12 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/src/main/java/christie/topology/manager/CreateTreeTopology.java	Fri Nov 30 10:46:33 2018 +0900
+++ b/src/main/java/christie/topology/manager/CreateTreeTopology.java	Fri Nov 30 11:17:06 2018 +0900
@@ -66,12 +66,12 @@
             HostMessage parentHost = nameTable.get(parentNodeName);
 
             // 相手からhostNameとportはもらっているので, nodeの情報だけ与えれば良い.
-            parentHost.setNodeInfo(parentNodeName, "parent", nodeName);
+            parentHost.setNodeInfo(nodeName, "parent", parentNodeName);
             getLocalDGM().put("nodeInfo", parentHost);
             cgm.setup(new RecordTopology());
 
             // newChildHost, newHostも同じ
-            newHost.setNodeInfo(nodeName, "child" + parentManager.getMyNumber(), parentNodeName);
+            newHost.setNodeInfo(parentNodeName, "child" + parentManager.getMyNumber(), nodeName);
             getLocalDGM().put("nodeInfo", newHost);
             cgm.setup(new RecordTopology());
         }
--- a/src/main/java/christie/topology/manager/FileParser.java	Fri Nov 30 10:46:33 2018 +0900
+++ b/src/main/java/christie/topology/manager/FileParser.java	Fri Nov 30 11:17:06 2018 +0900
@@ -32,10 +32,8 @@
             Parser parser = new Parser();
             parser.parse(reader);
 
-
             ArrayList<Graph> digraphs = parser.getGraphs();
 
-
             for (Graph digraph : digraphs) {
                 ArrayList<Node> nodes = digraph.getNodes(false);
                 nodeNum = nodes.size();
@@ -54,7 +52,10 @@
                     nodeInfo.setNodeInfo(edge.getSource().getNode().getId().getId(),
                                          edge.getAttribute("label"),
                                          edge.getTarget().getNode().getId().getId());
-                    resultParse.get(nodeInfo.getNodeName()).add(nodeInfo);
+
+                    // remote側のhost, portを与えるので, IncomingHostsで取りやすいように
+                    // <remoteNodeName, nodeInfo> って形にした.
+                    resultParse.get(nodeInfo.getRemoteNodeName()).add(nodeInfo);
                 }
             }
 
--- a/src/main/java/christie/topology/manager/RecordTopology.java	Fri Nov 30 10:46:33 2018 +0900
+++ b/src/main/java/christie/topology/manager/RecordTopology.java	Fri Nov 30 11:17:06 2018 +0900
@@ -35,14 +35,14 @@
         }
 
         // topologyNodeにつながる相手の情報を送る
-        if(topology.containsKey(remoteNodeName)){
-            getDGM(nodeName).put("remoteNodeInfo", topology.get(remoteNodeName).get(nodeName));
-            if(topology.get(remoteNodeName).containsKey(nodeName)){
-                getDGM(remoteNodeName).put("remoteNodeInfo", nodeInfo);
+        if(containsDGM(nodeName)){
+            getDGM(nodeName).put("remoteNodeInfo", nodeInfo);
+            if(topology.containsKey(remoteNodeName)){
+                if(topology.get(remoteNodeName).containsKey(nodeName)){
+                    getDGM(remoteNodeName).put("remoteNodeInfo", topology.get(remoteNodeName).get(nodeName));
+                }
             }
-
         }
-
     }
 
 }