Author: justi9
Date: 2010-07-29 13:28:53 -0400 (Thu, 29 Jul 2010)
New Revision: 4166
Modified:
mgmt/newdata/mint/python/mint/model.py
mgmt/newdata/mint/python/mint/update.py
Log:
Now that qmf-mint agent mapping is moved into the update queue, remove the agent locking
Modified: mgmt/newdata/mint/python/mint/model.py
===================================================================
--- mgmt/newdata/mint/python/mint/model.py 2010-07-29 16:44:00 UTC (rev 4165)
+++ mgmt/newdata/mint/python/mint/model.py 2010-07-29 17:28:53 UTC (rev 4166)
@@ -32,15 +32,6 @@
super(MintModel, self).init()
- def get_agent(self, qmf_agent):
- id = qmf_agent.getAgentBank()
-
- self.lock.acquire()
- try:
- return self.agents_by_id[id]
- finally:
- self.lock.release()
-
def print_event(self, level, message, *args):
log.debug(message, *args)
@@ -51,31 +42,21 @@
return "%s(%s)" % (self.__class__.__name__, self.model_dir)
class MintAgent(object):
- def __init__(self, model, qmf_agent):
+ def __init__(self, model, id):
self.model = model
- self.qmf_agent = qmf_agent
+ self.id = id
- self.id = qmf_agent.getAgentBank()
-
self.last_heartbeat = None
self.objects_by_id = dict()
- self.model.lock.acquire()
- try:
- assert self.id not in self.model.agents_by_id
- self.model.agents_by_id[self.id] = self
- finally:
- self.model.lock.release()
+ assert self.id not in self.model.agents_by_id
+ self.model.agents_by_id[self.id] = self
def delete(self):
assert self.model
- self.model.lock.acquire()
- try:
- del self.model.agents_by_id[self.id]
- finally:
- self.model.lock.release()
+ del self.model.agents_by_id[self.id]
self.model = None
Modified: mgmt/newdata/mint/python/mint/update.py
===================================================================
--- mgmt/newdata/mint/python/mint/update.py 2010-07-29 16:44:00 UTC (rev 4165)
+++ mgmt/newdata/mint/python/mint/update.py 2010-07-29 17:28:53 UTC (rev 4166)
@@ -178,7 +178,8 @@
def do_process(self, cursor, stats):
try:
- self.agent = self.model.get_agent(self.qmf_object.getAgent())
+ agent_id = self.qmf_object.getAgent().getAgentBank()
+ self.agent = self.model.agents_by_id[agent_id]
except KeyError:
raise UpdateDropped()
@@ -486,15 +487,15 @@
self.qmf_agent = qmf_agent
def do_process(self, cursor, stats):
+ agent_id = self.qmf_agent.getAgentBank()
+
try:
- agent = self.model.get_agent(self.qmf_agent)
+ agent = self.model.agents_by_id[agent_id]
except KeyError:
- agent_id = self.qmf_agent.getAgentBank()
+ agent = MintAgent(self.model, agent_id)
- self.delete_agent_objects(cursor, stats, agent_id)
+ self.delete_agent_objects(cursor, stats, agent)
- agent = MintAgent(self.model, self.qmf_agent)
-
#timestamp = timestamp / 1000000000
#agent.last_heartbeat = datetime.fromtimestamp(timestamp)
@@ -504,7 +505,7 @@
# XXX Add periodic update of update_time
- def delete_agent_objects(self, cursor, stats, agent_id):
+ def delete_agent_objects(self, cursor, stats, agent):
for pkg in self.model._packages:
for cls in pkg._classes:
if cls._storage == "none":
@@ -513,20 +514,22 @@
if cls is self.model.com_redhat_grid.Collector:
continue
- count = cls.delete_selection(cursor, _qmf_agent_id=agent_id)
+ count = cls.delete_selection(cursor, _qmf_agent_id=agent.id)
stats.deleted += count
class AgentDelete(AgentUpdate):
def do_process(self, cursor, stats):
+ agent_id = self.qmf_agent.getAgentBank()
+
try:
- agent = self.model.get_agent(self.qmf_agent)
+ agent = self.model.agents_by_id[agent_id]
except KeyError:
raise UpdateDropped()
agent.delete()
- self.delete_agent_objects(cursor, stats, agent.id)
+ self.delete_agent_objects(cursor, stats, agent)
class UpdateDropped(Exception):
pass