def update_data_block(virtual_block_number, block_data): server_number, block_number = block_number_translate(virtual_block_number) client_stub.update_data_block(block_number, block_data, server_number) for j in range(num_servers ): #finding the server number on which parity is located if mapping[block_number][j] == 'P': xor(j, block_data, block_number)
def free_data_block(vir_block_number): if vir_block_number != -1: server_number, block_number = block_number_translate(vir_block_number) global mapping mapping[block_number - initial_blk_number][server_number] = 0 #print(mapping) block_data, state = client_stub.get_data_block(block_number, server_number) for j in range( num_servers ): #finding the server number on which parity is located if mapping[block_number][j] == 'P': # xor(j,block_data,block_number) old_data, state = client_stub.get_data_block(block_number, j) a = old_data b = block_data data = ''.join(chr(ord(a) ^ ord(b)) for a, b in zip(a, b)) client_stub.update_data_block(block_number, data, j) client_stub.free_data_block(server_number, block_number)
def xor(server_number, new_data, block_number): print "Writing to Parity Block" old_data, state = client_stub.get_data_block( block_number, server_number) #getting old parity if state is False: #when the parity resides on a server that is corrupted, then XOR data from all the other servers and get the parity for servers in range(num_servers): if servers != server_number: a = old_data b = new_data b, state = client_stub.get_data_block(block_number, servers) b = ''.join(b) parity_data = ''.join( chr(ord(a) ^ ord(b)) for a, b in zip(a, b)) a = parity_data else: a = old_data b = new_data data = ''.join( chr(ord(a) ^ ord(b)) for a, b in zip(a, b)) #XORing the old parity with new data check_parity(block_number, server_number) client_stub.update_data_block( block_number, data, server_number ) #writing the new parity (while writing the data block)
def update_data_block(block_number, block_data): client_stub.update_data_block(block_number, block_data)
def update_data_block(block_number, block_data): if (RAID_5.has_been_called == True): client_stub.update_data_block(block_number, block_data) if (RAID_1.has_been_called == True): client_stub_RAID1.update_data_block(block_number, block_data)
def update_data_block(block_number, block_data, delay_sec): client_stub.update_data_block(block_number, block_data, delay_sec)