Mercurial > hg > Database > Alice
diff src/main/java/alice/topology/manager/CheckComingHost.java @ 434:4c62f76894c8 dispose
refactoring
author | sugi |
---|---|
date | Mon, 11 Aug 2014 18:45:33 +0900 |
parents | e565d481c52e |
children | 41bb86275910 |
line wrap: on
line diff
--- a/src/main/java/alice/topology/manager/CheckComingHost.java Mon Aug 11 18:23:18 2014 +0900 +++ b/src/main/java/alice/topology/manager/CheckComingHost.java Mon Aug 11 18:45:33 2014 +0900 @@ -1,7 +1,6 @@ package alice.topology.manager; -import java.util.LinkedList; - +import java.util.HashMap; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.Receiver; @@ -10,30 +9,28 @@ public class CheckComingHost extends CodeSegment { // checkIncomingHost private Receiver host = ids.create(CommandType.TAKE); - private Receiver messageList = ids.create(CommandType.PEEK); // HostMessage List - + private Receiver absCookieTable = ids.create(CommandType.TAKE); // cookie, AbsName HashMap + public CheckComingHost(){ this.host.setKey("host"); - this.messageList.setKey("messageList"); + this.absCookieTable.setKey("absCookieTable"); } - + @Override public void run() { HostMessage host = this.host.asClass(HostMessage.class); @SuppressWarnings("unchecked") - LinkedList<HostMessage> messageList = this.messageList.asClass(LinkedList.class); + HashMap<String, String> absCookieTable = this.absCookieTable.asClass(HashMap.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 (absCookieTable.containsKey(host.cookie)){ + match = true; + host.absName = absCookieTable.get(host.cookie); + } } - + if (match){ // coming host has ever joined this App System.out.println("reconnect host"); @@ -43,8 +40,8 @@ ods.put("orderHash", "order"); ods.put("newHost", host); } - - new CheckComingHost(); + + new CheckComingHost(); } }