Mercurial > hg > Database > Alice
changeset 584:8f765e3eed24 dispose
add Topology Manager Number to Topology Node Key
line wrap: on
line diff
--- a/src/main/java/alice/topology/HostMessage.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/HostMessage.java Wed Jan 27 18:10:50 2016 +0900 @@ -8,11 +8,11 @@ public int port; public int topMNum = 0;//複数のTopMに接続する際、どのTopMのノードかを識別する - public String connectionName; + public String connectionName;//"parent" or "child"+num public String absName; // this is absName which have these IP and port. - public String reverseName; - public String remoteAbsName; + public String reverseName;//"parent" or "child"+num + public String remoteAbsName;//nodeName public String cookie; // MD5 public boolean alive;
--- a/src/main/java/alice/topology/fix/ReceiveDisconnectMessage.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/fix/ReceiveDisconnectMessage.java Wed Jan 27 18:10:50 2016 +0900 @@ -4,6 +4,9 @@ import alice.datasegment.CommandType; import alice.datasegment.Receiver; +/** + * This class call FixTopology when connection closed + */ public class ReceiveDisconnectMessage extends CodeSegment { private Receiver info = ids.create(CommandType.PEEK);
--- a/src/main/java/alice/topology/manager/CheckComingHost.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/manager/CheckComingHost.java Wed Jan 27 18:10:50 2016 +0900 @@ -6,13 +6,16 @@ import alice.datasegment.Receiver; import alice.topology.HostMessage; +/** + * This class check hash and put "newHost"(host info) for CreateTopology when putted "host"(join request) from topology node + */ public class CheckComingHost extends CodeSegment { // checkIncomingHost private Receiver host = ids.create(CommandType.TAKE); private Receiver absCookieTable = ids.create(CommandType.PEEK); // cookie, AbsName HashMap public CheckComingHost(){ - this.host.setKey("host"); + this.host.setKey("host");//接続要求してきたノードの情報 this.absCookieTable.setKey("absCookieTable"); }
--- a/src/main/java/alice/topology/manager/ComingServiceHosts.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/manager/ComingServiceHosts.java Wed Jan 27 18:10:50 2016 +0900 @@ -4,6 +4,9 @@ import alice.datasegment.CommandType; import alice.datasegment.Receiver; +/** + * This class create topology when putted newHost by CheckComingHost + */ public class ComingServiceHosts extends CodeSegment{ private Receiver info = ids.create(CommandType.PEEK);
--- a/src/main/java/alice/topology/manager/CreateHash.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/manager/CreateHash.java Wed Jan 27 18:10:50 2016 +0900 @@ -10,6 +10,9 @@ import alice.datasegment.CommandType; import alice.datasegment.Receiver; +/** + * create host cookie + */ public class CreateHash extends CodeSegment{ // this CodeSegment change raw string to MD5
--- a/src/main/java/alice/topology/manager/CreateTreeTopology.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/manager/CreateTreeTopology.java Wed Jan 27 18:10:50 2016 +0900 @@ -13,18 +13,18 @@ private Receiver info = ids.create(CommandType.TAKE); private Receiver info1 = ids.create(CommandType.TAKE); - private Receiver info2 = ids.create(CommandType.TAKE); // HashMap - private Receiver info3 = ids.create(CommandType.TAKE); // MD5 + private Receiver info2 = ids.create(CommandType.TAKE); + private Receiver info3 = ids.create(CommandType.TAKE); private Receiver info4 = ids.create(CommandType.TAKE); private Receiver info6 = ids.create(CommandType.TAKE); public CreateTreeTopology(){ - info.setKey("newHost"); - info1.setKey("hostCount"); - info2.setKey("nameTable"); - info3.setKey("MD5"); - info4.setKey("absCookieTable"); - info6.setKey("parentManager"); + info.setKey("newHost"); //HostMessage + info1.setKey("hostCount"); //incoming host count number for put node name like node0, node1, node2 + info2.setKey("nameTable"); //HashMap.<String:nodeName, HostMessage> + info3.setKey("MD5"); //String:node's cookie that created by CreateHash + info4.setKey("absCookieTable"); //HashMap<String:cookie, String:nodeName> + info6.setKey("parentManager"); //ParentManager } @SuppressWarnings("unchecked") @@ -42,9 +42,8 @@ String nodeName = "node"+comingHostCount; // Manager connect to Node DataSegment.connect(nodeName, nodeName, host.name, host.port); - //ods.put(nodeName, "host", new HashMap<Integer, String>().put(host.topMNum, nodeName)); - ods.put(nodeName, "host", nodeName); - ods.put(nodeName, "cookie", cookie); + ods.put(nodeName, "host"+host.topMNum, nodeName); + ods.put(nodeName, "cookie"+host.topMNum, cookie); absCookieTable.put(cookie, nodeName); ods.put(info4.key, absCookieTable); @@ -53,7 +52,7 @@ nameTable.put(nodeName, host); manager.register(nodeName); - if (comingHostCount!=0) { + if (comingHostCount!=0) {///ルートでなければ親情報を持つ // put parent information own String parentAbsName = manager.getMyParent(); HostMessage parent = nameTable.get(parentAbsName);
--- a/src/main/java/alice/topology/manager/IncomingHosts.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/manager/IncomingHosts.java Wed Jan 27 18:10:50 2016 +0900 @@ -42,13 +42,13 @@ // Manager connect to Node DataSegment.connect(nodeName, "", host.name, host.port); //ods.put(nodeName, "host", new HashMap<Integer, String>() .put(host.topMNum, nodeName)); - ods.put(nodeName, "host", nodeName); + ods.put(nodeName, "host"+host.topMNum, nodeName); String cookie = this.cookie.asString(); absCookieTable.put(cookie, nodeName); ods.put(this.absCookieTable.key, absCookieTable); - ods.put(nodeName, "cookie", cookie); + ods.put(nodeName, "cookie"+host.topMNum, cookie); LinkedList<NodeInfo> nodes = topology.get(nodeName); for (NodeInfo nodeInfo : nodes) {
--- a/src/main/java/alice/topology/manager/RecodeTopology.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/manager/RecodeTopology.java Wed Jan 27 18:10:50 2016 +0900 @@ -8,6 +8,10 @@ import alice.datasegment.Receiver; import alice.topology.HostMessage; +/** + * This class update "topology"(topology info). + * "topology" has HashMap<String:nodeName, LinkedList<HostMessage>> + */ public class RecodeTopology extends CodeSegment { private Receiver info = ids.create(CommandType.TAKE); // NodeInfo
--- a/src/main/java/alice/topology/manager/SearchHostName.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/manager/SearchHostName.java Wed Jan 27 18:10:50 2016 +0900 @@ -33,7 +33,7 @@ DataSegment.remove(hostInfo.absName); DataSegment.connect(hostInfo.absName, "", hostInfo.name, hostInfo.port); //ods.put(hostInfo.absName, "host", new HashMap<Integer, String>() .put(hostInfo.topMNum, hostInfo.absName)); - ods.put(hostInfo.absName, "host", hostInfo.absName); + ods.put(hostInfo.absName, "host"+hostInfo.topMNum, hostInfo.absName); // put Host dataSegment on reconnect node if (topology.containsKey(hostInfo.absName)) {
--- a/src/main/java/alice/topology/node/IncomingAbstractHostName.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/node/IncomingAbstractHostName.java Wed Jan 27 18:10:50 2016 +0900 @@ -7,12 +7,17 @@ public class IncomingAbstractHostName extends CodeSegment { public Receiver absName = ids.create(CommandType.PEEK); + private int topMNumber; + + public IncomingAbstractHostName(int topMNumber){ + this.topMNumber = topMNumber; + } @Override public void run() { String absName = this.absName.asString(); - IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, 0); - cs.hostInfo.setKey("manager", absName); + IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, 0, topMNumber); + cs.hostInfo.setKey("manager"+topMNumber, absName); } }
--- a/src/main/java/alice/topology/node/IncomingConnectionInfo.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/node/IncomingConnectionInfo.java Wed Jan 27 18:10:50 2016 +0900 @@ -9,10 +9,11 @@ public class IncomingConnectionInfo extends CodeSegment { public Receiver hostInfo = ids.create(CommandType.TAKE); - private String absName; + private String absName;//nodeName private int count; + private int topMNumber; - public IncomingConnectionInfo(String absName, int count) { + public IncomingConnectionInfo(String absName, int count, int topMNumber) { this.absName = absName; this.count = count; } @@ -26,8 +27,9 @@ HostMessage hostInfo = this.hostInfo.asClass(HostMessage.class); if (DataSegment.contains(hostInfo.connectionName)) { // need to wait remove by DeleteConnection - ods.put("manager", absName, hostInfo); + ods.put("manager"+topMNumber, absName, hostInfo); } else { + //create RDSM of parent or child DataSegment.connect(hostInfo.connectionName, hostInfo.reverseName, hostInfo.name, hostInfo.port); ods.put(hostInfo.connectionName, "reverseKey", hostInfo.reverseName); count++; @@ -38,8 +40,8 @@ } - IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, count); - cs.hostInfo.setKey("manager", absName); + IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, count, topMNumber); + cs.hostInfo.setKey("manager"+topMNumber, absName); } }
--- a/src/main/java/alice/topology/node/SaveCookie.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/node/SaveCookie.java Wed Jan 27 18:10:50 2016 +0900 @@ -8,8 +8,8 @@ private Receiver info = ids.create(CommandType.PEEK); - public SaveCookie(){ - info.setKey("cookie"); + public SaveCookie(int topMNumber){ + info.setKey("cookie"+topMNumber); } @Override
--- a/src/main/java/alice/topology/node/StartTopologyNode.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/node/StartTopologyNode.java Wed Jan 27 18:10:50 2016 +0900 @@ -3,6 +3,7 @@ import java.net.InetAddress; import java.net.UnknownHostException; import java.util.ArrayList; +import java.util.LinkedList; import alice.codesegment.CodeSegment; import alice.datasegment.DataSegment; @@ -10,35 +11,37 @@ public class StartTopologyNode extends CodeSegment { + private LinkedList<TopologyNodeConfig> configs; private TopologyNodeConfig conf; private CodeSegment startCS; private int topMNumber; - public StartTopologyNode(TopologyNodeConfig conf, CodeSegment startCS, int topMNum) { - this.conf = conf; + public StartTopologyNode(LinkedList<TopologyNodeConfig> configs, CodeSegment startCS, int topMNum) { + this.configs = configs; + this.conf = configs.get(topMNum); this.startCS = startCS; this.topMNumber = topMNum; } @Override public void run() { - DataSegment.connect("manager", "manager", conf.getManagerHostName(), conf.getManagerPort()); + DataSegment.connect("manager"+ topMNumber, "manager" + topMNumber, conf.getManagerHostName(), conf.getManagerPort()); String localHostName = null; try { localHostName = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); } - new SaveCookie(); + new SaveCookie(topMNumber); HostMessage host = new HostMessage(localHostName, conf.localPort, topMNumber); host.cookie = conf.cookie; - ods.put("manager", "host", host); + ods.put("manager" + topMNumber, "host", host); ods.put("_CLIST", new ArrayList<String>()); - IncomingAbstractHostName cs = new IncomingAbstractHostName(); - cs.absName.setKey("local", "host"); + IncomingAbstractHostName cs = new IncomingAbstractHostName(topMNumber); + cs.absName.setKey("local", "host"+topMNumber); IncomingReverseKey cs2 = new IncomingReverseKey(); cs2.reverseKey.setKey("local", "reverseKey"); @@ -46,9 +49,13 @@ ods.put("local", "reverseCount", 0); - ConfigurationFinish cs3 = new ConfigurationFinish(startCS); - cs3.reverseCount.setKey("local", "reverseCount"); - cs3.configNodeNum.setKey("local", "configNodeNum"); + if (topMNumber == 0){ + ConfigurationFinish cs3 = new ConfigurationFinish(startCS); + cs3.reverseCount.setKey("local", "reverseCount"); + cs3.configNodeNum.setKey("local", "configNodeNum"); + } else { + new StartTopologyNode(configs, startCS, topMNumber - 1).execute(); + } }
--- a/src/main/java/alice/topology/node/TopologyNode.java Fri Dec 18 01:34:12 2015 +0900 +++ b/src/main/java/alice/topology/node/TopologyNode.java Wed Jan 27 18:10:50 2016 +0900 @@ -3,16 +3,23 @@ import alice.codesegment.CodeSegment; import alice.daemon.AliceDaemon; +import java.util.Collection; +import java.util.LinkedList; + public class TopologyNode { public TopologyNode(TopologyNodeConfig conf, CodeSegment startCS) { new AliceDaemon(conf).listen(); - new StartTopologyNode(conf, startCS, 0).execute(); + LinkedList<TopologyNodeConfig> confs = new LinkedList<TopologyNodeConfig>(); + confs.addFirst(conf); + new StartTopologyNode(confs, startCS, 0).execute(); } - public TopologyNode(TopologyNodeConfig conf, CodeSegment startCS, int TopMNumber) { - new AliceDaemon(conf).listen(); - new StartTopologyNode(conf, startCS, TopMNumber).execute(); + public TopologyNode(LinkedList<TopologyNodeConfig> configs, CodeSegment startCS) { + for (int i = 0; i < configs.size();i++){ + new AliceDaemon(configs.get(i)).listen(); + } + new StartTopologyNode(configs, startCS, configs.size()).execute(); } public static void main(String[] args) {