Mercurial > hg > Database > Alice
view src/main/java/alice/topology/manager/CheckComingHost.java @ 517:80e461aa10e9 dispose
bug fix
author | sugi |
---|---|
date | Thu, 22 Jan 2015 11:43:34 +0900 (2015-01-22) |
parents | 6161dcd3da02 |
children | 145c425db88d |
line wrap: on
line source
package alice.topology.manager; import java.util.HashMap; 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 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 public void run() { 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) { if (absCookieTable.containsKey(host.cookie)){ match = true; host.absName = absCookieTable.get(host.cookie); System.out.println("match"); } } if (match){ // coming host has ever joined this App ods.put("reconnectHost", host); if (conf.dynamic) { //dynamic topology if (conf.type == TopologyType.Tree) { ods.put("orderHash", "order"); ods.put("newHost", host); } } else { // static topology new SearchHostName(); } } else { host.cookie = null; ods.put("orderHash", "order"); ods.put("newHost", host); } new CheckComingHost(); } }