Mercurial > hg > Database > Christie
view src/main/java/christie/topology/manager/SearchHostName.java @ 43:ea9657dc8311
add CreateHash SearchHostName TopologyManager
author | akahori |
---|---|
date | Thu, 02 Aug 2018 11:41:29 +0900 |
parents | |
children | 8dfd93810041 |
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 org.msgpack.type.ValueFactory; import java.util.HashMap; import java.util.LinkedList; public class SearchHostName extends CodeGear { @Take // reconnect NodeInfo HostMessage reconnectHost; @Take HashMap<String, LinkedList<HostMessage>> topology; @Peek boolean running; public SearchHostName(){ } @Override protected void run(CodeGearManager cgm) { // Question: remove処理 どうしようか. いらない気もする. // DataSegment.remove(hostInfo.absName); cgm.createRemoteDGM(reconnectHost.absName, reconnectHost.name, reconnectHost.port); getDGM(reconnectHost.absName).put("host", reconnectHost.absName); // put Host dataSegment on reconnect node if (topology.containsKey(reconnectHost.absName)) { // Question: これはバグ...? // ods.put(reconnectHost.absName, "dummy"); // this is bug if (running){ getLocalDGM().put(reconnectHost.absName, ValueFactory.createNilValue()); } LinkedList<HostMessage> hostList = topology.get(reconnectHost.absName); for (HostMessage host : hostList){ getLocalDGM().put(reconnectHost.absName, host); System.out.println("put data in "+ reconnectHost.absName); } } // update topology information for (LinkedList<HostMessage> list :topology.values()){ for (HostMessage host : list){ // find and update old info if (!reconnectHost.absName.equals(host.absName)) continue; if (!reconnectHost.name.equals(host.name) || reconnectHost.port != host.port){ host.name = reconnectHost.name; host.port = reconnectHost.port; getLocalDGM().put(host.remoteAbsName, host); } else { // nothing to do ? } } } for (LinkedList<HostMessage> list :topology.values()){ System.out.print(list.get(0).remoteAbsName+" : "); for (HostMessage host : list){ System.out.print("[ "+host.absName+" "+host.name+" "+host.port+" "+host.connectionName+" "+host.reverseName+" "+host.remoteAbsName+" ]"); } System.out.println(); } getLocalDGM().put("topology", topology); } }