Mercurial > hg > Database > Alice
view src/main/java/alice/topology/manager/SearchHostName.java @ 655:1c93e82e05c6 default tip
fix timestamp
author | suruga |
---|---|
date | Sat, 17 Feb 2018 00:33:00 +0900 |
parents | 268b1280dc18 |
children | 0832af83583f 767d93626b88 1a860019b2fe ffa43f252492 |
line wrap: on
line source
package alice.topology.manager; import java.util.HashMap; import java.util.LinkedList; import org.msgpack.type.ValueFactory; import alice.codesegment.CodeSegment; import alice.datasegment.CommandType; import alice.datasegment.DataSegment; import alice.datasegment.Receiver; import alice.topology.HostMessage; public class SearchHostName extends CodeSegment { private Receiver info = ids.create(CommandType.TAKE); // reconnect NodeInfo private Receiver info1 = ids.create(CommandType.TAKE); // topology recode (HashMap) private Receiver info2 = ids.create(CommandType.PEEK); // check App running public SearchHostName(){ info.setKey("reconnectHost"); info1.setKey("topology"); info2.setKey("running"); } @Override public void run() { HostMessage hostInfo = info.asClass(HostMessage.class); boolean running = info2.asClass(boolean.class); @SuppressWarnings("unchecked") HashMap<String, LinkedList<HostMessage>> topology = info1.asClass(HashMap.class); DataSegment.remove(hostInfo.absName); DataSegment.connect(hostInfo.absName, "", hostInfo.name, hostInfo.port); ods.put(hostInfo.absName, "host", hostInfo.absName); // put Host dataSegment on reconnect node if (topology.containsKey(hostInfo.absName)) { LinkedList<HostMessage> clist = topology.get(hostInfo.absName); ods.put(hostInfo.absName, "dummy"); // this is bug if (running){ ods.put(hostInfo.absName, ValueFactory.createNilValue()); } for (HostMessage node : clist){ ods.put("local" ,hostInfo.absName, node); System.out.println("put data in "+ hostInfo.absName); } } // update topology information for (LinkedList<HostMessage> list :topology.values()){ for (HostMessage host : list){ // find and update old info if (hostInfo.absName.equals(host.absName)){ if (!hostInfo.name.equals(host.name) || (hostInfo.port != host.port)){ host.name = hostInfo.name; host.port = hostInfo.port; ods.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(); } ods.put("topology", topology); } }