Changeset 18

Show
Ignore:
Timestamp:
08/13/07 16:41:30 (1 year ago)
Author:
pitt-zhang
Message:

fix the 0 hop bug of deliver() in planet.test.dht.dhtapplication.java

Location:
trunk/src/planet
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/planet/chord/ChordNode.java

    r2 r18  
    591591                } else { 
    592592            sendData(message,closestPrecedingFinger(nextHop.getId()),REQUEST); 
    593                         Results.updateHopsMsg(message.getSource().getId(), message.getKey()); 
    594                 } 
     593                } 
     594                Results.updateHopsMsg(message.getSource().getId(), message.getKey()); 
    595595        } 
    596596         
  • trunk/src/planet/simulate/Results.java

    r16 r18  
    134134          } 
    135135          else {                                          
    136             hops.put(identif,new Integer(1)); 
     136            hops.put(identif,new Integer(0)); 
    137137          }                        
    138138        } 
     
    216216    } 
    217217         
     218        /** 
     219         *  the lookup and insert times  
     220         */ 
    218221        private static int lookup_number = 0; 
    219222        /** 
  • trunk/src/planet/test/dht/DHTApplication.java

    r2 r18  
    108108                data.put(mesg.getKey(), v); 
    109109            } 
    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    
    138145        /** 
    139146         * Generate a string with a representation of keys and values existing at 
  • trunk/src/planet/test/dht/DHTMessage.java

    r2 r18  
    3131   */ 
    3232  public static final int LOOKUP = 1; 
     33   
     34  /** 
     35 * Reply message when find or not find the data.  
     36 */ 
     37  public static final int REPLY =2; 
    3338 
    3439