Пример #1
0
	def handle_get(self, db, p):
		"""
			Check if file is in database and return list of
			server nodes that contain the file.
				- List of fname and triple tuples
				- NFOUND if fname is not valid (file not present in DFS)
		"""


		# Get fname from packet
		fname = p.getFileName()
		print "\t- Retrieving file name from packet..."

		# Get fsize and metalist from MDS
		fsize, metalist = db.GetFileInode(fname)

		if fsize:
			print "\t- Sending `get` response to copy.py..."
			q = Packet()
			q.BuildGetResponse(metalist, fsize)
			self.request.sendall(q.getEncodedPacket())
			print "\t- Done!"
		else:
			self.request.sendall("NFOUND")
			print "\t- File not found in MDS!"
Пример #2
0
    def handle_get(self, db, p):
        """Check if file is in database and return list of
			server nodes that contain the file.
		"""

        # Fill code to get the file name from packet and then
        # get the fsize and array of metadata server
        # Fill code
        #print("Getting file location info: ", p.getFileName())

        #Using GetFileInode() function to recieve the filesize and the
        #metalist that contains the amount of that contain the file data.
        fsize, metalist = db.GetFileInode(p.getFileName())
        #if the file is in the inode table then send the metalist and the filesize back to the client
        if fsize:
            #print("creating packet")
            #creating the response packet
            packet_send_copy = Packet()
            packet_send_copy.BuildGetResponse(metalist, fsize)
            #print("packet Response built:",metalist,fsize)
            copy_response = packet_send_copy.getEncodedPacket()
            self.request.sendall(copy_response)
            #print("packet sent")
        else:
            self.request.sendall("NFOUND")