Skip to content

Commit

Permalink
Remove superfluous node_exclusive attr from resource in store
Browse files Browse the repository at this point in the history
  • Loading branch information
oldpatricka committed Dec 10, 2012
1 parent c81c128 commit 6dcdec4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
11 changes: 8 additions & 3 deletions epu/processdispatcher/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -520,8 +520,6 @@ def ee_heartbeat(self, sender, beat):
#TODO? right now this will just wait for the next heartbeat
pass

log.debug("updating resource %s node_exclusive. was %s, now %s",
resource.resource_id, resource.node_exclusive, new_node_exclusive)
node = self.store.get_node(resource.node_id)
if not node:
msg = "Node %s doesn't exist, but you want to set node_exclusive?" % (
Expand Down Expand Up @@ -638,8 +636,9 @@ def _change_process_state(self, process, newstate, **updates):

def dump(self):
resources = {}
nodes = {}
processes = {}
state = dict(resources=resources, processes=processes)
state = dict(resources=resources, processes=processes, nodes=nodes)

for resource_id in self.store.get_resource_ids():
resource = self.store.get_resource(resource_id)
Expand All @@ -653,4 +652,10 @@ def dump(self):
continue
processes[process.upid] = dict(process)

for node_id in self.store.get_node_ids():
node = self.store.get_node(node_id)
if not node:
continue
nodes[node_id] = dict(node)

return state
2 changes: 2 additions & 0 deletions epu/processdispatcher/matchmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def matchmake(self):
matched_resource.node_id)
return

log.debug("updating %s with node_exclusive %s for %s" % (matched_node.node_id, process.node_exclusive, process.upid))
matched_node.node_exclusive.append(process.node_exclusive)

try:
Expand Down Expand Up @@ -638,6 +639,7 @@ def matchmake_process(self, process, node_containers):
log.warning("Can't find node %s?", node_id)
continue
if not node.node_exclusive_available(process.node_exclusive):
log.debug("Process %s with node_exclusive %s is not being matched to %s, which has this attribute" % (process.upid, process.node_exclusive, node_id))
continue

# now inspect each resource in the node looking for a match
Expand Down
11 changes: 1 addition & 10 deletions epu/processdispatcher/store.py
Original file line number Diff line number Diff line change
Expand Up @@ -1175,18 +1175,9 @@ def new(cls, resource_id, node_id, slot_count, properties=None,
props['resource_id'] = resource_id

d = dict(resource_id=resource_id, node_id=node_id, enabled=enabled,
slot_count=int(slot_count), properties=props, assigned=[],
node_exclusive=[])
slot_count=int(slot_count), properties=props, assigned=[])
return cls(d)

def node_exclusive_available(self, attr):
if attr is None:
return True
elif attr not in self.node_exclusive:
return True
else:
return False

@property
def available_slots(self):
return max(0, self.slot_count - len(self.assigned))
Expand Down

0 comments on commit 6dcdec4

Please sign in to comment.