Mercurial > hg > Database > Alice
changeset 435:41bb86275910 dispose
send MD5 "mode -t"
author | sugi |
---|---|
date | Tue, 12 Aug 2014 07:37:17 +0900 |
parents | 4c62f76894c8 |
children | a9ed8e932a1e |
files | src/main/java/alice/topology/manager/CheckComingHost.java src/main/java/alice/topology/manager/ComingServiceHosts.java src/main/java/alice/topology/manager/CreateHash.java src/main/java/alice/topology/manager/IncomingHosts.java src/main/java/alice/topology/manager/RecodeTopology.java src/main/java/alice/topology/manager/SearchHostName.java src/main/java/alice/topology/manager/StartTopologyManager.java |
diffstat | 7 files changed, 38 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/src/main/java/alice/topology/manager/CheckComingHost.java Mon Aug 11 18:45:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/CheckComingHost.java Tue Aug 12 07:37:17 2014 +0900 @@ -9,7 +9,7 @@ public class CheckComingHost extends CodeSegment { // checkIncomingHost private Receiver host = ids.create(CommandType.TAKE); - private Receiver absCookieTable = ids.create(CommandType.TAKE); // cookie, AbsName HashMap + private Receiver absCookieTable = ids.create(CommandType.PEEK); // cookie, AbsName HashMap public CheckComingHost(){ this.host.setKey("host"); @@ -27,7 +27,7 @@ if (absCookieTable.containsKey(host.cookie)){ match = true; host.absName = absCookieTable.get(host.cookie); - + } } @@ -35,6 +35,7 @@ // coming host has ever joined this App System.out.println("reconnect host"); ods.put("reconnectHost", host); + new SearchHostName(); } else { System.out.println("new host"); ods.put("orderHash", "order");
--- a/src/main/java/alice/topology/manager/ComingServiceHosts.java Mon Aug 11 18:45:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/ComingServiceHosts.java Tue Aug 12 07:37:17 2014 +0900 @@ -12,19 +12,24 @@ public class ComingServiceHosts extends CodeSegment{ - Receiver info = ids.create(CommandType.TAKE); - Receiver info1 = ids.create(CommandType.TAKE); - Receiver info2 = ids.create(CommandType.TAKE); // HashMap - int BINATY_TREE = 2; + 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 int BINATY_TREE = 2; public ComingServiceHosts(){ info.setKey("newHost"); info1.setKey("hostCount"); info2.setKey("nodeConnectionInfo"); + info3.setKey("MD5"); } @Override public void run() { + String cookie = info3.asString(); + System.out.println(cookie); HostMessage host = info.asClass(HostMessage.class); int comingHostCount = info1.asInteger(); @SuppressWarnings("unchecked") @@ -33,20 +38,31 @@ // Manager connect to Node DataSegment.connect(nodeName, "", host.name, host.port); ods.put(nodeName, "host", nodeName); + ods.put(nodeName, "cookie", cookie); + ods.update(info1.key, comingHostCount+1); - + for (int i=1;i < BINATY_TREE+1; i++) { - int num = 2 * comingHostCount+i; + // child number is own number(comingHostCount) * 2 add one or two + int num = BINATY_TREE * comingHostCount+i; HostMessage newHost = new HostMessage(host.name, host.port, "parent", "child"+(i-1)); - newHost.remoteAbsName = nodeName; - newHost.absName = "node"+num; - parentInfo.put(newHost.absName, newHost); - ods.put(newHost.absName, newHost); + newHost.absName = nodeName; + newHost.remoteAbsName = "node"+num; + parentInfo.put(newHost.remoteAbsName, newHost); + + ods.put("nodeInfo", newHost); + ods.put(newHost.remoteAbsName, newHost); + new RecodeTopology(); } if (comingHostCount!=0) { HostMessage parent = parentInfo.get(nodeName); - HostMessage newHost = new HostMessage(host.name, host.port, parent.reverseName, parent.connectionName); - ods.put(parent.remoteAbsName, newHost); + HostMessage newHost = new HostMessage(host.name, host.port, parent.reverseName, parent.connectionName); + newHost.absName = nodeName; + newHost.remoteAbsName = parent.absName; + + ods.put("nodeInfo", newHost); + ods.put(parent.absName, newHost); + new RecodeTopology(); } ods.put("nodeConnectionInfo", parentInfo);
--- a/src/main/java/alice/topology/manager/CreateHash.java Mon Aug 11 18:45:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/CreateHash.java Tue Aug 12 07:37:17 2014 +0900 @@ -23,6 +23,7 @@ @Override public void run() { + System.out.println("created"); @SuppressWarnings("unchecked") LinkedList<String> createdRawList = this.info1.asClass(LinkedList.class); boolean checkNewStr = false;
--- a/src/main/java/alice/topology/manager/IncomingHosts.java Mon Aug 11 18:45:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/IncomingHosts.java Tue Aug 12 07:37:17 2014 +0900 @@ -68,6 +68,7 @@ nodeInfo.connectionName, nodeInfo.reverseName); newHost.absName = nodeName; newHost.remoteAbsName = nodeInfo.sourceNodeName; + ods.put("nodeInfo", newHost); ods.put(nodeInfo.sourceNodeName, newHost); new RecodeTopology();
--- a/src/main/java/alice/topology/manager/RecodeTopology.java Mon Aug 11 18:45:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/RecodeTopology.java Tue Aug 12 07:37:17 2014 +0900 @@ -31,7 +31,6 @@ } connections.add(hostInfo); topology.put(hostInfo.remoteAbsName, connections); - ods.update(info1.key, topology); for (LinkedList<HostMessage> list :topology.values()){ System.out.print(list.get(0).remoteAbsName+" : "); @@ -40,6 +39,7 @@ } System.out.println(); } + ods.update(info1.key, topology); } }
--- a/src/main/java/alice/topology/manager/SearchHostName.java Mon Aug 11 18:45:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/SearchHostName.java Tue Aug 12 07:37:17 2014 +0900 @@ -37,7 +37,7 @@ // put Host dataSegment on reconnect node if (topology.containsKey(hostInfo.absName)) { LinkedList<HostMessage> clist = topology.get(hostInfo.absName); - ods.put(hostInfo.absName, "dummy"); + ods.put(hostInfo.absName, "dummy"); // this is bug if (running){ ods.put(hostInfo.absName, ValueFactory.createNilValue()); }
--- a/src/main/java/alice/topology/manager/StartTopologyManager.java Mon Aug 11 18:45:33 2014 +0900 +++ b/src/main/java/alice/topology/manager/StartTopologyManager.java Tue Aug 12 07:37:17 2014 +0900 @@ -77,9 +77,7 @@ } // for recode topology information - ods.put("topology", new HashMap<String, LinkedList<HostMessage>>()); // cookie List - ods.put("createdList", new LinkedList<String>()); ods.put("orderHash", "order"); ods.put("running", false); @@ -89,6 +87,7 @@ cs3.done.setKey("local", "done"); } else { System.out.println("mode -t"); + ods.put("running", true); new CheckComingHost(); HashMap<String,HostMessage> parentInfo = new HashMap<String,HostMessage>(); @@ -98,7 +97,9 @@ new ComingServiceHosts(); } + ods.put("topology", new HashMap<String, LinkedList<HostMessage>>()); ods.put("absCookieTable", new HashMap<String, String>()); + ods.put("createdList", new LinkedList<String>()); new CreateHash(); }