| 110 | | } |
| 111 | | // Message of type LOOKUP |
| 112 | | else { |
| 113 | | System.out.println("The local node is["+endPoint.getId()+"], and the mesg.originNode is ["+mesg.getOriginNode().getId()+"]"); |
| 114 | | //the response arrive to the source sender node |
| 115 | | if (endPoint.getId().equals(mesg.getOriginNode().getId())) |
| 116 | | { |
| 117 | | //if there is no contents, the key not exits into the DHT |
| 118 | | if (mesg.getVectorValue() == null) |
| 119 | | { |
| 120 | | System.out.println("Fail: The key {"+mesg.getKey()+ |
| 121 | | "} not found"); |
| 122 | | } else |
| 123 | | { |
| 124 | | System.out.println("Success: The key {"+mesg.getKey()+ |
| 125 | | "} has the values {"+mesg.getVectorValue()+"}"); |
| 126 | | } |
| 127 | | } |
| 128 | | //the message arrives to the final receiver node. |
| 129 | | else |
| 130 | | { |
| 131 | | DHTMessage msg = new DHTMessage(mesg.getOriginNode(), |
| 132 | | DHTMessage.LOOKUP, mesg.getKey(), (Vector) data |
| 133 | | .get(mesg.getKey())); |
| 134 | | endPoint.route(mesg.getOriginNode().getId(), msg, mesg.getOriginNode()); |
| 135 | | } |
| 136 | | } |
| 137 | | } |
| | 110 | } else if(mesg.getType() == DHTMessage.REPLY){ |
| | 111 | |
| | 112 | |
| | 113 | |
| | 114 | // the response arrive to the source sender node |
| | 115 | if (endPoint.getId().equals(mesg.getOriginNode().getId())) { |
| | 116 | |
| | 117 | // if there is no contents, the key not exits into the DHT |
| | 118 | if (mesg.getVectorValue() == null) { |
| | 119 | System.out.println("Fail: The key {" + mesg.getKey() |
| | 120 | + "} not found"); |
| | 121 | } else { |
| | 122 | System.out.println("Success: The key {" + mesg.getKey() |
| | 123 | + "} has the values {" + mesg.getVectorValue() |
| | 124 | + "}"); |
| | 125 | } |
| | 126 | } |
| | 127 | |
| | 128 | } else{ |
| | 129 | |
| | 130 | // the message arrives to the final receiver node. |
| | 131 | |
| | 132 | System.out.println("The local node is[" + endPoint.getId() |
| | 133 | + "], and the mesg.originNode is [" |
| | 134 | + mesg.getOriginNode().getId() + "]"); |
| | 135 | |
| | 136 | DHTMessage msg = new DHTMessage(mesg.getOriginNode(), |
| | 137 | DHTMessage.REPLY, mesg.getKey(), (Vector) data |
| | 138 | .get(mesg.getKey())); |
| | 139 | endPoint.route(mesg.getOriginNode().getId(), msg, mesg |
| | 140 | .getOriginNode()); |
| | 141 | |
| | 142 | } |
| | 143 | } |
| | 144 | |