Exemplo n.º 1
0
 def handle_message(self, msg):
         print "get inquery"
         """This function is called whenever the node recives a message bound for this service"""
         """Return True if message is handled correctly
         Return False if things go horribly wrong
         """
         if msg.service != self.service_id:
             return False
         start = msg.get_content("start")
         end = msg.get_content("end")
         N = msg.get_content("N")
         #record = msg.get_content("server_list")
         #linkset = msg.get_content("link_list")
         if not msg.reply_to == self.owner:
             if  not hash_util.hash_between(self.owner.key,start,end):
                 sucessor_cheat = hash_util.generate_lookup_key_with_index(self.owner.key,0)
                 msg.origin_node = self.owner
                 msg.destination_key = sucessor_cheat
                 #record.append(str(self.owner))
                 #linkset[str(node.thisNode)] = self.get_my_links()
                 #msg.add_content("server_list", record)
                 #msg.add_content("link_list",linkset)
                 msg.add_content("N",N+1)
                 self.send_message(msg, None)
             else:
                 msg.destination_key = msg.reply_to.key
                 self.send_message(msg, msg.reply_to)
         else:
             now = time.time()
             print "render inquery:", now - msg.start_time
             print N
Exemplo n.º 2
0
 def handle_message(self, msg):
     print "get inquery"
     """This function is called whenever the node recives a message bound for this service"""
     """Return True if message is handled correctly
         Return False if things go horribly wrong
         """
     if msg.service != self.service_id:
         return False
     start = msg.get_content("start")
     end = msg.get_content("end")
     N = msg.get_content("N")
     #record = msg.get_content("server_list")
     #linkset = msg.get_content("link_list")
     if not msg.reply_to == self.owner:
         if not hash_util.hash_between(self.owner.key, start, end):
             sucessor_cheat = hash_util.generate_lookup_key_with_index(
                 self.owner.key, 0)
             msg.origin_node = self.owner
             msg.destination_key = sucessor_cheat
             #record.append(str(self.owner))
             #linkset[str(node.thisNode)] = self.get_my_links()
             #msg.add_content("server_list", record)
             #msg.add_content("link_list",linkset)
             msg.add_content("N", N + 1)
             self.send_message(msg, None)
         else:
             msg.destination_key = msg.reply_to.key
             self.send_message(msg, msg.reply_to)
     else:
         now = time.time()
         print "render inquery:", now - msg.start_time
         print N
Exemplo n.º 3
0
 def start_inquery(self):
     sucessor_cheat = hash_util.generate_lookup_key_with_index(self.owner.key, 0)
     new_query = Toplogy_Poll_Message(self.owner, sucessor_cheat)
     linkset = {str(node.thisNode): self.get_my_links()}
     new_query.add_content("link_list", linkset)
     self.send_message(new_query)
     print "Send Inquery"
Exemplo n.º 4
0
 def start_inquery(self):
     sucessor_cheat = hash_util.generate_lookup_key_with_index(self.owner.key,0)
     new_query = Toplogy_Poll_Message(self.owner,sucessor_cheat)
     #linkset = {str(node.thisNode): self.get_my_links()}
     new_query.add_content("N",1)
     self.send_message(new_query, None)
     print "Send Inquery"
     self.last_start_time = time.time()
Exemplo n.º 5
0
 def start_inquery(self):
     sucessor_cheat = hash_util.generate_lookup_key_with_index(
         self.owner.key, 0)
     new_query = Toplogy_Poll_Message(self.owner, sucessor_cheat)
     #linkset = {str(node.thisNode): self.get_my_links()}
     new_query.add_content("N", 1)
     self.send_message(new_query, None)
     print "Send Inquery"
     self.last_start_time = time.time()