Mercurial > hg > Database > Alice
changeset 433:e565d481c52e dispose
separate checking process from IncomingHosts
author | sugi |
---|---|
date | Mon, 11 Aug 2014 18:23:18 +0900 |
parents | 59e84cd75403 |
children | 4c62f76894c8 |
files | src/main/java/alice/topology/manager/CheckComingHost.java src/main/java/alice/topology/manager/ComingServiceHosts.java src/main/java/alice/topology/manager/IncomingHosts.java src/main/java/alice/topology/manager/SearchHostName.java src/main/java/alice/topology/manager/StartTopologyManager.java |
diffstat | 5 files changed, 59 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/main/java/alice/topology/manager/CheckComingHost.java Mon Aug 11 18:23:18 2014 +0900 @@ -0,0 +1,50 @@ +package alice.topology.manager; + +import java.util.LinkedList; + +import alice.codesegment.CodeSegment; +import alice.datasegment.CommandType; +import alice.datasegment.Receiver; +import alice.topology.HostMessage; + +public class CheckComingHost extends CodeSegment { + // checkIncomingHost + private Receiver host = ids.create(CommandType.TAKE); + private Receiver messageList = ids.create(CommandType.PEEK); // HostMessage List + + public CheckComingHost(){ + this.host.setKey("host"); + this.messageList.setKey("messageList"); + } + + @Override + public void run() { + HostMessage host = this.host.asClass(HostMessage.class); + @SuppressWarnings("unchecked") + LinkedList<HostMessage> messageList = this.messageList.asClass(LinkedList.class); + boolean match = false; + // check cookie + if (host.cookie != null) { + for (HostMessage hostMessage : messageList) { + if (host.cookie.equals(hostMessage.cookie)) { + match = true; + host.absName = hostMessage.absName; + break; + } + } + } + + if (match){ + // coming host has ever joined this App + System.out.println("reconnect host"); + ods.put("reconnectHost", host); + } else { + System.out.println("new host"); + ods.put("orderHash", "order"); + ods.put("newHost", host); + } + + new CheckComingHost(); + } + +}
--- a/src/main/java/alice/topology/manager/ComingServiceHosts.java Mon Aug 04 20:34:41 2014 +0900 +++ b/src/main/java/alice/topology/manager/ComingServiceHosts.java Mon Aug 11 18:23:18 2014 +0900 @@ -18,7 +18,7 @@ int BINATY_TREE = 2; public ComingServiceHosts(){ - info.setKey("host"); + info.setKey("newHost"); info1.setKey("hostCount"); info2.setKey("nodeConnectionInfo"); }
--- a/src/main/java/alice/topology/manager/IncomingHosts.java Mon Aug 04 20:34:41 2014 +0900 +++ b/src/main/java/alice/topology/manager/IncomingHosts.java Mon Aug 11 18:23:18 2014 +0900 @@ -15,7 +15,7 @@ HashMap<String, LinkedList<NodeInfo>> topology; LinkedList<String> nodeNames; - private Receiver host = ids.create(CommandType.TAKE); //node name + private Receiver host = ids.create(CommandType.TAKE); //HostMessage private Receiver messageList = ids.create(CommandType.TAKE); // HostMessage List private Receiver cookie = ids.create(CommandType.TAKE); // MD5 @@ -41,7 +41,7 @@ match = true; System.out.println("cookie is match"); host.absName = hostMessage.absName; - ods.put("reconnect", host); + ods.put("reconnectHost", host); ods.put(this.messageList.key, messageList); new SearchHostName(); break;
--- a/src/main/java/alice/topology/manager/SearchHostName.java Mon Aug 04 20:34:41 2014 +0900 +++ b/src/main/java/alice/topology/manager/SearchHostName.java Mon Aug 11 18:23:18 2014 +0900 @@ -18,7 +18,7 @@ private Receiver info2 = ids.create(CommandType.PEEK); // check App running public SearchHostName(){ - info.setKey("reconnect"); + info.setKey("reconnectHost"); info1.setKey("topology"); info2.setKey("running"); }
--- a/src/main/java/alice/topology/manager/StartTopologyManager.java Mon Aug 04 20:34:41 2014 +0900 +++ b/src/main/java/alice/topology/manager/StartTopologyManager.java Mon Aug 11 18:23:18 2014 +0900 @@ -80,23 +80,26 @@ ods.put("topology", new HashMap<String, LinkedList<HostMessage>>()); // cookie List ods.put("createdList", new LinkedList<String>()); - ods.put("messageList", new LinkedList<HostMessage>()); ods.put("orderHash", "order"); ods.put("running", false); - new CreateHash(); new IncomingHosts(topology, nodeNames); ConfigWaiter cs3 = new ConfigWaiter(nodeNum); cs3.done.setKey("local", "done"); } else { System.out.println("mode -t"); + new CheckComingHost(); + HashMap<String,HostMessage> parentInfo = new HashMap<String,HostMessage>(); int cominghostCount = 0; ods.put("nodeConnectionInfo", parentInfo); ods.put("hostCount", cominghostCount); new ComingServiceHosts(); } + + ods.put("messageList", new LinkedList<HostMessage>()); + new CreateHash(); } }