Mercurial > hg > Database > Alice
changeset 403:539b7f5772c7 dispose
manager in extendTopology mode have parent Information at each node
author | sugi |
---|---|
date | Mon, 23 Jun 2014 15:53:33 +0900 |
parents | ca2947303438 |
children | fee3efd9257d |
files | src/main/java/alice/topology/HostMessage.java src/main/java/alice/topology/manager/ComingServiceHosts.java src/main/java/alice/topology/manager/StartTopologyManager.java src/main/java/alice/topology/node/IncomingAbstractHostName.java src/main/java/alice/topology/node/IncomingConnectionInfo.java src/main/java/alice/topology/node/StartTopologyNode.java |
diffstat | 6 files changed, 25 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/topology/HostMessage.java Mon Jun 23 14:02:36 2014 +0900 +++ b/src/main/java/alice/topology/HostMessage.java Mon Jun 23 15:53:33 2014 +0900 @@ -24,12 +24,4 @@ this.reverseName = reverseName; } - public void setABSName(String name){ - absName = name; - } - - public String getABSName(){ - return absName; - } - }
--- a/src/main/java/alice/topology/manager/ComingServiceHosts.java Mon Jun 23 14:02:36 2014 +0900 +++ b/src/main/java/alice/topology/manager/ComingServiceHosts.java Mon Jun 23 15:53:33 2014 +0900 @@ -1,5 +1,7 @@ package alice.topology.manager; +import java.util.ArrayList; + import org.msgpack.type.ValueFactory; import alice.codesegment.CodeSegment; @@ -12,17 +14,21 @@ Receiver info = ids.create(CommandType.TAKE); Receiver info1 = ids.create(CommandType.TAKE); + Receiver info2 = ids.create(CommandType.TAKE); int BINATY_TREE = 2; public ComingServiceHosts(){ info.setKey("host"); info1.setKey("hostCount"); + info2.setKey("parentList"); } @Override public void run() { HostMessage host = info.asClass(HostMessage.class); int comingHostCount = info1.asInteger(); + @SuppressWarnings("unchecked") + ArrayList<HostMessage> parentList = info2.asClass(ArrayList.class); String nodeName = "node"+comingHostCount; // Manager connect to Node DataSegment.connect(nodeName, "", host.name, host.port); @@ -32,10 +38,21 @@ for (int i=1;i < BINATY_TREE+1; i++) { int num = 2 * comingHostCount+i; HostMessage newHost = new HostMessage(host.name, host.port, "parent", "child"+(i-1)); - ods.put("node"+num, newHost); + newHost.absName = nodeName; + String absName = "node"+num; + parentList.add(num, newHost); + ods.put(absName, newHost); } + if (comingHostCount!=0) { + HostMessage parentInfo = parentList.get(comingHostCount); + HostMessage newHost = new HostMessage(host.name, host.port, parentInfo.reverseName, "parent"); + ods.put(parentInfo.absName, newHost); + } + + ods.put("parentList", parentList); ods.put(nodeName, ValueFactory.createNilValue()); - ods.put("start", ValueFactory.createNilValue()); + if (comingHostCount==0) + ods.put("start", ValueFactory.createNilValue()); } }
--- a/src/main/java/alice/topology/manager/StartTopologyManager.java Mon Jun 23 14:02:36 2014 +0900 +++ b/src/main/java/alice/topology/manager/StartTopologyManager.java Mon Jun 23 15:53:33 2014 +0900 @@ -10,6 +10,7 @@ import org.apache.log4j.Logger; import alice.codesegment.CodeSegment; +import alice.topology.HostMessage; import com.alexmerz.graphviz.ParseException; import com.alexmerz.graphviz.Parser; @@ -82,7 +83,10 @@ cs3.done.setKey("local", "done"); } else { System.out.println("mode -t"); + ArrayList<HostMessage> parentList = new ArrayList<HostMessage>(); + parentList.add(new HostMessage()); int cominghostCount = 0; + ods.put("parentList", parentList); ods.put("hostCount", cominghostCount); new ComingServiceHosts(); }
--- a/src/main/java/alice/topology/node/IncomingAbstractHostName.java Mon Jun 23 14:02:36 2014 +0900 +++ b/src/main/java/alice/topology/node/IncomingAbstractHostName.java Mon Jun 23 15:53:33 2014 +0900 @@ -3,23 +3,16 @@ import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; -import alice.topology.HostMessage; public class IncomingAbstractHostName extends CodeSegment { public Receiver absName = ids.create(CommandType.PEEK); - private HostMessage host; // need CodeSegment - - public IncomingAbstractHostName(HostMessage _host){ - host = _host; - } @Override public void run() { String absName = this.absName.asString(); IncomingConnectionInfo cs = new IncomingConnectionInfo(absName, 0); cs.hostInfo.setKey("manager", absName); - host.setABSName(absName); } }
--- a/src/main/java/alice/topology/node/IncomingConnectionInfo.java Mon Jun 23 14:02:36 2014 +0900 +++ b/src/main/java/alice/topology/node/IncomingConnectionInfo.java Mon Jun 23 15:53:33 2014 +0900 @@ -32,6 +32,7 @@ public void run() { if (this.hostInfo.getVal() == null) { ods.put("local", "configNodeNum", count); + this.recycle(); return; }
--- a/src/main/java/alice/topology/node/StartTopologyNode.java Mon Jun 23 14:02:36 2014 +0900 +++ b/src/main/java/alice/topology/node/StartTopologyNode.java Mon Jun 23 15:53:33 2014 +0900 @@ -29,7 +29,7 @@ HostMessage host = new HostMessage(localHostName, conf.localPort); ods.put("manager", "host", host); - IncomingAbstractHostName cs = new IncomingAbstractHostName(host); + IncomingAbstractHostName cs = new IncomingAbstractHostName(); cs.absName.setKey("local", "host"); IncomingReverseKey cs2 = new IncomingReverseKey();