Commit 2bf4e783 authored by Felix Seibert's avatar Felix Seibert
Browse files

adding recursion to account for failed fixing attempts

parent 324810b6
......@@ -23,6 +23,7 @@ max_processes_change_policy = 50
max_processes_add_replica = 50
max_processes_delete_replica = 15
# TODO add support for arbitrary subdirectory level
# (currently depth=2 is hardcoded, which is fine for GeoMultiSens purposes)
......@@ -180,7 +181,9 @@ class OSDManager(object):
'''
def fix_physical_layout(self, repeat_delete_interval_secs=15):
def fix_physical_layout(self, repeat_delete_interval_secs=15, iteration=0):
if self.debug:
print("starting to fix physical layout...this is fix-iteration " + str(iteration))
# list 1
change_policy_command_list = []
# list 2
......@@ -221,7 +224,13 @@ class OSDManager(object):
create_command = div_util.create_create_replica_command(absolute_file_path, osd_for_file)
create_replica_command_list.append(div_util.command_list_to_single_string(create_command))
# run commands
# end of recursion condition
if len(create_replica_command_list) == 0 and len(delete_replica_command_list) == 0:
if self.debug:
print("fixing physical layout done after " + str(iteration) + " fix-iterations.")
return
# run commands
start_time = time.time()
if self.debug:
print("starting execution of change policy commands...")
......@@ -233,7 +242,7 @@ class OSDManager(object):
str(round(end_time - start_time)) + " sec.")
# div_util.print_process_list(processes)
start_time = time.time()
start_time = time.time()
if self.debug:
print("starting execution of create replica commands...")
print(str(datetime.datetime.now()))
......@@ -249,7 +258,8 @@ class OSDManager(object):
if self.debug:
print("starting execution of delete replica commands...")
print(str(datetime.datetime.now()))
errored_processes = div_util.run_commands(delete_replica_command_list, max_processes_delete_replica, print_errors=False)
errored_processes = div_util.run_commands(delete_replica_command_list, max_processes_delete_replica,
print_errors=False)
# run and repeat delete commands, until they return no error
# (if an error is returned for another reason than that one would delete the last complete replica,
......@@ -265,7 +275,7 @@ class OSDManager(object):
if self.debug:
print("executing " + str(len(delete_replica_command_list))
+ " delete replica commands done. This is iteration "
+ " delete replica commands done. This is delete-iteration "
+ str(iterations))
# div_util.print_process_list(processes)
......@@ -289,13 +299,16 @@ class OSDManager(object):
if self.debug:
print("rerunning " + str(len(errored_deletions)) + " commands because replica could not be deleted...")
errored_processes = div_util.run_commands(errored_deletions, max_processes_change_policy, print_errors=False)
errored_processes = div_util.run_commands(errored_deletions, max_processes_change_policy,
print_errors=False)
iterations += 1
if self.debug:
end_time = time.time()
print("deleting replicas done in in " + str(round(end_time - start_time)) + " sec.")
self.fix_physical_layout(iteration=iteration + 1)
'''
create empty folders and assign OSDs.
'''
......
......@@ -80,7 +80,7 @@ def run_commands(commands, max_processes=200, print_errors=True):
errored_processes.append(finished_process)
if print_errors:
print_error(finished_process)
print("progress: " + str(num_finished) + "/" + str(num_total))
# print("progress: " + str(num_finished) + "/" + str(num_total))
# running_processes = running_processes.difference(difference)
for finished_process in difference:
......@@ -111,7 +111,7 @@ def run_commands(commands, max_processes=200, print_errors=True):
print_error(still_running_process)
num_finished += 1
print("progress: " + str(num_finished) + "/" + str(num_total))
# print("progress: " + str(num_finished) + "/" + str(num_total))
if timeout_processes > 0:
print("number of processes with expired timeout: " + str(timeout_processes))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment