Mercurial > hg > Database > Christie
view src/main/java/christie/topology/manager/CreateTreeTopology.java @ 92:f607fe2fc9a9
del ComingServiceHosts
author | akahori |
---|---|
date | Sat, 15 Sep 2018 11:27:36 +0900 |
parents | 331ad549e764 |
children | 7abfe041b75c |
line wrap: on
line source
package christie.topology.manager; import christie.annotation.Peek; import christie.annotation.Take; import christie.codegear.CodeGear; import christie.codegear.CodeGearManager; import christie.topology.HostMessage; import java.util.HashMap; public class CreateTreeTopology extends CodeGear{ @Take HostMessage newHost; @Take int hostCount; @Peek HashMap<String, HostMessage> nameTable; @Take String MD5; @Peek HashMap<String, String> absCookieTable; @Peek ParentManager parentManager; public CreateTreeTopology(){ } @Override protected void run(CodeGearManager cgm) { System.out.println("cookie:" + MD5); String nodeName = "node" + hostCount; // Manager connect to Node cgm.createRemoteDGM(nodeName, newHost.hostName, newHost.port); getDGM(nodeName).put("nodeName", nodeName); getDGM(nodeName).put("cookie", MD5); absCookieTable.put(MD5, nodeName); getLocalDGM().put("hostCount", hostCount + 1); newHost.alive = true; nameTable.put(nodeName, newHost); parentManager.register(nodeName); if (hostCount == 0) { // どこにも繋がれるところがないので, ルートのとき. // ルートなので, connectNodeNumもreverseCountも0でいい. getDGM(nodeName).put("connectNodeNum", 0); getDGM(nodeName).put("reverseCount", 0); } else { // 親のみにつながればいいので1 getDGM(nodeName).put("connectNodeNum", 1); // put parent information own String parentNodeName = parentManager.getMyParent(); HostMessage parent = nameTable.get(parentNodeName); int num = parentManager.getMyNumber(); HostMessage newParentHost = new HostMessage(parent.hostName, parent.port, "parent", "child" + num); newParentHost.nodeName = parentNodeName; newParentHost.remoteNodeName = nodeName; // address getLocalDGM().put("nodeInfo", newParentHost); cgm.setup(new RecordTopology()); // put own information parent HostMessage newChildHost = new HostMessage(newHost.hostName, newHost.port, "child" + num, "parent"); newChildHost.nodeName = nodeName; newChildHost.remoteNodeName = parentNodeName; getLocalDGM().put("nodeInfo", newChildHost); cgm.setup(new RecordTopology()); } getDGM(nodeName).put("start", "start"); cgm.setup(new CreateTreeTopology()); } }