Author: justi9
Date: 2007-11-08 17:31:09 -0500 (Thu, 08 Nov 2007)
New Revision: 1278
Modified:
mgmt/cumin/python/cumin/client.strings
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/resources/wooly.js
Log:
Adds a dict method to element that converts xml into a javascript map.
Uses this to make updateXXX callbacks more succinct.
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2007-11-08 22:03:47 UTC (rev 1277)
+++ mgmt/cumin/python/cumin/client.strings 2007-11-08 22:31:09 UTC (rev 1278)
@@ -36,24 +36,19 @@
function updateClientStatus(id, data) {
updateStatus(id, data);
- var ms = data.root().elem("measurements");
+ var rates = data.root().dict("measurement", "name",
"rate");
- var mprod = ms.elem("msgsproduced").elem("r").text().get();
- var bprod = ms.elem("bytesproduced").elem("r").text().get();
- var mcons = ms.elem("msgsconsumed").elem("r").text().get();
- var bcons = ms.elem("bytesconsumed").elem("r").text().get();
-
var status = wooly.doc().elembyid(id);
var trs =
status.elem("table").elem("tbody").elems("tr", 1);
var tds = null;
tds = trs.next().elems("td");
- tds.next().text().set(mprod);
- tds.next().text().set(bprod);
+ tds.next().text().set(rates["msgsProduced"]);
+ tds.next().text().set(rates["bytesProduced"]);
tds = trs.next().elems("td");
- tds.next().text().set(mcons);
- tds.next().text().set(bcons);
+ tds.next().text().set(rates["msgsConsumed"]);
+ tds.next().text().set(rates["bytesConsumed"]);
}
[ClientStatus.html]
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-11-08 22:03:47 UTC (rev 1277)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-11-08 22:31:09 UTC (rev 1278)
@@ -87,31 +87,25 @@
function updateExchangeStatus(id, data) {
updateStatus(id, data);
- var ms = data.root().elem("measurements");
+ var values = data.root().dict("measurement", "name",
"value");
+ var rates = data.root().dict("measurement", "name",
"rate");
- var mrecv = ms.elem("msgreceives").elem("r").text().get();
- var brecv = ms.elem("bytereceives").elem("r").text().get();
- var mrt = ms.elem("msgroutes").elem("r").text().get();
- var brt = ms.elem("byteroutes").elem("r").text().get();
- var mdrp = ms.elem("msgdrops").elem("v").text().get();
- var bdrp = ms.elem("bytedrops").elem("v").text().get();
-
var status = wooly.doc().elembyid(id);
var trs =
status.elem("table").elem("tbody").elems("tr", 1);
var tds = null;
tds = trs.next().elems("td");
- tds.next().text().set(mrecv);
- tds.next().text().set(brecv);
+ tds.next().text().set(rates["msgReceives"]);
+ tds.next().text().set(rates["byteReceives"]);
tds = trs.next().elems("td");
- tds.next().text().set(mrt);
- tds.next().text().set(brt);
+ tds.next().text().set(rates["msgRoutes"]);
+ tds.next().text().set(rates["byteRoutes"]);
tds = trs.next().elems("td");
- tds.next().text().set(mdrp);
- tds.next().text().set(bdrp);
+ tds.next().text().set(values["msgDrops"]);
+ tds.next().text().set(values["byteDrops"]);
}
[ExchangeStatus.html]
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-11-08 22:03:47 UTC (rev 1277)
+++ mgmt/cumin/python/cumin/model.py 2007-11-08 22:31:09 UTC (rev 1278)
@@ -193,13 +193,9 @@
writer.write("<warning-count>%i</warning-count>" %
len(self.warnings))
def write_measurement_xml(self, writer):
- writer.write("<measurements>")
-
for measure in self.measurements:
measure.write_xml(writer)
- writer.write("</measurements>")
-
class BrokerCluster(CuminModelObject):
def __init__(self, model):
super(BrokerCluster, self).__init__(model, model.broker_cluster)
@@ -387,8 +383,8 @@
return self.__low
def write_xml(self, writer):
-
writer.write("<%s><v>%i</v><r>%i</r></%s>" %
\
- (self.name, self.get_value(), self.get_rate(), self.name))
+ writer.write("<measurement name=\"%s\" value=\"%i\"
rate=\"%i\"/>" \
+ % (self.name, self.get_value(), self.get_rate()))
class Queue(CuminModelObject):
def __init__(self, model):
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-11-08 22:03:47 UTC (rev 1277)
+++ mgmt/cumin/python/cumin/queue.strings 2007-11-08 22:31:09 UTC (rev 1278)
@@ -92,36 +92,28 @@
function updateQueueStatus(id, data) {
updateStatus(id, data);
- var ms = data.root().elem("measurements");
+ var values = data.root().dict("measurement", "name",
"value");
+ var rates = data.root().dict("measurement", "name",
"rate");
- var menq = ms.elem("msgtotalenqueues").elem("r").text().get();
- var mdeq = ms.elem("msgtotaldequeues").elem("r").text().get();
- var benq = ms.elem("bytetotalenqueues").elem("r").text().get();
- var bdeq = ms.elem("bytetotaldequeues").elem("r").text().get();
- var mdep = ms.elem("msgdepth").elem("v").text().get();
- var bdep = ms.elem("bytedepth").elem("v").text().get();
- var mdepacc = ms.elem("msgdepth").elem("r").text().get();
- var bdepacc = ms.elem("bytedepth").elem("r").text().get();
-
var status = wooly.doc().elembyid(id);
var trs =
status.elem("table").elem("tbody").elems("tr", 1);
var tds = null;
tds = trs.next().elems("td");
- tds.next().text().set(menq);
- tds.next().text().set(mdeq);
+ tds.next().text().set(rates["msgTotalEnqueues"]);
+ tds.next().text().set(rates["byteTotalEnqueues"]);
tds = trs.next().elems("td");
- tds.next().text().set(benq);
- tds.next().text().set(bdeq);
+ tds.next().text().set(rates["msgTotalDequeues"]);
+ tds.next().text().set(rates["byteTotalDequeues"]);
tds = trs.next().elems("td");
- tds.next().set(mdep);
- tds.next().set(bdep);
+ tds.next().set(values["msgDepth"]);
+ tds.next().set(values["byteDepth"]);
tds = trs.next().elems("td");
- tds.next().text().set(mdepacc);
- tds.next().text().set(bdepacc);
+ tds.next().text().set(rates["msgDepth"]);
+ tds.next().text().set(rates["byteDepth"]);
}
[QueueStatus.html]
Modified: mgmt/cumin/resources/wooly.js
===================================================================
--- mgmt/cumin/resources/wooly.js 2007-11-08 22:03:47 UTC (rev 1277)
+++ mgmt/cumin/resources/wooly.js 2007-11-08 22:31:09 UTC (rev 1278)
@@ -188,6 +188,29 @@
return this;
}
+ this.getattr = function(name) {
+ return this.node.getAttribute(name);
+ }
+
+ this.setattr = function(name, value) {
+ this.node.setAttribute(name, value);
+
+ return value
+ }
+
+ this.dict = function(name, kattr, vattr) {
+ var dict = new Object();
+ var elems = this.elems(name);
+ var elem = elems.next();
+
+ while (elem != null) {
+ dict[elem.getattr(kattr)] = elem.getattr(vattr);
+ elem = elems.next();
+ }
+
+ return dict;
+ }
+
this.elems = function(name, start) {
if (start == null) {
start = 0;