Skip to content
Snippets Groups Projects
Commit 200123bf authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

Task #10811: fixed partial renaming action

parent b1f501dc
No related branches found
No related tags found
No related merge requests found
...@@ -1375,7 +1375,7 @@ class RADatabase: ...@@ -1375,7 +1375,7 @@ class RADatabase:
def get_conflicting_overlapping_claims(self, claim_id): def get_conflicting_overlapping_claims(self, claim_id):
'''returns a list of claimed claims which overlap with given claim and which prevent the given claim to be claimed (cause it to be in conflict)''' '''returns a list of claimed claims which overlap with given claim and which prevent the given claim to be claimed (cause it to be in conflict)'''
query = '''SELECT * from resource_monitoring.get_conflicting_overlapping_claims(%s)''' query = '''SELECT * from resource_allocation.get_conflicting_overlapping_claims(%s)'''
return list(self._executeQuery(query, (claim_id,), fetch=_FETCH_ALL)) return list(self._executeQuery(query, (claim_id,), fetch=_FETCH_ALL))
def get_conflicting_overlapping_tasks(self, claim_id): def get_conflicting_overlapping_tasks(self, claim_id):
...@@ -1390,7 +1390,7 @@ class RADatabase: ...@@ -1390,7 +1390,7 @@ class RADatabase:
else: else:
claim_status_id = claim_status claim_status_id = claim_status
query = '''SELECT * from resource_monitoring.get_max_resource_usage_between(%s, %s, %s, %s)''' query = '''SELECT * from resource_allocation.get_max_resource_usage_between(%s, %s, %s, %s)'''
result = self._executeQuery(query, (resource_id, claim_status_id, lower_bound, upper_bound), fetch=_FETCH_ONE) result = self._executeQuery(query, (resource_id, claim_status_id, lower_bound, upper_bound), fetch=_FETCH_ONE)
if result and result.get('usage') is not None: if result and result.get('usage') is not None:
...@@ -1400,7 +1400,7 @@ class RADatabase: ...@@ -1400,7 +1400,7 @@ class RADatabase:
def get_resource_claimable_capacity(self, resource_id, lower_bound, upper_bound): def get_resource_claimable_capacity(self, resource_id, lower_bound, upper_bound):
'''get the claimable capacity for the given resource within the timewindow given by lower_bound and upper_bound. '''get the claimable capacity for the given resource within the timewindow given by lower_bound and upper_bound.
this is the resource's available capacity (total-used) minus the maximum allocated usage in that timewindow.''' this is the resource's available capacity (total-used) minus the maximum allocated usage in that timewindow.'''
query = '''SELECT * from resource_monitoring.get_resource_claimable_capacity_between(%s, %s, %s)''' query = '''SELECT * from resource_allocation.get_resource_claimable_capacity_between(%s, %s, %s)'''
result = self._executeQuery(query, (resource_id, lower_bound, upper_bound), fetch=_FETCH_ONE) result = self._executeQuery(query, (resource_id, lower_bound, upper_bound), fetch=_FETCH_ONE)
if result: if result:
return result.get('get_resource_claimable_capacity_between', 0) return result.get('get_resource_claimable_capacity_between', 0)
...@@ -1408,7 +1408,7 @@ class RADatabase: ...@@ -1408,7 +1408,7 @@ class RADatabase:
def rebuild_resource_usages_table_from_claims(self): def rebuild_resource_usages_table_from_claims(self):
'''(re)builds the resource_usages table from all currently known resource_claims''' '''(re)builds the resource_usages table from all currently known resource_claims'''
query = '''SELECT * from resource_monitoring.rebuild_resource_usages_table_from_claims()''' query = '''SELECT * from resource_allocation.rebuild_resource_usages_table_from_claims()'''
self._executeQuery(query, fetch=_FETCH_NONE) self._executeQuery(query, fetch=_FETCH_NONE)
def insertSpecificationAndTask(self, mom_id, otdb_id, task_status, task_type, starttime, endtime, content, cluster, commit=True): def insertSpecificationAndTask(self, mom_id, otdb_id, task_status, task_type, starttime, endtime, content, cluster, commit=True):
...@@ -1560,7 +1560,7 @@ class RADatabase: ...@@ -1560,7 +1560,7 @@ class RADatabase:
:return: a nested dict with resource_id at the first level, then claim_status(name) at the second level, and then a list of time ordered usages. :return: a nested dict with resource_id at the first level, then claim_status(name) at the second level, and then a list of time ordered usages.
""" """
usages_per_resource = {} usages_per_resource = {}
query = '''SELECT * from resource_monitoring.resource_usage''' query = '''SELECT * from resource_allocation.resource_usage'''
conditions = [] conditions = []
qargs = [] qargs = []
......
...@@ -341,7 +341,7 @@ BEGIN ...@@ -341,7 +341,7 @@ BEGIN
TRUNCATE TABLE resource_allocation.resource_usage RESTART IDENTITY CASCADE; TRUNCATE TABLE resource_allocation.resource_usage RESTART IDENTITY CASCADE;
FOR claim IN SELECT * FROM resource_allocation.resource_claim LOOP FOR claim IN SELECT * FROM resource_allocation.resource_claim LOOP
PERFORM resource_monitoring.process_new_claim_into_resource_usages(claim); PERFORM resource_allocation.process_new_claim_into_resource_usages(claim);
END LOOP; END LOOP;
END; END;
$$ LANGUAGE plpgsql; $$ LANGUAGE plpgsql;
...@@ -378,10 +378,10 @@ BEGIN ...@@ -378,10 +378,10 @@ BEGIN
-- both usage_at_start and usage_at_end should exist (NOT NULL) -- both usage_at_start and usage_at_end should exist (NOT NULL)
IF usage_at_start IS NULL THEN IF usage_at_start IS NULL THEN
RAISE EXCEPTION 'resource_monitoring.on_delete_claim_update_resource_usages: usage_at_start should not be NULL.'; RAISE EXCEPTION 'resource_allocation.on_delete_claim_update_resource_usages: usage_at_start should not be NULL.';
END IF; END IF;
IF usage_at_end IS NULL THEN IF usage_at_end IS NULL THEN
RAISE EXCEPTION 'resource_monitoring.on_delete_claim_update_resource_usages: usage_at_end should not be NULL.'; RAISE EXCEPTION 'resource_allocation.on_delete_claim_update_resource_usages: usage_at_end should not be NULL.';
END IF; END IF;
IF usage_at_start.usage = old_claim.claim_size THEN IF usage_at_start.usage = old_claim.claim_size THEN
...@@ -487,7 +487,7 @@ DECLARE ...@@ -487,7 +487,7 @@ DECLARE
max_resource_usage_value int; max_resource_usage_value int;
available_capacity bigint; available_capacity bigint;
BEGIN BEGIN
SELECT * FROM resource_monitoring.get_max_resource_usage_between(_resource_id, claimed_status_id, _lower, _upper) INTO max_resource_usage; SELECT * FROM resource_allocation.get_max_resource_usage_between(_resource_id, claimed_status_id, _lower, _upper) INTO max_resource_usage;
IF max_resource_usage IS NULL THEN IF max_resource_usage IS NULL THEN
max_resource_usage_value := 0; max_resource_usage_value := 0;
...@@ -514,7 +514,7 @@ DECLARE ...@@ -514,7 +514,7 @@ DECLARE
overlapping_claims_min_starttime timestamp; overlapping_claims_min_starttime timestamp;
overlapping_claims_max_endtime timestamp; overlapping_claims_max_endtime timestamp;
BEGIN BEGIN
-- this function is quite similar to resource_monitoring.get_conflicting_overlapping_claims -- this function is quite similar to resource_allocation.get_conflicting_overlapping_claims
-- for performance reasons we repeat the common code here instead of wrapping the common code in a function -- for performance reasons we repeat the common code here instead of wrapping the common code in a function
--get all overlapping_claims, whether they cause a conflict or not. --get all overlapping_claims, whether they cause a conflict or not.
...@@ -534,7 +534,7 @@ BEGIN ...@@ -534,7 +534,7 @@ BEGIN
SELECT max(starttime) FROM overlapping_claims INTO overlapping_claims_max_endtime; SELECT max(starttime) FROM overlapping_claims INTO overlapping_claims_max_endtime;
-- get the free free_claimable_capacity for this resource for the full overlapping claim time window -- get the free free_claimable_capacity for this resource for the full overlapping claim time window
SELECT * FROM resource_monitoring.get_resource_claimable_capacity_between(claim.resource_id, overlapping_claims_min_starttime, overlapping_claims_max_endtime) INTO free_claimable_capacity; SELECT * FROM resource_allocation.get_resource_claimable_capacity_between(claim.resource_id, overlapping_claims_min_starttime, overlapping_claims_max_endtime) INTO free_claimable_capacity;
return claim.claim_size > free_claimable_capacity; return claim.claim_size > free_claimable_capacity;
END; END;
...@@ -556,7 +556,7 @@ BEGIN ...@@ -556,7 +556,7 @@ BEGIN
LIMIT 1 LIMIT 1
INTO claim; INTO claim;
RETURN QUERY SELECT * FROM resource_monitoring.get_conflicting_overlapping_claims(claim); RETURN QUERY SELECT * FROM resource_allocation.get_conflicting_overlapping_claims(claim);
END; END;
$$ LANGUAGE plpgsql; $$ LANGUAGE plpgsql;
ALTER FUNCTION resource_allocation.get_conflicting_overlapping_claims(claim_id int) OWNER TO resourceassignment; ALTER FUNCTION resource_allocation.get_conflicting_overlapping_claims(claim_id int) OWNER TO resourceassignment;
...@@ -571,7 +571,7 @@ $$ ...@@ -571,7 +571,7 @@ $$
DECLARE DECLARE
claim_claimed_status_id int := 1; --beware: hard coded instead of lookup for performance claim_claimed_status_id int := 1; --beware: hard coded instead of lookup for performance
BEGIN BEGIN
-- this function is quite similar to resource_monitoring.has_conflict_with_overlapping_claims -- this function is quite similar to resource_allocation.has_conflict_with_overlapping_claims
-- for performance reasons we repeat the common code here instead of wrapping the common code in a function -- for performance reasons we repeat the common code here instead of wrapping the common code in a function
--get all overlapping_claims, whether they cause a conflict or not. --get all overlapping_claims, whether they cause a conflict or not.
...@@ -588,7 +588,7 @@ BEGIN ...@@ -588,7 +588,7 @@ BEGIN
RETURN QUERY SELECT * RETURN QUERY SELECT *
FROM overlapping_claims oc FROM overlapping_claims oc
WHERE (SELECT * FROM resource_monitoring.get_resource_claimable_capacity_between(claim.resource_id, oc.starttime, oc.endtime)) < claim.claim_size; WHERE (SELECT * FROM resource_allocation.get_resource_claimable_capacity_between(claim.resource_id, oc.starttime, oc.endtime)) < claim.claim_size;
END; END;
$$ LANGUAGE plpgsql; $$ LANGUAGE plpgsql;
ALTER FUNCTION resource_allocation.get_conflicting_overlapping_claims(claim resource_allocation.resource_claim) OWNER TO resourceassignment; ALTER FUNCTION resource_allocation.get_conflicting_overlapping_claims(claim resource_allocation.resource_claim) OWNER TO resourceassignment;
...@@ -637,7 +637,7 @@ BEGIN ...@@ -637,7 +637,7 @@ BEGIN
OLD.starttime <> NEW.starttime OR OLD.starttime <> NEW.starttime OR
OLD.endtime <> NEW.endtime)) THEN OLD.endtime <> NEW.endtime)) THEN
--check if claim fits or has conflicts --check if claim fits or has conflicts
SELECT * FROM resource_monitoring.has_conflict_with_overlapping_claims(NEW) INTO claim_has_conflicts; SELECT * FROM resource_allocation.has_conflict_with_overlapping_claims(NEW) INTO claim_has_conflicts;
IF claim_has_conflicts AND NEW.status_id <> claim_conflict_status_id THEN IF claim_has_conflicts AND NEW.status_id <> claim_conflict_status_id THEN
-- conflict with others, so set claim status to conflict -- conflict with others, so set claim status to conflict
...@@ -687,12 +687,12 @@ DECLARE ...@@ -687,12 +687,12 @@ DECLARE
BEGIN BEGIN
IF TG_OP = 'UPDATE' OR TG_OP = 'DELETE' THEN IF TG_OP = 'UPDATE' OR TG_OP = 'DELETE' THEN
--update the resource usages affected by this claim --update the resource usages affected by this claim
PERFORM resource_monitoring.process_old_claim_outof_resource_usages(OLD); PERFORM resource_allocation.process_old_claim_outof_resource_usages(OLD);
END IF; END IF;
IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN IF TG_OP = 'INSERT' OR TG_OP = 'UPDATE' THEN
--update the resource usages affected by this claim --update the resource usages affected by this claim
PERFORM resource_monitoring.process_new_claim_into_resource_usages(NEW); PERFORM resource_allocation.process_new_claim_into_resource_usages(NEW);
END IF; END IF;
-- in the before trigger function, everything on the claim has been checked and adapted. -- in the before trigger function, everything on the claim has been checked and adapted.
...@@ -722,7 +722,7 @@ BEGIN ...@@ -722,7 +722,7 @@ BEGIN
AND rc.starttime <= OLD.endtime LOOP AND rc.starttime <= OLD.endtime LOOP
--check if claim fits or has conflicts --check if claim fits or has conflicts
SELECT * FROM resource_monitoring.has_conflict_with_overlapping_claims(affected_claim) INTO claim_has_conflicts; SELECT * FROM resource_allocation.has_conflict_with_overlapping_claims(affected_claim) INTO claim_has_conflicts;
IF NOT claim_has_conflicts THEN IF NOT claim_has_conflicts THEN
-- no conflict (anymore) with others, so set claim status to tentative -- no conflict (anymore) with others, so set claim status to tentative
...@@ -743,7 +743,7 @@ BEGIN ...@@ -743,7 +743,7 @@ BEGIN
AND rc.starttime <= NEW.endtime LOOP AND rc.starttime <= NEW.endtime LOOP
--check if claim fits or has conflicts --check if claim fits or has conflicts
SELECT * FROM resource_monitoring.has_conflict_with_overlapping_claims(affected_claim) INTO claim_has_conflicts; SELECT * FROM resource_allocation.has_conflict_with_overlapping_claims(affected_claim) INTO claim_has_conflicts;
IF claim_has_conflicts THEN IF claim_has_conflicts THEN
-- new conflict for affected_claim because this NEW claim is now claimed -- new conflict for affected_claim because this NEW claim is now claimed
......
...@@ -491,7 +491,7 @@ class ResourceAssignmentDatabaseTest(unittest.TestCase): ...@@ -491,7 +491,7 @@ class ResourceAssignmentDatabaseTest(unittest.TestCase):
# suppose the resource_usages table is broken for some reason, fix it.... # suppose the resource_usages table is broken for some reason, fix it....
# break it first... # break it first...
self._execute_query('TRUNCATE TABLE resource_monitoring.resource_usage;') self._execute_query('TRUNCATE TABLE resource_allocation.resource_usage;')
#check that it's broken #check that it's broken
self.assertNotEqual(40, self.radb.get_max_resource_usage_between(117, task1['starttime'], task1['starttime'], 'claimed')['usage']) self.assertNotEqual(40, self.radb.get_max_resource_usage_between(117, task1['starttime'], task1['starttime'], 'claimed')['usage'])
#fix it #fix it
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment