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
 def handle_request(self, message,addr):
     operation=message.split(" ")[0].strip(' \t\n\r')
     message=message.strip(' \t\n\r')
     if (operation == "PUTCHUNK"):
         data = Data(self.db_path)
         file_id=message.split(" ")[2]
         chunk_number=message.split(" ")[3]
         now=datetime.now()
         try:
             body = message.split(CRLF+CRLF)[1]
         except:
             print_message("Invalid message from "+str(addr))
         if(len(body)<2): 
             print_message("The PUTCHUNK split failed")
             return False
         can_store=True
         if(data.chunk_owner(file_id)):
             can_store=False
         if((file_id+chunk_number) in self.reject_putchunks and now<self.reject_putchunks[file_id+chunk_number]):
             can_store=False
         if ((self.backup_size - self.check_directory_size(self.backup_dir)) <= len(body)):
             can_store=False 
         if(can_store):
             self.backup_chunk(message)
         else: 
             print_message("PUTCHUNK rejected")
             
     elif(operation == "GETCHUNK"):
         self.create_restore_subscription(message)
         self.get_and_send_chunk(message)
     elif(operation == "CHUNK"):
         print message.split(CRLF+CRLF)[0]
         self.save_chunk_to_restore(message)
     elif(operation=="DELETE"):
         self.can_send_removed=False
         self.delete_chunks(message)
         time.sleep(1)
         self.can_send_removed=True
     elif(operation=="DELETE2"):
         self.can_send_removed=False
         self.delete_chunks(message)
         file_id=message.split(" ")[1].strip(CRLF+CRLF)
         self.mc.sendto("deleted "+str(file_id),(addr[0],SHELL_PORT))
         time.sleep(1)
         self.can_send_removed=True   
     elif(operation=="STORED"):
         if (not self.check_bigger_replication_degree(message, addr)):
             self.increment_chunk_replication_degree(message,addr)
     elif(operation=="REMOVED"):
         self.update_chunk_replication_degree(message,addr)