Commit ef5fe0a5 authored by Felix Seibert's avatar Felix Seibert
Browse files

update and improve documentation of add_folders()

parent 9404f864
......@@ -92,16 +92,32 @@ class DataDistribution(object):
random_osd_assignment=False,
ignore_folder_sizes=False,
debug=False):
# TODO update doc
"""
adds a list of folders to the data distribution.
if not specified otherwise, the assignments are calculated using the LPT algorithm.
returns a list of assignments from folders to OSDs, for which (folders) there was previously no assignment.
if the optional arguments are given, OSDs are assigned data proportionally to their ratio_parameter.
if osd_information and ratio_parameter are given,
OSDs are assigned data proportionally to their ratio_parameter.
osd_information is a map (that we now call outer map) that contains, for each OSD, an inner_map.
outer_map[osd_uuid][ratio_parameter] is used to calculate the proportion of data assigned to OSD with uuid
osd_uuid.
if ignore_osd_capacities=False,
outer_map[osd_uuid][capacity] is used (only in combination with random_osd_assignment=True)
to generate random assignments that do not surpass the capacities of the OSDs.
(random assignment respecting OSD capacities)
if random_osd_assignment=True and ignore_osd_capacities=True, a totally random OSD assignment generated.
if random_osd_assignment=True and ignore_folder_sizes=True,
folders are randomly assigned to OSDs such that all OSDs have the same number of folders (if possible).
the assignment is stable (i.e., folders already assigned to an OSD are not reassigned to another OSD).
"""
# find out which folders are not assigned yet
new_folders = []
for a_folder in folders:
containing_osd = self.get_containing_osd(a_folder.id)
......@@ -113,6 +129,8 @@ class DataDistribution(object):
if debug:
print("dataDistribution: random_osd_assignment: " + str(random_osd_assignment))
# keep track of which unassigned folder gets assigned to which OSD.
# this information must be returned
osds_for_new_folders = []
# totally random OSD assignment, even ignoring OSD capacities
......@@ -158,11 +176,13 @@ class DataDistribution(object):
random.shuffle(modified_folders)
return self.add_folders(modified_folders)
# balanced deterministic OSD assignment
# (following largest processing time first or post-greedy approach)
# balanced deterministic OSD assignment (LPT)
# (following largest processing time first, also called post-greedy approach)
list.sort(new_folders, key=lambda x: x.size, reverse=True)
osd_ratios = {}
# ratios are given - use them to assign proportionally
if osd_information is not None and ratio_parameter != '':
total_osd_size = 0
for osd_size in osd_information.values():
......@@ -170,6 +190,7 @@ class DataDistribution(object):
for osd_uuid, osd_size in osd_information.items():
osd_ratios[osd_uuid] = float(osd_size[ratio_parameter]) / float(total_osd_size)
# no ratios are given - assume that all OSDs have same capacity
else:
for osd_uuid in self.OSDs.keys():
osd_ratios[osd_uuid] = float(1)
......@@ -184,7 +205,6 @@ class DataDistribution(object):
least_used_osd.add_folder(a_folder.id, a_folder.size)
osds_for_new_folders.append((a_folder.id,
least_used_osd.uuid))
return osds_for_new_folders
def update_folder(self, folder, size):
......
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