Exemple #1
0
    def handle(self):

        # Establish a connection with the local database
        db = mds_db("dfs.db")
        db.Connect()

        # Define a packet object to decode packet messages
        p = Packet()

        # Receive a msg from the list, data-node, or copy clients
        msg = self.request.recv(1024)
        print msg, type(msg)

        # Decode the packet received
        p.DecodePacket(msg)

        # Extract the command part of the received packet
        cmd = p.getCommand()

        # Invoke the proper action
        if cmd == "reg":
            # Registration client
            self.handle_reg(db, p)

        elif cmd == "list":
            # Client asking for a list of files
            # Fill code
            self.handle_list(db)
            #fill code ends

        elif cmd == "put":
            # Client asking for servers to put data
            # Fill code
            self.handle_put(db, p)
            #fill code ends

        elif cmd == "get":
            # Client asking for servers to get data
            # Fill code
            self.handle_get(db, p)  #justify
            #fill code ends

        elif cmd == "dblks":
            # Client sending data blocks for file
            # Fill code
            self.handle_blocks(db, p)
            #fill code ends

        db.Close()
Exemple #2
0
	def handle(self):

		# Establish a connection with the local database
		db = mds_db("dfs.db")
		db.Connect()

		# Define a packet object to decode packet messages
		p = Packet()

		# Receive a msg from the list, data-node, or copy clients
		msg = self.request.recv(1024)
		print msg, type(msg)
		
		# Decode the packet received
		p.DecodePacket(msg)
	

		# Extract the command part of the received packet
		cmd = p.getCommand()

		# Invoke the proper action 
		if   cmd == "reg":
			# Registration client
			self.handle_reg(db, p)

		elif cmd == "list":
			pass
			# Client asking for a list of files
			# Fill code
		
		elif cmd == "put":
			pass
			# Client asking for servers to put data
			# Fill code
		
		elif cmd == "get":
			pass
			# Client asking for servers to get data
			# Fill code

		elif cmd == "dblks":
			pass
			# Client sending data blocks for file
			 # Fill code


		db.Close()
	def handle(self):

		# Establish a connection with the local database
		db = mds_db("dfs.db")
		db.Connect()

		# Define a packet object to decode packet messages
		p = Packet()

		# Receive a msg from the list, data-node, or copy clients
		msg = self.request.recv(CHUNKLIST_BUFFER)
		
		# Decode the packet received
		p.DecodePacket(msg)

		# Extract the command part of the received packet
		cmd = p.getCommand()

		# Invoke the proper action 
		if   cmd == "reg":
			# data-node.py polling for registration
			print "\nHandling `reg` request from %s:%s..." % (p.getAddr(), p.getPort())
			self.handle_reg(db, p)

		elif cmd == "list":
			# ls.py asking for a list of files
			print "\nHandling `ls` request..."
			self.handle_list(db)
		
		elif cmd == "put":
			# copy.py asking for servers to put data
			print "\nHandling `put` request..."
			self.handle_put(db, p)
		
		elif cmd == "get":
			# copy.py asking for servers to get data
			print "\nHandling `get` request..."
			self.handle_get(db, p)

		elif cmd == "dblks":
			# copy.py sending data blocks for file
			print "\nHandling `dblks` request..."
			self.handle_blocks(db, p)
		else:
			print "\nNo `cmd` was specified..."

		db.Close()
###############################################################################
#
# Filename: test.py
# Author: Jose R. Ortiz and ... (hopefully some students contribution)
#
# Description:
#       Script to test the MySQL support library for the DFS project.
#
#

# This is how to import a local library
from mds_db import *

# Create an object of type mds_db
db = mds_db("dfs.db")

# Connect to the database
print "Connecting to database"
db.Connect()

# Testing how to add a new node to the metadata server.
# Note that I used a node name, the address and the port.
# Address and port are necessary for connection.

print "Testing node addition"
id1 = db.AddDataNode("136.145.54.10", 80)
id2 = db.AddDataNode("136.145.54.11", 80)
print
print "Testing if node was inserted"
print "A tupple with node name and connection info must appear"
print db.CheckNode(id1)
Exemple #5
0
###############################################################################
#
# Filename: test.py
# Author: Jose R. Ortiz and ... (hopefully some students contribution)
#
# Description:
#       Script to test the MySQL support library for the DFS project.
#
#

# This is how to import a local library
from mds_db import *

# Create an object of type mds_db
db = mds_db("dfs.db") 

# Connect to the database
print "Connecting to database" 
db.Connect() 

# Testing how to add a new node to the metadata server.
# Note that I used a node name, the address and the port.
# Address and port are necessary for connection.

print "Testing node addition"
id1 = db.AddDataNode("136.145.54.10", 80) 
id2 = db.AddDataNode("136.145.54.11", 80) 
print 
print "Testing if node was inserted"
print "A tupple with node name and connection info must appear"
print db.CheckNode("136.145.54.10", 80)
Exemple #6
0
			info = data.split(" ") # Split the message at every space.
			
			db.AddDataNode("n" + info[1], info[2], info[3]) # Add data-node to database.
			
			conn.sendall("Node created") # Send succes to the socket. 
			
		else: # Command not recognized.
			
			print "Command not recognized"
			
			print

		conn.close()            # Close the connection.

# Create an object of type mds_db.
db = mds_db() 

# Connect to the database.
print "Connecting to database" 

db.Connect() 

max_threads = 20 # Maximum Threads allowed.

threads = []*max_threads # Store threads.

i = 0	# Count Threads.

HOST = str(sys.argv[1])                                             # Symbolic name, meaning all available interfaces.

PORT = int(sys.argv[2])                               # Arbitrary non-privileged port.