Mercurial > hg > Database > Alice
changeset 515:6161dcd3da02 dispose
dynamic reconnect
author | sugi |
---|---|
date | Wed, 21 Jan 2015 14:08:26 +0900 |
parents | 6732d03d0174 |
children | a7f140f4bcb1 |
files | src/main/java/alice/topology/manager/CheckComingHost.java src/main/java/alice/topology/manager/CreateTreeTopology.java src/main/java/alice/topology/manager/StartTopologyManager.java |
diffstat | 3 files changed, 21 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/topology/manager/CheckComingHost.java Sat Jan 17 16:49:02 2015 +0900 +++ b/src/main/java/alice/topology/manager/CheckComingHost.java Wed Jan 21 14:08:26 2015 +0900 @@ -1,6 +1,7 @@ package alice.topology.manager; import java.util.HashMap; + import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; @@ -10,10 +11,12 @@ // checkIncomingHost private Receiver host = ids.create(CommandType.TAKE); private Receiver absCookieTable = ids.create(CommandType.PEEK); // cookie, AbsName HashMap + private Receiver config = ids.create(CommandType.PEEK); public CheckComingHost(){ this.host.setKey("host"); this.absCookieTable.setKey("absCookieTable"); + this.config.setKey("TMConfig"); } @Override @@ -21,6 +24,7 @@ HostMessage host = this.host.asClass(HostMessage.class); @SuppressWarnings("unchecked") HashMap<String, String> absCookieTable = this.absCookieTable.asClass(HashMap.class); + TopologyManagerConfig conf = this.config.asClass(TopologyManagerConfig.class); boolean match = false; // check cookie if (host.cookie != null) { @@ -34,7 +38,14 @@ if (match){ // coming host has ever joined this App ods.put("reconnectHost", host); - new SearchHostName(); + if (conf.dynamic) { //dynamic topology + if (conf.type == TopologyType.Tree) { + ods.put("orderHash", "order"); + ods.put("newHost", host); + } + } else { // static topology + new SearchHostName(); + } } else { ods.put("orderHash", "order"); ods.put("newHost", host);
--- a/src/main/java/alice/topology/manager/CreateTreeTopology.java Sat Jan 17 16:49:02 2015 +0900 +++ b/src/main/java/alice/topology/manager/CreateTreeTopology.java Wed Jan 21 14:08:26 2015 +0900 @@ -39,13 +39,18 @@ HashMap<String, HostMessage> nameTable = info2.asClass(HashMap.class); HashMap<String, String> absCookieTable = info4.asClass(HashMap.class); - String nodeName = "node"+comingHostCount; + String nodeName = null; + if (host.absName!=null) { + nodeName = host.absName; + } else { + nodeName = "node"+comingHostCount; + absCookieTable.put(cookie, nodeName); + } // Manager connect to Node DataSegment.connect(nodeName, nodeName, host.name, host.port); ods.put(nodeName, "host", nodeName); ods.put(nodeName, "cookie", cookie); - absCookieTable.put(cookie, nodeName); ods.put(info4.key, absCookieTable); ods.put(info1.key, comingHostCount+1); host.alive = true;
--- a/src/main/java/alice/topology/manager/StartTopologyManager.java Sat Jan 17 16:49:02 2015 +0900 +++ b/src/main/java/alice/topology/manager/StartTopologyManager.java Wed Jan 21 14:08:26 2015 +0900 @@ -32,6 +32,7 @@ public void run() { new CheckComingHost(); ods.put("absCookieTable", new HashMap<String, String>()); + ods.put("TMConfig", conf); if (!conf.dynamic) { LinkedList<String> nodeNames = new LinkedList<String>(); @@ -95,7 +96,7 @@ ods.put("running", true); HashMap<String, HostMessage> nameTable = new HashMap<String, HostMessage>(); - + // if you want to add Topology, add code here if (conf.type == TopologyType.Tree) { int cominghostCount = 0; ParentManager manager = new ParentManager(conf.hasChild);