def Initialize(): print "Number of Data Servers : ", config.NUM_OF_SERVERS delay = 0 try: delay = int(raw_input("Enter delay value : ")) except Exception as err: print err print "Delay defaulted to ", delay config.SLEEP_TIME = delay while (True): try: startpoint = raw_input( "Please enter 4 digit starting port number : ") if len(startpoint) == 4: config.SERVER_PORT_BEGIN = int(startpoint) raw_input("Press enter after starting the servers : ") FileSystem.Initialize_My_FileSystem() break print("The length is not 4!") except ValueError: print("That's not an Integer!") return
import FileSystem FileSystem.Initialize_My_FileSystem() interface = FileSystem.FileSystemOperations() #1. MAKING NEW DIRECTORY ''' interface.mkdir("/A") interface.mkdir("/A/B") interface.mkdir("/A/B/C") interface.mkdir("D") interface.status() ''' #2. WRITING NEW FILES AND READING. [[BEFORE WRTING WE HAVE TO CRTEATE THE FILE ]] ''' interface.create("/1.txt") interface.write("/1.txt", "Principles of Computer System Design") interface.mkdir("/A") interface.create("/A/2.txt") interface.write("/A/2.txt", "Hello World!") interface.status() interface.read("/1.txt") interface.read("/A/2.txt", 2, 3) #reading only 3 words from offset 2 (including the offset) ''' #3. OVERWIRING OR APPEND FILE AT THE GIVEN OFFSET. ''' interface.create("/1.txt") interface.write("/1.txt", "ABC") interface.read("/1.txt")
name = '/d' * (i) + '/f' my_object.rm(name) if __name__ == '__main__': if len(sys.argv) != 2 and len(sys.argv) != 3: print("Must (only) specify raid mode.") quit() raid_mode = sys.argv[1] if raid_mode != '1' and raid_mode != '5': print("Must use raid mode 1 or 5 - terminating program.") quit() FileSystem.Initialize_My_FileSystem(4, raid_mode) if (len(sys.argv) < 3): my_object = FileSystemOperations() print('Delaying 5s to allow termination of a server.') print('Server may also be terminated during execution.') time.sleep(5) for i in range(12): name = '/d' * (i + 1) my_object.mkdir(name) test_case_6(my_object) test_case_7(my_object) test_case_8(my_object) my_object.create('/f') my_object.mv('/f', '/d/f') my_object.rm('/d/f') print('\nTests Complete.')
interface = FileSystem.FileSystemOperations() client = Memory.client MemoryOps = Memory.Operations() for i in range(int(sys.argv[1])): os.system('gnome-terminal -e \"python server_stub.py ' + str(8000 + i) + '\"') #GET SERVER PID # pid_table = os.popen(r'ps a | grep "stub"').readlines() # pid_num = [] # for entry in pid_table: # if entry.find('server_stub.py') != -1: pid_num.append(entry) # for index in range(len(pid_num)): pid_num[index] = pid_num[index].split(" ")[0] raid_mode = int(input('Please input raid mode (1 for RAID-1, 5 for RAID-5): ')) FileSystem.Initialize_My_FileSystem(int(sys.argv[1]), raid_mode) while True: command_str = raw_input("$ ") raw_command_list = command_str.split(' ', 1) command = raw_command_list[0] if command == 'write': try: data = command_str[command_str.index('"') + 1:command_str[command_str.index('"') + 1:].index('"') + command_str.index('"') + 1] command_str = command_str.replace('"' + data + '"', "", 1) argv = command_str.split(" ") while bool(argv.count('')): argv.remove('') path = argv[1]
if __name__ == "__main__": print( "Hello, this is a demo for our RAID 5 file system. We are able to tolerate a fail-stop of one server/disk and recover all data.\n" ) print( "Please input the number of servers, between 4 and 16, that you would like to test this with." ) print( "Ensure that this number of servers reflects the number of servers instantiated with backChannel.py" ) num_servers = int(input()) while num_servers < 4 or num_servers > 16: print('Please enter a number of servers between 4 and 16.') num_servers = int(input()) print( "Please input the raid mode, 1 or 5, that you would like to test this with." ) print( "Ensure that this raid mode reflects the raid mode instantiated with backChannel.py" ) raid_mode = input() while raid_mode != '1' and raid_mode != '5': print('Please enter a raid mode 1 or 5.') raid_mode = input() FileSystem.Initialize_My_FileSystem(num_servers, raid_mode) file_system_repl()