コード例 #1
0
 def increment_chunk_replication_degree(self,message,addr):
     ip=addr[0]
     data = Data(self.db_path)
     file_id=message.split(" ")[2]
     chunk_number=message.split(" ")[3]
     print "file_id: *"+file_id+"*"
     print "chunk_number: *"+chunk_number+"*"
     if(data.increment_replication_degree(file_id, chunk_number,ip)):
         print "replication degree: " + str(data.get_chunk_replication_degree(file_id, chunk_number))
コード例 #2
0
 def check_bigger_replication_degree(self, message, addr):
     data = Data(self.db_path)
     file_id = message.split(" ")[2]
     chunk_number = message.split(" ")[3]
     replication_degree = data.get_chunk_replication_degree(file_id, chunk_number)
     minimum_replication_degree = data.get_chunk_minimum_replication_degree(file_id, chunk_number)
     if (data.chunk_owner(file_id) and replication_degree >= minimum_replication_degree and not data.chunk_have_replication_host(file_id, chunk_number, addr[0])):
         print_message("Sending a chunk delete  to "+str(addr[0])+" because the replication degree was already enough")
         message="deletechunk " + file_id + " "+ chunk_number
         self.shell.sendto(message, (addr[0], SHELL_PORT))
         return True
     return False
コード例 #3
0
 def update_chunk_replication_degree(self,message,addr):
     file_id=message.split(" ")[2]
     chunk_number=message.split(" ")[3].strip(CRLF+CRLF)
     host=addr[0]
     data = Data(self.db_path)
     if(data.get_chunk_id(chunk_number, file_id)):
         data.remove_chunk_replication_degree(file_id, chunk_number, host)
         # check replication degree
         replication_degree=data.get_chunk_replication_degree(file_id, chunk_number)
         minimum_replication_degree=data.get_chunk_minimum_replication_degree(file_id , chunk_number)
         print_message("Chunk replication degree is "+str(replication_degree) +  " and minimum is "+str(minimum_replication_degree))
         if(replication_degree<minimum_replication_degree):
             print_message("Chunk replication degree is not enough. Sending a PUTCHUNK")
             self.put_chunk(file_id,chunk_number,replication_degree)