diff src/main/java/alice/topology/manager/IncomingHosts.java @ 434:4c62f76894c8 dispose

refactoring
author sugi
date Mon, 11 Aug 2014 18:45:33 +0900
parents e565d481c52e
children 41bb86275910
line wrap: on
line diff
--- a/src/main/java/alice/topology/manager/IncomingHosts.java	Mon Aug 11 18:23:18 2014 +0900
+++ b/src/main/java/alice/topology/manager/IncomingHosts.java	Mon Aug 11 18:45:33 2014 +0900
@@ -16,7 +16,7 @@
     HashMap<String, LinkedList<NodeInfo>> topology;
     LinkedList<String> nodeNames;
     private Receiver host = ids.create(CommandType.TAKE); //HostMessage
-    private Receiver messageList = ids.create(CommandType.TAKE); // HostMessage List
+    private Receiver absCookieTable = ids.create(CommandType.TAKE); // cookie, AbsName HashMap
     private Receiver cookie = ids.create(CommandType.TAKE); // MD5
 
     public IncomingHosts(HashMap<String, LinkedList<NodeInfo>> topology,
@@ -24,7 +24,7 @@
         this.topology = topology;
         this.nodeNames = nodeNames;
         this.host.setKey("host");
-        this.messageList.setKey("messageList");
+        this.absCookieTable.setKey("absCookieTable");
         this.cookie.setKey("MD5");
     }
 
@@ -32,20 +32,19 @@
     public void run() {
         HostMessage host = this.host.asClass(HostMessage.class);
         @SuppressWarnings("unchecked")
-        LinkedList<HostMessage> messageList = this.messageList.asClass(LinkedList.class);
+        HashMap<String, String> absCookieTable = this.absCookieTable.asClass(HashMap.class);
         boolean match = false;
         // check cookie
         if (host.cookie != null) {
-            for (HostMessage hostMessage : messageList) {
-                if (host.cookie.equals(hostMessage.cookie)) {
-                    match = true;
-                    System.out.println("cookie is match");
-                    host.absName = hostMessage.absName;
-                    ods.put("reconnectHost", host);
-                    ods.put(this.messageList.key, messageList);
-                    new SearchHostName();
-                    break;
-                }
+            if (absCookieTable.containsKey(host.cookie)){
+                match = true;
+                System.out.println("cookie is match");
+                host.absName = absCookieTable.get(host.cookie);
+                ods.put("reconnectHost", host);
+                
+                ods.put(this.absCookieTable.key, absCookieTable);
+                new SearchHostName();
+                
             }
         }
         
@@ -58,11 +57,8 @@
             ods.put(nodeName, "host", nodeName);
 
             String cookie = this.cookie.asString();
-            HostMessage record = new HostMessage();
-            record.absName = nodeName;
-            record.cookie = cookie;
-            messageList.add(record);
-            ods.put(this.messageList.key, messageList);
+            absCookieTable.put(cookie, nodeName);
+            ods.put(this.absCookieTable.key, absCookieTable);
             
             ods.put(nodeName, "cookie", cookie);