rhmessaging commits: r1287 - store/trunk/cpp/tests/jrnl.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-12 11:43:01 -0500 (Mon, 12 Nov 2007)
New Revision: 1287
Modified:
store/trunk/cpp/tests/jrnl/Makefile.am
Log:
Fixed Makefile.am so as not to cause a build when DISTEXTRAS are being handled
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-11-12 16:31:20 UTC (rev 1286)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-11-12 16:43:01 UTC (rev 1287)
@@ -41,20 +41,13 @@
unit_test_jinf
unit_test_jexception_SOURCES = unit_test_jexception.cpp
-unit_test_jexception_LDADD = ../../lib/.libs/jexception.o ../../lib/.libs/jerrno.o
-unit_test_jexception_LDFLAGS = -lboost_unit_test_framework
+unit_test_jexception_LDFLAGS = -lboost_unit_test_framework -lbdbstore -L../../lib/.libs
unit_test_jerrno_SOURCES = unit_test_jerrno.cpp
-unit_test_jerrno_LDADD = ../../lib/.libs/jerrno.o
-unit_test_jerrno_LDFLAGS = -lboost_unit_test_framework
+unit_test_jerrno_LDFLAGS = -lboost_unit_test_framework -lbdbstore -L../../lib/.libs
unit_test_jinf_SOURCES = unit_test_jinf.cpp
-unit_test_jinf_LDADD = \
- ../../lib/.libs/jinf.o \
- ../../lib/.libs/file_hdr.o \
- ../../lib/.libs/jexception.o \
- ../../lib/.libs/jerrno.o
-unit_test_jinf_LDFLAGS = -lboost_unit_test_framework -lrt
+unit_test_jinf_LDFLAGS = -lboost_unit_test_framework -lbdbstore -lrt -L../../lib/.libs
JournalSystemTests_la_SOURCES = \
JournalSystemTests.cpp \
@@ -65,4 +58,11 @@
libdlclose_noop_la_SOURCES = ../dlclose_noop.c
libdlclose_noop_la_LDFLAGS = -module -rpath $(abs_builddir)
-EXTRA_DIST = $(TESTS) rtest janalyze.py tests.ods rtests.csv rwtests.csv wtests.csv
+EXTRA_DIST = \
+ run-journal-tests \
+ rtest \
+ janalyze.py \
+ tests.ods \
+ rtests.csv \
+ rwtests.csv \
+ wtests.csv
17 years, 1 month
rhmessaging commits: r1286 - in mgmt/cumin: resources and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-12 11:31:20 -0500 (Mon, 12 Nov 2007)
New Revision: 1286
Modified:
mgmt/cumin/python/cumin/measurement.py
mgmt/cumin/python/cumin/measurement.strings
mgmt/cumin/resources/wooly.js
Log:
Simplifications and improvements to the javascript functions.
Modified: mgmt/cumin/python/cumin/measurement.py
===================================================================
--- mgmt/cumin/python/cumin/measurement.py 2007-11-12 15:36:33 UTC (rev 1285)
+++ mgmt/cumin/python/cumin/measurement.py 2007-11-12 16:31:20 UTC (rev 1286)
@@ -48,7 +48,7 @@
def render_item_extra(self, session, measure):
if measure.highlow:
- return "<small>high</small> <span ph=\"1\">%i</span> <small>low</small> <span ph=\"2\">%i</span>" \
+ return "<small>high</small> <span>%i</span> <small>low</small> <span>%i</span>" \
% (measure.get_high() or 0, measure.get_low() or 0)
else:
unit = self.unit_abbrevs.get(measure.unit, measure.unit)
Modified: mgmt/cumin/python/cumin/measurement.strings
===================================================================
--- mgmt/cumin/python/cumin/measurement.strings 2007-11-12 15:36:33 UTC (rev 1285)
+++ mgmt/cumin/python/cumin/measurement.strings 2007-11-12 16:31:20 UTC (rev 1286)
@@ -9,17 +9,21 @@
if (attr) {
var m = object.measurement[attr];
+ var tds = tr.elems("td", null, null, 0, 2);
- var tds = tr.elems("td");
tds.next().text().set(m.value);
var td = tds.next();
- var ph1 = td.placeholder("1");
- var ph2 = td.placeholder("2");
- if (ph1 && ph2) {
- ph1.set(m.high);
- ph2.set(m.low);
+ var phs = td.elems("span", null, null, 0, 2);
+ var ph = phs.next();
+
+ if (ph) {
+ ph.set(m.high);
+
+ ph = phs.next();
+
+ ph.set(m.low);
} else {
td.text().set(m.rate);
}
Modified: mgmt/cumin/resources/wooly.js
===================================================================
--- mgmt/cumin/resources/wooly.js 2007-11-12 15:36:33 UTC (rev 1285)
+++ mgmt/cumin/resources/wooly.js 2007-11-12 16:31:20 UTC (rev 1286)
@@ -140,43 +140,46 @@
return node;
}
- function find(nodeParent, nodeType, nodeName, attr, attrValue) {
+ function find(found, limit,
+ nodeParent, nodeType, nodeName,
+ attr, attrValue) {
+ /*
+ assert(found);
+ assert(found instanceof Array);
assert(nodeParent);
assert(nodeType);
+ */
var children = nodeParent.childNodes;
- var found;
for (var i = 0; i < children.length; i++) {
- if (found) {
- break;
- }
-
var child = children[i];
var candidate = child;
if (child.nodeType != nodeType) {
candidate = null;
- } else if (nodeName && child.nodeName.toLowerCase() != nodeName) {
+ } else if (nodeName != null && child.nodeName.toLowerCase() != nodeName) {
candidate = null;
- } else if (attr && child.nodeType == 1) {
+ } else if (attr != null && child.nodeType == 1) {
var value = child.getAttribute(attr);
if (!value) {
candidate = null;
- } else if (value != attrValue) {
+ } else if (attrValue != null && value != attrValue) {
candidate = null;
}
}
if (candidate) {
- found = candidate;
+ found.push(candidate);
+
+ if (found.length == limit) {
+ return;
+ }
} else {
- found = find(child, nodeType, nodeName, attr, attrValue);
+ find(found, limit, child, nodeType, nodeName, attr, attrValue);
}
}
-
- return found;
}
function Wooly() {
@@ -252,7 +255,7 @@
}
var nodes = this.node.getElementsByTagName(name);
- var iter = new WoolyIterator(this, WoolyElement, nodes, 1, name);
+ var iter = new WoolyIterator(this, nodes, WoolyElement);
for (var i = 0; i < start; i++) {
iter.next();
@@ -266,39 +269,25 @@
}
}
- function WoolyIterator(doc, nodeClass, nodes, nodeType, nodeName) {
+ function WoolyIterator(doc, nodes, nodeClass) {
assert(doc);
- assert(doc instanceof WoolyDocument);
- assert(nodeClass);
assert(nodes);
- assert(nodes instanceof NodeList);
- assert(nodeType);
- assert(typeof nodeType == "number");
- if (nodeName) assert(typeof nodeName == "string");
+ assert(nodeClass);
this.doc = doc;
this.nodes = nodes;
this.nodeClass = nodeClass;
- this.nodeType = nodeType;
- this.nodeName = nodeName;
- this.lastIndex = -1;
+ this.pos = 0;
this.next = function() {
- var node;
+ var node = nodes[this.pos++]
- for (var i = this.lastIndex + 1; i < this.nodes.length; i++) {
- node = this.nodes[i];
-
- if ((this.nodeType == null || node.nodeType == this.nodeType)
- && (this.nodeName == null
- || node.nodeName.toLowerCase() == this.nodeName)) {
- this.lastIndex = i;
- return new this.nodeClass(this.doc, node);
- }
+ if (node) {
+ return new this.nodeClass(this.doc, node);
+ } else {
+ return null;
}
-
- return null;
}
}
@@ -380,15 +369,17 @@
return new WoolyElement(this.doc, node);
}
- this.elems = function(name, start) {
+ this.elems = function(name, attr, attrValue, start, limit) {
if (start == null) {
start = 0;
}
- var iter = new WoolyIterator(this.doc, WoolyElement,
- this.node.childNodes,
- 1, name);
+ var nodes = new Array();
+ find(nodes, limit, this.node, 1, name, attr, attrValue);
+
+ var iter = new WoolyIterator(this.doc, nodes, WoolyElement);
+
for (var i = 0; i < start; i++) {
iter.next();
}
@@ -396,29 +387,27 @@
return iter;
}
- this.elem = function(name, n) {
- return this.elems(name, n).next();
+ this.elem = function(name, attr, attrValue, n) {
+ return this.elems(name, attr, attrValue, n, n + 1).next();
}
- this.text = function() {
- var text = find(this.node, 3);
+ this.texts = function(start, limit) {
+ var nodes = new Array();
- if (text) {
- return new WoolyText(this.doc, text);
- } else {
- return null;
- }
- }
+ find(nodes, limit, this.node, 3);
- this.placeholder = function(name) {
- var ph = find(this.node, 1, "span", "ph", name);
+ var iter = new WoolyIterator(this.doc, nodes, WoolyText);
- if (ph) {
- return new WoolyElement(this.doc, ph);
- } else {
- return null;
+ for (var i = 0; i < start; i++) {
+ iter.next();
}
+
+ return iter;
}
+
+ this.text = function() {
+ return this.texts(0, 1).next();
+ }
}
function WoolyText(doc, node) {
17 years, 1 month
rhmessaging commits: r1285 - store/trunk/cpp/tests.
by rhmessaging-commits@lists.jboss.org
Author: cctrieloff
Date: 2007-11-12 10:36:33 -0500 (Mon, 12 Nov 2007)
New Revision: 1285
Modified:
store/trunk/cpp/tests/persistence.py
Log:
- correction on confirm mode.
Modified: store/trunk/cpp/tests/persistence.py
===================================================================
--- store/trunk/cpp/tests/persistence.py 2007-11-12 15:04:11 UTC (rev 1284)
+++ store/trunk/cpp/tests/persistence.py 2007-11-12 15:36:33 UTC (rev 1285)
@@ -118,7 +118,7 @@
#delete a queue
channel.queue_delete(queue="queue-c")
- channel.message_subscribe(destination="ctag", queue="queue-a")
+ channel.message_subscribe(destination="ctag", queue="queue-a", confirm_mode=1)
channel.message_flow(destination="ctag", unit=0, value=0xFFFFFFFF)
channel.message_flow(destination="ctag", unit=1, value=0xFFFFFFFF)
included = self.client.queue("ctag")
17 years, 1 month
rhmessaging commits: r1284 - in mgmt/cumin: resources and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-11-12 10:04:11 -0500 (Mon, 12 Nov 2007)
New Revision: 1284
Modified:
mgmt/cumin/python/cumin/client.strings
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/measurement.py
mgmt/cumin/python/cumin/measurement.strings
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/page.strings
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/resources/wooly.js
Log:
Big ajax and javascript update.
Adds a function to the js for changing xml tree into js objects.
Adds a cumin object with slots for type-specific listeners, eg queue
update listeners.
Adds a placeholder method to Element for finding regions of text we
want to update.
Makes the queue stats page ajax update.
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/client.strings 2007-11-12 15:04:11 UTC (rev 1284)
@@ -36,19 +36,16 @@
function updateClientStatus(id, data) {
updateStatus(id, data);
- var rates = data.root().dict("measurement", "name", "rate");
+ var m = data.root().object().measurement;
+ var mdata = {
+ "tr": [
+ null,
+ {"td": [m.msgsProduced.rate, m.bytesProduced.rate]},
+ {"td": [m.msgsConsumed.rate, m.bytesConsumed.rate]}
+ ]
+ };
- 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(rates["msgsProduced"]);
- tds.next().text().set(rates["bytesProduced"]);
-
- tds = trs.next().elems("td");
- tds.next().text().set(rates["msgsConsumed"]);
- tds.next().text().set(rates["bytesConsumed"]);
+ wooly.doc().elembyid(id).descendant("table.tbody").update(mdata);
}
[ClientStatus.html]
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-11-12 15:04:11 UTC (rev 1284)
@@ -87,25 +87,17 @@
function updateExchangeStatus(id, data) {
updateStatus(id, data);
- var values = data.root().dict("measurement", "name", "value");
- var rates = data.root().dict("measurement", "name", "rate");
+ var m = data.root().object().measurement;
+ var mdata = {
+ "tr": [
+ null,
+ {"td": [m.msgReceives.rate, m.byteReceives.rate]},
+ {"td": [m.msgRoutes.rate, m.byteRoutes.rate]},
+ {"td": [m.msgDrops.value, m.byteDrops.value]}
+ ]
+ };
- 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(rates["msgReceives"]);
- tds.next().text().set(rates["byteReceives"]);
-
- tds = trs.next().elems("td");
- tds.next().text().set(rates["msgRoutes"]);
- tds.next().text().set(rates["byteRoutes"]);
-
- tds = trs.next().elems("td");
- tds.next().text().set(values["msgDrops"]);
- tds.next().text().set(values["byteDrops"]);
+ wooly.doc().elembyid(id).descendant("table.tbody").update(mdata);
}
[ExchangeStatus.html]
Modified: mgmt/cumin/python/cumin/measurement.py
===================================================================
--- mgmt/cumin/python/cumin/measurement.py 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/measurement.py 2007-11-12 15:04:11 UTC (rev 1284)
@@ -35,6 +35,9 @@
def render_item_title(self, session, measure):
return measure.title
+ def render_item_name(self, session, measure):
+ return measure.name
+
def render_item_value(self, session, measure):
if measure.link_cb:
branch = session.branch()
@@ -45,7 +48,7 @@
def render_item_extra(self, session, measure):
if measure.highlow:
- return "<small>high</small> %i <small>low</small> %i" \
+ return "<small>high</small> <span ph=\"1\">%i</span> <small>low</small> <span ph=\"2\">%i</span>" \
% (measure.get_high() or 0, measure.get_low() or 0)
else:
unit = self.unit_abbrevs.get(measure.unit, measure.unit)
Modified: mgmt/cumin/python/cumin/measurement.strings
===================================================================
--- mgmt/cumin/python/cumin/measurement.strings 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/measurement.strings 2007-11-12 15:04:11 UTC (rev 1284)
@@ -1,7 +1,36 @@
+[MeasurementSet.javascript]
+function updateMeasurements(id, object) {
+ var table = wooly.doc().elembyid(id)
+ var trs = table.elem("tbody").elems("tr");
+ var tr = trs.next();
+ while (tr) {
+ var attr = tr.getattr("m");
+ if (attr) {
+ var m = object.measurement[attr];
+
+ var tds = tr.elems("td");
+ tds.next().text().set(m.value);
+
+ var td = tds.next();
+ var ph1 = td.placeholder("1");
+ var ph2 = td.placeholder("2");
+
+ if (ph1 && ph2) {
+ ph1.set(m.high);
+ ph2.set(m.low);
+ } else {
+ td.text().set(m.rate);
+ }
+ }
+
+ tr = trs.next();
+ }
+}
+
[MeasurementSet.html]
-<table class="mobjects">
+<table id="{id}" class="mobjects">
<tr>
<th style="width: 45%;">Statistic</th>
<th style="width: 20%;" class="ralign">Current</th>
@@ -12,7 +41,7 @@
</table>
[MeasurementSet.item_html]
-<tr>
+<tr m="{item_name}">
<th>{item_title}</th>
<td class="ralign">{item_value}</td>
<td class="ralign">{item_extra}</td>
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/model.py 2007-11-12 15:04:11 UTC (rev 1284)
@@ -383,8 +383,13 @@
return self.__low
def write_xml(self, writer):
- writer.write("<measurement name=\"%s\" value=\"%i\" rate=\"%i\"/>" \
- % (self.name, self.get_value(), self.get_rate()))
+ hl = ""
+
+ if self.highlow:
+ hl = "high=\"%i\" low=\"%i\"" % (self.get_high(), self.get_low())
+
+ writer.write("<measurement name=\"%s\" value=\"%i\" rate=\"%i\" %s/>" \
+ % (self.name, self.get_value(), self.get_rate(), hl))
class Queue(CuminModelObject):
def __init__(self, model):
Modified: mgmt/cumin/python/cumin/page.strings
===================================================================
--- mgmt/cumin/python/cumin/page.strings 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/page.strings 2007-11-12 15:04:11 UTC (rev 1284)
@@ -547,11 +547,23 @@
}
[CuminPage.javascript]
-function updateStatus(id, data) {
- var ecount = data.elem("error-count").text().get();
+var cumin;
+
+(function() {
+ cumin = new Cumin();
+
+ function Cumin() {
+ this.queue = new Object();
+ this.queue.latest = new Object();
+ this.queue.listeners = new Array();
+ }
+}())
+
+function updateStatus(id, object) {
+ var ecount = object["error-count"];
var errors = ecount + " " + (ecount == "1" && "error" || "errors");
- var wcount = data.elem("warning-count").text().get();
+ var wcount = object["warning-count"];
var warnings = wcount + " " + (wcount == "1" && "warning" || "warnings");
var status = wooly.doc().elembyid(id);
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/queue.py 2007-11-12 15:04:11 UTC (rev 1284)
@@ -108,9 +108,6 @@
return "Queue '%s'" % queue.name
class QueueStatus(CuminStatus):
- def render_data_url(self, session, queue):
- return "queue.xml?id=%i" % queue.id
-
def render_consumers(self, session, queue):
return queue.get_measurement("consumers").get_value()
@@ -171,6 +168,9 @@
def get_title(self, session, queue):
return "Queue '%s'" % queue.name
+ def render_data_url(self, session, queue):
+ return "queue.xml?id=%i" % queue.id
+
def render_name(self, session, queue):
return queue.name
@@ -417,15 +417,14 @@
def __init__(self, app, name):
super(QueueStatistics.StatisticsCurrent, self).__init__(app, name)
- self.add_child(MeasurementSet(app, "general_stats", "general"))
- self.add_child(MeasurementSet(app, "disk_stats", "disk"))
+ self.add_child(MeasurementSet(app, "general", "general"))
+ self.add_child(MeasurementSet(app, "disk", "disk"))
self.add_child(MeasurementSet \
- (app, "transactional_stats", "transactional"))
+ (app, "transactional", "transactional"))
self.add_child(MeasurementSet \
- (app, "persistent_stats", "persistent"))
-
+ (app, "persistent", "persistent"))
self.add_child(MeasurementSet \
- (app, "transaction_stats", "transaction"))
+ (app, "transaction", "transaction"))
def get_title(self, session, queue):
return "Current"
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/python/cumin/queue.strings 2007-11-12 15:04:11 UTC (rev 1284)
@@ -89,31 +89,21 @@
</script>
[QueueStatus.javascript]
-function updateQueueStatus(id, data) {
- updateStatus(id, data);
+function updateQueueStatus(id, queue) {
+ updateStatus(id, queue);
- var values = data.root().dict("measurement", "name", "value");
- var rates = data.root().dict("measurement", "name", "rate");
+ var m = queue.measurement;
+ var mdata = {
+ "tr": [
+ null,
+ {"td": [m.msgTotalEnqueues.rate, m.byteTotalEnqueues.rate]},
+ {"td": [m.msgTotalDequeues.rate, m.byteTotalDequeues.rate]},
+ {"td": [m.msgDepth.value, m.byteDepth.value]},
+ {"td": [m.msgDepth.rate, m.byteDepth.rate]}
+ ]
+ };
- 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(rates["msgTotalEnqueues"]);
- tds.next().text().set(rates["byteTotalEnqueues"]);
-
- tds = trs.next().elems("td");
- tds.next().text().set(rates["msgTotalDequeues"]);
- tds.next().text().set(rates["byteTotalDequeues"]);
-
- tds = trs.next().elems("td");
- tds.next().set(values["msgDepth"]);
- tds.next().set(values["byteDepth"]);
-
- tds = trs.next().elems("td");
- tds.next().text().set(rates["msgDepth"]);
- tds.next().text().set(rates["byteDepth"]);
+ wooly.doc().elembyid(id).descendant("table.tbody").update(mdata);
}
[QueueStatus.html]
@@ -151,10 +141,25 @@
</table>
</div>
<script>
- wooly.setIntervalUpdate("{id}", "{data_url}", updateQueueStatus, 3000);
+ cumin.queue.listeners["{id}"] = updateQueueStatus
</script>
+[QueueView.javascript]
+function updateQueue(data) {
+ var queue = data.root().object();
+
+ //wooly.dir(cumin.queue.listeners);
+
+ for (var id in cumin.queue.listeners) {
+ cumin.queue.listeners[id](id, queue);
+ }
+}
+
[QueueView.html]
+<script>
+ wooly.setIntervalUpdate("{data_url}", updateQueue, 3000);
+</script>
+
{status}
<h1><img src="resource?name=queue-36.png"> {title}</h1>
@@ -233,18 +238,24 @@
<tr>
<td class="twocol">
<h2>General</h2>
- {general_stats}
+ {general}
<h2>Persistent Messages</h2>
- {persistent_stats}
+ {persistent}
</td>
<td class="twocol">
<h2>Transactional Messages</h2>
- {transactional_stats}
+ {transactional}
<h2>Transactions</h2>
- {transaction_stats}
+ {transaction}
</td>
</tr>
</table>
+<script>
+ cumin.queue.listeners["{id}.general"] = updateMeasurements;
+ cumin.queue.listeners["{id}.persistent"] = updateMeasurements;
+ cumin.queue.listeners["{id}.transactional"] = updateMeasurements;
+ cumin.queue.listeners["{id}.transaction"] = updateMeasurements;
+</script>
[StatisticsHistory.html]
<h2>Depth</h2>
Modified: mgmt/cumin/resources/wooly.js
===================================================================
--- mgmt/cumin/resources/wooly.js 2007-11-11 19:34:55 UTC (rev 1283)
+++ mgmt/cumin/resources/wooly.js 2007-11-12 15:04:11 UTC (rev 1284)
@@ -6,7 +6,8 @@
function assert() {
for (var i = 0; i < arguments.length; i++) {
if (!arguments[i]) {
- throw new Error("Assertion failure in " + arguments.callee.caller.prototype);
+ throw new Error("Assertion failure in " +
+ arguments.callee.caller.prototype);
}
}
}
@@ -23,6 +24,161 @@
}
}
+ function translate(node, parent) {
+ //log("node", node.nodeType, node, "parent", parent);
+
+ var first = node.firstChild;
+ var name = node.nodeName;
+
+ if (first && first.nodeType == 3 && parent) {
+ parent[name] = first.nodeValue;
+
+ return null;
+ }
+
+ var object = new Object();
+ var attrs = node.attributes;
+
+ if (parent) {
+ var keyattr = null;
+
+ if (attrs) {
+ keyattr = attrs.getNamedItem("id");
+
+ if (keyattr == null) {
+ keyattr = attrs.getNamedItem("key");
+ }
+
+ if (keyattr == null) {
+ keyattr = attrs.getNamedItem("name");
+ }
+
+ if (keyattr) {
+ var key = keyattr.nodeValue;
+ var extant = parent[name];
+
+ if (extant == null) {
+ extant = new Object();
+ parent[name] = extant;
+ }
+
+ extant[key] = object;
+ }
+ }
+
+ if (keyattr == null) {
+ var extant = parent[name];
+
+ if (extant == null) {
+ parent[name] = object;
+ } else {
+ var array;
+
+ if (extant instanceof Array) {
+ array = extant;
+ } else {
+ array = new Array();
+ array.push(extant);
+
+ parent[name] = array;
+ }
+
+ array.push(object);
+ }
+ }
+ }
+
+ var attr;
+
+ for (var i = 0; i < attrs.length; i++) {
+ attr = attrs[i];
+ object[attr.nodeName] = attr.nodeValue;
+ }
+
+ var childs = node.childNodes;
+
+ for (var i = 0; i < childs.length; i++) {
+ translate(childs[i], object);
+ }
+
+ return object;
+ }
+
+ function update(elem, elems, object) {
+ //log("update", "elem", elem, "elems", elems, "object", object);
+
+ if (typeof(object) == "string") {
+ if (elem.firstChild.nodeType == 3) {
+ elem.firstChild.data = object;
+ }
+ } else if (object instanceof Array) {
+ for (var i = 0; i < object.length; i++) {
+ update(elems[i], elems, object[i]);
+ }
+ } else {
+ for (var child in object) {
+ var elems = elem.getElementsByTagName(child);
+ update(elems[0], elems, object[child]);
+ }
+ }
+ }
+
+ function descendant(elem, path) {
+ var names = path.split(".");
+ var node = elem;
+
+ for (var i = 0; i < names.length; i++) {
+ var elems = elem.getElementsByTagName(names[i]);
+
+ if (elems.length) {
+ node = elems[0];
+ } else {
+ break;
+ }
+ }
+
+ return node;
+ }
+
+ function find(nodeParent, nodeType, nodeName, attr, attrValue) {
+ assert(nodeParent);
+ assert(nodeType);
+
+ var children = nodeParent.childNodes;
+ var found;
+
+ for (var i = 0; i < children.length; i++) {
+ if (found) {
+ break;
+ }
+
+ var child = children[i];
+ var candidate = child;
+
+ if (child.nodeType != nodeType) {
+ candidate = null;
+ } else if (nodeName && child.nodeName.toLowerCase() != nodeName) {
+ candidate = null;
+ } else if (attr && child.nodeType == 1) {
+ var value = child.getAttribute(attr);
+
+ if (!value) {
+ candidate = null;
+ } else if (value != attrValue) {
+ candidate = null;
+ }
+ }
+
+ if (candidate) {
+ found = candidate;
+ } else {
+ found = find(child, nodeType, nodeName, attr, attrValue);
+ }
+ }
+
+ return found;
+ }
+
function Wooly() {
this.request = new XMLHttpRequest();
@@ -34,7 +190,7 @@
this.console = window.console;
}
- this.setIntervalUpdate = function(id, url, callback, interval) {
+ this.setIntervalUpdate = function(url, callback, interval) {
var req = this.request;
function fetch() {
@@ -43,20 +199,20 @@
req.send(null);
}
- var timerid = window.setInterval(fetch, interval);
+ var id = window.setInterval(fetch, interval);
function update() {
try {
if (req.readyState == 4 && req.status == 200) {
//dir(req);
- callback(id, wooly.doc(req.responseXML));
+ callback(wooly.doc(req.responseXML));
}
} catch (e) {
log(e);
// XXX might want to retry for a bit before we do
// this
- window.clearInterval(timerid);
+ window.clearInterval(id);
throw e;
}
}
@@ -134,13 +290,11 @@
for (var i = this.lastIndex + 1; i < this.nodes.length; i++) {
node = this.nodes[i];
- if (this.nodeType == null
- || node.nodeType == this.nodeType) {
- if (this.nodeName == null
- || node.nodeName.toLowerCase() == this.nodeName) {
+ if ((this.nodeType == null || node.nodeType == this.nodeType)
+ && (this.nodeName == null
+ || node.nodeName.toLowerCase() == this.nodeName)) {
this.lastIndex = i;
return new this.nodeClass(this.doc, node);
- }
}
}
@@ -172,6 +326,7 @@
this.add = function(content) {
if (typeof content == "string") {
+ // XXX flatten this out
this.add(new WoolyText(this.doc, null).set(content));
} else if (content.hasOwnProperty("node")) {
this.node.appendChild(content.node);
@@ -211,6 +366,20 @@
return dict;
}
+ this.object = function() {
+ return translate(this.node, null);
+ }
+
+ this.update = function(data) {
+ update(this.node, null, data);
+ }
+
+ this.descendant = function(path) {
+ var node = descendant(this.node, path);
+
+ return new WoolyElement(this.doc, node);
+ }
+
this.elems = function(name, start) {
if (start == null) {
start = 0;
@@ -232,15 +401,23 @@
}
this.text = function() {
- var children = this.node.childNodes;
+ var text = find(this.node, 3);
- for (var i = 0; i < children.length; i++) {
- var child = children[i];
+ if (text) {
+ return new WoolyText(this.doc, text);
+ } else {
+ return null;
+ }
+ }
- if (child.nodeType == 3) return new WoolyText(this.doc, child);
+ this.placeholder = function(name) {
+ var ph = find(this.node, 1, "span", "ph", name);
+
+ if (ph) {
+ return new WoolyElement(this.doc, ph);
+ } else {
+ return null;
}
-
- return null;
}
}
17 years, 1 month
rhmessaging commits: r1283 - in store/trunk/cpp: tests and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-11 14:34:55 -0500 (Sun, 11 Nov 2007)
New Revision: 1283
Added:
store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp
store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp
Removed:
store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp
Modified:
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jinf.cpp
store/trunk/cpp/lib/jrnl/jinf.hpp
store/trunk/cpp/tests/jrnl/
store/trunk/cpp/tests/jrnl/Makefile.am
store/trunk/cpp/tests/system_test.sh
Log:
Added boost test framework unit tests for some journal classes.
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-10 13:25:32 UTC (rev 1282)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-11 19:34:55 UTC (rev 1283)
@@ -364,14 +364,7 @@
throw jexception(jerrno::JERR__RTCLOCK, ss.str().c_str(), "jcntl", "write_infofile");
}
jinf ji(_jid, _jdir.dirname(), _base_filename, ts);
- std::stringstream fn;
- fn << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
- std::ofstream of(fn.str().c_str(), std::ofstream::out | std::ofstream::trunc);
- if (!of.good())
- throw jexception(jerrno::JERR__FILEIO, fn.str().c_str(), "jcntl", "write_infofile");
- std::string s;
- of << ji.xml_str(s);
- of.close();
+ ji.write();
}
#define AIO_CMPL_SLEEP 10000 // 10 ms
Modified: store/trunk/cpp/lib/jrnl/jinf.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.cpp 2007-11-10 13:25:32 UTC (rev 1282)
+++ store/trunk/cpp/lib/jrnl/jinf.cpp 2007-11-11 19:34:55 UTC (rev 1283)
@@ -185,6 +185,18 @@
return _start_file;
}
+void
+jinf::write()
+{
+ std::stringstream fn;
+ fn << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
+ std::ofstream of(fn.str().c_str(), std::ofstream::out | std::ofstream::trunc);
+ if (!of.good())
+ throw jexception(jerrno::JERR__FILEIO, fn.str().c_str(), "jcntl", "write_infofile");
+ of << xml_str();
+ of.close();
+}
+
const u_int16_t
jinf::get_start_file() throw (jexception)
{
@@ -193,8 +205,8 @@
return _start_file;
}
-const std::string&
-jinf::to_string(std::string& s) const
+const std::string
+jinf::to_string() const
{
std::stringstream ss;
ss << std::setfill('0');
@@ -215,20 +227,19 @@
ss << " Read page size (JRNL_RMGR_PAGE_SIZE): " << _rmgr_page_size_dblks << " dblks" <<
std::endl;
ss << " Number of read pages (JRNL_RMGR_PAGES): " << _rmgr_num_pages << std::endl;
- s.assign(ss.str());
- return s;
+ return ss.str();
}
-const std::string&
-jinf::xml_str(std::string& s) const
+const std::string
+jinf::xml_str() const
{
std::stringstream ss;
// TODO: I'm sure a more elegant way can be found to do this, but direct and simple
// seems like a good start!
ss << std::setfill('0');
- ss << "<?xml version=\"1.0\"?>" << std::endl;
+ ss << "<?xml version=\"1.0\" ?>" << std::endl;
ss << "<jrnl>" << std::endl;
- ss << " <journal_version value=\"" << (unsigned)_jver << "\"/>" << std::endl;
+ ss << " <journal_version value=\"" << (unsigned)_jver << "\" />" << std::endl;
ss << " <journal_id>" << std::endl;
ss << " <id_string value=\"" << _jid << "\" />" << std::endl;
ss << " <directory value=\"" << _jdir << "\" />" << std::endl;
@@ -254,8 +265,7 @@
ss << " <JRNL_RMGR_PAGES value=\"" << _rmgr_num_pages << "\" />" << std::endl;
ss << " </journal_file_geometry>" << std::endl;
ss << "</jrnl>" << std::endl;
- s.assign(ss.str());
- return s;
+ return ss.str();
}
void
@@ -295,13 +305,13 @@
_rmgr_page_size_dblks = u_int32_value(buff);
else if(::strstr(buff, "JRNL_RMGR_PAGES"))
_rmgr_num_pages = u_int32_value(buff);
+ else if(::strstr(buff, "nanoseconds"))
+ _ts.tv_nsec = u_int32_value(buff);
else if(::strstr(buff, "seconds"))
{
_ts.tv_sec = u_int32_value(buff);
_tm_ptr = ::localtime(&_ts.tv_sec);
}
- else if(::strstr(buff, "nanoseconds"))
- _ts.tv_nsec = u_int32_value(buff);
}
jinfs.close();
}
Modified: store/trunk/cpp/lib/jrnl/jinf.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.hpp 2007-11-10 13:25:32 UTC (rev 1282)
+++ store/trunk/cpp/lib/jrnl/jinf.hpp 2007-11-11 19:34:55 UTC (rev 1283)
@@ -66,13 +66,16 @@
u_int16_t _start_file;
public:
+ // constructor for reading existing jinf file
jinf(const std::string& jinf_filename, bool validate_flag) throw (jexception);
+ // constructor for writing jinf file
jinf(const std::string& jid, const std::string& jdir, const std::string& base_filename,
const timespec& ts);
~jinf();
void validate() throw (jexception);
const u_int16_t analyze() throw (jexception);
+ void write();
inline const u_int8_t jver() const { return _jver; }
inline const std::string& jid() const { return _jid; }
@@ -89,8 +92,8 @@
inline const u_int32_t rmgr_num_pages() const { return _rmgr_num_pages; }
const u_int16_t get_start_file() throw (jexception);
- const std::string& to_string(std::string& s) const;
- const std::string& xml_str(std::string& s) const;
+ const std::string to_string() const;
+ const std::string xml_str() const;
private:
void read(const std::string& jinf_filename) throw (jexception);
Property changes on: store/trunk/cpp/tests/jrnl
___________________________________________________________________
Name: svn:ignore
- .deps
.libs
Makefile
Makefile.in
jtest
+ .deps
.libs
Makefile
Makefile.in
jtest
unit_test_jerrno
unit_test_jexception
unit_test_jinf
Deleted: store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp 2007-11-10 13:25:32 UTC (rev 1282)
+++ store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp 2007-11-11 19:34:55 UTC (rev 1283)
@@ -1,106 +0,0 @@
-/**
-* \file JournalUnitTests.cpp
-*
-* Red Hat Messaging - Message Journal
-*
-* This file contains the unit tests for the journal.
-*
-* \author Kim van der Riet
-*
-* Copyright 2007 Red Hat, Inc.
-*
-* This file is part of Red Hat Messaging.
-*
-* Red Hat Messaging is free software; you can redistribute it and/or
-* modify it under the terms of the GNU Lesser General Public
-* License as published by the Free Software Foundation; either
-* version 2.1 of the License, or (at your option) any later version.
-*
-* This library is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-* Lesser General Public License for more details.
-*
-* You should have received a copy of the GNU Lesser General Public
-* License along with this library; if not, write to the Free Software
-* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
-* USA
-*
-* The GNU Lesser General Public License is available in the file COPYING.
-*/
-
-#include "../test_plugin.h"
-
-#include <jrnl/jexception.hpp>
-
-using namespace rhm::journal;
-using namespace std;
-
-class JournalUnitTests : public CppUnit::TestCase
-{
- CPPUNIT_TEST_SUITE(JournalUnitTests);
- CPPUNIT_TEST(JournalExceptionTest);
- CPPUNIT_TEST_SUITE_END();
-
-public:
-
- void JournalExceptionTest()
- {
- {
- jexception e0;
- CPPUNIT_ASSERT_MESSAGE("e1: Error code bad.", e0.err_code() == 0);
- CPPUNIT_ASSERT_MESSAGE("e1: Additional information bad.", e0.additional_info() == NULL);
- CPPUNIT_ASSERT_MESSAGE("e1: Throwing class bad.", e0.throwing_class() == NULL);
- CPPUNIT_ASSERT_MESSAGE("e1: Throwing function bad.", e0.throwing_fn() == NULL);
- }
- {
- jexception e1(1);
- CPPUNIT_ASSERT_MESSAGE("e1: Error code bad.", e1.err_code() == 1);
- CPPUNIT_ASSERT_MESSAGE("e1: Additional information bad.", e1.additional_info() == NULL);
- CPPUNIT_ASSERT_MESSAGE("e1: Throwing class bad.", e1.throwing_class() == NULL);
- CPPUNIT_ASSERT_MESSAGE("e1: Throwing function bad.", e1.throwing_fn() == NULL);
- }
- {
- jexception e2("exception2");
- CPPUNIT_ASSERT_MESSAGE("e2: Error code bad.", e2.err_code() == 0);
- CPPUNIT_ASSERT_MESSAGE("e2: Additional information bad.",
- ::strcmp(e2.additional_info(), "exception2") == 0);
- CPPUNIT_ASSERT_MESSAGE("e2: Throwing class bad.", e2.throwing_class() == NULL);
- CPPUNIT_ASSERT_MESSAGE("e2: Throwing function bad.", e2.throwing_fn() == NULL);
- }
- {
- jexception e3(3, "exception3");
- CPPUNIT_ASSERT_MESSAGE("e3: Error code bad.", e3.err_code() == 3);
- CPPUNIT_ASSERT_MESSAGE("e3: Additional information bad.",
- ::strcmp(e3.additional_info(), "exception3") == 0);
- CPPUNIT_ASSERT_MESSAGE("e3: Throwing class bad.", e3.throwing_class() == NULL);
- CPPUNIT_ASSERT_MESSAGE("e3: Throwing function bad.", e3.throwing_fn() == NULL);
- }
- {
- jexception e4(4, "class4", "fn4");
- CPPUNIT_ASSERT_MESSAGE("e4: Error code bad.", e4.err_code() == 4);
- CPPUNIT_ASSERT_MESSAGE("e4: Additional information bad.", e4.additional_info() == NULL);
- CPPUNIT_ASSERT_MESSAGE("e4: Throwing class bad.",
- ::strcmp(e4.throwing_class(), "class4") == 0);
- CPPUNIT_ASSERT_MESSAGE("e4: Throwing function bad.",
- ::strcmp(e4.throwing_fn(), "fn4") == 0);
- }
- {
- jexception e5(5, "exception5", "class5", "fn5");
- CPPUNIT_ASSERT_MESSAGE("e5: Error code bad.", e5.err_code() == 5);
- CPPUNIT_ASSERT_MESSAGE("e5: Additional information bad.",
- ::strcmp(e5.additional_info(), "exception5") == 0);
- CPPUNIT_ASSERT_MESSAGE("e5: Throwing class bad.",
- ::strcmp(e5.throwing_class(), "class5") == 0);
- CPPUNIT_ASSERT_MESSAGE("e5: Throwing function bad.",
- ::strcmp(e5.throwing_fn(), "fn5") == 0);
- }
- }
-
-private:
-
-};
-
-// Make this test suite a plugin.
-CPPUNIT_PLUGIN_IMPLEMENT();
-CPPUNIT_TEST_SUITE_REGISTRATION(JournalUnitTests);
Modified: store/trunk/cpp/tests/jrnl/Makefile.am
===================================================================
--- store/trunk/cpp/tests/jrnl/Makefile.am 2007-11-10 13:25:32 UTC (rev 1282)
+++ store/trunk/cpp/tests/jrnl/Makefile.am 2007-11-11 19:34:55 UTC (rev 1283)
@@ -25,26 +25,40 @@
INCLUDES=-I../../lib
-TESTS = run-journal-tests
+TESTS = \
+ unit_test_jexception \
+ unit_test_jerrno \
+ unit_test_jinf \
+ run-journal-tests
check_LTLIBRARIES = \
- JournalUnitTests.la \
- JournalSystemTests.la \
- libdlclose_noop.la
+ JournalSystemTests.la \
+ libdlclose_noop.la
-JournalUnitTests_la_SOURCES = \
- JournalUnitTests.cpp
-JournalUnitTests_la_LDFLAGS = -module -rpath $(abs_builddir)
+check_PROGRAMS = \
+ unit_test_jexception \
+ unit_test_jerrno \
+ unit_test_jinf
+unit_test_jexception_SOURCES = unit_test_jexception.cpp
+unit_test_jexception_LDADD = ../../lib/.libs/jexception.o ../../lib/.libs/jerrno.o
+unit_test_jexception_LDFLAGS = -lboost_unit_test_framework
+
+unit_test_jerrno_SOURCES = unit_test_jerrno.cpp
+unit_test_jerrno_LDADD = ../../lib/.libs/jerrno.o
+unit_test_jerrno_LDFLAGS = -lboost_unit_test_framework
+
+unit_test_jinf_SOURCES = unit_test_jinf.cpp
+unit_test_jinf_LDADD = \
+ ../../lib/.libs/jinf.o \
+ ../../lib/.libs/file_hdr.o \
+ ../../lib/.libs/jexception.o \
+ ../../lib/.libs/jerrno.o
+unit_test_jinf_LDFLAGS = -lboost_unit_test_framework -lrt
+
JournalSystemTests_la_SOURCES = \
JournalSystemTests.cpp \
- jtest.cpp \
- msg_producer.cpp \
- msg_consumer.cpp \
- JournalSystemTests.hpp \
- jtest.hpp \
- msg_producer.hpp \
- msg_consumer.hpp
+ JournalSystemTests.hpp
JournalSystemTests_la_LDFLAGS = -lpthread -module -rpath $(abs_builddir)
JournalSystemTests_la_LIBADD = ../../lib/libbdbstore.la $(CPPUNIT_LIBS)
Added: store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/unit_test_jerrno.cpp 2007-11-11 19:34:55 UTC (rev 1283)
@@ -0,0 +1,65 @@
+/**
+* \file unit_test_jexception.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include <boost/test/results_reporter.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <iostream>
+#include <jrnl/jerrno.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+// Test functions of the form
+// void fn() {...}
+
+void test_jerrno()
+{
+ const char* m = "JERR__MALLOC";
+ std::string malloc_msg = std::string(jerrno::err_msg(jerrno::JERR__MALLOC));
+ BOOST_CHECK(malloc_msg.substr(0, ::strlen(m)).compare(m) == 0);
+ BOOST_CHECK(::strcmp(jerrno::err_msg(0), "<Unknown error code>") == 0);
+}
+
+// Initialize test suite and include test functions
+
+test_suite* init_unit_test_suite(int, char**)
+{
+ std::cout << "--------" << std::endl << "unit_test_jerrno: ";
+ test_suite* ts = BOOST_TEST_SUITE("unit_test_jerrno");
+
+ results_reporter::set_level(SHORT_REPORT);
+ unit_test_log_t::instance().set_threshold_level(log_messages);
+
+ ts->add(BOOST_TEST_CASE(&test_jerrno));
+
+ return ts;
+}
Added: store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-11-11 19:34:55 UTC (rev 1283)
@@ -0,0 +1,205 @@
+/**
+* \file unit_test_jexception.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include <boost/test/results_reporter.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <iostream>
+#include <jrnl/jexception.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+// Test functions of the form
+// void fn() {...}
+
+void test_constructor_1()
+{
+ try
+ {
+ jexception e1;
+ BOOST_CHECK_EQUAL(e1.err_code(), (u_int32_t)0);
+ BOOST_CHECK(e1.additional_info() == NULL);
+ BOOST_CHECK(e1.throwing_class() == NULL);
+ BOOST_CHECK(e1.throwing_fn() == NULL);
+ BOOST_CHECK(e1.what() != NULL);
+ throw e1;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
+ BOOST_CHECK(e.additional_info() == NULL);
+ BOOST_CHECK(e.throwing_class() == NULL);
+ BOOST_CHECK(e.throwing_fn() == NULL);
+ BOOST_CHECK(e.what() != NULL);
+ }
+}
+
+void test_constructor_2()
+{
+ u_int32_t err_code = 2;
+ try
+ {
+ jexception e2(err_code);
+ BOOST_CHECK_EQUAL(e2.err_code(), err_code);
+ BOOST_CHECK(e2.additional_info() == NULL);
+ BOOST_CHECK(e2.throwing_class() == NULL);
+ BOOST_CHECK(e2.throwing_fn() == NULL);
+ BOOST_CHECK(e2.what() != NULL);
+ throw e2;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), err_code);
+ BOOST_CHECK(e.additional_info() == NULL);
+ BOOST_CHECK(e.throwing_class() == NULL);
+ BOOST_CHECK(e.throwing_fn() == NULL);
+ BOOST_CHECK(e.what() != NULL);
+ }
+}
+
+void test_constructor_3()
+{
+ const char* err_msg = "exception3";
+ try
+ {
+ jexception e3(err_msg);
+ BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
+ BOOST_CHECK(::strcmp(e3.additional_info(), err_msg) == 0);
+ BOOST_CHECK(e3.throwing_class() == NULL);
+ BOOST_CHECK(e3.throwing_fn() == NULL);
+ BOOST_CHECK(e3.what() != NULL);
+ throw e3;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
+ BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
+ BOOST_CHECK(e.throwing_class() == NULL);
+ BOOST_CHECK(e.throwing_fn() == NULL);
+ BOOST_CHECK(e.what() != NULL);
+ }
+}
+
+void test_constructor_4()
+{
+ u_int32_t err_code = 4;
+ const char* err_msg = "exception4";
+ try
+ {
+ jexception e4(err_code, err_msg);
+ BOOST_CHECK_EQUAL(e4.err_code(), err_code);
+ BOOST_CHECK(::strcmp(e4.additional_info(), err_msg) == 0);
+ BOOST_CHECK(e4.throwing_class() == NULL);
+ BOOST_CHECK(e4.throwing_fn() == NULL);
+ BOOST_CHECK(e4.what() != NULL);
+ throw e4;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), err_code);
+ BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
+ BOOST_CHECK(e.throwing_class() == NULL);
+ BOOST_CHECK(e.throwing_fn() == NULL);
+ BOOST_CHECK(e.what() != NULL);
+ }
+}
+
+void test_constructor_5()
+{
+ u_int32_t err_code = 5;
+ const char* err_class = "class5";
+ const char* err_fn = "fn5";
+ try
+ {
+ jexception e5(err_code, err_class, err_fn);
+ BOOST_CHECK_EQUAL(e5.err_code(), err_code);
+ BOOST_CHECK(e5.additional_info() == NULL);
+ BOOST_CHECK(::strcmp(e5.throwing_class(), err_class) == 0);
+ BOOST_CHECK(::strcmp(e5.throwing_fn(), err_fn) == 0);
+ BOOST_CHECK(e5.what() != NULL);
+ throw e5;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), err_code);
+ BOOST_CHECK(e.additional_info() == NULL);
+ BOOST_CHECK(::strcmp(e.throwing_class(), err_class) == 0);
+ BOOST_CHECK(::strcmp(e.throwing_fn(), err_fn) == 0);
+ BOOST_CHECK(e.what() != NULL);
+ }
+}
+
+void test_constructor_6()
+{
+ u_int32_t err_code = 6;
+ const char* err_msg = "exception6";
+ const char* err_class = "class6";
+ const char* err_fn = "fn6";
+ try
+ {
+ jexception e6(err_code, err_msg, err_class, err_fn);
+ BOOST_CHECK_EQUAL(e6.err_code(), err_code);
+ BOOST_CHECK(::strcmp(e6.additional_info(), err_msg) == 0);
+ BOOST_CHECK(::strcmp(e6.throwing_class(), err_class) == 0);
+ BOOST_CHECK(::strcmp(e6.throwing_fn(), err_fn) == 0);
+ BOOST_CHECK(e6.what() != NULL);
+ throw e6;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), err_code);
+ BOOST_CHECK(::strcmp(e.additional_info(), err_msg) == 0);
+ BOOST_CHECK(::strcmp(e.throwing_class(), err_class) == 0);
+ BOOST_CHECK(::strcmp(e.throwing_fn(), err_fn) == 0);
+ BOOST_CHECK(e.what() != NULL);
+ }
+}
+
+// Initialize test suite and include test functions
+
+test_suite* init_unit_test_suite(int, char**)
+{
+ std::cout << "--------" << std::endl << "unit_test_jexception: ";
+ test_suite* ts = BOOST_TEST_SUITE("unit_test_jexception");
+
+ results_reporter::set_level(SHORT_REPORT);
+ unit_test_log_t::instance().set_threshold_level(log_messages);
+
+ ts->add(BOOST_TEST_CASE(&test_constructor_1));
+ ts->add(BOOST_TEST_CASE(&test_constructor_2));
+ ts->add(BOOST_TEST_CASE(&test_constructor_3));
+ ts->add(BOOST_TEST_CASE(&test_constructor_4));
+ ts->add(BOOST_TEST_CASE(&test_constructor_5));
+ ts->add(BOOST_TEST_CASE(&test_constructor_6));
+
+ return ts;
+}
Added: store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp (rev 0)
+++ store/trunk/cpp/tests/jrnl/unit_test_jinf.cpp 2007-11-11 19:34:55 UTC (rev 1283)
@@ -0,0 +1,257 @@
+/**
+* \file unit_test_jexception.cpp
+*
+* Red Hat Messaging - Message Journal
+*
+* This file contains the unit tests for the journal.
+*
+* \author Kim van der Riet
+*
+* Copyright 2007 Red Hat, Inc.
+*
+* This file is part of Red Hat Messaging.
+*
+* Red Hat Messaging is free software; you can redistribute it and/or
+* modify it under the terms of the GNU Lesser General Public
+* License as published by the Free Software Foundation; either
+* version 2.1 of the License, or (at your option) any later version.
+*
+* This library is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this library; if not, write to the Free Software
+* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
+* USA
+*
+* The GNU Lesser General Public License is available in the file COPYING.
+*/
+
+#include <boost/test/results_reporter.hpp>
+#include <boost/test/unit_test.hpp>
+#include <boost/test/unit_test_log.hpp>
+#include <fstream>
+#include <iostream>
+#include <jrnl/file_hdr.hpp>
+#include <jrnl/jcfg.hpp>
+#include <jrnl/jerrno.hpp>
+#include <jrnl/jexception.hpp>
+#include <jrnl/jinf.hpp>
+
+using namespace boost::unit_test;
+using namespace rhm::journal;
+
+// Test functions of the form
+// void fn() {...}
+
+const std::string jid("test journal id");
+const std::string jdir("/tmp");
+const std::string base_filename("test_base");
+timespec ts;
+enum rid_scheme { RID_NONE, RID_LINEAR };
+
+// Helper functions
+void create_journal_filenames(std::vector<std::string>& jfiles);
+void create_journal_files(std::vector<std::string>& jfiles, rid_scheme scheme,
+ u_int32_t min_fid_offs = 0, u_int64_t rid_offs = 0);
+void clean_journal_files(std::vector<std::string>& jfiles);
+void init_fhdr(file_hdr& fh, u_int32_t fid, u_int64_t rid, bool no_enq = false);
+void clean_journal_info_file();
+
+
+void test_write_constructor()
+{
+ ::clock_gettime(CLOCK_REALTIME, &ts);
+ jinf ji(jid, jdir, base_filename, ts);
+ BOOST_CHECK_EQUAL(ji.jver(), RHM_JDAT_VERSION);
+ BOOST_CHECK(ji.jid().compare(jid) == 0);
+ BOOST_CHECK(ji.jdir().compare(jdir) == 0);
+ BOOST_CHECK(ji.base_filename().compare(base_filename) == 0);
+ timespec this_ts = ji.ts();
+ BOOST_CHECK_EQUAL(this_ts.tv_sec, ts.tv_sec);
+ BOOST_CHECK_EQUAL(this_ts.tv_nsec, ts.tv_nsec);
+ BOOST_CHECK_EQUAL(ji.num_files(), (u_int16_t)JRNL_NUM_FILES);
+ BOOST_CHECK_EQUAL(ji.fsize_sblks(), (u_int32_t)JRNL_FILE_SIZE);
+ BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
+ BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
+ BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
+ BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
+ BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
+ BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
+ ji.write();
+}
+
+void test_read_constructor()
+{
+ std::stringstream fn;
+ fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+ jinf ji(fn.str(), false);
+ BOOST_CHECK_EQUAL(ji.jver(), RHM_JDAT_VERSION);
+ BOOST_CHECK(ji.jid().compare(jid) == 0);
+ BOOST_CHECK(ji.jdir().compare(jdir) == 0);
+ BOOST_CHECK(ji.base_filename().compare(base_filename) == 0);
+ const timespec this_ts = ji.ts();
+ BOOST_CHECK_EQUAL(this_ts.tv_sec, ts.tv_sec);
+ BOOST_CHECK_EQUAL(this_ts.tv_nsec, ts.tv_nsec);
+ BOOST_CHECK_EQUAL(ji.num_files(), (u_int16_t)JRNL_NUM_FILES);
+ BOOST_CHECK_EQUAL(ji.fsize_sblks(), (u_int32_t)JRNL_FILE_SIZE);
+ BOOST_CHECK_EQUAL(ji.sblk_size_dblks(), (u_int16_t)JRNL_SBLK_SIZE);
+ BOOST_CHECK_EQUAL(ji.dblk_size(), (u_int32_t)JRNL_DBLK_SIZE);
+ BOOST_CHECK_EQUAL(ji.wmgr_page_size_dblks(), (u_int32_t)JRNL_WMGR_PAGE_SIZE);
+ BOOST_CHECK_EQUAL(ji.wmgr_num_pages(), (u_int32_t)JRNL_WMGR_PAGES);
+ BOOST_CHECK_EQUAL(ji.rmgr_page_size_dblks(), (u_int32_t)JRNL_RMGR_PAGE_SIZE);
+ BOOST_CHECK_EQUAL(ji.rmgr_num_pages(), (u_int32_t)JRNL_RMGR_PAGES);
+}
+
+void test_validate()
+{
+ std::stringstream fn;
+ fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+ jinf ji(fn.str(), true);
+ // TODO: Check validation picks up conflict, but need to be friend to jinf to do it
+}
+
+void test_analyze_empty_journal()
+{
+ std::vector<std::string> jfiles;
+ create_journal_filenames(jfiles);
+
+ create_journal_files(jfiles, RID_NONE);
+
+ std::stringstream fn;
+ fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+ jinf ji(fn.str(), false);
+ try { ji.analyze(); }
+ catch (jexception e)
+ {
+ if (e.err_code() != jerrno::JERR_JINF_JDATEMPTY)
+ BOOST_ERROR("Failed to throw expected exception jerrno::JERR_JINF_JDATEMPTY");
+ }
+
+ clean_journal_files(jfiles);
+}
+
+void test_analyze_linear_journal()
+{
+ std::vector<std::string> jfiles;
+ for (int i=0; i<JRNL_NUM_FILES; i++)
+ {
+ create_journal_filenames(jfiles);
+
+ create_journal_files(jfiles, RID_LINEAR, i, 0x12340000);
+
+ std::stringstream fn;
+ fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+ jinf ji(fn.str(), false);
+ BOOST_CHECK_EQUAL(ji.analyze(), i);
+
+ clean_journal_files(jfiles);
+ }
+
+ // last test cleans up jinf file
+ clean_journal_info_file();
+}
+
+// Helper functions
+
+void create_journal_filenames(std::vector<std::string>& jfiles)
+{
+ for (int fnum=0; fnum<JRNL_NUM_FILES; fnum++)
+ {
+ std::stringstream fn;
+ fn << jdir << "/" << base_filename << ".";
+ fn << std::setfill('0') << std::setw(4) << fnum << "." << JRNL_DATA_EXTENSION;
+ jfiles.push_back(fn.str());
+ }
+}
+
+void create_journal_files(std::vector<std::string>& jfiles, rid_scheme scheme,
+ u_int32_t min_fid_offs, u_int64_t rid_offs)
+{
+ const u_int64_t rid_incr = 0x10;
+ file_hdr fh;
+ std::vector<std::string>::iterator itr;
+ u_int32_t fid = 0;
+ u_int64_t rid = rid_offs + ((JRNL_NUM_FILES - min_fid_offs) % JRNL_NUM_FILES) * rid_incr;
+ for (itr=jfiles.begin(); itr<jfiles.end(); itr++)
+ {
+
+ std::ofstream of(itr->c_str(), std::ofstream::out | std::ofstream::trunc);
+ if (!of.good())
+ BOOST_FAIL("Unable to open test journal file " << *itr << " for writing.");
+
+ // prepare file_hdr
+ if (scheme == RID_NONE) // create file containing 0s
+ ::memset(&fh, 0, sizeof(file_hdr));
+ else
+ init_fhdr(fh, fid, rid);
+
+ // write file header
+ int cnt = sizeof(file_hdr);
+ of.write((const char*)&fh, cnt);
+
+ // fill remaining sblk with 0s
+ while (cnt++ < JRNL_DBLK_SIZE * JRNL_SBLK_SIZE)
+ of.put(0);
+ of.close();
+
+ if (++fid == min_fid_offs)
+ rid -= rid_incr * (JRNL_NUM_FILES - 1);
+ else
+ rid += rid_incr;
+ }
+}
+
+void clean_journal_info_file()
+{
+ std::stringstream fn;
+ fn << jdir << "/" << base_filename << "." << JRNL_INFO_EXTENSION;
+ BOOST_WARN_MESSAGE(::unlink(fn.str().c_str()) == 0, "Failed to remove file " << fn.str());
+}
+
+void clean_journal_files(std::vector<std::string>& jfiles)
+{
+ for (std::vector<std::string>::iterator itr=jfiles.begin(); itr != jfiles.end(); itr++)
+ BOOST_WARN_MESSAGE(::unlink(itr->c_str()) == 0, "Failed to remove file " << *itr);
+ jfiles.clear();
+}
+
+void init_fhdr(file_hdr& fh, u_int32_t fid, u_int64_t rid, bool no_enq)
+{
+ fh._hdr._magic = RHM_JDAT_FILE_MAGIC;
+ fh._hdr._version = RHM_JDAT_VERSION;
+#if defined(JRNL_BIG_ENDIAN)
+ fh._hdr._eflag = RHM_BENDIAN_FLAG;
+#else
+ fh._hdr._eflag = RHM_LENDIAN_FLAG;
+#endif
+ fh._hdr._uflag = 0;
+ fh._hdr._rid = rid;
+ fh._fid = fid;
+ fh._fro = no_enq ? 0 : 0x200;
+ timespec ts;
+ ::clock_gettime(CLOCK_REALTIME, &ts);
+ fh._ts_sec = ts.tv_sec;
+ fh._ts_nsec = ts.tv_nsec;
+}
+
+// Initialize test suite and include test functions
+
+test_suite* init_unit_test_suite(int, char**)
+{
+ std::cout << "--------" << std::endl << "unit_test_jinf: ";
+ test_suite* ts = BOOST_TEST_SUITE("unit_test_jinf");
+
+ results_reporter::set_level(SHORT_REPORT);
+ unit_test_log_t::instance().set_threshold_level(log_messages);
+
+ ts->add(BOOST_TEST_CASE(&test_write_constructor));
+ ts->add(BOOST_TEST_CASE(&test_read_constructor));
+ ts->add(BOOST_TEST_CASE(&test_validate));
+ ts->add(BOOST_TEST_CASE(&test_analyze_empty_journal));
+ ts->add(BOOST_TEST_CASE(&test_analyze_linear_journal));
+
+ return ts;
+}
Modified: store/trunk/cpp/tests/system_test.sh
===================================================================
--- store/trunk/cpp/tests/system_test.sh 2007-11-10 13:25:32 UTC (rev 1282)
+++ store/trunk/cpp/tests/system_test.sh 2007-11-11 19:34:55 UTC (rev 1283)
@@ -21,12 +21,6 @@
#
# The GNU Lesser General Public License is available in the file COPYING.
-#temporarily disable valgrind until broker can shutdown cleanly again
-VALGRIND=
-echo ""
-echo "WARNING: valgrind temporarily disabled until broker can shutdown cleanly!"
-echo ""
-
if ! test -d "$QPID_DIR" ; then
echo "WARNING: QPID_DIR is not set skipping system tests."
echo "To enable system tests run ./configure --with-qpid-checkout."
@@ -74,7 +68,7 @@
fi
for p in `seq 1 6`; do
log="$abs_srcdir/vg-log.$mode.$p"
- echo "$vg $QPIDD -s $LIBBDBSTORE $JRNLFLAGS"
+ #echo "$vg $QPIDD -s $LIBBDBSTORE $JRNLFLAGS"
$vg $QPIDD -s $LIBBDBSTORE $JRNLFLAGS >> "$abs_srcdir/qpid.log" 2> $log & pid=$!
sleep 5
17 years, 1 month
rhmessaging commits: r1282 - store/trunk/cpp/tests.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-10 08:25:32 -0500 (Sat, 10 Nov 2007)
New Revision: 1282
Modified:
store/trunk/cpp/tests/OrderingTest.cpp
store/trunk/cpp/tests/SimpleTest.cpp
store/trunk/cpp/tests/TransactionalTest.cpp
store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
Log:
Reverted previous checkin as qpid checkin 593726 restored DeliveryMode enum
Modified: store/trunk/cpp/tests/OrderingTest.cpp
===================================================================
--- store/trunk/cpp/tests/OrderingTest.cpp 2007-11-10 05:09:44 UTC (rev 1281)
+++ store/trunk/cpp/tests/OrderingTest.cpp 2007-11-10 13:25:32 UTC (rev 1282)
@@ -40,8 +40,6 @@
using namespace qpid::broker;
using namespace qpid::framing;
-enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
-
class OrderingTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(OrderingTest);
Modified: store/trunk/cpp/tests/SimpleTest.cpp
===================================================================
--- store/trunk/cpp/tests/SimpleTest.cpp 2007-11-10 05:09:44 UTC (rev 1281)
+++ store/trunk/cpp/tests/SimpleTest.cpp 2007-11-10 13:25:32 UTC (rev 1282)
@@ -45,8 +45,6 @@
using namespace qpid::broker;
using namespace qpid::framing;
-enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
-
struct DummyHandler : OutputHandler
{
std::vector<AMQFrame> frames;
Modified: store/trunk/cpp/tests/TransactionalTest.cpp
===================================================================
--- store/trunk/cpp/tests/TransactionalTest.cpp 2007-11-10 05:09:44 UTC (rev 1281)
+++ store/trunk/cpp/tests/TransactionalTest.cpp 2007-11-10 13:25:32 UTC (rev 1282)
@@ -38,8 +38,6 @@
using namespace qpid::broker;
using namespace qpid::framing;
-enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
-
class TransactionalTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(TransactionalTest);
Modified: store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
===================================================================
--- store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-11-10 05:09:44 UTC (rev 1281)
+++ store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-11-10 13:25:32 UTC (rev 1282)
@@ -38,8 +38,6 @@
using namespace qpid::broker;
using namespace qpid::framing;
-enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
-
class TwoPhaseCommitTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(TwoPhaseCommitTest);
17 years, 1 month
rhmessaging commits: r1281 - in store/trunk/cpp: lib/jrnl and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-10 00:09:44 -0500 (Sat, 10 Nov 2007)
New Revision: 1281
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
store/trunk/cpp/lib/JournalImpl.cpp
store/trunk/cpp/lib/TxnCtxt.h
store/trunk/cpp/lib/jrnl/data_tok.cpp
store/trunk/cpp/lib/jrnl/deq_rec.cpp
store/trunk/cpp/lib/jrnl/enq_map.cpp
store/trunk/cpp/lib/jrnl/enq_rec.cpp
store/trunk/cpp/lib/jrnl/file_hdr.cpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jdir.cpp
store/trunk/cpp/lib/jrnl/jerrno.cpp
store/trunk/cpp/lib/jrnl/jerrno.hpp
store/trunk/cpp/lib/jrnl/jexception.cpp
store/trunk/cpp/lib/jrnl/jexception.hpp
store/trunk/cpp/lib/jrnl/jinf.cpp
store/trunk/cpp/lib/jrnl/jrec.cpp
store/trunk/cpp/lib/jrnl/nlfh.cpp
store/trunk/cpp/lib/jrnl/pmgr.cpp
store/trunk/cpp/lib/jrnl/rmgr.cpp
store/trunk/cpp/lib/jrnl/txn_map.cpp
store/trunk/cpp/lib/jrnl/txn_rec.cpp
store/trunk/cpp/lib/jrnl/wmgr.cpp
store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp
store/trunk/cpp/tests/jrnl/jtest.cpp
store/trunk/cpp/tests/jrnl/msg_consumer.cpp
store/trunk/cpp/tests/jrnl/msg_producer.cpp
Log:
Clean-up and simplification of jexception class
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -190,7 +190,7 @@
journal::jdir::delete_dir(getJrnlBaseDir(),true);
}
catch ( journal::jexception& e) {
- THROW_STORE_EXCEPTION("Truncate clean up failed: " +e.to_string() );
+ THROW_STORE_EXCEPTION(std::string("Truncate clean up failed: ") + e.what() );
}
}
@@ -207,7 +207,7 @@
// init will create the deque's for the init...
jQueue->initialize();
} catch (journal::jexception& e) {
- THROW_STORE_EXCEPTION(e.to_string() + queue.getName());
+ THROW_STORE_EXCEPTION(e.what() + queue.getName());
}
}
@@ -388,7 +388,7 @@
recoverMessages(txn, registry, queue, prepared, messages);
jQueue->recover_complete(); // start journal.
} catch (const journal::jexception& e) {
- THROW_STORE_EXCEPTION(e.to_string() + queueName);
+ THROW_STORE_EXCEPTION(std::string(e.what()) + queueName);
}
//read all messages: done on a per queue basis if using Journal
}
@@ -855,7 +855,7 @@
jc->flush();
}
}catch ( journal::jexception& e) {
- THROW_STORE_EXCEPTION("Flush failed: " + e.to_string() );
+ THROW_STORE_EXCEPTION(std::string("Flush failed: ") + e.what() );
}
}
@@ -980,7 +980,7 @@
}
}catch ( journal::jexception& e) {
// std::cout << "-------------" << e << std::endl;
- THROW_STORE_EXCEPTION("Enqueue failed: " +e.to_string() );
+ THROW_STORE_EXCEPTION(std::string("Enqueue failed: ") + e.what() );
}catch (DbException& e) {
THROW_STORE_EXCEPTION_2("Error storing message", e);
}
@@ -1075,7 +1075,7 @@
dres = jc->dequeue_txn_data_record(ddtokp.get(), tid);
}
} catch (rhm::journal::jexception& e) {
- THROW_STORE_EXCEPTION("Error dequeuing message" + e.to_string());
+ THROW_STORE_EXCEPTION(std::string("Error dequeuing message") + e.what());
}
switch (dres)
{
Modified: store/trunk/cpp/lib/JournalImpl.cpp
===================================================================
--- store/trunk/cpp/lib/JournalImpl.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/JournalImpl.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -143,12 +143,12 @@
std::stringstream ss;
ss << "read_data_record() returned " << journal::pmgr::iores_str(res);
ss << "; exceeded maximum wait time";
- throw jexception(ss.str());
+ throw jexception(0, ss.str().c_str(), "JournalImpl", "loadMsgContent");
}
} else {
std::stringstream ss;
ss << "read_data_record() returned " << journal::pmgr::iores_str(res);
- throw jexception(ss.str());
+ throw jexception(0, ss.str().c_str(), "JournalImpl", "loadMsgContent");
}
}
}
@@ -157,7 +157,7 @@
if (offset + length > _dlen) {
std::stringstream ss;
ss << "loadMsgContent(): offset + length exceeds available message size";
- throw jexception(ss.str());
+ throw jexception(0, ss.str().c_str(), "JournalImpl", "loadMsgContent");
}
data.append((const char*)_datap + offset, length);
return true;
Modified: store/trunk/cpp/lib/TxnCtxt.h
===================================================================
--- store/trunk/cpp/lib/TxnCtxt.h 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/TxnCtxt.h 2007-11-10 05:09:44 UTC (rev 1281)
@@ -77,7 +77,7 @@
}
} catch (rhm::journal::jexception& e) {
//std::cout << "Error commit" << e << std::endl;
- THROW_STORE_EXCEPTION("Error commit" + e.to_string());
+ THROW_STORE_EXCEPTION(std::string("Error commit") + e.what());
}
}
@@ -117,7 +117,7 @@
}
}catch (rhm::journal::jexception& e) {
//std::cout << " TxnCtxt: Error sync 3" << e << std::flush;
- THROW_STORE_EXCEPTION("Error sync" + e.to_string());
+ THROW_STORE_EXCEPTION(std::string("Error sync") + e.what());
}
}
firstloop = false;
Modified: store/trunk/cpp/lib/jrnl/data_tok.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -162,7 +162,8 @@
std::stringstream ss;
ss << "Attempted to change read state to " << rstate_str(rstate);
ss << " while write state is not enqueued (wstate ENQ); wstate=" << wstate_str() << ".";
- throw new jexception(jerrno::JERR_DTOK_ILLEGALSTATE, ss.str(), "data_tok","set_rstate");
+ throw new jexception(jerrno::JERR_DTOK_ILLEGALSTATE, ss.str().c_str(), "data_tok",
+ "set_rstate");
}
_rstate = rstate;
}
Modified: store/trunk/cpp/lib/jrnl/deq_rec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/deq_rec.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/deq_rec.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -277,7 +277,7 @@
{
std::stringstream ss;
ss << "_buff malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "deq_rec", "decode");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "deq_rec", "decode");
}
const u_int32_t hdr_xid_dblks = size_dblks(deq_hdr::size() + _deq_hdr._xidsize);
const u_int32_t hdr_xid_tail_dblks = size_dblks(deq_hdr::size() + _deq_hdr._xidsize +
@@ -350,7 +350,7 @@
{
std::stringstream ss;
ss << "_buff malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "deq_rec", "decode");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "deq_rec", "rcv_decode");
}
// Decode xid
ifsp->read((char*)_buff, _deq_hdr._xidsize);
@@ -416,7 +416,7 @@
ss << "deq magic: rid=0x" << std::setw(16) << _deq_hdr._hdr._rid;
ss << ": expected=0x" << std::setw(8) << RHM_JDAT_DEQ_MAGIC;
ss << " read=0x" << std::setw(2) << (int)_deq_hdr._hdr._magic;
- throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "deq_rec", "chk_hdr");
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "deq_rec", "chk_hdr");
}
}
Modified: store/trunk/cpp/lib/jrnl/enq_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/enq_map.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -69,7 +69,7 @@
{
std::stringstream ss;
ss << std::hex << "rid=0x" << rid << " fid=0x" << fid;
- throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str(), "enq_map", "insert");
+ throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str().c_str(), "enq_map", "insert");
}
}
@@ -83,13 +83,13 @@
{
std::stringstream ss;
ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "enq_map", "get_fid");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_fid");
}
if (itr->second.second) // locked
{
std::stringstream ss;
ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_LOCKED, ss.str(), "enq_map", "get_fid");
+ throw jexception(jerrno::JERR_MAP_LOCKED, ss.str().c_str(), "enq_map", "get_fid");
}
return itr->second.first;
}
@@ -104,14 +104,14 @@
pthread_mutex_unlock(&_mutex);
std::stringstream ss;
ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "enq_map", "get_remove_fid");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_remove_fid");
}
if (itr->second.second && !txn_flag) // locked, but not a commit/abort
{
pthread_mutex_unlock(&_mutex);
std::stringstream ss;
ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_LOCKED, ss.str(), "enq_map", "get_remove_fid");
+ throw jexception(jerrno::JERR_MAP_LOCKED, ss.str().c_str(), "enq_map", "get_remove_fid");
}
u_int16_t fid = itr->second.first;
_map.erase(itr);
@@ -142,7 +142,7 @@
pthread_mutex_unlock(&_mutex);
std::stringstream ss;
ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "enq_map", "get_remove_fid");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_remove_fid");
}
itr->second.second = true;
pthread_mutex_unlock(&_mutex);
@@ -158,7 +158,7 @@
pthread_mutex_unlock(&_mutex);
std::stringstream ss;
ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "enq_map", "get_remove_fid");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_remove_fid");
}
itr->second.second = false;
pthread_mutex_unlock(&_mutex);
@@ -174,7 +174,7 @@
{
std::stringstream ss;
ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "enq_map", "get_fid");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_fid");
}
return itr->second.second;
}
Modified: store/trunk/cpp/lib/jrnl/enq_rec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_rec.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/enq_rec.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -355,7 +355,7 @@
{
std::stringstream ss;
ss << "_buff malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "deq_rec", "decode");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "enq_rec", "decode");
}
const u_int32_t hdr_xid_dblks = size_dblks(enq_hdr::size() + _enq_hdr._xidsize);
@@ -469,7 +469,7 @@
{
std::stringstream ss;
ss << "_buff malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "deq_rec", "decode");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "enq_rec", "rcv_decode");
}
// Decode xid
ifsp->read((char*)_buff, _enq_hdr._xidsize);
@@ -565,7 +565,7 @@
ss << "enq magic: rid=0x" << std::setw(16) << _enq_hdr._hdr._rid;
ss << ": expected=0x" << std::setw(8) << RHM_JDAT_ENQ_MAGIC;
ss << " read=0x" << std::setw(2) << (int)_enq_hdr._hdr._magic;
- throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "enq_rec", "chk_hdr");
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "enq_rec", "chk_hdr");
}
}
Modified: store/trunk/cpp/lib/jrnl/file_hdr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/file_hdr.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/file_hdr.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -173,7 +173,7 @@
{
std::stringstream ss;
ss << "errno=" << errno;
- throw jexception(jerrno::JERR__RTCLOCK, ss.str(), "file_hdr", "set_time");
+ throw jexception(jerrno::JERR__RTCLOCK, ss.str().c_str(), "file_hdr", "set_time");
}
_ts_sec = ts.tv_sec;
_ts_nsec = ts.tv_nsec;
Modified: store/trunk/cpp/lib/jrnl/jcntl.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -290,7 +290,7 @@
{
std::stringstream ss;
ss << "pthread_mutex_trylock() returned " << errno << " (" << strerror(errno) << ")";
- throw jexception(jerrno::JERR__PTHREAD, ss.str(), "jcntl", "get_wr_events");
+ throw jexception(jerrno::JERR__PTHREAD, ss.str().c_str(), "jcntl", "get_wr_events");
}
return 0; // already locked, return immediately
}
@@ -361,14 +361,14 @@
{
std::stringstream ss;
ss << "errno=" << errno;
- throw jexception(jerrno::JERR__RTCLOCK, ss.str(), "jcntl", "write_infofile");
+ throw jexception(jerrno::JERR__RTCLOCK, ss.str().c_str(), "jcntl", "write_infofile");
}
jinf ji(_jid, _jdir.dirname(), _base_filename, ts);
std::stringstream fn;
fn << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
std::ofstream of(fn.str().c_str(), std::ofstream::out | std::ofstream::trunc);
if (!of.good())
- throw jexception(jerrno::JERR__FILEIO, fn.str(), "jcntl", "write_infofile");
+ throw jexception(jerrno::JERR__FILEIO, fn.str().c_str(), "jcntl", "write_infofile");
std::string s;
of << ji.xml_str(s);
of.close();
@@ -581,7 +581,7 @@
default:
std::stringstream ss;
ss << std::hex << std::setfill('0') << "Magic=0x" << std::setw(8) << h._magic;
- throw jexception(jerrno::JERR_JCNTL_UNKNOWNMAGIC, ss.str(), "jcntl",
+ throw jexception(jerrno::JERR_JCNTL_UNKNOWNMAGIC, ss.str().c_str(), "jcntl",
"rcvr_get_next_record");
}
@@ -610,7 +610,7 @@
ss << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
ifsp->open(ss.str().c_str());
if (!ifsp->good())
- throw jexception(jerrno::JERR__FILEIO, ss.str(), "jcntl", "rcvr_get_next_record");
+ throw jexception(jerrno::JERR__FILEIO, ss.str().c_str(), "jcntl", "jfile_cycle");
// Read file header
file_hdr fhdr;
Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -84,7 +84,7 @@
{
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str(), "jdir", "create_dir");
+ throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str().c_str(), "jdir", "create_dir");
}
}
}
@@ -123,7 +123,7 @@
}
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str(), "jdir", "clear_dir");
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str().c_str(), "jdir", "clear_dir");
}
#ifndef RHM_JOWRITE
struct dirent* entry;
@@ -152,7 +152,8 @@
std::stringstream ss;
ss << "file=\"" << oldname.str() << "\" dest=\"" <<
newname.str() << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_FMOVE, ss.str(), "jdir", "clear_dir");
+ throw jexception(jerrno::JERR_JDIR_FMOVE, ss.str().c_str(), "jdir",
+ "clear_dir");
}
}
}
@@ -165,14 +166,14 @@
// std::stringstream ss;
// ss << "dir=\"" << dirname << "\" errno=" << errno;
// ::closedir(dir); // Try to close, it makes no sense to trap errors here...
-// throw jexception(jerrno::JERR_JDIR_READDIR, ss.str(), "jdir", "clear_dir");
+// throw jexception(jerrno::JERR_JDIR_READDIR, ss.str().c_str(), "jdir", "clear_dir");
// }
#endif
if (::closedir(dir))
{
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str(), "jdir", "clear_dir");
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str().c_str(), "jdir", "clear_dir");
}
}
@@ -199,7 +200,7 @@
{
std::stringstream ss;
ss << "dir=\"" << dirname << "\"";
- throw jexception(jerrno::JERR_JDIR_NOTDIR, ss.str(), "jdir", "verify_dir");
+ throw jexception(jerrno::JERR_JDIR_NOTDIR, ss.str().c_str(), "jdir", "verify_dir");
}
// Read jinf file, then verify all journal files are present
@@ -211,7 +212,7 @@
ss << std::setw(4) << std::setfill('0') << std::hex << fnum;
ss << "." << JRNL_DATA_EXTENSION;
if (!exists(ss.str()))
- throw jexception(jerrno::JERR_JDIR_NOSUCHFILE, ss.str(), "jdir", "verify_dir");
+ throw jexception(jerrno::JERR_JDIR_NOSUCHFILE, ss.str().c_str(), "jdir", "verify_dir");
}
}
@@ -243,7 +244,7 @@
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str(), "jdir", "delete_dir");
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str().c_str(), "jdir", "delete_dir");
}
else
{
@@ -257,7 +258,8 @@
{
std::stringstream ss;
ss << "stat: file=\"" << full_name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_STAT, ss.str(), "jdir", "delete_dir");
+ throw jexception(jerrno::JERR_JDIR_STAT, ss.str().c_str(), "jdir",
+ "delete_dir");
}
// FIXME: This fn does not handle symbolic links correctly and throws up
// For some reason, S_ISLNK() fails to identify links correctly.
@@ -267,7 +269,8 @@
{
std::stringstream ss;
ss << "unlink: file=\"" << entry->d_name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_UNLINK, ss.str(), "jdir", "delete_dir");
+ throw jexception(jerrno::JERR_JDIR_UNLINK, ss.str().c_str(), "jdir",
+ "delete_dir");
}
}
else if (S_ISDIR(s.st_mode)) // This is a dir
@@ -279,7 +282,8 @@
std::stringstream ss;
ss << "file=\"" << entry->d_name << "\" is not a dir, file or slink.";
ss << " (mode=0x" << std::hex << s.st_mode << std::dec << ")";
- throw jexception(jerrno::JERR_JDIR_BADFTYPE, ss.str(), "jdir", "delete_dir");
+ throw jexception(jerrno::JERR_JDIR_BADFTYPE, ss.str().c_str(), "jdir",
+ "delete_dir");
}
}
}
@@ -290,7 +294,7 @@
// std::stringstream ss;
// ss << "dir=\"" << dirname << "\" errno=" << errno;
// ::closedir(dir); // Try to close, it makes no sense to trap errors here...
-// throw jexception(jerrno::JERR_JDIR_READDIR, ss.str(), "jdir", "delete_dir");
+// throw jexception(jerrno::JERR_JDIR_READDIR, ss.str().c_str(), "jdir", "delete_dir");
// }
}
// Now dir is empty, close and delete it
@@ -298,7 +302,7 @@
{
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str(), "jdir", "delete_dir");
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str().c_str(), "jdir", "delete_dir");
}
if (!children_only)
@@ -306,7 +310,7 @@
{
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_RMDIR, ss.str(), "jdir", "delete_dir");
+ throw jexception(jerrno::JERR_JDIR_RMDIR, ss.str().c_str(), "jdir", "delete_dir");
}
}
@@ -321,7 +325,7 @@
{
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str(), "jdir", "create_bak_dir");
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str().c_str(), "jdir", "create_bak_dir");
}
struct dirent* entry;
while ((entry = ::readdir(dir)) != NULL)
@@ -349,13 +353,13 @@
// std::stringstream ss;
// ss << "dir=\"" << dirname << "\" errno=" << errno;
// ::closedir(dir); // Try to close, it makes no sense to trap errors here...
-// throw jexception(jerrno::JERR_JDIR_READDIR, ss.str(), "jdir", "clear_dir");
+// throw jexception(jerrno::JERR_JDIR_READDIR, ss.str().c_str(), "jdir", "clear_dir");
// }
if (::closedir(dir))
{
std::stringstream ss;
ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str(), "jdir", "create_bak_dir");
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str().c_str(), "jdir", "create_bak_dir");
}
std::stringstream dn;
dn << dirname << "/_" << base_filename << ".bak." << std::hex << std::setw(4) <<
@@ -364,7 +368,7 @@
{
std::stringstream ss;
ss << "dir=\"" << dn.str() << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str(), "jdir", "create_bak_dir");
+ throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str().c_str(), "jdir", "create_bak_dir");
}
return std::string(dn.str());
}
@@ -377,7 +381,7 @@
{
std::stringstream ss;
ss << "file=\"" << name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_STAT, ss.str(), "jdir", "is_dir");
+ throw jexception(jerrno::JERR_JDIR_STAT, ss.str().c_str(), "jdir", "is_dir");
}
return S_ISDIR(s.st_mode);
}
@@ -399,7 +403,7 @@
// Throw for any other condition
std::stringstream ss;
ss << "file=\"" << name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_STAT, ss.str(), "jdir", "is_dir");
+ throw jexception(jerrno::JERR_JDIR_STAT, ss.str().c_str(), "jdir", "is_dir");
}
return true;
}
Modified: store/trunk/cpp/lib/jrnl/jerrno.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jerrno.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -39,8 +39,8 @@
namespace journal
{
-std::map<u_int32_t, std::string> jerrno::_err_map;
-std::map<u_int32_t, std::string>::iterator jerrno::_err_map_itr;
+std::map<u_int32_t, const char*> jerrno::_err_map;
+std::map<u_int32_t, const char*>::iterator jerrno::_err_map_itr;
bool jerrno::_initialized = jerrno::__init();
// generic errors
@@ -63,7 +63,7 @@
const u_int32_t jerrno::JERR_JDIR_NOTDIR = 0x0300;
const u_int32_t jerrno::JERR_JDIR_MKDIR = 0x0301;
const u_int32_t jerrno::JERR_JDIR_OPENDIR = 0x0302;
-const u_int32_t jerrno::JERR_JDIR_READDIR = 0x0303;
+//const u_int32_t jerrno::JERR_JDIR_READDIR = 0x0303;
const u_int32_t jerrno::JERR_JDIR_CLOSEDIR = 0x0304;
const u_int32_t jerrno::JERR_JDIR_RMDIR = 0x0305;
const u_int32_t jerrno::JERR_JDIR_NOSUCHFILE = 0x0306;
@@ -83,12 +83,10 @@
// class file_hdr
-// class jrec
-const u_int32_t jerrno::JERR_JREC_INVRTAIL = 0x0600;
+// class jrec, enq_rec, deq_rec, txn_rec
+const u_int32_t jerrno::JERR_JREC_BADRECHDR = 0x0600;
+const u_int32_t jerrno::JERR_JREC_BADRECTAIL = 0x0601;
-// class data_rec
-const u_int32_t jerrno::JERR_DREC_INVRHDR = 0x0701;
-
// class wmgr
const u_int32_t jerrno::JERR_WMGR_BADPGSTATE = 0x0801;
const u_int32_t jerrno::JERR_WMGR_BADDTOKSTATE = 0x0802;
@@ -98,13 +96,13 @@
// class rmgr
const u_int32_t jerrno::JERR_RMGR_UNKNOWNMAGIC = 0x0900;
const u_int32_t jerrno::JERR_RMGR_RIDMISMATCH = 0x0901;
-const u_int32_t jerrno::JERR_RMGR_FIDMISMATCH = 0x0902;
+//const u_int32_t jerrno::JERR_RMGR_FIDMISMATCH = 0x0902;
const u_int32_t jerrno::JERR_RMGR_ENQSTATE = 0x0903;
const u_int32_t jerrno::JERR_RMGR_BADRECTYPE = 0x0904;
// class data_tok
const u_int32_t jerrno::JERR_DTOK_ILLEGALSTATE = 0x0a00;
-const u_int32_t jerrno::JERR_DTOK_RIDNOTSET = 0x0a01;
+// const u_int32_t jerrno::JERR_DTOK_RIDNOTSET = 0x0a01;
// class enq_map, txn_map
const u_int32_t jerrno::JERR_MAP_DUPLICATE = 0x0b00;
@@ -118,119 +116,112 @@
const u_int32_t jerrno::JERR_JINF_JDATEMPTY = 0x0c03;
+// static initialization fn
+
bool
jerrno::__init()
{
// generic errors
- _err_map[JERR__MALLOC] = std::string("JERR__MALLOC: Buffer memory allocation failed.");
- _err_map[JERR__UNDERFLOW] = std::string("JERR__UNDERFLOW: Underflow error");
- _err_map[JERR__NINIT] = std::string("JERR__NINIT: Operation on uninitialized class.");
- _err_map[JERR__AIO] = std::string("JERR__AIO: AIO error.");
- _err_map[JERR__FILEIO] = std::string("JERR__FILEIO: File read or write failure.");
- _err_map[JERR__RTCLOCK] = std::string("JERR__RTCLOCK: Reading real-time clock failed.");
- _err_map[JERR__PTHREAD] = std::string("JERR__PTHREAD: pthread failure.");
+ _err_map[JERR__MALLOC] = "JERR__MALLOC: Buffer memory allocation failed.";
+ _err_map[JERR__UNDERFLOW] = "JERR__UNDERFLOW: Underflow error";
+ _err_map[JERR__NINIT] = "JERR__NINIT: Operation on uninitialized class.";
+ _err_map[JERR__AIO] = "JERR__AIO: AIO error.";
+ _err_map[JERR__FILEIO] = "JERR__FILEIO: File read or write failure.";
+ _err_map[JERR__RTCLOCK] = "JERR__RTCLOCK: Reading real-time clock failed.";
+ _err_map[JERR__PTHREAD] = "JERR__PTHREAD: pthread failure.";
// class jcntl
- _err_map[JERR_JCNTL_STOPPED] = std::string("JERR_JCNTL_STOPPED: Operation on stopped journal.");
- _err_map[JERR_JCNTL_READONLY] = std::string("JERR_JCNTL_READONLY: "
- "Write operation on read-only journal (during recovery).");
- _err_map[JERR_JCNTL_AIOCMPLWAIT] = std::string("JERR_JCNTL_AIOCMPLWAIT: "
- "Timeout waiting for AIOs to complete.");
- _err_map[JERR_JCNTL_UNKNOWNMAGIC] = std::string("JERR_JCNTL_UNKNOWNMAGIC: "
- "Found record with unknown magic.");
- _err_map[JERR_JCNTL_NOTRECOVERED] = std::string("JERR_JCNTL_NOTRECOVERED: "
- "Operation requires recover() to be run first.");
+ _err_map[JERR_JCNTL_STOPPED] = "JERR_JCNTL_STOPPED: Operation on stopped journal.";
+ _err_map[JERR_JCNTL_READONLY] = "JERR_JCNTL_READONLY: "
+ "Write operation on read-only journal (during recovery).";
+ _err_map[JERR_JCNTL_AIOCMPLWAIT] = "JERR_JCNTL_AIOCMPLWAIT: "
+ "Timeout waiting for AIOs to complete.";
+ _err_map[JERR_JCNTL_UNKNOWNMAGIC] = "JERR_JCNTL_UNKNOWNMAGIC: Found record with unknown magic.";
+ _err_map[JERR_JCNTL_NOTRECOVERED] = "JERR_JCNTL_NOTRECOVERED: "
+ "Operation requires recover() to be run first.";
// class jdir
- _err_map[JERR_JDIR_NOTDIR] = std::string("JERR_JDIR_NOTDIR: "
- "Directory name exists but is not a directory.");
- _err_map[JERR_JDIR_MKDIR] = std::string("JERR_JDIR_MKDIR: Directory creation failed.");
- _err_map[JERR_JDIR_OPENDIR] = std::string("JERR_JDIR_OPENDIR: Directory open failed.");
- _err_map[JERR_JDIR_READDIR] = std::string("JERR_JDIR_READDIR: Directory read failed.");
- _err_map[JERR_JDIR_CLOSEDIR] = std::string("JERR_JDIR_CLOSEDIR: Directory close failed.");
- _err_map[JERR_JDIR_RMDIR] = std::string("JERR_JDIR_RMDIR: Directory delete failed.");
- _err_map[JERR_JDIR_NOSUCHFILE] = std::string("JERR_JDIR_NOSUCHFILE: File does not exist.");
- _err_map[JERR_JDIR_FMOVE] = std::string("JERR_JDIR_FMOVE: File move failed.");
- _err_map[JERR_JDIR_STAT] = std::string("JERR_JDIR_STAT: File stat failed.");
- _err_map[JERR_JDIR_UNLINK] = std::string("JERR_JDIR_UNLINK: File delete failed.");
- _err_map[JERR_JDIR_BADFTYPE] = std::string("JERR_JDIR_BADFTYPE: "
- "Bad or unknown file type (stat mode).");
+ _err_map[JERR_JDIR_NOTDIR] = "JERR_JDIR_NOTDIR: Directory name exists but is not a directory.";
+ _err_map[JERR_JDIR_MKDIR] = "JERR_JDIR_MKDIR: Directory creation failed.";
+ _err_map[JERR_JDIR_OPENDIR] = "JERR_JDIR_OPENDIR: Directory open failed.";
+ //_err_map[JERR_JDIR_READDIR] = "JERR_JDIR_READDIR: Directory read failed.";
+ _err_map[JERR_JDIR_CLOSEDIR] = "JERR_JDIR_CLOSEDIR: Directory close failed.";
+ _err_map[JERR_JDIR_RMDIR] = "JERR_JDIR_RMDIR: Directory delete failed.";
+ _err_map[JERR_JDIR_NOSUCHFILE] = "JERR_JDIR_NOSUCHFILE: File does not exist.";
+ _err_map[JERR_JDIR_FMOVE] = "JERR_JDIR_FMOVE: File move failed.";
+ _err_map[JERR_JDIR_STAT] = "JERR_JDIR_STAT: File stat failed.";
+ _err_map[JERR_JDIR_UNLINK] = "JERR_JDIR_UNLINK: File delete failed.";
+ _err_map[JERR_JDIR_BADFTYPE] = "JERR_JDIR_BADFTYPE: Bad or unknown file type (stat mode).";
// class nlfh
- _err_map[JERR_NLFH_OPENRD] = std::string("JERR_JNLFH_OPENRD: Unable to open file for read.");
- _err_map[JERR_NLFH_OPENWR] = std::string("JERR_JNLFH_OPENWR: Unable to open file for write.");
- _err_map[JERR_NLFH_WRITE] = std::string("JERR_JNLFH_WRITE: Unable to write to file.");
- _err_map[JERR_NLFH_CLOSE] = std::string("JERR_JNLFH_CLOSE: File close failed.");
- _err_map[JERR_NLFH_FILEOFFSOVFL] = std::string("JERR_NLFH_FILEOFFSOVFL: "
- "Attempted increase file offset past file size.");
- _err_map[JERR_NFLH_CMPLOFFSOVFL] = std::string("JERR_NFLH_CMPLOFFSOVFL: "
- "Attempted increase completed file offset past submitted offset.");
- _err_map[JERR_NFLH_RDOFFSOVFL] = std::string("JERR_NFLH_RDOFFSOVFL: "
- "Attempted increase read offset past write offset.");
+ _err_map[JERR_NLFH_OPENRD] = "JERR_JNLFH_OPENRD: Unable to open file for read.";
+ _err_map[JERR_NLFH_OPENWR] = "JERR_JNLFH_OPENWR: Unable to open file for write.";
+ _err_map[JERR_NLFH_WRITE] = "JERR_JNLFH_WRITE: Unable to write to file.";
+ _err_map[JERR_NLFH_CLOSE] = "JERR_JNLFH_CLOSE: File close failed.";
+ _err_map[JERR_NLFH_FILEOFFSOVFL] = "JERR_NLFH_FILEOFFSOVFL: "
+ "Attempted increase file offset past file size.";
+ _err_map[JERR_NFLH_CMPLOFFSOVFL] = "JERR_NFLH_CMPLOFFSOVFL: "
+ "Attempted increase completed file offset past submitted offset.";
+ _err_map[JERR_NFLH_RDOFFSOVFL] = "JERR_NFLH_RDOFFSOVFL: "
+ "Attempted increase read offset past write offset.";
// class file_hdr
- // class jrec
- _err_map[JERR_JREC_INVRTAIL] = std::string("JERR_JREC_INVRTAIL: Invalid data record tail.");
+ // class jrec, enq_rec, deq_rec, txn_rec
+ _err_map[JERR_JREC_BADRECHDR] = "JERR_JREC_BADRECHDR: Invalid data record header.";
+ _err_map[JERR_JREC_BADRECTAIL] = "JERR_JREC_BADRECTAIL: Invalid data record tail.";
- // class data_rec
- _err_map[JERR_DREC_INVRHDR] = std::string("JERR_DREC_INVRHDR: Invalid data record header.");
-
// class wmgr
- _err_map[JERR_WMGR_BADPGSTATE] = std::string("JERR_WMGR_BADPGSTATE: "
- "Page buffer in illegal state for operation.");
- _err_map[JERR_WMGR_BADDTOKSTATE] = std::string("JERR_WMGR_BADDTOKSTATE: "
- "Data token in illegal state for operation.");
- _err_map[JERR_WMGR_ENQDISCONT] = std::string("JERR_WMGR_ENQDISCONT: "
- "Enqueued new dtok when previous enqueue returned partly completed (state ENQ_PART).");
- _err_map[JERR_WMGR_DEQDISCONT] = std::string("JERR_WMGR_DEQDISCONT: "
- "Dequeued new dtok when previous dequeue returned partly completed (state DEQ_PART).");
+ _err_map[JERR_WMGR_BADPGSTATE] = "JERR_WMGR_BADPGSTATE: "
+ "Page buffer in illegal state for operation.";
+ _err_map[JERR_WMGR_BADDTOKSTATE] = "JERR_WMGR_BADDTOKSTATE: "
+ "Data token in illegal state for operation.";
+ _err_map[JERR_WMGR_ENQDISCONT] = "JERR_WMGR_ENQDISCONT: "
+ "Enqueued new dtok when previous enqueue returned partly completed (state ENQ_PART).";
+ _err_map[JERR_WMGR_DEQDISCONT] = "JERR_WMGR_DEQDISCONT: "
+ "Dequeued new dtok when previous dequeue returned partly completed (state DEQ_PART).";
// class rmgr
- _err_map[JERR_RMGR_UNKNOWNMAGIC] = std::string("JERR_RMGR_UNKNOWNMAGIC: "
- "Found record with unknown magic.");
- _err_map[JERR_RMGR_RIDMISMATCH] = std::string("JERR_RMGR_RIDMISMATCH: "
- "RID mismatch between current record and dtok RID");
- _err_map[JERR_RMGR_FIDMISMATCH] = std::string("JERR_RMGR_FIDMISMATCH: "
- "FID mismatch between emap and rrfc");
- _err_map[JERR_RMGR_ENQSTATE] = std::string("JERR_RMGR_ENQSTATE: "
- "Attempted read when data token wstate was not ENQ");
- _err_map[JERR_RMGR_BADRECTYPE] = std::string("JERR_RMGR_BADRECTYPE: "
- "Attempted operation on inappropriate record type");
+ _err_map[JERR_RMGR_UNKNOWNMAGIC] = "JERR_RMGR_UNKNOWNMAGIC: Found record with unknown magic.";
+ _err_map[JERR_RMGR_RIDMISMATCH] = "JERR_RMGR_RIDMISMATCH: "
+ "RID mismatch between current record and dtok RID";
+ //_err_map[JERR_RMGR_FIDMISMATCH] = "JERR_RMGR_FIDMISMATCH: FID mismatch between emap and rrfc";
+ _err_map[JERR_RMGR_ENQSTATE] = "JERR_RMGR_ENQSTATE: "
+ "Attempted read when data token wstate was not ENQ";
+ _err_map[JERR_RMGR_BADRECTYPE] = "JERR_RMGR_BADRECTYPE: "
+ "Attempted operation on inappropriate record type";
// class data_tok
- _err_map[JERR_DTOK_ILLEGALSTATE] = std::string("JERR_MTOK_ILLEGALSTATE: "
- "Attempted to change to illegal state.");
- _err_map[JERR_DTOK_RIDNOTSET] = std::string("JERR_DTOK_RIDNOTSET: Record ID not set.");
+ _err_map[JERR_DTOK_ILLEGALSTATE] = "JERR_MTOK_ILLEGALSTATE: "
+ "Attempted to change to illegal state.";
+ //_err_map[JERR_DTOK_RIDNOTSET] = "JERR_DTOK_RIDNOTSET: Record ID not set.";
// class enq_map, txn_map
- _err_map[JERR_MAP_DUPLICATE] = std::string("JERR_MAP_DUPLICATE: "
- "Attempted to insert record into map using duplicate key.");
- _err_map[JERR_MAP_NOTFOUND] = std::string("JERR_MAP_NOTFOUND: Key not found in map.");
- _err_map[JERR_MAP_LOCKED] = std::string("JERR_MAP_LOCKED: "
- "Record ID locked by a pending transaction.");
+ _err_map[JERR_MAP_DUPLICATE] = "JERR_MAP_DUPLICATE: "
+ "Attempted to insert record into map using duplicate key.";
+ _err_map[JERR_MAP_NOTFOUND] = "JERR_MAP_NOTFOUND: Key not found in map.";
+ _err_map[JERR_MAP_LOCKED] = "JERR_MAP_LOCKED: Record ID locked by a pending transaction.";
// class jinf
- _err_map[JERR_JINF_CVALIDFAIL] = std::string("JERR_JINF_CVALIDFAIL: "
- "Compatibility validation failure.");
- _err_map[JERR_JINF_NOVALUESTR] = std::string("JERR_JINF_NOVALUESTR: "
- "No value attribute found in jinf file");
- _err_map[JERR_JINF_BADVALUESTR] = std::string("JERR_JINF_BADVALUESTR: "
- "Bad format for value attribute in jinf file");
- _err_map[JERR_JINF_JDATEMPTY] = std::string("JERR_JINF_JDATEMPTY: Journal data files empty.");
+ _err_map[JERR_JINF_CVALIDFAIL] = "JERR_JINF_CVALIDFAIL: "
+ "Journal compatibility validation failure.";
+ _err_map[JERR_JINF_NOVALUESTR] = "JERR_JINF_NOVALUESTR: No value attribute found in jinf file.";
+ _err_map[JERR_JINF_BADVALUESTR] = "JERR_JINF_BADVALUESTR: "
+ "Bad format for value attribute in jinf file";
+ _err_map[JERR_JINF_JDATEMPTY] = "JERR_JINF_JDATEMPTY: Journal data files empty.";
- //_err_map[] = std::string("");
+ //_err_map[] = "";
return true;
}
-const std::string&
-jerrno::err_msg(const u_int32_t err_no) throw (int)
+const char*
+jerrno::err_msg(const u_int32_t err_no) throw ()
{
_err_map_itr = _err_map.find(err_no);
if (_err_map_itr == _err_map.end())
- throw -1; // not found
+ return "<Unknown error code>";
return _err_map_itr->second;
}
Modified: store/trunk/cpp/lib/jrnl/jerrno.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jerrno.hpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jerrno.hpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -55,8 +55,8 @@
*/
class jerrno
{
- static std::map<u_int32_t, std::string> _err_map; ///< Map of error messages
- static std::map<u_int32_t, std::string>::iterator _err_map_itr; ///< Iterator
+ static std::map<u_int32_t, const char*> _err_map; ///< Map of error messages
+ static std::map<u_int32_t, const char*>::iterator _err_map_itr; ///< Iterator
static bool _initialized; ///< Dummy flag, used to initialise map.
public:
@@ -80,7 +80,7 @@
static const u_int32_t JERR_JDIR_NOTDIR; ///< Exists but is not a directory
static const u_int32_t JERR_JDIR_MKDIR; ///< Directory creation failed
static const u_int32_t JERR_JDIR_OPENDIR; ///< Directory open failed
- static const u_int32_t JERR_JDIR_READDIR; ///< Directory read failed
+ //static const u_int32_t JERR_JDIR_READDIR; ///< Directory read failed
static const u_int32_t JERR_JDIR_CLOSEDIR; ///< Directory close failed
static const u_int32_t JERR_JDIR_RMDIR; ///< Directory delete failed
static const u_int32_t JERR_JDIR_NOSUCHFILE; ///< File does not exist
@@ -100,12 +100,10 @@
// class file_hdr
- // class jrec
- static const u_int32_t JERR_JREC_INVRTAIL; ///< Invalid data record tail
-
- // class data_rec
- static const u_int32_t JERR_DREC_INVRHDR; ///< Invalid data record header
-
+ // class jrec, enq_rec, deq_rec, txn_rec
+ static const u_int32_t JERR_JREC_BADRECHDR; ///< Invalid data record header
+ static const u_int32_t JERR_JREC_BADRECTAIL; ///< Invalid data record tail
+
// class wmgr
static const u_int32_t JERR_WMGR_BADPGSTATE; ///< Page buffer in illegal state.
static const u_int32_t JERR_WMGR_BADDTOKSTATE; ///< Data token in illegal state.
@@ -115,13 +113,13 @@
// class rmgr
static const u_int32_t JERR_RMGR_UNKNOWNMAGIC; ///< Found record with unknown magic
static const u_int32_t JERR_RMGR_RIDMISMATCH; ///< RID mismatch between rec and dtok
- static const u_int32_t JERR_RMGR_FIDMISMATCH; ///< FID mismatch between emap and rrfc
+ //static const u_int32_t JERR_RMGR_FIDMISMATCH; ///< FID mismatch between emap and rrfc
static const u_int32_t JERR_RMGR_ENQSTATE; ///< Attempted read when wstate not ENQ
static const u_int32_t JERR_RMGR_BADRECTYPE; ///< Attempted op on incorrect rec type
// class data_tok
static const u_int32_t JERR_DTOK_ILLEGALSTATE; ///< Attempted to change to illegal state
- static const u_int32_t JERR_DTOK_RIDNOTSET; ///< Record ID not set
+// static const u_int32_t JERR_DTOK_RIDNOTSET; ///< Record ID not set
// class enq_map, txn_map
static const u_int32_t JERR_MAP_DUPLICATE; ///< Attempted to insert using duplicate key
@@ -137,7 +135,7 @@
/**
* \brief Method to access error message from known error number.
*/
- static const std::string& err_msg(const u_int32_t err_no) throw (int);
+ static const char* err_msg(const u_int32_t err_no) throw ();
private:
/**
Modified: store/trunk/cpp/lib/jrnl/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -42,38 +42,51 @@
namespace journal
{
-jexception::jexception(const u_int32_t err_code):
+jexception::jexception() throw ():
+ std::exception(),
+ _err_code(0),
+ _additional_info(NULL),
+ _throwing_class(NULL),
+ _throwing_fn(NULL)
+{}
+
+jexception::jexception(const u_int32_t err_code) throw ():
+ std::exception(),
_err_code(err_code),
- _additional_info(),
- _throwing_class(),
- _throwing_fn()
+ _additional_info(NULL),
+ _throwing_class(NULL),
+ _throwing_fn(NULL)
{}
-jexception::jexception(const std::string& additional_info):
+jexception::jexception(const char* additional_info) throw ():
+ std::exception(),
_err_code(0),
_additional_info(additional_info),
- _throwing_class(),
- _throwing_fn()
+ _throwing_class(NULL),
+ _throwing_fn(NULL)
{}
-jexception::jexception(const u_int32_t err_code, const std::string& additional_info):
+jexception::jexception(const u_int32_t err_code, const char* additional_info) throw ():
+ std::exception(),
_err_code(err_code),
_additional_info(additional_info),
- _throwing_class(),
- _throwing_fn()
+ _throwing_class(NULL),
+ _throwing_fn(NULL)
{}
-jexception::jexception(const u_int32_t err_code, const std::string& throwing_class,
- const std::string& throwing_fn):
+jexception::jexception(const u_int32_t err_code, const char* throwing_class,
+ const char* throwing_fn) throw ():
+ std::exception(),
_err_code(err_code),
- _additional_info(),
+ _additional_info(NULL),
_throwing_class(throwing_class),
_throwing_fn(throwing_fn)
{}
-jexception::jexception(const u_int32_t err_code, const std::string& additional_info,
- const std::string& throwing_class, const std::string& throwing_fn):
+jexception::jexception(const u_int32_t err_code, const char* additional_info,
+ const char* throwing_class, const char* throwing_fn) throw ():
+ std::exception(),
_err_code(err_code),
_additional_info(additional_info),
_throwing_class(throwing_class),
@@ -83,40 +96,30 @@
jexception::~jexception() throw ()
{}
-const std::string
-jexception::to_string() const
+const char*
+jexception::what() const throw ()
{
std::stringstream ss;
- if (!_throwing_class.empty() && !_throwing_fn.empty())
+ if (_throwing_class && _throwing_fn)
ss << _throwing_class << "::" << _throwing_fn << "() threw ";
- std::string err_msg;
- try { err_msg = jerrno::err_msg(_err_code); }
- catch (int) { err_msg.assign("<Unknown error code>"); }
ss << "jexception: 0x" << std::hex << std::setw(4) << std::setfill('0') << _err_code;
- ss << " " << err_msg;
- if (!_additional_info.empty())
+ ss << " " << jerrno::err_msg(_err_code);
+ if (_additional_info)
ss << " (" << _additional_info << ")";
- return ss.str();
+ return ss.str().c_str();
}
-const char*
-jexception::what() const throw ()
-{
-// return _additional_info.c_str();
- return to_string().c_str();
-}
-
std::ostream&
operator<<(std::ostream& os, const jexception& je)
{
- os << je.to_string();
+ os << je.what();
return os;
}
std::ostream&
operator<<(std::ostream& os, const jexception* jePtr)
{
- os << jePtr->to_string();
+ os << jePtr->what();
return os;
}
Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -59,26 +59,26 @@
{
private:
u_int32_t _err_code;
- std::string _additional_info;
- std::string _throwing_class;
- std::string _throwing_fn;
+ const char* _additional_info;
+ const char* _throwing_class;
+ const char* _throwing_fn;
public:
- jexception(const u_int32_t err_code);
- jexception(const std::string& additional_info);
- jexception(const u_int32_t err_code, const std::string& additional_info);
- jexception(const u_int32_t err_code, const std::string& throwing_class,
- const std::string& throwing_fn);
- jexception(const u_int32_t err_code, const std::string& additional_info,
- const std::string& throwing_class, const std::string& throwing_fn);
+ jexception() throw ();
+ jexception(const u_int32_t err_code) throw ();
+ jexception(const char* additional_info) throw ();
+ jexception(const u_int32_t err_code, const char* additional_info) throw ();
+ jexception(const u_int32_t err_code, const char* throwing_class, const char* throwing_fn)
+ throw ();
+ jexception(const u_int32_t err_code, const char* additional_info,
+ const char* throwing_class, const char* throwing_fn) throw ();
virtual ~jexception() throw ();
- const std::string to_string() const;
virtual const char* what() const throw (); // override std::exception::what()
- inline const u_int32_t err_code() const { return _err_code; }
- inline const std::string& additional_info() const { return _additional_info; }
- inline const std::string& throwing_class() const { return _throwing_class; }
- inline const std::string& throwing_fn() const { return _throwing_fn; }
+ inline const u_int32_t err_code() const throw () { return _err_code; }
+ inline const char* additional_info() const throw () { return _additional_info; }
+ inline const char* throwing_class() const throw () { return _throwing_class; }
+ inline const char* throwing_fn() const throw () { return _throwing_fn; }
friend std::ostream& operator<<(std::ostream& os, const jexception& je);
friend std::ostream& operator<<(std::ostream& os, const jexception* jePtr);
Modified: store/trunk/cpp/lib/jrnl/jinf.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jinf.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jinf.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -147,7 +147,7 @@
err = true;
}
if (err)
- throw jexception(jerrno::JERR_JINF_CVALIDFAIL, ss.str(), "jinf", "validate");
+ throw jexception(jerrno::JERR_JINF_CVALIDFAIL, ss.str().c_str(), "jinf", "validate");
_valid_flag = true;
}
@@ -167,7 +167,7 @@
ss << "." << JRNL_DATA_EXTENSION;
std::ifstream jifs(ss.str().c_str());
if (!jifs.good())
- throw jexception(jerrno::JERR__FILEIO, ss.str(), "jinf", "analyze");
+ throw jexception(jerrno::JERR__FILEIO, ss.str().c_str(), "jinf", "analyze");
file_hdr fhdr;
jifs.read((char*)&fhdr, sizeof(fhdr));
if (fhdr._hdr._magic != RHM_JDAT_FILE_MAGIC)
@@ -267,7 +267,7 @@
char buff[1024];
std::ifstream jinfs(jinf_filename.c_str());
if (!jinfs.good())
- throw jexception(jerrno::JERR__FILEIO, jinf_filename, "jinf", "read");
+ throw jexception(jerrno::JERR__FILEIO, jinf_filename.c_str(), "jinf", "read");
while (jinfs.good())
{
jinfs.getline(buff, 1024);
Modified: store/trunk/cpp/lib/jrnl/jrec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jrec.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/jrec.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -71,7 +71,7 @@
std::stringstream ss;
ss << std::hex << std::setfill('0');
ss << "enq magic NULL: rid=0x" << std::setw(16) << hdr._rid;
- throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "jrec", "chk_hdr");
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
}
if (hdr._version != RHM_JDAT_VERSION)
{
@@ -80,7 +80,7 @@
ss << "version: rid=0x" << std::setw(16) << hdr._rid;
ss << ": expected=0x" << std::setw(2) << (int)RHM_JDAT_VERSION;
ss << " read=0x" << std::setw(2) << (int)hdr._version;
- throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "jrec", "chk_hdr");
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
}
#if defined (JRNL_LITTLE_ENDIAN)
u_int8_t endian_flag = RHM_LENDIAN_FLAG;
@@ -94,7 +94,7 @@
ss << "endian_flag: rid=" << std::setw(16) << hdr._rid;
ss << ": expected=0x" << std::setw(2) << (int)endian_flag;
ss << " read=0x" << std::setw(2) << (int)hdr._eflag;
- throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "jrec", "chk_hdr");
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
}
}
@@ -107,7 +107,7 @@
ss << std::hex << std::setfill('0');
ss << "rid mismatch: expected=0x" << std::setw(16) << rid;
ss << " read=0x" << std::setw(16) << hdr._rid;
- throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "jrec", "chk_hdr");
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
}
}
@@ -121,7 +121,7 @@
ss << "magic: rid=0x" << std::setw(16) << hdr._rid;
ss << ": expected=0x" << std::setw(8) << ~hdr._magic;
ss << " read=0x" << std::setw(8) << tail._xmagic;
- throw jexception(jerrno::JERR_JREC_INVRTAIL, ss.str(), "jrec", "chk_tail");
+ throw jexception(jerrno::JERR_JREC_BADRECTAIL, ss.str().c_str(), "jrec", "chk_tail");
}
if (tail._rid != hdr._rid)
{
@@ -129,7 +129,7 @@
ss << std::hex << std::setfill('0');
ss << "rid: rid=0x" << std::setw(16) << hdr._rid;
ss << ": read=0x" << std::setw(16) << tail._rid;
- throw jexception(jerrno::JERR_JREC_INVRTAIL, ss.str(), "jrec", "chk_tail");
+ throw jexception(jerrno::JERR_JREC_BADRECTAIL, ss.str().c_str(), "jrec", "chk_tail");
}
}
Modified: store/trunk/cpp/lib/jrnl/nlfh.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/nlfh.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -143,7 +143,7 @@
{
ss << ": posix_memalign() failed: size=" << writesize << " blk_size=" << sblksize;
ss << " errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "nlfh", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "nlfh", "initialize");
}
::memset(nullbuf, 0, writesize);
@@ -153,7 +153,7 @@
{
ss << ": open() failed:" << "\" errno=" << errno;
::free(nullbuf);
- throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str(), "nlfh", "initialize");
+ throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str().c_str(), "nlfh", "initialize");
}
while (nsblks > 0)
@@ -166,7 +166,8 @@
ss << ": wr_size=" << (this_write_sblks * sblksize) << " errno=" << errno;
::close(fh);
::free(nullbuf);
- throw jexception(jerrno::JERR_NLFH_WRITE, ss.str(), "nlfh", "initialize");
+ throw jexception(jerrno::JERR_NLFH_WRITE, ss.str().c_str(), "nlfh",
+ "initialize");
}
nsblks -= this_write_sblks;
}
@@ -176,7 +177,7 @@
if (::close(fh))
{
ss << ": errno=" << errno;
- throw jexception(jerrno::JERR_NLFH_CLOSE, ss.str(), "jcntl", "initialize");
+ throw jexception(jerrno::JERR_NLFH_CLOSE, ss.str().c_str(), "nlfh", "initialize");
}
}
#ifdef RHM_JOWRITE
@@ -246,7 +247,7 @@
{
std::stringstream ss;
ss << "_rec_enqcnt=" << _rec_enqcnt << " decr=" << s;
- throw jexception (jerrno::JERR__UNDERFLOW, ss.str(), "nlfh", "decr_enqcnt");
+ throw jexception (jerrno::JERR__UNDERFLOW, ss.str().c_str(), "nlfh", "subtr_enqcnt");
}
_rec_enqcnt -= s;
return _rec_enqcnt;
@@ -260,7 +261,8 @@
std::stringstream ss;
ss << "_rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
- throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, ss.str(), "nlfh", "incr_rd_subm_cnt_dblks");
+ throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, ss.str().c_str(), "nlfh",
+ "incr_rd_subm_cnt_dblks");
}
return ++_rd_subm_cnt_dblks;
}
@@ -273,7 +275,8 @@
std::stringstream ss;
ss << "_rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks << " incr=" << a;
ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
- throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, ss.str(), "nlfh", "add_rd_subm_cnt_dblks");
+ throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, ss.str().c_str(), "nlfh",
+ "add_rd_subm_cnt_dblks");
}
_rd_subm_cnt_dblks += a;
return _rd_subm_cnt_dblks;
@@ -287,7 +290,7 @@
std::stringstream ss;
ss << "_rd_cmpl_cnt_dblks=" << _rd_cmpl_cnt_dblks;
ss << " _rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
- throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str().c_str(), "nlfh",
"incr_rd_cmpl_cnt_dblks");
}
return ++_rd_cmpl_cnt_dblks;
@@ -301,7 +304,7 @@
std::stringstream ss;
ss << "_rd_cmpl_cnt_dblks=" << _rd_cmpl_cnt_dblks << " incr=" << a;
ss << " _rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
- throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str().c_str(), "nlfh",
"add_rd_cmpl_cnt_dblks");
}
_rd_cmpl_cnt_dblks += a;
@@ -316,7 +319,7 @@
std::stringstream ss;
ss << "_wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
ss << " fsize=" << JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1) << " dblks";
- throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str(), "nlfh",
+ throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str().c_str(), "nlfh",
"incr_wr_subm_cnt_dblks");
}
return ++_wr_subm_cnt_dblks;
@@ -330,7 +333,7 @@
std::stringstream ss;
ss << "_wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks << " incr=" << a;
ss << " fsize=" << JRNL_SBLK_SIZE * (JRNL_FILE_SIZE + 1) << " dblks";
- throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str(), "nlfh",
+ throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str().c_str(), "nlfh",
"add_wr_subm_cnt_dblks");
}
_wr_subm_cnt_dblks += a;
@@ -345,7 +348,7 @@
std::stringstream ss;
ss << "_wr_cmpl_cnt_dblks=" << _wr_cmpl_cnt_dblks;
ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
- throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str().c_str(), "nlfh",
"incr_wr_cmpl_cnt_dblks");
}
return ++_wr_cmpl_cnt_dblks;
@@ -359,7 +362,7 @@
std::stringstream ss;
ss << "_wr_cmpl_cnt_dblks=" << _wr_cmpl_cnt_dblks << " incr=" << a;
ss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
- throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str(), "nlfh",
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, ss.str().c_str(), "nlfh",
"add_wr_cmpl_cnt_dblks");
}
_wr_cmpl_cnt_dblks += a;
@@ -387,7 +390,7 @@
{
std::stringstream ss;
ss << "file=\"" << _fname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_NLFH_OPENRD, ss.str(), "nlfh", "open");
+ throw jexception(jerrno::JERR_NLFH_OPENRD, ss.str().c_str(), "nlfh", "open");
}
_wr_fh = ::open(_fname.c_str(), O_WRONLY | O_DIRECT,
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // 0644 -rw-r--r--
@@ -395,7 +398,7 @@
{
std::stringstream ss;
ss << "file=\"" << _fname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str(), "nlfh", "open");
+ throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str().c_str(), "nlfh", "open");
}
}
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -147,7 +147,7 @@
clean();
ss << "posix_memalign(): blksize=" << _sblksize << " size=" << pagesize;
ss << " errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "pmgr", "initialize");
}
// 2. Allocate array of page pointers
_page_ptr_arr = (void**)::malloc(_pages * sizeof(void*));
@@ -155,7 +155,7 @@
{
clean();
ss << "_page_ptr_arr malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "pmgr", "initialize");
}
// 3. Allocate and initilaize page control block (page_cb) array
@@ -164,7 +164,7 @@
{
clean();
ss << "_page_cb_arr malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "pmgr", "initialize");
}
::memset(_page_cb_arr, 0, _pages * sizeof(page_cb));
@@ -174,7 +174,7 @@
{
clean();
ss << "_iocb_arr malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "pmgr", "initialize");
}
// 6. Set page pointers in _page_ptr_arr, _page_cb_arr and iocbs to pages within page block
@@ -196,14 +196,14 @@
{
clean();
ss << "_ioevt_arr malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "pmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "pmgr", "initialize");
}
// 8. Initialize AIO context
if (int ret = ::io_queue_init(max_aio_evts, &_ioctx))
{
ss << "io_queue_init() failed: " << strerror(-ret) << " (" << ret << ")";
- throw jexception(jerrno::JERR__AIO, ss.str(), "pmgr", "initialize");
+ throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "pmgr", "initialize");
}
}
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -78,88 +78,88 @@
return RHM_IORES_NOTIMPL;
-// TODO - untangle this...
-// _hdr.reset();
-// // Read header, determine next record type
-// while (true)
-// {
-// if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
-// {
-// aio_cycle(); // check if any AIOs have returned
-// return RHM_IORES_EMPTY;
-// }
-// if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
-// {
-// aio_cycle();
-// return RHM_IORES_AIO_WAIT;
-// }
-// void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] +
-// (_pg_offset_dblks * JRNL_DBLK_SIZE));
-// ::memcpy(&_hdr, rptr, sizeof(hdr));
-// switch (_hdr._magic)
-// {
-// case RHM_JDAT_ENQ_MAGIC:
-// {
-// size_t xid_size = *((size_t*)((char*)rptr + sizeof(hdr)
-// #if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
-// + sizeof(u_int32_t) // filler0
-// #endif
-// ));
-// size_t data_size = *((size_t*)((char*)rptr + sizeof(hdr) + sizeof(u_int64_t)
-// #if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
-// + sizeof(u_int32_t) // filler1
-// #endif
-// ));
-// // TODO: Check if transaction is still in transaction map. If so, block read
-// // (unless in recovery, in whcih case return info normally
-// // std::string xid = ?? (decode xid here)
-// // if (xid_size && !readonly && tx_map.exists(xid))
-// // return RHM_IORES_TXPENDING;
-// rid = _hdr._rid;
-// dsize = data_size;
-//
-// // Analyze how much of message is available
-// void* data_ptr = (char*)rptr + sizeof(enq_hdr) + xid_size;
-// void* page_end_ptr = (char*)_page_base_ptr + _pagesize * _sblksize * _pages;
-// u_int16_t data_start_pg_index = _pg_index;
-// u_int16_t data_start_pg_index = _pg_index;
-// for (u_int16_t i=0; i<_pages; i++)
-// {
-// pi = (i + _pg_index) % _pages;
-// if (data_ptr >= _page_ptr_arr[pi] &&
-// data_ptr < (char*)_page_ptr_arr[pi] + _pagesize * _sblksize)
-// data_end_pg_index = pi; // found start page index
-//
-// }
-// u_int16_t data_end_pg_index;
-// u_int16_t last_pg_avail_index;
-//
-// void* data_ptr = (char*)rptr + sizeof(enq_hdr) + xid_size;
-// void* page_end_ptr = (char*)_page_base_ptr + _pagesize * _sblksize * _pages;
-// if (data_ptr >= page_end_ptr) // folded, go back to first page...
-// data_ptr = (char*)_page_base_ptr + data_ptr - page_end_ptr;
-// void* data_end_ptr = (char*)data_ptr + data_size;
-// if (data_end_ptr >= page_end_ptr) // folded, go back to first page...
-// data_end_ptr = (char*)_page_base_ptr + data_end_ptr - page_end_ptr;
-// dsize_avail = ??;
-// if(data_ptr folded)
-// else
-// *data = data_ptr;
-// }
-// break;
-// case RHM_JDAT_DEQ_MAGIC:
-// consume_deq();
-// break;
-// case RHM_JDAT_EMPTY_MAGIC:
-// consume_filler();
-// break;
-// default:
-// std::stringstream ss;
-// ss << std::hex << std::setfill('0');
-// ss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
-// throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, ss.str(), "rmgr", "read");
-// } // switch(_hdr._magic)
-// } // while
+//TODO - untangle this...
+/* _hdr.reset();
+ // Read header, determine next record type
+ while (true)
+ {
+ if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
+ {
+ aio_cycle(); // check if any AIOs have returned
+ return RHM_IORES_EMPTY;
+ }
+ if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
+ {
+ aio_cycle();
+ return RHM_IORES_AIO_WAIT;
+ }
+ void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] +
+ (_pg_offset_dblks * JRNL_DBLK_SIZE));
+ ::memcpy(&_hdr, rptr, sizeof(hdr));
+ switch (_hdr._magic)
+ {
+ case RHM_JDAT_ENQ_MAGIC:
+ {
+ size_t xid_size = *((size_t*)((char*)rptr + sizeof(hdr)
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ + sizeof(u_int32_t) // filler0
+#endif
+ ));
+ size_t data_size = *((size_t*)((char*)rptr + sizeof(hdr) + sizeof(u_int64_t)
+#if defined(JRNL_BIG_ENDIAN) && defined(JRNL_32_BIT)
+ + sizeof(u_int32_t) // filler1
+#endif
+ ));
+ // TODO: Check if transaction is still in transaction map. If so, block read
+ // (unless in recovery, in whcih case return info normally
+// std::string xid = ?? (decode xid here)
+// if (xid_size && !readonly && tx_map.exists(xid))
+// return RHM_IORES_TXPENDING;
+ rid = _hdr._rid;
+ dsize = data_size;
+
+ // Analyze how much of message is available
+ void* data_ptr = (char*)rptr + sizeof(enq_hdr) + xid_size;
+ void* page_end_ptr = (char*)_page_base_ptr + _pagesize * _sblksize * _pages;
+ u_int16_t data_start_pg_index = _pg_index;
+ u_int16_t data_start_pg_index = _pg_index;
+ for (u_int16_t i=0; i<_pages; i++)
+ {
+ pi = (i + _pg_index) % _pages;
+ if (data_ptr >= _page_ptr_arr[pi] &&
+ data_ptr < (char*)_page_ptr_arr[pi] + _pagesize * _sblksize)
+ data_end_pg_index = pi; // found start page index
+
+ }
+ u_int16_t data_end_pg_index;
+ u_int16_t last_pg_avail_index;
+
+ void* data_ptr = (char*)rptr + sizeof(enq_hdr) + xid_size;
+ void* page_end_ptr = (char*)_page_base_ptr + _pagesize * _sblksize * _pages;
+ if (data_ptr >= page_end_ptr) // folded, go back to first page...
+ data_ptr = (char*)_page_base_ptr + data_ptr - page_end_ptr;
+ void* data_end_ptr = (char*)data_ptr + data_size;
+ if (data_end_ptr >= page_end_ptr) // folded, go back to first page...
+ data_end_ptr = (char*)_page_base_ptr + data_end_ptr - page_end_ptr;
+ dsize_avail = ??;
+ if(data_ptr folded)
+ else
+ *data = data_ptr;
+ }
+ break;
+ case RHM_JDAT_DEQ_MAGIC:
+ consume_deq();
+ break;
+ case RHM_JDAT_EMPTY_MAGIC:
+ consume_filler();
+ break;
+ default:
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
+ throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, ss.str().c_str(), "rmgr", "get");
+ } // switch(_hdr._magic)
+ } // while */
}
const iores
@@ -172,43 +172,44 @@
return RHM_IORES_NOTIMPL;
-// TODO - untangle this...
-// _hdr.reset();
-// // Read header, determine next record type
-// while (true)
-// {
-// if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
-// {
-// aio_cycle(); // check if any AIOs have returned
-// return RHM_IORES_EMPTY;
-// }
-// if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
-// {
-// aio_cycle();
-// return RHM_IORES_AIO_WAIT;
-// }
-// void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] +
-// (_pg_offset_dblks * JRNL_DBLK_SIZE));
-// ::memcpy(&_hdr, rptr, sizeof(hdr));
-// switch (_hdr._magic)
-// {
-// case RHM_JDAT_ENQ_MAGIC:
-// {
-// }
-// break;
-// case RHM_JDAT_DEQ_MAGIC:
-// consume_deq();
-// break;
-// case RHM_JDAT_EMPTY_MAGIC:
-// consume_filler();
-// break;
-// default:
-// std::stringstream ss;
-// ss << std::hex << std::setfill('0');
-// ss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
-// throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, ss.str(), "rmgr", "read");
-// } // switch
-// } // while
+/* TODO - untangle this...
+ _hdr.reset();
+ // Read header, determine next record type
+ while (true)
+ {
+ if(dblks_rem() == 0 && _rrfc.is_compl() && !_rrfc.is_wr_aio_outstanding())
+ {
+ aio_cycle(); // check if any AIOs have returned
+ return RHM_IORES_EMPTY;
+ }
+ if (_page_cb_arr[_pg_index]._state != AIO_COMPLETE)
+ {
+ aio_cycle();
+ return RHM_IORES_AIO_WAIT;
+ }
+ void* rptr = (void*)((char*)_page_ptr_arr[_pg_index] +
+ (_pg_offset_dblks * JRNL_DBLK_SIZE));
+ ::memcpy(&_hdr, rptr, sizeof(hdr));
+ switch (_hdr._magic)
+ {
+ case RHM_JDAT_ENQ_MAGIC:
+ {
+ }
+ break;
+ case RHM_JDAT_DEQ_MAGIC:
+ consume_deq();
+ break;
+ case RHM_JDAT_EMPTY_MAGIC:
+ consume_filler();
+ break;
+ default:
+ std::stringstream ss;
+ ss << std::hex << std::setfill('0');
+ ss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
+ throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, ss.str().c_str(), "rmgr",
+ "discard");
+ } // switch
+ } // while */
}
const iores
@@ -345,7 +346,7 @@
ss << "rid=0x" << std::setw(16) << _hdr._rid;
ss << "; dtok_rid=" << std::setw(16) << dtokp->rid();
ss << "; dtok_id=0x" << std::setw(8) << dtokp->id();
- throw jexception(jerrno::JERR_RMGR_RIDMISMATCH, ss.str(), "rmgr",
+ throw jexception(jerrno::JERR_RMGR_RIDMISMATCH, ss.str().c_str(), "rmgr",
"read");
}
}
@@ -362,7 +363,8 @@
// ss << "rid=0x" << std::setw(16) << _hdr._rid;
// ss << "; emap_fid=0x" << std::setw(4) << fid;
// ss << "; current_fid=" << _rrfc.fid();
-// throw jexception(jerrno::JERR_RMGR_FIDMISMATCH, ss.str(), "rmgr", "read");
+// throw jexception(jerrno::JERR_RMGR_FIDMISMATCH, ss.str().c_str(), "rmgr",
+// "read");
// }
#endif
const iores res = read_enq(_hdr, rptr, dtokp);
@@ -399,7 +401,7 @@
std::stringstream ss;
ss << std::hex << std::setfill('0');
ss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
- throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, ss.str(), "rmgr", "read");
+ throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, ss.str().c_str(), "rmgr", "read");
}
}
}
@@ -414,7 +416,7 @@
return 0;
std::stringstream ss;
ss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
- throw jexception(jerrno::JERR__AIO, ss.str(), "rmgr", "get_events");
+ throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "rmgr", "get_events");
}
u_int32_t tot_data_toks = 0;
@@ -424,7 +426,7 @@
{
std::stringstream ss;
ss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
- throw jexception(jerrno::JERR__UNDERFLOW, ss.str(), "rmgr", "get_events");
+ throw jexception(jerrno::JERR__UNDERFLOW, ss.str().c_str(), "rmgr", "get_events");
}
_aio_evt_rem--;
iocb* iocbp = _ioevt_arr[i].obj; // This I/O control block (iocb)
@@ -436,7 +438,7 @@
ss << "AIO read operation failed: " << strerror(-aioret) << " (" << aioret << ")";
ss << " [pg=" << pcbp->_index << " size=" << iocbp->u.c.nbytes;
ss << " offset=" << iocbp->u.c.offset << " fh=" << iocbp->aio_fildes << "]";
- throw jexception(jerrno::JERR__AIO, ss.str(), "rmgr", "get_events");
+ throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "rmgr", "get_events");
}
// Transfer all data tokens
@@ -500,7 +502,8 @@
ss << "dtok_id=0x" << std::setw(8) << dtokp->id();
ss << "; dtok_rid=0x" << std::setw(16) << dtokp->rid();
ss << "; dtok_wstate=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_RMGR_ENQSTATE, ss.str(), "rmgr", "read");
+ throw jexception(jerrno::JERR_RMGR_ENQSTATE, ss.str().c_str(), "rmgr",
+ "pre_read_check");
}
}
@@ -586,7 +589,7 @@
{
std::stringstream ss;
ss << "Record type found = \"" << (char*)&h._magic << "\"";
- throw jexception(jerrno::JERR_RMGR_BADRECTYPE, ss.str(), "rmgr", "consume_xid_rec");
+ throw jexception(jerrno::JERR_RMGR_BADRECTYPE, ss.str().c_str(), "rmgr", "consume_xid_rec");
}
dtokp->set_dblocks_read(0);
skip(dtokp);
Modified: store/trunk/cpp/lib/jrnl/txn_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_map.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/txn_map.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -93,7 +93,7 @@
{
std::stringstream ss;
ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "txn_map", "get_tdata_list");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "get_tdata_list");
}
return itr->second;
}
@@ -108,7 +108,8 @@
pthread_mutex_unlock(&_mutex);
std::stringstream ss;
ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "txn_map", "get_remove_tdata_list");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map",
+ "get_remove_tdata_list");
}
txn_data_list list = itr->second;
_map.erase(itr);
@@ -126,7 +127,7 @@
{
std::stringstream ss;
ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "txn_map", "get_rid_count");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "get_rid_count");
}
return itr->second.size();
}
@@ -141,7 +142,7 @@
pthread_mutex_unlock(&_mutex);
std::stringstream ss;
ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "txn_map", "is_txn_synced");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "is_txn_synced");
}
//std::cout << " its: found XID" << std::flush;
bool is_synced = true;
@@ -191,7 +192,7 @@
{
std::stringstream ss;
ss << std::hex << "xid=\"" << xid << "\" rid=" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "txn_map", "set_aio_compl");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "set_aio_compl");
}
return ok;
}
Modified: store/trunk/cpp/lib/jrnl/txn_rec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/txn_rec.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/txn_rec.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -273,7 +273,7 @@
{
std::stringstream ss;
ss << "_buff malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "txn_rec", "decode");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "txn_rec", "decode");
}
const u_int32_t hdr_xid_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize);
const u_int32_t hdr_xid_tail_dblks = size_dblks(txn_hdr::size() + _txn_hdr._xidsize +
@@ -342,7 +342,7 @@
{
std::stringstream ss;
ss << "_buff malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "deq_rec", "decode");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "deq_rec", "rcv_decode");
}
// Decode xid
ifsp->read((char*)_buff, _txn_hdr._xidsize);
@@ -409,7 +409,7 @@
ss << ": expected=(0x" << std::setw(8) << RHM_JDAT_TXA_MAGIC;
ss << " or 0x" << RHM_JDAT_TXC_MAGIC;
ss << ") read=0x" << std::setw(2) << (int)_txn_hdr._hdr._magic;
- throw jexception(jerrno::JERR_DREC_INVRHDR, ss.str(), "txn_rec", "chk_hdr");
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "txn_rec", "chk_hdr");
}
}
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -119,7 +119,7 @@
{
std::stringstream ss;
ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_ENQDISCONT, ss.str(), "wmgr", "enqueue");
+ throw jexception(jerrno::JERR_WMGR_ENQDISCONT, ss.str().c_str(), "wmgr", "enqueue");
}
}
else
@@ -254,7 +254,7 @@
{
std::stringstream ss;
ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str(), "wmgr", "dequeue");
+ throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str().c_str(), "wmgr", "dequeue");
}
}
else
@@ -402,7 +402,7 @@
{
std::stringstream ss;
ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str(), "wmgr", "abort");
+ throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str().c_str(), "wmgr", "abort");
}
}
else
@@ -460,7 +460,7 @@
{
std::stringstream ss;
ss << std::hex << "_txn_pending_set: xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str(), "wmgr", "abort");
+ throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str().c_str(), "wmgr", "abort");
}
#endif
@@ -545,7 +545,7 @@
{
std::stringstream ss;
ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str(), "wmgr", "commit");
+ throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str().c_str(), "wmgr", "commit");
}
}
else
@@ -602,7 +602,7 @@
{
std::stringstream ss;
ss << std::hex << "_txn_pending_set: xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str(), "wmgr", "commit");
+ throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str().c_str(), "wmgr", "commit");
}
#endif
@@ -693,7 +693,8 @@
{
std::stringstream ss;
ss << "pg_index=" << _pg_index << " state=" << _page_cb_arr[_pg_index].state_str();
- throw jexception(jerrno::JERR_WMGR_BADPGSTATE, ss.str(), "wmgr", "write_flush");
+ throw jexception(jerrno::JERR_WMGR_BADPGSTATE, ss.str().c_str(), "wmgr",
+ "write_flush");
}
// Send current page using AIO
@@ -747,7 +748,7 @@
return 0;
std::stringstream ss;
ss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
- throw jexception(jerrno::JERR__AIO, ss.str(), "wmgr", "get_events");
+ throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "wmgr", "get_events");
}
u_int32_t tot_data_toks = 0;
@@ -757,7 +758,7 @@
{
std::stringstream ss;
ss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
- throw jexception(jerrno::JERR__UNDERFLOW, ss.str(), "wmgr", "get_events");
+ throw jexception(jerrno::JERR__UNDERFLOW, ss.str().c_str(), "wmgr", "get_events");
}
_aio_evt_rem--;
iocb* iocbp = _ioevt_arr[i].obj; // This I/O control block (iocb)
@@ -769,7 +770,7 @@
ss << "AIO write operation failed: " << strerror(-aioret) << " (" << aioret << ")";
ss << " [pg=" << pcbp->_index << " size=" << iocbp->u.c.nbytes;
ss << " offset=" << iocbp->u.c.offset << " fh=" << iocbp->aio_fildes << "]";
- throw jexception(jerrno::JERR__AIO, ss.str(), "wmgr", "get_events");
+ throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "wmgr", "get_events");
}
if (pcbp) // Page writes have pcb
{
@@ -802,7 +803,8 @@
{
std::stringstream ss;
ss << std::hex << "_txn_pending_set: abort xid=\"" << dtp->xid() << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "wmgr", "get_events");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "wmgr",
+ "get_events");
}
_txn_pending_set.erase(it);
#endif
@@ -816,7 +818,8 @@
{
std::stringstream ss;
ss << std::hex << "_txn_pending_set: commit xid=\"" << dtp->xid() << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str(), "wmgr", "get_events");
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "wmgr",
+ "get_events");
}
_txn_pending_set.erase(it);
#endif
@@ -824,7 +827,7 @@
default:
std::stringstream ss;
ss << "dtok_id=" << dtp->id() << "dtok_state=" << dtp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str(), "wmgr",
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str().c_str(), "wmgr",
"get_events");
}
_dtokl->push_back(dtp);
@@ -887,7 +890,7 @@
std::stringstream ss;
ss << "posix_memalign(): blksize=" << _sblksize << " size=" << _sblksize;
ss << " errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "wmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "wmgr", "initialize");
}
_fhdr_ptr_arr = (void**)::malloc(_pages * sizeof(void*));
if (_fhdr_ptr_arr == NULL)
@@ -895,7 +898,7 @@
clean();
std::stringstream ss;
ss << "_fhdr_ptr_arr malloc(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "wmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "wmgr", "initialize");
}
_iocba = (iocb**)::malloc(sizeof(iocb*) * JRNL_NUM_FILES);
if (_iocba == NULL)
@@ -903,7 +906,7 @@
clean();
std::stringstream ss;
ss << "_iocba new(): errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str(), "wmgr", "initialize");
+ throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "wmgr", "initialize");
}
::memset(_iocba, 0, sizeof(iocb*) * JRNL_NUM_FILES);
for (u_int16_t i=0; i<JRNL_NUM_FILES; i++)
@@ -939,7 +942,8 @@
std::stringstream ss;
ss << "op=" << _op_str[op] << " index=" << _pg_index << " state=";
ss << _page_cb_arr[_pg_index].state_str();
- throw jexception(jerrno::JERR_WMGR_BADPGSTATE, ss.str(), "wmgr", "pre_write_check");
+ throw jexception(jerrno::JERR_WMGR_BADPGSTATE, ss.str().c_str(), "wmgr",
+ "pre_write_check");
}
}
@@ -952,7 +956,7 @@
std::stringstream ss;
ss << "op=" << _op_str[op] << " dtok_id=" << dtokp->id();
ss << " dtok_state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str(), "wmgr",
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str().c_str(), "wmgr",
"pre_write_check");
}
break;
@@ -962,7 +966,7 @@
std::stringstream ss;
ss << "op=" << _op_str[op] << " dtok_id=" << dtokp->id();
ss << " dtok_state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str(), "wmgr",
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str().c_str(), "wmgr",
"pre_write_check");
}
break;
Modified: store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/tests/jrnl/JournalUnitTests.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -46,74 +46,55 @@
void JournalExceptionTest()
{
- jexception e1(1);
- CPPUNIT_ASSERT_MESSAGE("e1: Error code bad.", e1.err_code() == 1);
- CPPUNIT_ASSERT_MESSAGE("e1: Additional information bad.", e1.additional_info().empty());
- CPPUNIT_ASSERT_MESSAGE("e1: Throwing class bad.", e1.throwing_class().empty());
- CPPUNIT_ASSERT_MESSAGE("e1: Throwing function bad.", e1.throwing_fn().empty());
-
- jexception e2("exception2");
- CPPUNIT_ASSERT_MESSAGE("e2: Error code bad.", e2.err_code() == 0);
- CPPUNIT_ASSERT_MESSAGE("e2: Additional information bad.",
- e2.additional_info().compare("exception2") == 0);
- CPPUNIT_ASSERT_MESSAGE("e2: Throwing class bad.", e2.throwing_class().empty());
- CPPUNIT_ASSERT_MESSAGE("e2: Throwing function bad.", e2.throwing_fn().empty());
-
- string msg3("exception3");
- jexception e3(msg3);
- CPPUNIT_ASSERT_MESSAGE("e3: Error code bad.", e3.err_code() == 0);
- CPPUNIT_ASSERT_MESSAGE("e3: Additional information bad.",
- e3.additional_info().compare(msg3) == 0);
- CPPUNIT_ASSERT_MESSAGE("e3: Throwing class bad.", e3.throwing_class().empty());
- CPPUNIT_ASSERT_MESSAGE("e3: Throwing function bad.", e3.throwing_fn().empty());
-
- jexception e4(4, "exception4");
- CPPUNIT_ASSERT_MESSAGE("e4: Error code bad.", e4.err_code() == 4);
- CPPUNIT_ASSERT_MESSAGE("e4: Additional information bad.",
- e4.additional_info().compare("exception4") == 0);
- CPPUNIT_ASSERT_MESSAGE("e4: Throwing class bad.", e4.throwing_class().empty());
- CPPUNIT_ASSERT_MESSAGE("e4: Throwing function bad.", e4.throwing_fn().empty());
-
- string msg5("exception5");
- jexception e5(5, msg5);
- CPPUNIT_ASSERT_MESSAGE("e5: Error code bad.", e5.err_code() == 5);
- CPPUNIT_ASSERT_MESSAGE("e5: Additional information bad.",
- e5.additional_info().compare(msg5) == 0);
- CPPUNIT_ASSERT_MESSAGE("e5: Throwing class bad.", e5.throwing_class().empty());
- CPPUNIT_ASSERT_MESSAGE("e5: Throwing function bad.", e5.throwing_fn().empty());
-
- jexception e6(6, "class6", "fn6");
- CPPUNIT_ASSERT_MESSAGE("e6: Error code bad.", e6.err_code() == 6);
- CPPUNIT_ASSERT_MESSAGE("e6: Additional information bad.", e6.additional_info().empty());
- CPPUNIT_ASSERT_MESSAGE("e6: Throwing class bad.",
- e6.throwing_class().compare("class6") == 0);
- CPPUNIT_ASSERT_MESSAGE("e6: Throwing function bad.", e6.throwing_fn().compare("fn6") == 0);
-
- string cls7("class7");
- string fn7("fn7");
- jexception e7(7, cls7, fn7);
- CPPUNIT_ASSERT_MESSAGE("e7: Error code bad.", e7.err_code() == 7);
- CPPUNIT_ASSERT_MESSAGE("e7: Additional information bad.", e7.additional_info().empty());
- CPPUNIT_ASSERT_MESSAGE("e7: Throwing class bad.", e7.throwing_class().compare(cls7) == 0);
- CPPUNIT_ASSERT_MESSAGE("e7: Throwing function bad.", e7.throwing_fn().compare(fn7) == 0);
-
- jexception e8(8, "exception8", "class8", "fn8");
- CPPUNIT_ASSERT_MESSAGE("e8: Error code bad.", e8.err_code() == 8);
- CPPUNIT_ASSERT_MESSAGE("e8: Additional information bad.",
- e8.additional_info().compare("exception8") == 0);
- CPPUNIT_ASSERT_MESSAGE("e8: Throwing class bad.",
- e8.throwing_class().compare("class8") == 0);
- CPPUNIT_ASSERT_MESSAGE("e8: Throwing function bad.", e8.throwing_fn().compare("fn8") == 0);
-
- string msg9("exception9");
- string cls9("class9");
- string fn9("fn9");
- jexception e9(9, msg9, cls9, fn9);
- CPPUNIT_ASSERT_MESSAGE("e9: Error code bad.", e9.err_code() == 9);
- CPPUNIT_ASSERT_MESSAGE("e9: Additional information bad.",
- e9.additional_info().compare(msg9) == 0);
- CPPUNIT_ASSERT_MESSAGE("e9: Throwing class bad.", e9.throwing_class().compare(cls9) == 0);
- CPPUNIT_ASSERT_MESSAGE("e9: Throwing function bad.", e9.throwing_fn().compare(fn9) == 0);
+ {
+ jexception e0;
+ CPPUNIT_ASSERT_MESSAGE("e1: Error code bad.", e0.err_code() == 0);
+ CPPUNIT_ASSERT_MESSAGE("e1: Additional information bad.", e0.additional_info() == NULL);
+ CPPUNIT_ASSERT_MESSAGE("e1: Throwing class bad.", e0.throwing_class() == NULL);
+ CPPUNIT_ASSERT_MESSAGE("e1: Throwing function bad.", e0.throwing_fn() == NULL);
+ }
+ {
+ jexception e1(1);
+ CPPUNIT_ASSERT_MESSAGE("e1: Error code bad.", e1.err_code() == 1);
+ CPPUNIT_ASSERT_MESSAGE("e1: Additional information bad.", e1.additional_info() == NULL);
+ CPPUNIT_ASSERT_MESSAGE("e1: Throwing class bad.", e1.throwing_class() == NULL);
+ CPPUNIT_ASSERT_MESSAGE("e1: Throwing function bad.", e1.throwing_fn() == NULL);
+ }
+ {
+ jexception e2("exception2");
+ CPPUNIT_ASSERT_MESSAGE("e2: Error code bad.", e2.err_code() == 0);
+ CPPUNIT_ASSERT_MESSAGE("e2: Additional information bad.",
+ ::strcmp(e2.additional_info(), "exception2") == 0);
+ CPPUNIT_ASSERT_MESSAGE("e2: Throwing class bad.", e2.throwing_class() == NULL);
+ CPPUNIT_ASSERT_MESSAGE("e2: Throwing function bad.", e2.throwing_fn() == NULL);
+ }
+ {
+ jexception e3(3, "exception3");
+ CPPUNIT_ASSERT_MESSAGE("e3: Error code bad.", e3.err_code() == 3);
+ CPPUNIT_ASSERT_MESSAGE("e3: Additional information bad.",
+ ::strcmp(e3.additional_info(), "exception3") == 0);
+ CPPUNIT_ASSERT_MESSAGE("e3: Throwing class bad.", e3.throwing_class() == NULL);
+ CPPUNIT_ASSERT_MESSAGE("e3: Throwing function bad.", e3.throwing_fn() == NULL);
+ }
+ {
+ jexception e4(4, "class4", "fn4");
+ CPPUNIT_ASSERT_MESSAGE("e4: Error code bad.", e4.err_code() == 4);
+ CPPUNIT_ASSERT_MESSAGE("e4: Additional information bad.", e4.additional_info() == NULL);
+ CPPUNIT_ASSERT_MESSAGE("e4: Throwing class bad.",
+ ::strcmp(e4.throwing_class(), "class4") == 0);
+ CPPUNIT_ASSERT_MESSAGE("e4: Throwing function bad.",
+ ::strcmp(e4.throwing_fn(), "fn4") == 0);
+ }
+ {
+ jexception e5(5, "exception5", "class5", "fn5");
+ CPPUNIT_ASSERT_MESSAGE("e5: Error code bad.", e5.err_code() == 5);
+ CPPUNIT_ASSERT_MESSAGE("e5: Additional information bad.",
+ ::strcmp(e5.additional_info(), "exception5") == 0);
+ CPPUNIT_ASSERT_MESSAGE("e5: Throwing class bad.",
+ ::strcmp(e5.throwing_class(), "class5") == 0);
+ CPPUNIT_ASSERT_MESSAGE("e5: Throwing function bad.",
+ ::strcmp(e5.throwing_fn(), "fn5") == 0);
+ }
}
private:
Modified: store/trunk/cpp/tests/jrnl/jtest.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/tests/jrnl/jtest.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -285,7 +285,7 @@
{
ss << "Illegal number of args: expected 2, found " << (argc - 1) <<
" (Hint: use \"jtest [test_def_file] [testnum]\")";
- throw rhm::journal::jexception(EXCEPTION_BASE+0, ss.str());
+ throw rhm::journal::jexception(EXCEPTION_BASE+0, ss.str().c_str());
}
*test_file_name = argv[1];
if (argv[2][0] == '-')
@@ -293,7 +293,7 @@
if (strcspn(argv[2], num_chars) != 1)
{
ss << "Test number argument \"" << argv[2] << "\" not a valid number.";
- throw rhm::journal::jexception(EXCEPTION_BASE+1, ss.str());
+ throw rhm::journal::jexception(EXCEPTION_BASE+1, ss.str().c_str());
}
}
else
@@ -301,14 +301,14 @@
if (strcspn(argv[2], num_chars) != 0)
{
ss << "Test number argument \"" << argv[2] << "\" not a valid number.";
- throw rhm::journal::jexception(EXCEPTION_BASE+2, ss.str());
+ throw rhm::journal::jexception(EXCEPTION_BASE+2, ss.str().c_str());
}
}
*test_num = atoi(argv[2]);
if (*test_num < 0)
{
ss << "Illegal test number \""<< test_num << "\"";
- throw rhm::journal::jexception(EXCEPTION_BASE+3, ss.str());
+ throw rhm::journal::jexception(EXCEPTION_BASE+3, ss.str().c_str());
}
}
Modified: store/trunk/cpp/tests/jrnl/msg_consumer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/tests/jrnl/msg_consumer.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -240,7 +240,8 @@
ss << " is valid, but exptected size must lie between " << min_msg_size;
ss << " and " << max_msg_size;
}
- throw rhm::journal::jexception(EXCEPTION_BASE+3, ss.str(), "msg_consumer", "check_msg");
+ throw rhm::journal::jexception(EXCEPTION_BASE+3, ss.str().c_str(), "msg_consumer",
+ "check_msg");
}
if (chk_data)
{
@@ -253,7 +254,7 @@
std::stringstream ss;
ss << "Message " << msgCntr << " failed content check at char " << i;
ss << ": found \'" << found << "\'; expected \'" << expected << "\'";
- throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str(), "msg_consumer",
+ throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str().c_str(), "msg_consumer",
"check_msg");
}
}
@@ -276,7 +277,8 @@
ss << " is valid, but exptected size must lie between " << min_xid_size;
ss << " and " << max_xid_size;
}
- throw rhm::journal::jexception(EXCEPTION_BASE+5, ss.str(), "msg_consumer", "check_xid");
+ throw rhm::journal::jexception(EXCEPTION_BASE+5, ss.str().c_str(), "msg_consumer",
+ "check_xid");
}
if (chk_xid_data)
{
@@ -289,7 +291,7 @@
std::stringstream ss;
ss << "Message " << msgCntr << " failed XID check at char " << i;
ss << ": found \'" << found << "\'; expected \'" << expected << "\'";
- throw rhm::journal::jexception(EXCEPTION_BASE+6, ss.str(), "msg_consumer",
+ throw rhm::journal::jexception(EXCEPTION_BASE+6, ss.str().c_str(), "msg_consumer",
"check_xid");
}
}
@@ -307,7 +309,7 @@
ss << "Message " << msgCntr << " failed transience check: found ";
ss << (transient_flag?"transient":"persistent") << "; expected ";
ss << (transient_expected_flag?"transient":"persistent") << ".";
- throw rhm::journal::jexception(EXCEPTION_BASE+7, ss.str(), "msg_consumer",
+ throw rhm::journal::jexception(EXCEPTION_BASE+7, ss.str().c_str(), "msg_consumer",
"check_transience");
}
}
@@ -323,7 +325,7 @@
ss << "Message " << msgCntr << " failed external check: found ";
ss << (external_flag?"external":"internal") << "; expected ";
ss << (external_expected_flag?"external":"internal") << ".";
- throw rhm::journal::jexception(EXCEPTION_BASE+8, ss.str(), "msg_consumer",
+ throw rhm::journal::jexception(EXCEPTION_BASE+8, ss.str().c_str(), "msg_consumer",
"check_transience");
}
}
Modified: store/trunk/cpp/tests/jrnl/msg_producer.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-10 01:48:38 UTC (rev 1280)
+++ store/trunk/cpp/tests/jrnl/msg_producer.cpp 2007-11-10 05:09:44 UTC (rev 1281)
@@ -212,8 +212,8 @@
std::stringstream ss;
ss << "msg_producer::produce() Unexpected msg state: id=" <<
dtokp->id() << " ws=" << wsstr << " res=" << iores_str[eres];
- throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str(), "msg_producer",
- "produce");
+ throw rhm::journal::jexception(EXCEPTION_BASE+4, ss.str().c_str(),
+ "msg_producer", "produce");
}
//print_dbug(msgCntr, size, (char*)msg, true);
@@ -355,8 +355,8 @@
std::stringstream ss;
ss << "msg_producer::send_deferred_dequeues() Unexpected msg state: id=" <<
ddtokp->id() << " ws=" << wsstr << " res=" << iores_str[dres];
- throw rhm::journal::jexception(EXCEPTION_BASE+7, ss.str(), "msg_producer",
- "send_deferred_dequeues");
+ throw rhm::journal::jexception(EXCEPTION_BASE+7, ss.str().c_str(),
+ "msg_producer", "send_deferred_dequeues");
}
}
@@ -398,7 +398,7 @@
ss << "msg_producer::send_deferred_dequeues() "
"Unexpected msg state: id=" << ddtokp->id() << " ws=" <<
wsstr << " res=" << iores_str[dres];
- throw rhm::journal::jexception(EXCEPTION_BASE+9, ss.str(),
+ throw rhm::journal::jexception(EXCEPTION_BASE+9, ss.str().c_str(),
"msg_producer", "send_deferred_dequeues");
}
}
@@ -428,7 +428,7 @@
std::stringstream ss;
ss << "Journal flush phase 1 failed, _num_msgs_enq=" << _num_msgs_enq;
ss << " num_msgs_sent=" << num_msgs_sent;
- throw rhm::journal::jexception(EXCEPTION_BASE+10, ss.str(), "msg_producer",
+ throw rhm::journal::jexception(EXCEPTION_BASE+10, ss.str().c_str(), "msg_producer",
"jrnl_flush");
}
//std::cout << "+" << std::flush;
@@ -469,8 +469,8 @@
std::stringstream ss;
ss << "Journal flush phase 2 failed, _num_msgs_deq=" << _num_msgs_deq;
ss << " num_msgs_sent=" << num_msgs_sent;
- throw rhm::journal::jexception(EXCEPTION_BASE+12, ss.str(), "msg_producer",
- "jrnl_flush");
+ throw rhm::journal::jexception(EXCEPTION_BASE+12, ss.str().c_str(),
+ "msg_producer", "jrnl_flush");
}
//std::cout << "*" << std::flush;
jc.get_wr_events();
17 years, 1 month
rhmessaging commits: r1280 - store/trunk/cpp/tests.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-11-09 20:48:38 -0500 (Fri, 09 Nov 2007)
New Revision: 1280
Modified:
store/trunk/cpp/tests/OrderingTest.cpp
store/trunk/cpp/tests/SimpleTest.cpp
store/trunk/cpp/tests/TransactionalTest.cpp
store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
Log:
Tests compiles broken as result of qpid checkin 593692; fixed by adding local enum defn for PERSISTENT.
Modified: store/trunk/cpp/tests/OrderingTest.cpp
===================================================================
--- store/trunk/cpp/tests/OrderingTest.cpp 2007-11-09 17:04:09 UTC (rev 1279)
+++ store/trunk/cpp/tests/OrderingTest.cpp 2007-11-10 01:48:38 UTC (rev 1280)
@@ -40,6 +40,8 @@
using namespace qpid::broker;
using namespace qpid::framing;
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
class OrderingTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(OrderingTest);
Modified: store/trunk/cpp/tests/SimpleTest.cpp
===================================================================
--- store/trunk/cpp/tests/SimpleTest.cpp 2007-11-09 17:04:09 UTC (rev 1279)
+++ store/trunk/cpp/tests/SimpleTest.cpp 2007-11-10 01:48:38 UTC (rev 1280)
@@ -45,6 +45,8 @@
using namespace qpid::broker;
using namespace qpid::framing;
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
struct DummyHandler : OutputHandler
{
std::vector<AMQFrame> frames;
@@ -56,6 +58,7 @@
class SimpleTest : public CppUnit::TestCase
{
+
CPPUNIT_TEST_SUITE(SimpleTest);
CPPUNIT_TEST(testCreateDeleteSync);
CPPUNIT_TEST(testEmptyRecoverSync);
Modified: store/trunk/cpp/tests/TransactionalTest.cpp
===================================================================
--- store/trunk/cpp/tests/TransactionalTest.cpp 2007-11-09 17:04:09 UTC (rev 1279)
+++ store/trunk/cpp/tests/TransactionalTest.cpp 2007-11-10 01:48:38 UTC (rev 1280)
@@ -38,6 +38,8 @@
using namespace qpid::broker;
using namespace qpid::framing;
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
class TransactionalTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(TransactionalTest);
Modified: store/trunk/cpp/tests/TwoPhaseCommitTest.cpp
===================================================================
--- store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-11-09 17:04:09 UTC (rev 1279)
+++ store/trunk/cpp/tests/TwoPhaseCommitTest.cpp 2007-11-10 01:48:38 UTC (rev 1280)
@@ -38,6 +38,8 @@
using namespace qpid::broker;
using namespace qpid::framing;
+enum DeliveryMode { TRANSIENT = 1, PERSISTENT = 2};
+
class TwoPhaseCommitTest : public CppUnit::TestCase
{
CPPUNIT_TEST_SUITE(TwoPhaseCommitTest);
17 years, 1 month
rhmessaging commits: r1279 - mgmt/mint.
by rhmessaging-commits@lists.jboss.org
Author: nunofsantos
Date: 2007-11-09 12:04:09 -0500 (Fri, 09 Nov 2007)
New Revision: 1279
Modified:
mgmt/mint/schemaparser.py
Log:
updted to reflect changes in xml schema
Modified: mgmt/mint/schemaparser.py
===================================================================
--- mgmt/mint/schemaparser.py 2007-11-08 22:31:09 UTC (rev 1278)
+++ mgmt/mint/schemaparser.py 2007-11-09 17:04:09 UTC (rev 1279)
@@ -8,20 +8,27 @@
# mapping between xml schema types and database column types
dataTypesMap = {}
sqlOutput = ""
+ indexes = ""
+ currentTable = ""
syle = None
def __init__(self, style):
self.sqlOutput = ""
+ self.indexes = ""
+ self.currentTable = ""
self.style = style
- self.dataTypesMap["string"] = "VARCHAR(2000)"
+ # see xml/MgmtTypes.xml
+ self.dataTypesMap["objId"] = "INT8"
+ self.dataTypesMap["uint8"] = self.dataTypesMap["hilo8"] = self.dataTypesMap["count8"] = "INT2"
+ self.dataTypesMap["uint16"] = self.dataTypesMap["hilo16"] = self.dataTypesMap["count16"] = "INT2"
+ self.dataTypesMap["uint32"] = self.dataTypesMap["hilo32"] = self.dataTypesMap["count32"] = "INT4"
+ self.dataTypesMap["uint64"] = self.dataTypesMap["hilo64"] = self.dataTypesMap["count64"] = "INT8"
self.dataTypesMap["bool"] = "BOOLEAN"
- self.dataTypesMap["uint16"] = "INT2"
- self.dataTypesMap["uint32"] = "INT4"
- self.dataTypesMap["uint32_wm"] = "INT4"
- self.dataTypesMap["uint64"] = "INT8"
- self.dataTypesMap["ipAddress"] = "VARCHAR(100)"
- self.dataTypesMap["enum"] = "VARCHAR(100) CHECK ("
- self.dataTypesMap["fieldTable"] = "VARCHAR(2000)"
+ self.dataTypesMap["sstr"] = "VARCHAR(1000)"
+ self.dataTypesMap["lstr"] = "VARCHAR(4000)"
+ #self.dataTypesMap["ipAddress"] = "VARCHAR(100)"
+ #self.dataTypesMap["enum"] = "VARCHAR(100) CHECK ("
+ #self.dataTypesMap["fieldTable"] = "VARCHAR(2000)"
def generate(self, name, elements, type):
self.startTable(name, type)
@@ -34,8 +41,10 @@
actualName = name
else:
actualName = name + "_stats"
- self.sqlOutput += "CREATE TABLE " + actualName + " (\n"
+ self.currentTable = actualName
+ self.sqlOutput += "\nCREATE TABLE " + actualName + " (\n"
self.sqlOutput += " id BIGSERIAL PRIMARY KEY,\n"
+ self.sqlOutput += " id_original BIGINT,\n"
if (type == "config"):
self.sqlOutput += " " + name + "_stats_id BIGINT,\n"
else:
@@ -48,8 +57,14 @@
def generateTimestampColumn(self, col):
self.sqlOutput += " " + col + "_time TIMESTAMP,\n"
+ def generateIndex(self, name):
+ self.indexes += "\nCREATE INDEX " + self.currentTable + "_" + name + "_index ON " + self.currentTable + "(" + name + ");\n"
+
def generateColumn(self, elem, suffix=""):
actualName = self.style.pythonAttrToDBColumn(elem["@name"] + suffix)
+ if (actualName.endswith("_id")):
+ # handle case where XML attrib ends in "Id", which confuses SqlObject into thinking it's a foreign key
+ actualName = actualName.replace("_id", "_ident")
if (elem["@type"].startswith("enum")):
actualType = "enum"
params = actualName + " IN ("
@@ -64,14 +79,18 @@
self.sqlOutput += " " + foreignKeyTable + "_id BIGINT REFERENCES " + foreignKeyTable + ",\n"
else:
self.sqlOutput += " " + actualName + " " + self.dataTypesMap[actualType] + params + ",\n"
- if (elem["@type"].endswith("_wm") and suffix == ""):
+ if (elem["@type"].startswith("hilo") and suffix == ""):
self.generateColumn(elem, "High")
self.generateColumn(elem, "Low")
+ if (elem["@index"] == "y"):
+ self.generateIndex(actualName)
def endTable(self, name, type):
- self.sqlOutput = self.sqlOutput[:-2] + "\n);\n\n"
+ self.sqlOutput = self.sqlOutput[:-2] + "\n);\n" + self.indexes
if (type == "inst"):
- self.sqlOutput += "ALTER TABLE " + name + " ADD FOREIGN KEY (" + name + "_stats_id) REFERENCES " + name + "_stats;\n\n"
+ self.sqlOutput += "\nALTER TABLE " + name + " ADD FOREIGN KEY (" + name + "_stats_id) REFERENCES " + name + "_stats;\n"
+ self.currentTable = ""
+ self.indexes = ""
def getCode(self):
return self.sqlOutput
@@ -82,12 +101,14 @@
"""generates Python code from broker XML schema"""
pythonOutput = ""
+ additional = ""
syle = None
-
+
def __init__(self, style, dsn):
self.pythonOutput = "from sqlobject import *\n\n" + \
"conn = connectionForURI('" + dsn + "')\n" + \
"sqlhub.processConnection = conn\n\n"
+ self.additional = ""
self.style = style
def attrNameFromDbColumn(self, name, prefix="", removeSuffix=""):
@@ -104,18 +125,20 @@
self.generateMethod(elem)
self.endClass(name)
- def generateForeignKeys(self, name, elements):
- dbName = name
+ def generateAdditionalAttribs(self, name, elements):
name = self.attrNameFromDbColumn(name)
for elem in elements:
refName = elem["@name"]
if (refName.endswith("Ref")):
+ # generate foreign keys
refName = self.attrNameFromDbColumn(refName, "Mgmt", "Ref")
- self.pythonOutput += "\n" + refName + ".sqlmeta.addJoin(MultipleJoin('" + name + \
- "', joinMethodName='all" + name.replace("Mgmt", "") + "s'))\n\n"
+ # add missing attribute (not added correctly with SqlObject 0.7.7; may need to be removed in later versions)
+ self.pythonOutput += " _SO_class_" + self.style.pythonAttrToDBColumn(refName).capitalize() + " = " + refName + "()\n"
+ self.additional += "\n" + refName + ".sqlmeta.addJoin(MultipleJoin('" + name + \
+ "', joinMethodName='all" + name.replace("Mgmt", "") + "s'))"
def startClass(self, name):
- self.pythonOutput += "class " + name + "(SQLObject):\n"
+ self.pythonOutput += "\nclass " + name + "(SQLObject):\n"
self.pythonOutput += " class sqlmeta:\n"
self.pythonOutput += " fromDatabase = True\n"
@@ -126,14 +149,16 @@
comment = ""
self.pythonOutput += " def " + elem["@name"] + "():\n"
self.pythonOutput += comment
- self.pythonOutput += " pass\n\n"
+ self.pythonOutput += " pass\n"
def endClass(self, name=""):
+ if (self.additional != ""):
+ self.pythonOutput += self.additional + "\n"
+ self.additional = ""
if (name != "" and not name.endswith("Stats")):
# add missing attribute (not added correctly with SqlObject 0.7.7; may need to be removed in later versions)
self.pythonOutput += " _SO_class_" + self.style.pythonAttrToDBColumn(name).capitalize() + "_stats = " + name + "Stats()\n"
- self.pythonOutput += "\n"
-
+
def getCode(self):
return self.pythonOutput
@@ -166,13 +191,13 @@
sqlFile = open(self.options["sqlOutput"], "w")
pythonFile = open(self.options["pythonOutput"], "w")
schema = qpid.mllib.xml_parse(self.options["schemaXML"])
- objects = schema.query["schema/object"]
- for obj in objects:
- actualName = "mgmt_" + obj["@name"]
- self.sqlGen.generate(actualName, obj.query["configElement"], "config")
- self.sqlGen.generate(actualName, obj.query["instElement"], "inst")
- self.pythonGen.generate(actualName, obj.query["method"])
- self.pythonGen.generateForeignKeys(actualName, obj.query["configElement"])
+ classes = schema.query["schema/class"]
+ for cls in classes:
+ actualName = "mgmt_" + cls["@name"]
+ self.sqlGen.generate(actualName, cls.query["configElement"], "config")
+ self.sqlGen.generate(actualName, cls.query["instElement"], "inst")
+ self.pythonGen.generate(actualName, cls.query["method"])
+ self.pythonGen.generateAdditionalAttribs(actualName, cls.query["configElement"])
sqlFile.write(self.sqlGen.getCode())
pythonFile.write(self.pythonGen.getCode())
sqlFile.close()
17 years, 1 month
rhmessaging commits: r1278 - in mgmt/cumin: resources and 1 other directory.
by rhmessaging-commits@lists.jboss.org
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;
17 years, 1 month