annotate src/main/java/alice/topology/manager/CheckComingHost.java @ 517:80e461aa10e9 dispose

bug fix
author sugi
date Thu, 22 Jan 2015 11:43:34 +0900
parents 6161dcd3da02
children 145c425db88d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
1 package alice.topology.manager;
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
2
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
3 import java.util.HashMap;
515
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
4
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
5 import alice.codesegment.CodeSegment;
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
6 import alice.datasegment.CommandType;
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
7 import alice.datasegment.Receiver;
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
8 import alice.topology.HostMessage;
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
9
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
10 public class CheckComingHost extends CodeSegment {
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
11 // checkIncomingHost
466
268b1280dc18 remove debug message
sugi
parents: 436
diff changeset
12 private Receiver host = ids.create(CommandType.TAKE);
435
41bb86275910 send MD5 "mode -t"
sugi
parents: 434
diff changeset
13 private Receiver absCookieTable = ids.create(CommandType.PEEK); // cookie, AbsName HashMap
515
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
14 private Receiver config = ids.create(CommandType.PEEK);
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
15
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
16 public CheckComingHost(){
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
17 this.host.setKey("host");
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
18 this.absCookieTable.setKey("absCookieTable");
515
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
19 this.config.setKey("TMConfig");
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
20 }
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
21
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
22 @Override
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
23 public void run() {
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
24 HostMessage host = this.host.asClass(HostMessage.class);
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
25 @SuppressWarnings("unchecked")
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
26 HashMap<String, String> absCookieTable = this.absCookieTable.asClass(HashMap.class);
515
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
27 TopologyManagerConfig conf = this.config.asClass(TopologyManagerConfig.class);
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
28 boolean match = false;
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
29 // check cookie
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
30 if (host.cookie != null) {
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
31 if (absCookieTable.containsKey(host.cookie)){
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
32 match = true;
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
33 host.absName = absCookieTable.get(host.cookie);
436
a9ed8e932a1e pass reconnect test but have many bug
sugi
parents: 435
diff changeset
34 System.out.println("match");
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
35 }
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
36 }
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
37
466
268b1280dc18 remove debug message
sugi
parents: 436
diff changeset
38 if (match){
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
39 // coming host has ever joined this App
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
40 ods.put("reconnectHost", host);
515
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
41 if (conf.dynamic) { //dynamic topology
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
42 if (conf.type == TopologyType.Tree) {
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
43 ods.put("orderHash", "order");
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
44 ods.put("newHost", host);
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
45 }
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
46 } else { // static topology
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
47 new SearchHostName();
6161dcd3da02 dynamic reconnect
sugi
parents: 466
diff changeset
48 }
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
49 } else {
517
80e461aa10e9 bug fix
sugi
parents: 515
diff changeset
50 host.cookie = null;
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
51 ods.put("orderHash", "order");
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
52 ods.put("newHost", host);
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
53 }
434
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
54
4c62f76894c8 refactoring
sugi
parents: 433
diff changeset
55 new CheckComingHost();
433
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
56 }
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
57
e565d481c52e separate checking process from IncomingHosts
sugi
parents:
diff changeset
58 }