Mercurial > hg > Database > Christie
changeset 158:e295cb59e514
update refactor topology manager
author | akahori |
---|---|
date | Wed, 16 Jan 2019 18:57:04 +0900 |
parents | 7a2108775da7 |
children | a0391cfdcef6 |
files | src/main/java/christie/topology/HostMessage.java src/main/java/christie/topology/manager/CreateTreeTopology.java src/main/java/christie/topology/manager/IncomingHosts.java src/main/java/christie/topology/manager/RecordTopology.java src/main/java/christie/topology/manager/TopologyManager.java src/main/java/christie/topology/node/CreateConnectionList.java src/main/java/christie/topology/node/IncomingConnectionInfo.java src/main/java/christie/topology/node/PrepareToClose.java |
diffstat | 8 files changed, 37 insertions(+), 35 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/christie/topology/HostMessage.java Tue Jan 15 20:38:26 2019 +0900 +++ b/src/main/java/christie/topology/HostMessage.java Wed Jan 16 18:57:04 2019 +0900 @@ -7,8 +7,8 @@ @Message public class HostMessage implements Cloneable { - private String hostName; - private int port; + private String hostName = ""; + private int port ; private String nodeName; // this is nodeName which have these IP and port. private String connectionName; private String remoteNodeName; @@ -28,6 +28,10 @@ } } + public void setHostAndPort(HostMessage hostMessage) { + setHostAndPort(hostMessage.getHostName(), hostMessage.getPort()); + } + public void setHostAndPort(String hostName, int port) { this.hostName = hostName; this.port = port;
--- a/src/main/java/christie/topology/manager/CreateTreeTopology.java Tue Jan 15 20:38:26 2019 +0900 +++ b/src/main/java/christie/topology/manager/CreateTreeTopology.java Wed Jan 16 18:57:04 2019 +0900 @@ -71,11 +71,13 @@ parentHost.setNodeInfo(nodeName, "parent", parentNodeName); //parentHost.setNodeInfo(parentNodeName, "child", nodeName); getLocalDGM().put("nodeInfo", parentHost); + getDGM(nodeName).put("remoteNodeInfo", parentHost); cgm.setup(new RecordTopology()); // newChildHost, newHostも同じ newHost.setNodeInfo(parentNodeName, "child" + parentManager.getMyNumber(), nodeName); getLocalDGM().put("nodeInfo", newHost); + getDGM(parentNodeName).put("remoteNodeInfo", newHost); cgm.setup(new RecordTopology()); }
--- a/src/main/java/christie/topology/manager/IncomingHosts.java Tue Jan 15 20:38:26 2019 +0900 +++ b/src/main/java/christie/topology/manager/IncomingHosts.java Wed Jan 16 18:57:04 2019 +0900 @@ -24,6 +24,9 @@ @Take String MD5; + //@Peek + //HashMap<String, LinkedList<HostMessage>> topology; + public IncomingHosts() { } @@ -34,11 +37,10 @@ String nodeName = nodeNames.poll(); getLocalDGM().put("nodeNames", nodeNames); - String newHostName = newHost.getHostName(); - int newHostPort = newHost.getPort(); - // Manager connect to Node - cgm.createRemoteDGM(nodeName, newHostName, newHostPort); + cgm.createRemoteDGM(nodeName, + newHost.getHostName(), + newHost.getPort()); absCookieTable.put(MD5, nodeName); getLocalDGM().put("absCookieTable", absCookieTable); @@ -47,12 +49,13 @@ getDGM(nodeName).put("cookie", MD5); LinkedList<HostMessage> nodeInfoList = resultParse.get(nodeName); - getDGM(nodeName).put("connectNodeNum", nodeInfoList.size()); + getDGM(nodeName).put("connectNodeNum",nodeInfoList.size()); for (HostMessage nodeInfo : nodeInfoList) { - nodeInfo.setHostAndPort(newHostName, newHostPort); + + nodeInfo.setHostAndPort(newHost); getLocalDGM().put("nodeInfo", nodeInfo); - + getDGM(nodeName).put("remoteNodeInfo", nodeInfo); cgm.setup(new RecordTopology()); } getLocalDGM().put("resultParse", resultParse);
--- a/src/main/java/christie/topology/manager/RecordTopology.java Tue Jan 15 20:38:26 2019 +0900 +++ b/src/main/java/christie/topology/manager/RecordTopology.java Wed Jan 16 18:57:04 2019 +0900 @@ -8,6 +8,7 @@ import christie.topology.HostMessage; import java.util.HashMap; +import java.util.LinkedList; // Recordだけじゃなく, sendも担っているので名前変えたほうがいいかも @@ -17,36 +18,24 @@ HostMessage nodeInfo; @Take - HashMap<String, HashMap<String, HostMessage>> topology; // ノード数nの全結合のデータ数 (n-1)*n + n + HashMap<String, LinkedList<HostMessage>> topology; @Override protected void run(CodeGearManager cgm) { String nodeName = nodeInfo.getNodeName(); - String remoteNodeName = nodeInfo.getRemoteNodeName(); + + LinkedList<HostMessage> connections; - // topologyにつながりを保存する. - if (topology.containsKey(nodeName)) { - topology.get(nodeName).put(remoteNodeName, nodeInfo); - + if (!topology.containsKey(nodeName)) { + connections = new LinkedList<HostMessage>(); } else { - HashMap<String, HostMessage> connections = new HashMap<String, HostMessage>(); - connections.put(remoteNodeName, nodeInfo); - topology.put(nodeName, connections); + connections = topology.get(nodeName); } - - // topologyNodeにつながる相手の情報を送る - 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)); - } - } - } + connections.add(nodeInfo); + topology.put(nodeName, connections); getLocalDGM().put("topology", topology); - } }
--- a/src/main/java/christie/topology/manager/TopologyManager.java Tue Jan 15 20:38:26 2019 +0900 +++ b/src/main/java/christie/topology/manager/TopologyManager.java Wed Jan 16 18:57:04 2019 +0900 @@ -45,7 +45,7 @@ cgm.setup(new CreateHash()); cgm.setup(new TopologyFinish()); - getLocalDGM().put("topology", new HashMap<String, HashMap<String, HostMessage>>()); + getLocalDGM().put("topology", new HashMap<String, LinkedList<HostMessage>>()); getLocalDGM().put("createdList", new LinkedList<String>()); }
--- a/src/main/java/christie/topology/node/CreateConnectionList.java Tue Jan 15 20:38:26 2019 +0900 +++ b/src/main/java/christie/topology/node/CreateConnectionList.java Wed Jan 16 18:57:04 2019 +0900 @@ -17,7 +17,6 @@ @Override protected void run(CodeGearManager cgm) { - _CLIST.add(cMember); getLocalDGM().put("_CLIST", _CLIST); }
--- a/src/main/java/christie/topology/node/IncomingConnectionInfo.java Tue Jan 15 20:38:26 2019 +0900 +++ b/src/main/java/christie/topology/node/IncomingConnectionInfo.java Wed Jan 16 18:57:04 2019 +0900 @@ -13,20 +13,25 @@ @Take HostMessage remoteNodeInfo; + int count; + public IncomingConnectionInfo() { + this.count = 0; } + @Override protected void run(CodeGearManager cgm) { String connectionName = remoteNodeInfo.getConnectionName(); cgm.createRemoteDGM(connectionName, - remoteNodeInfo.getHostName(), - remoteNodeInfo.getPort()); - + remoteNodeInfo.getHostName(), + remoteNodeInfo.getPort()); + getDGM(connectionName).put("reverseNodeName", "node"); getLocalDGM().put("cMember", connectionName); cgm.setup(new CreateConnectionList()); + cgm.setup(new IncomingConnectionInfo()); }