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

add random assignment two step rebalancing

parent c3bdc9ec
......@@ -259,7 +259,7 @@ class TestDataDistribution(unittest.TestCase):
distribution.add_osd_list(create_test_osd_list(num_osds, osd_bandwidths))
distribution.add_folders(create_test_folder_list(num_folders, folder_sizes), random_osd_assignment=True)
distribution.rebalance_two_steps()
distribution.rebalance_two_steps_optimal_matching()
osds = distribution.get_osd_list()
total_folder_sizes = list(map(lambda x: distribution.OSDs[x].total_folder_size, osds))
......@@ -276,7 +276,7 @@ class TestDataDistribution(unittest.TestCase):
distribution.add_osd_list(create_test_osd_list(num_osds, osd_bandwidths))
distribution.add_folders(create_test_folder_list(num_folders, folder_sizes), random_osd_assignment=True)
distribution.rebalance_two_steps()
distribution.rebalance_two_steps_optimal_matching()
osds = distribution.get_osd_list()
total_folder_sizes = list(map(lambda x: distribution.OSDs[x].total_folder_size, osds))
......
......@@ -340,7 +340,7 @@ class DataDistribution(object):
return movements
def rebalance_two_steps(self):
def rebalance_two_steps_optimal_matching(self):
"""
rebalance the distribution in two steps:
1. calculate new distribution, independently of the current one
......@@ -440,6 +440,31 @@ class DataDistribution(object):
return movements
def rebalance_two_steps_random_matching(self):
"""
rebalance the distribution in two steps:
1. calculate new distribution, independently of the current one
2. the OSDs of the new (virtual) matching are randomly assigned to the actual (current OSDs), i.e.,
no matter which OSD has which folders.
while any algorithm (solving/approximating that kind of problem) could be used for the first step,
we here only implement the LPT algorithm, as it is a pretty good approximation with extremely good running time.
:return:
"""
virtual_distribution = copy.deepcopy(self)
virtual_distribution.rebalance_lpt(rebalance_factor=0)
movements = {}
for virtual_osd in virtual_distribution.OSDs.values():
for virtual_folder in virtual_osd.folders.keys():
if not self.OSDs[virtual_osd.uuid].contains_folder(virtual_folder):
movements[virtual_folder] = (self.get_containing_osd(virtual_folder).uuid, virtual_osd.uuid)
for virtual_osd in virtual_distribution.OSDs.values():
self.replace_osd(virtual_osd)
return movements
def get_suitable_osds(self, folder_size):
"""
create a list of OSDs with at least folder_size free capacity.
......
Markdown is supported
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