Author: tmckay
Date: 2013-02-25 21:17:01 +0000 (Mon, 25 Feb 2013)
New Revision: 5724
Modified:
branches/tmckay/cumin/python/cumin/grid/pool.py
branches/tmckay/sage/python/sage/wallaby/wallabyoperations.py
Log:
More cache tweaking. Add tags_by_node in wallaby operations.
Modified: branches/tmckay/cumin/python/cumin/grid/pool.py
===================================================================
--- branches/tmckay/cumin/python/cumin/grid/pool.py 2013-02-25 16:30:30 UTC (rev 5723)
+++ branches/tmckay/cumin/python/cumin/grid/pool.py 2013-02-25 21:17:01 UTC (rev 5724)
@@ -108,7 +108,6 @@
self.limits = LimitSelector(app, "limits")
self.view.add_tab(self.limits)
- self.edit_node_tags = TagsNodeEditTask(app, self)
config_editor = TagInventory(app, "tagi")
self.view.add_tab(config_editor)
Modified: branches/tmckay/sage/python/sage/wallaby/wallabyoperations.py
===================================================================
--- branches/tmckay/sage/python/sage/wallaby/wallabyoperations.py 2013-02-25 16:30:30 UTC
(rev 5723)
+++ branches/tmckay/sage/python/sage/wallaby/wallabyoperations.py 2013-02-25 21:17:01 UTC
(rev 5724)
@@ -89,6 +89,7 @@
# Cache a list of nodes that are members of a tag
self._nodes_by_tag = dict()
+ self._tags_by_node = dict()
# Store the name of the partition group so we can filter it out
# of tags/groups that we return
@@ -304,12 +305,8 @@
names = []
self._lock.acquire()
try:
- if node_name in self._cache[WBTypes.NODES].data:
- names = self._cache[WBTypes.NODES].data[node_name].getLabels()
- # This is a hack until remove group works
- names = [n for n in names \
- if n in self._nodes_by_tag and \
- node_name in self._nodes_by_tag[n]]
+ if node_name in self._tags_by_node:
+ names = self._tags_by_node[node_name]
finally:
self._lock.release()
return names
@@ -375,9 +372,15 @@
for tag in tags:
#for n in self._nodes_by_tag[tag]:
# n.refresh()
+ nodes = self._nodes_by_tag[tag]
del self._nodes_by_tag[tag]
del self._cache["tags"].data[tag]
del self._cache["groups"].data[tag]
+ for n in nodes:
+ try:
+ self._tags_by_node[n].remove(tag)
+ except:
+ pass
self._lock.release()
if callback and not self._replaying:
@@ -404,12 +407,23 @@
start = time.time()
# this is a workaround
self._store.getPartitionGroup()
- n.modifyLabels("REPLACE", list(tags),
create_missing_tags=True)
+
+ # In case multiple cumin users are fighting
+ # check the list of tags for validity
+ bogus = []
+ for t in tags:
+ if not t in self._cache[WBTypes.TAGS].data:
+ bogus.append(t)
+ for b in bogus:
+ tags.remove(b)
+
+ n.modifyLabels("REPLACE", list(tags))
status = True
delta = time.time() - start
log.debug("WallabyOperations: edit_tags %s" % delta)
except Exception, e:
- log.debug("WallabyOperations: edit_tags, exception suppressed,
%s" % str(e))
+ log.debug("WallabyOperations: edit_tags, "\
+ "exception suppressed, %s" % str(e))
if status:
self._lock.acquire()
@@ -422,6 +436,7 @@
val.remove(node)
except:
pass
+ self._tags_by_node[node] = list(tags)
self._lock.release()
callback = "callback" in kwargs and kwargs["callback"] or
None
@@ -729,6 +744,7 @@
groups = ops.get_data(WBTypes.GROUPS)
tags = []
nodes_by_tag = dict()
+ tags_by_node = dict()
for g in groups:
if not g.name.startswith("+++") and \
ops._store.isLabel(g):
@@ -738,11 +754,17 @@
delta = time.time() - start
log.debug("WallabyOperations: update g.membership %s " %
delta)
nodes_by_tag[g.name] = nodes
+ for n in nodes:
+ if n in tags_by_node:
+ tags_by_node[n].append(g.name)
+ else:
+ tags_by_node[n] = [g.name]
ops._lock.acquire()
try:
ops._cache[WBTypes.TAGS].data = ops._to_dict(tags)
ops._nodes_by_tag = nodes_by_tag
+ ops._tags_by_node = tags_by_node
finally:
ops._lock.release()
log.debug("WallabyOperations: %s list updated (%s items)" \
Show replies by date