changed sleep to 2 sec. fixed the setting of swift_conn during deletion process. Timeout of ssl increased to 10. Added checks to segment files: they have to be power of 2.
This commit is contained in:
24
utility.py
24
utility.py
@@ -3,6 +3,7 @@ __author__ = 'xgiovio'
|
||||
import authentication
|
||||
import sys, platform,os
|
||||
import time
|
||||
import math
|
||||
|
||||
|
||||
def get_local_files (localpath):
|
||||
@@ -28,7 +29,7 @@ def get_list (fail_tries,swift_conn,swift_container,prefix) :
|
||||
except Exception as e:
|
||||
print("Exception during the download of remote list")
|
||||
print(e)
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
if fail_tries_counter == fail_tries - 1 :
|
||||
print("Maximum tries reached. Can't download remote list for container " + swift_container + " with prefix " +prefix +". Exiting.")
|
||||
sys.exit(-1)
|
||||
@@ -73,7 +74,7 @@ def list_compute_correct_size (fail_tries,objects,swift_conn,swift_container,pre
|
||||
except Exception as e:
|
||||
print("Exception during the request of metadata")
|
||||
print(e)
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
if fail_tries_counter == fail_tries - 1 :
|
||||
print("Maximum tries reached. Can't download sizes for all large files on container " + swift_container + " with prefix: " +prefix +". Exiting.")
|
||||
sys.exit(-1)
|
||||
@@ -144,7 +145,7 @@ def list_compute_manifest (fail_tries,objects,swift_conn,swift_container,prefix)
|
||||
except Exception as e:
|
||||
print("Exception during the request of metadata")
|
||||
print(e)
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
if fail_tries_counter == fail_tries - 1 :
|
||||
print("Maximum tries reached. Can't download sizes for all large files on container " + swift_container + " with prefix: " +prefix +". Exiting.")
|
||||
sys.exit(-1)
|
||||
@@ -175,10 +176,15 @@ def listall (objects,prefix):
|
||||
return remotefiles
|
||||
|
||||
def check_segments_size (size_limit_reading_os,size_limit_to_segment):
|
||||
if size_limit_reading_os%2 != 0 or size_limit_to_segment%2 != 0 or size_limit_reading_os > size_limit_to_segment or size_limit_reading_os < 16:
|
||||
if size_limit_reading_os%2 != 0 or size_limit_to_segment%2 != 0 or size_limit_reading_os > size_limit_to_segment or size_limit_reading_os < 16 or not is_power_of_2(size_limit_reading_os) or not is_power_of_2(size_limit_to_segment):
|
||||
print ("Error size segments")
|
||||
sys.exit(-2)
|
||||
|
||||
def is_power_of_2 (number):
|
||||
result = math.log(number,2)
|
||||
return (result == int(result))
|
||||
|
||||
|
||||
def check_segments_size_single (size_limit_reading_os):
|
||||
if size_limit_reading_os%2 != 0 or size_limit_reading_os < 16:
|
||||
print ("Error size segments")
|
||||
@@ -259,24 +265,22 @@ def delete_object (swift_conn,swift_container,object,manifest,fail_tries):
|
||||
print("Exception during deletion of manifest files")
|
||||
print(e)
|
||||
errors_deleting_files_of_large_obj +=1
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
swift_conn = authentication.set_authentication()
|
||||
if fail_tries_counter1 == fail_tries - 1 :
|
||||
print("Maximum tries reached. Can't delete " + swift_container + "/" + object +" manifest files.Skipping")
|
||||
skipped_files_of_large_obj += 1
|
||||
else:
|
||||
swift_conn = authentication.set_authentication ()
|
||||
else :
|
||||
break
|
||||
except Exception as e:
|
||||
print("Exception during deletion of file")
|
||||
print(e)
|
||||
errors_deleting_file += 1
|
||||
time.sleep(1)
|
||||
time.sleep(2)
|
||||
swift_conn = authentication.set_authentication()
|
||||
if fail_tries_counter == fail_tries - 1 :
|
||||
print("Maximum tries reached. Can't delete " + swift_container + "/" + object +".Skipping")
|
||||
skipped_file +=1
|
||||
else:
|
||||
swift_conn = authentication.set_authentication ()
|
||||
else :
|
||||
break
|
||||
return [swift_conn,errors_deleting_file,errors_deleting_files_of_large_obj,skipped_file,skipped_files_of_large_obj]
|
||||
|
||||
Reference in New Issue
Block a user