Commit 12b3ccb0 authored by Felix Seibert's avatar Felix Seibert
Browse files

add computation of a lower bound for the optimal makespan

parent a41b8e99
......@@ -285,6 +285,33 @@ class TestDataDistribution(unittest.TestCase):
self.assertEqual(9, max(total_folder_sizes))
self.assertEqual(36, sum(total_folder_sizes))
def test_get_lower_bound_on_makespan(self):
folder_sizes = [1]
num_folders = 5
osd_bandwidths = [1]
num_osds = 4
distribution = dataDistribution.DataDistribution()
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)
self.assertEqual(5 / 4, distribution.get_lower_bound_on_makespan())
folder_sizes = [1]
num_folders = 60
osd_bandwidths = [3, 2, 1]
osd_capacities = [2, 5, 100]
num_osds = 4
distribution = dataDistribution.DataDistribution()
distribution.add_osd_list(create_test_osd_list(num_osds, osd_bandwidths))
distribution.set_osd_bandwidths(create_osd_information(num_osds, osd_bandwidths))
distribution.set_osd_capacities(create_osd_information(num_osds, osd_capacities))
distribution.add_folders(create_test_folder_list(num_folders, folder_sizes))
self.assertEqual(8, distribution.get_maximum_processing_time()[1])
def create_test_osd_list(num_osds, osd_capacities):
test_osds = []
......
......@@ -184,6 +184,26 @@ class DataDistribution(object):
maximum_osd = osd
return maximum_osd, maximum_processing_time
def get_lower_bound_on_makespan(self):
total_remaining_file_size = self.get_total_folder_size()
artificial_data_distribution = copy.deepcopy(self)
for tmp_osd in artificial_data_distribution.OSDs.values():
for a_folder in list(tmp_osd.folders.keys()):
tmp_osd.remove_folder(a_folder)
while total_remaining_file_size > 0:
free_OSDs = list(filter(lambda x: x.get_free_capacity() > 0, artificial_data_distribution.OSDs.values()))
total_bandwidth = sum(list(map(lambda x: x.bandwidth, free_OSDs)))
assigned_file_size = 0
for free_OSD in free_OSDs:
optimal_share = (free_OSD.bandwidth / total_bandwidth) * total_remaining_file_size
assignable_share = min(optimal_share, free_OSD.get_free_capacity())
free_OSD.add_folder("dummy_id", assignable_share)
assigned_file_size += assignable_share
total_remaining_file_size -= assigned_file_size
return artificial_data_distribution.get_maximum_processing_time()[1]
def add_folders(self, folders,
ignore_osd_capacities=True,
random_osd_assignment=False,
......
......@@ -50,6 +50,9 @@ class OSD(object):
def get_load(self):
return self.total_folder_size
def get_free_capacity(self):
return self.capacity - self.total_folder_size
def get_processing_time(self):
return self.total_folder_size / self.bandwidth
......
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