Permalink
Browse files

Switch to dispatch_times, rather than start_times in throttling

  • Loading branch information...
oldpatricka committed Apr 5, 2013
1 parent fd96f00 commit e64c6a4d3479ccd2405373886831a0c94baccdb9
Showing with 12 additions and 4 deletions.
  1. +1 −1 epu/processdispatcher/core.py
  2. +3 −2 epu/processdispatcher/matchmaker.py
  3. +8 −1 epu/processdispatcher/store.py
@@ -227,7 +227,7 @@ def schedule_process(self, owner, upid, definition_id=None,
if definition_id != definition['definition_id']:
raise BadRequestError(
"process %s definition_id %s doesn't match request"
- % (upid, ))
+ % (upid, definition_id))
process.update(process_updates)
process.state = ProcessState.REQUESTED
@@ -472,6 +472,7 @@ def _maybe_update_assigned_process(self, process, resource):
while process.state < ProcessState.PENDING:
process.assigned = resource.resource_id
process.state = ProcessState.PENDING
+ process.increment_dispatches()
# pull hostname directly onto process record, if available.
# it is commonly desired information and this saves the need to
@@ -609,10 +610,10 @@ def _throttle_end_time(self, process):
return 0
# Process only needs throttling if it has been restarted at least once
- if len(process.start_times) <= 1:
+ if len(process.dispatch_times) <= 1:
return 0
- last_start = max(process.start_times)
+ last_start = max(process.dispatch_times)
return last_start + minimum_time_between_starts
def _mark_process_stale(self, process):
@@ -1438,18 +1438,25 @@ def new(cls, owner, upid, definition, state, configuration=None,
starts = 0
start_times = []
+ dispatches = 0
+ dispatch_times = []
d = dict(owner=owner, upid=upid, subscribers=subscribers, state=state,
round=int(round), definition=definition, configuration=conf,
constraints=const, assigned=assigned, hostname=hostname,
queueing_mode=queueing_mode, restart_mode=restart_mode,
starts=starts, node_exclusive=node_exclusive, name=name,
- start_times=start_times)
+ start_times=start_times, dispatches=dispatches,
+ dispatch_times=dispatch_times)
return cls(d)
def increment_starts(self):
self.starts += 1
self.start_times.append(time.time())
+ def increment_dispatches(self):
+ self.dispatches += 1
+ self.dispatch_times.append(time.time())
+
def get_key(self):
return self.owner, self.upid, self.round

0 comments on commit e64c6a4

Please sign in to comment.