rhmessaging commits: r1466 - mgmt/notes.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-12 13:28:51 -0500 (Wed, 12 Dec 2007)
New Revision: 1466
Modified:
mgmt/notes/justin-todo.txt
Log:
Todo updates.
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-12 16:42:57 UTC (rev 1465)
+++ mgmt/notes/justin-todo.txt 2007-12-12 18:28:51 UTC (rev 1466)
@@ -26,6 +26,17 @@
* Prevent users from mapping a broker to a group more than once
+ * Deal with problem of calling method on broker that is not there
+
+ * Only put something in pending actions if the call succeeds
+
+ * Fix initial group box in broker register form, or remove it
+
+ * Handle other exception conditions on broker connect more gracefully
+
+ * Need to handle exceptions in broker connect thread, so it doesn't
+ stop trying
+
Deferred
* Add a do_get_item_count, and cache result for use by get_item_count
18 years, 4 months
rhmessaging commits: r1465 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-12 11:42:57 -0500 (Wed, 12 Dec 2007)
New Revision: 1465
Modified:
mgmt/cumin/python/cumin/client.strings
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/widgets.strings
Log:
Hides the errors and warnings in status boxes. We don't have real
data for them yet.
Adds pending actions where it was missing.
Fixes up client status javascript.
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2007-12-12 16:33:33 UTC (rev 1464)
+++ mgmt/cumin/python/cumin/client.strings 2007-12-12 16:42:57 UTC (rev 1465)
@@ -36,24 +36,26 @@
function updateClientStatus(id, client) {
updateStatus(id, client);
- var m = client.measurement;
- var mdata = {
+ var s = client.stat;
+ var sdata = {
"tr": [
null,
- {"td": [m.msgsProduced.rate, m.bytesProduced.rate]},
- {"td": [m.msgsConsumed.rate, m.bytesConsumed.rate]}
+ {"td": [s.msgsProduced.rate, s.bytesProduced.rate]},
+ {"td": [s.msgsConsumed.rate, s.bytesConsumed.rate]}
]
};
- wooly.doc().elembyid(id).descendant("table.tbody").update(mdata);
+ wooly.doc().elembyid(id).descendant("table.tbody").update(sdata);
}
[ClientStatus.html]
<div id="{id}" class="{class}">
- <h2>Client Status</h2>
+ <h2>Status</h2>
- <div>{status_info}</div>
+ <!-- <div>{status_info}</div> -->
+ <div>{pending_actions}</div>
+
<table>
<tr>
<th></th>
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-12-12 16:33:33 UTC (rev 1464)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-12-12 16:42:57 UTC (rev 1465)
@@ -103,9 +103,9 @@
[ExchangeStatus.html]
<div id="{id}" class="{class}">
- <h2>Exchange Status</h2>
+ <h2>Status</h2>
- <div>{status_info}</div>
+ <!-- <div>{status_info}</div> -->
<div>{actions_pending}</div>
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-12-12 16:33:33 UTC (rev 1464)
+++ mgmt/cumin/python/cumin/queue.strings 2007-12-12 16:42:57 UTC (rev 1465)
@@ -109,9 +109,9 @@
[QueueStatus.html]
<div id="{id}" class="{class}">
- <h2>Queue Status</h2>
+ <h2>Status</h2>
- <div>{status_info}</div>
+ <!-- <div>{status_info}</div> -->
<div>{actions_pending}</div>
Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings 2007-12-12 16:33:33 UTC (rev 1464)
+++ mgmt/cumin/python/cumin/widgets.strings 2007-12-12 16:42:57 UTC (rev 1465)
@@ -15,14 +15,15 @@
[CuminStatus.javascript]
function updateStatus(id, object) {
+ var status = wooly.doc().elembyid(id);
+
+ /*
var ecount = object.events.errors
var errors = ecount + " " + (ecount == "1" && "error" || "errors");
var wcount = object.events.warnings
var warnings = wcount + " " + (wcount == "1" && "warning" || "warnings");
- var status = wooly.doc().elembyid(id);
-
if (ecount != "0") {
status.setattr("class", "mstatus red");
} else if (wcount != "0") {
@@ -30,10 +31,11 @@
} else {
status.setattr("class", "mstatus green");
}
+ */
var divs = status.elems("div", null, null, 0, 2)
- divs.next().set(errors + ", " + warnings);
+ //divs.next().set(errors + ", " + warnings);
var acount = object.actions.pending;
var actions = acount + " " + (acount == "1" && "action" || "actions") + " pending";
@@ -45,7 +47,7 @@
<div id="{id}" class="{class}">
<h2>Status</h2>
- <div>{status_info}</div>
+ <!-- <div>{status_info}</div> -->
<div>{actions_pending}</div>
</div>
18 years, 4 months
rhmessaging commits: r1464 - in mgmt: notes and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-12 11:33:33 -0500 (Wed, 12 Dec 2007)
New Revision: 1464
Modified:
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/widgets.py
mgmt/notes/justin-todo.txt
Log:
Paginates queue and exchange bindings.
Adds a BindingSet used in common by ExchangeBindingSet and
QueueBindingSet.
Adds a PaginatedItemSet for use in any collection that is to be
paginated.
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/exchange.py 2007-12-12 16:33:33 UTC (rev 1464)
@@ -204,12 +204,17 @@
def render_updated(self, session, exchange):
return fmt_datetime(exchange.recTime)
-class ExchangeBindingSet(ItemSet):
+class ExchangeBindingSet(BindingSet):
def get_title(self, session, exchange):
- return "Queue Bindings %s" % fmt_count(len(exchange.bindings))
+ return "Queue Bindings %s" % \
+ fmt_count(self.get_item_count(session, exchange))
+ def get_item_count(self, session, exchange):
+ return Binding.select(Binding.q.exchangeID == exchange.id).count()
+
def do_get_items(self, session, exchange):
- return sorted_by(exchange.bindings, "id")
+ start, end = self.get_bounds(session)
+ return Binding.select(Binding.q.exchangeID == exchange.id)[start:end]
def render_item_href(self, session, binding):
branch = session.branch()
@@ -219,17 +224,6 @@
def render_item_name(self, session, binding):
return binding.queue.name
- def render_item_binding_key(self, session, binding):
- return binding.bindingKey
-
- def render_item_messages_matched(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return stat.value(binding)
-
- def render_item_messages_matched_rate(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return fmt_rate(stat.rate(binding), "msg", "sec")
-
class ExchangeForm(CuminForm):
def __init__(self, app, name):
super(ExchangeForm, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-12-12 16:33:33 UTC (rev 1464)
@@ -169,6 +169,9 @@
{tabs}
[ExchangeBindingSet.html]
+<div class="rfloat">{page}</div>
+<ul class="radiotabs"> </ul>
+
<table class="ExchangeBindingSet mobjects">
<tr>
<th>Queue</th>
@@ -181,7 +184,7 @@
[ExchangeBindingSet.item_html]
<tr>
- <td><a href="{item_href}">Queue '{item_name}'</a></td>
+ <td><a href="{item_href}">{item_name}</a></td>
<td>{item_binding_key}</td>
<td class="ralign">{item_messages_matched_rate}</td>
<td class="ralign">{item_messages_matched}</td>
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/queue.py 2007-12-12 16:33:33 UTC (rev 1464)
@@ -15,22 +15,16 @@
strings = StringCatalog(__file__)
-class QueueSet(ItemSet):
+class QueueSet(PaginatedItemSet):
def __init__(self, app, name):
super(QueueSet, self).__init__(app, name)
self.unit = UnitSwitch(app, "unit")
self.add_child(self.unit)
- self.paginator = Paginator(app, "page")
- self.add_child(self.paginator)
-
def get_title(self, session, vhost):
return "Queues %s" % fmt_count(self.get_item_count(session, vhost))
- def do_process(self, session, vhost):
- self.paginator.set_count(session, self.get_item_count(session, vhost))
-
def render_unit_singular(self, session, vhost):
return self.unit.get(session) == "b" and "Byte" or "Msg."
@@ -42,9 +36,10 @@
def do_get_items(self, session, vhost):
if vhost:
- start, end = self.paginator.get_bounds(session)
+ start, end = self.get_bounds(session)
return Queue.select(Queue.q.vhostID == vhost.id,
- join=LEFTJOINOn(None, QueueStats, Queue.q.statsCurrID == QueueStats.q.id),
+ join=LEFTJOINOn(None, QueueStats,
+ Queue.q.statsCurrID == QueueStats.q.id),
orderBy="name")[start:end]
def render_item_link(self, session, queue):
@@ -213,12 +208,17 @@
self.parent().show_purge(branch)
return branch.marshal()
-class QueueBindingSet(ItemSet):
+class QueueBindingSet(BindingSet):
def get_title(self, session, queue):
- return "Exchange Bindings %s" % fmt_count(len(queue.bindings))
+ return "Exchange Bindings %s" % \
+ fmt_count(self.get_item_count(session, queue))
+ def get_item_count(self, session, queue):
+ return Binding.select(Binding.q.queueID == queue.id).count()
+
def do_get_items(self, session, queue):
- return sorted_by(queue.bindings, "id")
+ start, end = self.get_bounds(session)
+ return Binding.select(Binding.q.queueID == queue.id)[start:end]
def render_item_href(self, session, binding):
branch = session.branch()
@@ -228,17 +228,6 @@
def render_item_name(self, session, binding):
return binding.exchange.name
- def render_item_binding_key(self, session, binding):
- return binding.bindingKey
-
- def render_item_messages_matched(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return stat.value(binding)
-
- def render_item_messages_matched_rate(self, session, binding):
- stat = self.app.model.binding.get_stat("msgMatched")
- return fmt_rate(stat.rate(binding), "msg", "sec")
-
class QueueForm(CuminForm):
def __init__(self, app, name):
super(QueueForm, self).__init__(app, name)
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/queue.strings 2007-12-12 16:33:33 UTC (rev 1464)
@@ -190,6 +190,9 @@
{tabs}
[QueueBindingSet.html]
+<div class="rfloat">{page}</div>
+<ul class="radiotabs"> </ul>
+
<table class="QueueBindingSet mobjects">
<tr>
<th>Exchange</th>
@@ -202,7 +205,7 @@
[QueueBindingSet.item_html]
<tr>
- <td><a href="{item_href}">Exchange '{item_name}'</a></td>
+ <td><a href="{item_href}">{item_name}</a></td>
<td>{item_binding_key}</td>
<td class="ralign">{item_messages_matched_rate}</td>
<td class="ralign">{item_messages_matched}</td>
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/cumin/python/cumin/widgets.py 2007-12-12 16:33:33 UTC (rev 1464)
@@ -3,6 +3,7 @@
from wooly import *
from wooly.widgets import *
from wooly.forms import *
+from mint import *
from parameters import *
from charts import *
@@ -311,6 +312,21 @@
def render_item_content(self, session, page):
return page + 1
+class PaginatedItemSet(ItemSet):
+ def __init__(self, app, name):
+ super(PaginatedItemSet, self).__init__(app, name)
+
+ self.paginator = Paginator(app, "page")
+ self.add_child(self.paginator)
+
+ def do_process(self, session, object):
+ super(PaginatedItemSet, self).do_process(session, object)
+
+ self.paginator.set_count(session, self.get_item_count(session, object))
+
+ def get_bounds(self, session):
+ return self.paginator.get_bounds(session)
+
class SQLObjectItemSet(ItemSet):
def get_item_count(self, session, object):
items = self.get_items(session, object)
@@ -329,10 +345,35 @@
self.add_parameter(self.get_parameter())
def do_get_items(self, session, model):
- return list(BrokerGroup.select())
+ return list(BrokerGroup.select()) #XXX avoid list()ing this?
def render_item_value(self, session, group):
return group.id
def render_item_content(self, session, group):
return group.name
+
+class BindingSet(PaginatedItemSet):
+ def __init__(self, app, name):
+ super(BindingSet, self).__init__(app, name)
+
+ def get_title(self, session, queue):
+ return "Bindings"
+
+ def get_item_count(self, session, object):
+ return Binding.select().count()
+
+ def do_get_items(self, session, object):
+ start, end = self.get_bounds(session)
+ return Binding.select()[start:end]
+
+ def render_item_binding_key(self, session, binding):
+ return binding.bindingKey
+
+ def render_item_messages_matched(self, session, binding):
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return stat.value(binding)
+
+ def render_item_messages_matched_rate(self, session, binding):
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return fmt_rate(stat.rate(binding), "msg", "sec")
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-12 15:37:02 UTC (rev 1463)
+++ mgmt/notes/justin-todo.txt 2007-12-12 16:33:33 UTC (rev 1464)
@@ -18,8 +18,6 @@
* Email amqp-list, Jonathan, and Lana with doc requirements for mgmt
- * Paginate queue bindings in exchange view
-
* Paginate producers
* Paginate consumers
18 years, 4 months
rhmessaging commits: r1463 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-12 10:37:02 -0500 (Wed, 12 Dec 2007)
New Revision: 1463
Modified:
mgmt/cumin/python/cumin/model.py
Log:
Removes duplicate adder calls.
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-12-12 15:33:22 UTC (rev 1462)
+++ mgmt/cumin/python/cumin/model.py 2007-12-12 15:37:02 UTC (rev 1463)
@@ -10,13 +10,8 @@
self.classes = dict()
self.queue = CuminQueue(self)
- self.add_class(self.queue)
-
self.exchange = CuminExchange(self)
- self.add_class(self.exchange)
-
self.binding = CuminBinding(self)
- self.add_class(self.binding)
def add_class(self, cls):
self.classes[cls.mint_class] = cls
18 years, 4 months
rhmessaging commits: r1462 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-12 10:33:22 -0500 (Wed, 12 Dec 2007)
New Revision: 1462
Modified:
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/model.py
mgmt/cumin/python/cumin/queue.py
Log:
Adds ui metadata for binding stats and uses it to properly statify
some column values.
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-12-12 15:18:04 UTC (rev 1461)
+++ mgmt/cumin/python/cumin/exchange.py 2007-12-12 15:33:22 UTC (rev 1462)
@@ -223,11 +223,12 @@
return binding.bindingKey
def render_item_messages_matched(self, session, binding):
- return binding.statsCurr.msgMatched #XXX statify
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return stat.value(binding)
def render_item_messages_matched_rate(self, session, binding):
- value = binding.statsCurr.msgMatched #XXX statify
- return fmt_rate(value, "msg", "sec")
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return fmt_rate(stat.rate(binding), "msg", "sec")
class ExchangeForm(CuminForm):
def __init__(self, app, name):
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-12-12 15:18:04 UTC (rev 1461)
+++ mgmt/cumin/python/cumin/model.py 2007-12-12 15:33:22 UTC (rev 1462)
@@ -15,6 +15,9 @@
self.exchange = CuminExchange(self)
self.add_class(self.exchange)
+ self.binding = CuminBinding(self)
+ self.add_class(self.binding)
+
def add_class(self, cls):
self.classes[cls.mint_class] = cls
@@ -330,3 +333,14 @@
self.write_stat_xml(exchange, writer)
writer.write("</exchange>")
+
+class CuminBinding(CuminClass):
+ def __init__(self, model):
+ super(CuminBinding, self).__init__(model, "binding", Binding)
+
+ self.mint_stats_class = BindingStats
+
+ stat = CuminStat(self, "msgMatched", "int")
+ stat.title = "Msgs. Matched"
+ stat.unit = "message"
+ stat.categories = ("general")
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-12-12 15:18:04 UTC (rev 1461)
+++ mgmt/cumin/python/cumin/queue.py 2007-12-12 15:33:22 UTC (rev 1462)
@@ -232,13 +232,12 @@
return binding.bindingKey
def render_item_messages_matched(self, session, binding):
- #stat = self.app.model.binding.get_stat("msgMatched")
- return binding.statsCurr.msgMatched #XXX
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return stat.value(binding)
def render_item_messages_matched_rate(self, session, binding):
- #stat = self.app.model.binding.get_stat("msgMatched")
- value = binding.statsCurr.msgMatched #XXX
- return fmt_rate(value, "msg", "sec")
+ stat = self.app.model.binding.get_stat("msgMatched")
+ return fmt_rate(stat.rate(binding), "msg", "sec")
class QueueForm(CuminForm):
def __init__(self, app, name):
18 years, 4 months
rhmessaging commits: r1461 - in mgmt: notes and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-12 10:18:04 -0500 (Wed, 12 Dec 2007)
New Revision: 1461
Modified:
mgmt/cumin/python/cumin/model.py
mgmt/notes/justin-todo.txt
Log:
Makes the xml for object names more compact.
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2007-12-11 23:20:58 UTC (rev 1460)
+++ mgmt/cumin/python/cumin/model.py 2007-12-12 15:18:04 UTC (rev 1461)
@@ -265,8 +265,7 @@
stat.categories = ("byte", "persistent")
def write_xml(self, queue, writer):
- writer.write("<queue id=\"%i\">" % queue.id)
- writer.write("<name>%s</name>" % queue.name)
+ writer.write("<queue id=\"%i\" name=\"%s\">" % (queue.id, queue.name))
self.write_event_xml(queue, writer)
self.write_action_xml(queue, writer)
@@ -323,8 +322,8 @@
stat.categories = ("general")
def write_xml(self, exchange, writer):
- writer.write("<exchange id=\"%i\">" % exchange.id)
- writer.write("<name>%s</name>" % exchange.name)
+ writer.write("<exchange id=\"%i\" name=\"%s\">" % \
+ (exchange.id, exchange.name))
self.write_event_xml(exchange, writer)
self.write_action_xml(exchange, writer)
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-11 23:20:58 UTC (rev 1460)
+++ mgmt/notes/justin-todo.txt 2007-12-12 15:18:04 UTC (rev 1461)
@@ -10,11 +10,6 @@
* Sort in tables
- * Add a ~3 second (or use broker update interval, if we can get that)
- cache to *XmlPage
-
- * Add said cache to ChartPages as well, perhaps
-
* Render stats without values as something other than 0, say a --
* Render the "" exchange as "Default"
@@ -25,8 +20,23 @@
* Paginate queue bindings in exchange view
+ * Paginate producers
+
+ * Paginate consumers
+
+ * Paginate clients
+
+ * Prevent users from mapping a broker to a group more than once
+
Deferred
+ * Add a do_get_item_count, and cache result for use by get_item_count
+
+ * Add a ~3 second (or use broker update interval, if we can get that)
+ cache to *XmlPage
+
+ * Add said cache to ChartPages as well, perhaps
+
* Better demo data
* Make mini status tables a little prettier
18 years, 4 months
rhmessaging commits: r1460 - in store/trunk/cpp: tests/jrnl and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: kpvdr
Date: 2007-12-11 18:20:58 -0500 (Tue, 11 Dec 2007)
New Revision: 1460
Modified:
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.hpp
store/trunk/cpp/lib/jrnl/jcntl.cpp
store/trunk/cpp/lib/jrnl/jdir.cpp
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/unit_test_jexception.cpp
Log:
More tidyup - added std::string back into jexception class, also switched instances of std::stringstream for std::ostringstream.
Modified: store/trunk/cpp/lib/jrnl/data_tok.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/data_tok.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -145,10 +145,10 @@
{
if (_wstate != ENQ && rstate != UNREAD)
{
- 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().c_str(), "data_tok",
+ std::ostringstream oss;
+ oss << "Attempted to change read state to " << rstate_str(rstate);
+ oss << " while write state is not enqueued (wstate ENQ); wstate=" << wstate_str() << ".";
+ throw new jexception(jerrno::JERR_DTOK_ILLEGALSTATE, oss.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-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/deq_rec.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -386,14 +386,14 @@
std::string&
deq_rec::str(std::string& str) const
{
- std::stringstream ss;
- ss << "deq_rec: m=" << _deq_hdr._magic;
- ss << " v=" << (int)_deq_hdr._version;
- ss << " rid=" << _deq_hdr._rid;
- ss << " drid=" << _deq_hdr._deq_rid;
+ std::ostringstream oss;
+ oss << "deq_rec: m=" << _deq_hdr._magic;
+ oss << " v=" << (int)_deq_hdr._version;
+ oss << " rid=" << _deq_hdr._rid;
+ oss << " drid=" << _deq_hdr._deq_rid;
if (_xidp)
- ss << " xid=\"" << _xidp << "\"";
- str.append(ss.str());
+ oss << " xid=\"" << _xidp << "\"";
+ str.append(oss.str());
return str;
}
@@ -415,12 +415,12 @@
jrec::chk_hdr(_deq_hdr);
if (_deq_hdr._magic != RHM_JDAT_DEQ_MAGIC)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "deq magic: rid=0x" << std::setw(16) << _deq_hdr._rid;
- ss << ": expected=0x" << std::setw(8) << RHM_JDAT_DEQ_MAGIC;
- ss << " read=0x" << std::setw(2) << (int)_deq_hdr._magic;
- throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "deq_rec", "chk_hdr");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "deq magic: rid=0x" << std::setw(16) << _deq_hdr._rid;
+ oss << ": expected=0x" << std::setw(8) << RHM_JDAT_DEQ_MAGIC;
+ oss << " read=0x" << std::setw(2) << (int)_deq_hdr._magic;
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "deq_rec", "chk_hdr");
}
}
Modified: store/trunk/cpp/lib/jrnl/enq_map.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/enq_map.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/enq_map.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -67,9 +67,9 @@
pthread_mutex_unlock(&_mutex);
if (ret.second == false)
{
- std::stringstream ss;
- ss << std::hex << "rid=0x" << rid << " fid=0x" << fid;
- throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str().c_str(), "enq_map", "insert");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid << " fid=0x" << fid;
+ throw jexception(jerrno::JERR_MAP_DUPLICATE, oss.str(), "enq_map", "insert");
}
}
@@ -81,15 +81,15 @@
pthread_mutex_unlock(&_mutex);
if (itr == _map.end()) // not found in map
{
- std::stringstream ss;
- ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_fid");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid;
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.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().c_str(), "enq_map", "get_fid");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid;
+ throw jexception(jerrno::JERR_MAP_LOCKED, oss.str(), "enq_map", "get_fid");
}
return itr->second.first;
}
@@ -102,16 +102,16 @@
if (itr == _map.end()) // not found in map
{
pthread_mutex_unlock(&_mutex);
- std::stringstream ss;
- ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_remove_fid");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid;
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.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().c_str(), "enq_map", "get_remove_fid");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid;
+ throw jexception(jerrno::JERR_MAP_LOCKED, oss.str(), "enq_map", "get_remove_fid");
}
u_int16_t fid = itr->second.first;
_map.erase(itr);
@@ -140,9 +140,9 @@
if (itr == _map.end()) // not found in map
{
pthread_mutex_unlock(&_mutex);
- std::stringstream ss;
- ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_remove_fid");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid;
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "enq_map", "get_remove_fid");
}
itr->second.second = true;
pthread_mutex_unlock(&_mutex);
@@ -156,9 +156,9 @@
if (itr == _map.end()) // not found in map
{
pthread_mutex_unlock(&_mutex);
- std::stringstream ss;
- ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_remove_fid");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid;
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "enq_map", "get_remove_fid");
}
itr->second.second = false;
pthread_mutex_unlock(&_mutex);
@@ -172,9 +172,9 @@
pthread_mutex_unlock(&_mutex);
if (itr == _map.end()) // not found in map
{
- std::stringstream ss;
- ss << std::hex << "rid=0x" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "enq_map", "get_fid");
+ std::ostringstream oss;
+ oss << std::hex << "rid=0x" << rid;
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.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-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/enq_rec.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -539,14 +539,14 @@
std::string&
enq_rec::str(std::string& str) const
{
- std::stringstream ss;
- ss << "enq_rec: m=" << _enq_hdr._magic;
- ss << " v=" << (int)_enq_hdr._version;
- ss << " rid=" << _enq_hdr._rid;
+ std::ostringstream oss;
+ oss << "enq_rec: m=" << _enq_hdr._magic;
+ oss << " v=" << (int)_enq_hdr._version;
+ oss << " rid=" << _enq_hdr._rid;
if (_xidp)
- ss << " xid=\"" << _xidp << "\"";
- ss << " len=" << _enq_hdr._dsize;
- str.append(ss.str());
+ oss << " xid=\"" << _xidp << "\"";
+ oss << " len=" << _enq_hdr._dsize;
+ str.append(oss.str());
return str;
}
@@ -583,12 +583,12 @@
jrec::chk_hdr(_enq_hdr);
if (_enq_hdr._magic != RHM_JDAT_ENQ_MAGIC)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "enq magic: rid=0x" << std::setw(16) << _enq_hdr._rid;
- ss << ": expected=0x" << std::setw(8) << RHM_JDAT_ENQ_MAGIC;
- ss << " read=0x" << std::setw(2) << (int)_enq_hdr._magic;
- throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "enq_rec", "chk_hdr");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "enq magic: rid=0x" << std::setw(16) << _enq_hdr._rid;
+ oss << ": expected=0x" << std::setw(8) << RHM_JDAT_ENQ_MAGIC;
+ oss << " read=0x" << std::setw(2) << (int)_enq_hdr._magic;
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "enq_rec", "chk_hdr");
}
}
Modified: store/trunk/cpp/lib/jrnl/file_hdr.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/file_hdr.hpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/file_hdr.hpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -176,9 +176,9 @@
timespec ts;
if (::clock_gettime(CLOCK_REALTIME, &ts))
{
- std::stringstream ss;
- ss << "errno=" << errno;
- throw jexception(jerrno::JERR__RTCLOCK, ss.str().c_str(), "file_hdr", "set_time");
+ std::ostringstream oss;
+ oss << "errno=" << errno;
+ throw jexception(jerrno::JERR__RTCLOCK, oss.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-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/jcntl.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -111,9 +111,9 @@
::memset(_datafh, 0, sizeof(lfh*) * _num_jfiles);
for (u_int16_t i=0; i<_num_jfiles; i++)
{
- std::stringstream ss;
- ss << _jdir << "/" << _base_filename;
- _datafh[i] = ::new lfh(ss.str(), i, _jfsize_sblks, NULL);
+ std::ostringstream oss;
+ oss << _jdir << "/" << _base_filename;
+ _datafh[i] = ::new lfh(oss.str(), i, _jfsize_sblks, NULL);
}
// TODO: Check the following comment/note (may be obsolete):
@@ -162,9 +162,9 @@
::memset(_datafh, 0, sizeof(lfh*) * _num_jfiles);
for (u_int16_t i=0; i<_num_jfiles; i++)
{
- std::stringstream ss;
- ss << _jdir << "/" << _base_filename;
- _datafh[i] = ::new lfh(ss.str(), i, _jfsize_sblks, &_rcvdat);
+ std::ostringstream oss;
+ oss << _jdir << "/" << _base_filename;
+ _datafh[i] = ::new lfh(oss.str(), i, _jfsize_sblks, &_rcvdat);
}
// TODO: Check the following comment/note (may be obsolete):
@@ -369,9 +369,9 @@
timespec ts;
if (::clock_gettime(CLOCK_REALTIME, &ts))
{
- std::stringstream ss;
- ss << "errno=" << errno;
- throw jexception(jerrno::JERR__RTCLOCK, ss.str().c_str(), "jcntl", "write_infofile");
+ std::ostringstream oss;
+ oss << "errno=" << errno;
+ throw jexception(jerrno::JERR__RTCLOCK, oss.str(), "jcntl", "write_infofile");
}
jinf ji(_jid, _jdir.dirname(), _base_filename, _num_jfiles, _jfsize_sblks, ts);
ji.write();
@@ -586,10 +586,10 @@
rd._eo = read_pos;
return false;
}
- std::stringstream ss;
- ss << std::hex << std::setfill('0') << "Magic=0x" << std::setw(8) << h._magic;
- ss << " fid=" << fid << " foffs=0x" << std::setw(8) << read_pos;
- throw jexception(jerrno::JERR_JCNTL_UNKNOWNMAGIC, ss.str().c_str(), "jcntl",
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0') << "Magic=0x" << std::setw(8) << h._magic;
+ oss << " fid=" << fid << " foffs=0x" << std::setw(8) << read_pos;
+ throw jexception(jerrno::JERR_JCNTL_UNKNOWNMAGIC, oss.str(), "jcntl",
"rcvr_get_next_record");
}
return true;
@@ -641,12 +641,12 @@
}
if (!ifsp->is_open())
{
- std::stringstream ss;
- ss << _jdir.dirname() << "/" << _base_filename << ".";
- ss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
- ifsp->open(ss.str().c_str(), std::ios_base::in | std::ios_base::binary);
+ std::ostringstream oss;
+ oss << _jdir.dirname() << "/" << _base_filename << ".";
+ oss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
+ ifsp->open(oss.str().c_str(), std::ios_base::in | std::ios_base::binary);
if (!ifsp->good())
- throw jexception(jerrno::JERR__FILEIO, ss.str().c_str(), "jcntl", "jfile_cycle");
+ throw jexception(jerrno::JERR__FILEIO, oss.str(), "jcntl", "jfile_cycle");
// Read file header
file_hdr fhdr;
@@ -681,12 +681,12 @@
rd._eo = read_pos;
return false;
}
- std::stringstream ss;
- ss << std::hex << std::setfill('0') << "Magic=0x" << std::setw(8) << h._magic;
- ss << " fid=0x" << std::setw(4) << fid << " rid=0x" << std::setw(8) << h._rid;
- ss << " foffs=0x" << std::setw(8) << read_pos;
- ss << " expected_fid=0x" << std::setw(4) << expected_fid;
- throw jexception(jerrno::JERR_JCNTL_OWIMISMATCH, ss.str().c_str(), "jcntl",
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0') << "Magic=0x" << std::setw(8) << h._magic;
+ oss << " fid=0x" << std::setw(4) << fid << " rid=0x" << std::setw(8) << h._rid;
+ oss << " foffs=0x" << std::setw(8) << read_pos;
+ oss << " expected_fid=0x" << std::setw(4) << expected_fid;
+ throw jexception(jerrno::JERR_JCNTL_OWIMISMATCH, oss.str(), "jcntl",
"check_owi");
}
if (rd._h_rid < h._rid)
@@ -707,14 +707,13 @@
(JRNL_SBLK_SIZE - (sblk_offs/JRNL_DBLK_SIZE)) <<
" filler record(s) required." << std::endl;
const u_int32_t xmagic = RHM_JDAT_EMPTY_MAGIC;
- std::stringstream ss;
- ss << _jdir.dirname() << "/" << _base_filename << ".";
- ss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
- std::ofstream ofsp(ss.str().c_str(),
+ std::ostringstream oss;
+ oss << _jdir.dirname() << "/" << _base_filename << ".";
+ oss << std::hex << std::setfill('0') << std::setw(4) << fid << "." << JRNL_DATA_EXTENSION;
+ std::ofstream ofsp(oss.str().c_str(),
std::ios_base::in | std::ios_base::out | std::ios_base::binary);
if (!ofsp.good())
- throw jexception(jerrno::JERR__FILEIO, ss.str().c_str(), "jcntl",
- "check_journal_alignment");
+ throw jexception(jerrno::JERR__FILEIO, oss.str(), "jcntl", "check_journal_alignment");
ofsp.seekp(rec_offset);
void* buff = ::malloc(JRNL_DBLK_SIZE);
assert(buff != NULL);
Modified: store/trunk/cpp/lib/jrnl/jdir.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jdir.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/jdir.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -85,9 +85,9 @@
{
if (::mkdir(dirname.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH))
{
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str().c_str(), "jdir", "create_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_MKDIR, oss.str(), "jdir", "create_dir");
}
}
}
@@ -123,9 +123,9 @@
create_dir(dirname);
return;
}
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str().c_str(), "jdir", "clear_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, oss.str(), "jdir", "clear_dir");
}
#ifndef RHM_JOWRITE
struct dirent* entry;
@@ -145,17 +145,16 @@
bak_dir = create_bak_dir(dirname, base_filename);
found = true;
}
- std::stringstream oldname;
+ std::ostringstream oldname;
oldname << dirname << "/" << entry->d_name;
- std::stringstream newname;
+ std::ostringstream newname;
newname << bak_dir << "/" << entry->d_name;
if (::rename(oldname.str().c_str(), newname.str().c_str()))
{
- std::stringstream ss;
- ss << "file=\"" << oldname.str() << "\" dest=\"" <<
+ std::ostringstream oss;
+ oss << "file=\"" << oldname.str() << "\" dest=\"" <<
newname.str() << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_FMOVE, ss.str().c_str(), "jdir",
- "clear_dir");
+ throw jexception(jerrno::JERR_JDIR_FMOVE, oss.str(), "jdir", "clear_dir");
}
}
}
@@ -165,17 +164,17 @@
// While commented out, there is no error capture from reading dir entries.
// if (errno)
// {
-// std::stringstream ss;
-// ss << "dir=\"" << dirname << "\" errno=" << errno;
+// std::ostringstream oss;
+// oss << "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().c_str(), "jdir", "clear_dir");
+// throw jexception(jerrno::JERR_JDIR_READDIR, oss.str(), "jdir", "clear_dir");
// }
#endif
if (::closedir(dir))
{
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str().c_str(), "jdir", "clear_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, oss.str(), "jdir", "clear_dir");
}
}
@@ -200,21 +199,21 @@
{
if (!is_dir(dirname))
{
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\"";
- throw jexception(jerrno::JERR_JDIR_NOTDIR, ss.str().c_str(), "jdir", "verify_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\"";
+ throw jexception(jerrno::JERR_JDIR_NOTDIR, oss.str(), "jdir", "verify_dir");
}
// Read jinf file, then verify all journal files are present
jinf ji(dirname + "/" + base_filename + "." + JRNL_INFO_EXTENSION, true);
for (u_int16_t fnum=0; fnum < ji.num_jfiles(); fnum++)
{
- std::stringstream ss;
- ss << dirname << "/" << base_filename << ".";
- 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().c_str(), "jdir", "verify_dir");
+ std::ostringstream oss;
+ oss << dirname << "/" << base_filename << ".";
+ oss << std::setw(4) << std::setfill('0') << std::hex << fnum;
+ oss << "." << JRNL_DATA_EXTENSION;
+ if (!exists(oss.str()))
+ throw jexception(jerrno::JERR_JDIR_NOSUCHFILE, oss.str(), "jdir", "verify_dir");
}
}
@@ -244,9 +243,9 @@
if (errno == ENOENT) // dir does not exist.
return;
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str().c_str(), "jdir", "delete_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, oss.str(), "jdir", "delete_dir");
}
else
{
@@ -258,10 +257,9 @@
std::string full_name(dirname + "/" + entry->d_name);
if (::stat(full_name.c_str(), &s))
{
- std::stringstream ss;
- ss << "stat: file=\"" << full_name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_STAT, ss.str().c_str(), "jdir",
- "delete_dir");
+ std::ostringstream oss;
+ oss << "stat: file=\"" << full_name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_STAT, oss.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.
@@ -269,10 +267,9 @@
{
if(::unlink(full_name.c_str()))
{
- std::stringstream ss;
- ss << "unlink: file=\"" << entry->d_name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_UNLINK, ss.str().c_str(), "jdir",
- "delete_dir");
+ std::ostringstream oss;
+ oss << "unlink: file=\"" << entry->d_name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_UNLINK, oss.str(), "jdir", "delete_dir");
}
}
else if (S_ISDIR(s.st_mode)) // This is a dir
@@ -281,11 +278,10 @@
}
else // all other types, throw up!
{
- 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().c_str(), "jdir",
- "delete_dir");
+ std::ostringstream oss;
+ oss << "file=\"" << entry->d_name << "\" is not a dir, file or slink.";
+ oss << " (mode=0x" << std::hex << s.st_mode << std::dec << ")";
+ throw jexception(jerrno::JERR_JDIR_BADFTYPE, oss.str(), "jdir", "delete_dir");
}
}
}
@@ -293,26 +289,26 @@
// While commented out, there is no error capture from reading dir entries.
// if (errno)
// {
-// std::stringstream ss;
-// ss << "dir=\"" << dirname << "\" errno=" << errno;
+// std::ostringstream oss;
+// oss << "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().c_str(), "jdir", "delete_dir");
+// throw jexception(jerrno::JERR_JDIR_READDIR, oss.str(), "jdir", "delete_dir");
// }
}
// Now dir is empty, close and delete it
if (::closedir(dir))
{
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str().c_str(), "jdir", "delete_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, oss.str(), "jdir", "delete_dir");
}
if (!children_only)
if (::rmdir(dirname.c_str()))
{
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_RMDIR, ss.str().c_str(), "jdir", "delete_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_RMDIR, oss.str(), "jdir", "delete_dir");
}
}
@@ -324,9 +320,9 @@
long dir_num = 0L;
if (!dir)
{
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_OPENDIR, ss.str().c_str(), "jdir", "create_bak_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_OPENDIR, oss.str(), "jdir", "create_bak_dir");
}
struct dirent* entry;
while ((entry = ::readdir(dir)) != NULL)
@@ -336,9 +332,9 @@
{
if (::strlen(entry->d_name) == base_filename.size() + 10) // Format: basename.bak.XXXX
{
- std::stringstream ss;
- ss << "_" << base_filename << ".bak.";
- if (::strncmp(entry->d_name, ss.str().c_str(), base_filename.size() + 6) == 0)
+ std::ostringstream oss;
+ oss << "_" << base_filename << ".bak.";
+ if (::strncmp(entry->d_name, oss.str().c_str(), base_filename.size() + 6) == 0)
{
long this_dir_num = ::strtol(entry->d_name + base_filename.size() + 6,
NULL, 16);
@@ -352,25 +348,25 @@
// While commented out, there is no error capture from reading dir entries.
// if (errno)
// {
-// std::stringstream ss;
-// ss << "dir=\"" << dirname << "\" errno=" << errno;
+// std::ostringstream oss;
+// oss << "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().c_str(), "jdir", "clear_dir");
+// throw jexception(jerrno::JERR_JDIR_READDIR, oss.str(), "jdir", "clear_dir");
// }
if (::closedir(dir))
{
- std::stringstream ss;
- ss << "dir=\"" << dirname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_CLOSEDIR, ss.str().c_str(), "jdir", "create_bak_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dirname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_CLOSEDIR, oss.str(), "jdir", "create_bak_dir");
}
- std::stringstream dn;
+ std::ostringstream dn;
dn << dirname << "/_" << base_filename << ".bak." << std::hex << std::setw(4) <<
std::setfill('0') << ++dir_num;
if (::mkdir(dn.str().c_str(), S_IRWXU | S_IRWXG | S_IROTH))
{
- std::stringstream ss;
- ss << "dir=\"" << dn.str() << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_MKDIR, ss.str().c_str(), "jdir", "create_bak_dir");
+ std::ostringstream oss;
+ oss << "dir=\"" << dn.str() << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_MKDIR, oss.str(), "jdir", "create_bak_dir");
}
return std::string(dn.str());
}
@@ -381,9 +377,9 @@
struct stat s;
if (::stat(name, &s))
{
- std::stringstream ss;
- ss << "file=\"" << name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_STAT, ss.str().c_str(), "jdir", "is_dir");
+ std::ostringstream oss;
+ oss << "file=\"" << name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_STAT, oss.str(), "jdir", "is_dir");
}
return S_ISDIR(s.st_mode);
}
@@ -403,9 +399,9 @@
if (errno == ENOENT) // No such dir or file
return false;
// Throw for any other condition
- std::stringstream ss;
- ss << "file=\"" << name << "\" errno=" << errno;
- throw jexception(jerrno::JERR_JDIR_STAT, ss.str().c_str(), "jdir", "is_dir");
+ std::ostringstream oss;
+ oss << "file=\"" << name << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_JDIR_STAT, oss.str(), "jdir", "is_dir");
}
return true;
}
Modified: store/trunk/cpp/lib/jrnl/jexception.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/jexception.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -46,143 +46,97 @@
jexception::jexception() throw ():
std::exception(),
_err_code(0)
-{
- ::sprintf(_what_msg, "jexception 0x0000");
- *_additional_info = '\0';
- *_throwing_class = '\0';
- *_throwing_fn = '\0';
-}
+{}
jexception::jexception(const u_int32_t err_code) throw ():
std::exception(),
_err_code(err_code)
-{
- ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
- ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
- *_additional_info = '\0';
- *_throwing_class = '\0';
- *_throwing_fn = '\0';
-}
+{}
jexception::jexception(const char* additional_info) throw ():
std::exception(),
- _err_code(0)
-{
- ::sprintf(_what_msg, "jexception ");
- if (additional_info)
- {
- ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
- _additional_info[MAX_MSG_SIZE - 1] = '\0';
- ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
- }
- else
- *_additional_info = '\0';
- *_throwing_class = '\0';
- *_throwing_fn = '\0';
-}
+ _err_code(0),
+ _additional_info(additional_info)
+{}
+jexception::jexception(const std::string& additional_info) throw ():
+ std::exception(),
+ _err_code(0),
+ _additional_info(additional_info)
+{}
+
jexception::jexception(const u_int32_t err_code, const char* additional_info) throw ():
std::exception(),
- _err_code(err_code)
-{
- ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
- ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
- if (additional_info)
- {
- ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
- _additional_info[MAX_MSG_SIZE - 1] = '\0';
- ::strncat(_what_msg, " (", CATLEN(_what_msg));
- ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
- ::strncat(_what_msg, ")", CATLEN(_what_msg));
- }
- else
- *_additional_info = '\0';
- *_throwing_class = '\0';
- *_throwing_fn = '\0';
-}
+ _err_code(err_code),
+ _additional_info(additional_info)
+{}
+jexception::jexception(const u_int32_t err_code, const std::string& additional_info) throw ():
+ std::exception(),
+ _err_code(err_code),
+ _additional_info(additional_info)
+{}
+
jexception::jexception(const u_int32_t err_code, const char* throwing_class,
const char* throwing_fn) throw ():
std::exception(),
- _err_code(err_code)
-{
- ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
- *_additional_info = '\0';
- if (throwing_class)
- {
- ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE - 1);
- _throwing_class[MAX_THROWING_SIZE - 1] = '\0';
- ::strncat(_what_msg, _throwing_class, CATLEN(_what_msg));
- if (throwing_fn)
- ::strncat(_what_msg, "::", CATLEN(_what_msg));
- else
- ::strncat(_what_msg, " ", CATLEN(_what_msg));
- }
- else
- *_throwing_class = '\0';
- if (throwing_fn)
- {
- ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE - 1);
- _throwing_fn[MAX_THROWING_SIZE - 1] = '\0';
- ::strncat(_what_msg, _throwing_fn, CATLEN(_what_msg));
- ::strncat(_what_msg, "() ", CATLEN(_what_msg));
- }
- else
- *_throwing_fn = '\0';
- if (throwing_class || throwing_fn)
- ::strncat(_what_msg, "threw ", CATLEN(_what_msg));
- ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
-}
+ _err_code(err_code),
+ _throwing_class(throwing_class),
+ _throwing_fn(throwing_fn)
+{}
+jexception::jexception(const u_int32_t err_code, const std::string& throwing_class,
+ const std::string& throwing_fn) throw ():
+ std::exception(),
+ _err_code(err_code),
+ _throwing_class(throwing_class),
+ _throwing_fn(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)
-{
- ::sprintf(_what_msg, "jexception 0x%04X ", err_code);
- if (throwing_class)
- {
- ::strncpy(_throwing_class, throwing_class, MAX_THROWING_SIZE - 1);
- _throwing_class[MAX_THROWING_SIZE - 1] = '\0';
- ::strncat(_what_msg, _throwing_class, CATLEN(_what_msg));
- if (throwing_fn)
- ::strncat(_what_msg, "::", CATLEN(_what_msg));
- else
- ::strncat(_what_msg, " ", CATLEN(_what_msg));
- }
- else
- *_throwing_class = '\0';
- if (throwing_fn)
- {
- ::strncpy(_throwing_fn, throwing_fn, MAX_THROWING_SIZE - 1);
- _throwing_fn[MAX_THROWING_SIZE - 1] = '\0';
- ::strncat(_what_msg, _throwing_fn, CATLEN(_what_msg));
- ::strncat(_what_msg, "() ", CATLEN(_what_msg));
- }
- else
- *_throwing_fn = '\0';
- if (throwing_class || throwing_fn)
- ::strncat(_what_msg, "threw ", CATLEN(_what_msg));
- ::strncat(_what_msg, jerrno::err_msg(err_code), CATLEN(_what_msg));
- if (additional_info)
- {
- ::strncpy(_additional_info, additional_info, MAX_MSG_SIZE - 1);
- _additional_info[MAX_MSG_SIZE - 1] = '\0';
- ::strncat(_what_msg, " (", CATLEN(_what_msg));
- ::strncat(_what_msg, _additional_info, CATLEN(_what_msg));
- ::strncat(_what_msg, ")", CATLEN(_what_msg));
- }
- else
- *_additional_info = '\0';
-}
+ _err_code(err_code),
+ _additional_info(additional_info),
+ _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) throw ():
+ std::exception(),
+ _err_code(err_code),
+ _additional_info(additional_info),
+ _throwing_class(throwing_class),
+ _throwing_fn(throwing_fn)
+{}
+
jexception::~jexception() throw ()
{}
const char*
jexception::what() const throw ()
{
- return _what_msg;
+ const bool ai = !_additional_info.empty();
+ const bool tc = !_throwing_class.empty();
+ const bool tf = !_throwing_fn.empty();
+ std::ostringstream oss;
+ oss << "jexception 0x" << std::hex << std::setfill('0') << std::setw(4) << _err_code << " ";
+ if (tc)
+ {
+ oss << _throwing_class;
+ if (tf)
+ oss << "::";
+ else
+ oss << " ";
+ }
+ if (tf)
+ oss << _throwing_class << "() ";
+ if (tc || tf)
+ oss << "threw " << jerrno::err_msg(_err_code);
+ if (ai)
+ oss << " (" << _additional_info << ")";
+ return oss.str().c_str();
}
std::ostream&
Modified: store/trunk/cpp/lib/jrnl/jexception.hpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jexception.hpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/jexception.hpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -52,20 +52,17 @@
#define MALLOC_CHK(ptr, var, cls, fn) if(ptr == NULL) { \
clean(); \
- std::stringstream ss; \
- ss << var << ": malloc() failed: " << FORMAT_SYSERR(errno); \
- throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), cls, fn); \
+ std::ostringstream oss; \
+ oss << var << ": malloc() failed: " << FORMAT_SYSERR(errno); \
+ throw jexception(jerrno::JERR__MALLOC, oss.str(), cls, fn); \
}
#define PTHREAD_CHK(err, pfn, cls, fn) if(err != 0) { \
- std::stringstream ss; \
- ss << pfn << " failed: " << FORMAT_SYSERR(err); \
- throw jexception(jerrno::JERR__PTHREAD, ss.str().c_str(), cls, fn); \
+ std::ostringstream oss; \
+ oss << pfn << " failed: " << FORMAT_SYSERR(err); \
+ throw jexception(jerrno::JERR__PTHREAD, oss.str(), cls, fn); \
}
-#define MAX_MSG_SIZE 1024
-#define MAX_THROWING_SIZE 128
-
namespace rhm
{
namespace journal
@@ -78,27 +75,38 @@
{
private:
u_int32_t _err_code;
- char _what_msg[MAX_MSG_SIZE];
- char _additional_info[MAX_MSG_SIZE];
- char _throwing_class[MAX_THROWING_SIZE];
- char _throwing_fn[MAX_THROWING_SIZE];
+ std::string _additional_info;
+ std::string _throwing_class;
+ std::string _throwing_fn;
public:
jexception() throw ();
+
jexception(const u_int32_t err_code) throw ();
+
jexception(const char* additional_info) throw ();
+ jexception(const std::string& additional_info) throw ();
+
jexception(const u_int32_t err_code, const char* additional_info) throw ();
+ jexception(const u_int32_t err_code, const std::string& 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 std::string& throwing_class,
+ const std::string& throwing_fn) throw ();
+
jexception(const u_int32_t err_code, const char* additional_info,
const char* throwing_class, const char* throwing_fn) throw ();
+ jexception(const u_int32_t err_code, const std::string& additional_info,
+ const std::string& throwing_class, const std::string& throwing_fn) throw ();
+
virtual ~jexception() throw ();
virtual const char* what() const throw (); // override std::exception::what()
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; }
+ inline const std::string additional_info() const throw () { return _additional_info; }
+ inline const std::string throwing_class() const throw () { return _throwing_class; }
+ inline const std::string 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-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/jinf.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -94,63 +94,63 @@
jinf::validate()
{
bool err = false;
- std::stringstream ss;
+ std::ostringstream oss;
if (_jver != RHM_JDAT_VERSION)
{
- ss << "RHM_JDAT_VERSION mismatch: " << _jver;
- ss << "; required=" << RHM_JDAT_VERSION << std::endl;
+ oss << "RHM_JDAT_VERSION mismatch: " << _jver;
+ oss << "; required=" << RHM_JDAT_VERSION << std::endl;
err = true;
}
if (_num_jfiles < JRNL_MIN_NUM_FILES)
{
- ss << "Number of journal files too small: found=" << _num_jfiles;
- ss << "; minimum=" << JRNL_MIN_NUM_FILES << std::endl;
+ oss << "Number of journal files too small: found=" << _num_jfiles;
+ oss << "; minimum=" << JRNL_MIN_NUM_FILES << std::endl;
err = true;
}
if (_jfsize_sblks < JRNL_MIN_FILE_SIZE)
{
- ss << "Journal file size too small: found=" << _jfsize_sblks;
- ss << "; minimum=" << JRNL_MIN_FILE_SIZE << " (sblks)" << std::endl;
+ oss << "Journal file size too small: found=" << _jfsize_sblks;
+ oss << "; minimum=" << JRNL_MIN_FILE_SIZE << " (sblks)" << std::endl;
err = true;
}
if (_sblk_size_dblks != JRNL_SBLK_SIZE)
{
- ss << "JRNL_SBLK_SIZE mismatch: " << _sblk_size_dblks;
- ss << "; required=" << JRNL_SBLK_SIZE << std::endl;
+ oss << "JRNL_SBLK_SIZE mismatch: " << _sblk_size_dblks;
+ oss << "; required=" << JRNL_SBLK_SIZE << std::endl;
err = true;
}
if (_dblk_size != JRNL_DBLK_SIZE)
{
- ss << "JRNL_DBLK_SIZE mismatch: " << _dblk_size;
- ss << "; required=" << JRNL_DBLK_SIZE << std::endl;
+ oss << "JRNL_DBLK_SIZE mismatch: " << _dblk_size;
+ oss << "; required=" << JRNL_DBLK_SIZE << std::endl;
err = true;
}
if (_wmgr_page_size_dblks != JRNL_WMGR_PAGE_SIZE)
{
- ss << "JRNL_WMGR_PAGE_SIZE mismatch: " << _wmgr_page_size_dblks;
- ss << "; required=" << JRNL_WMGR_PAGE_SIZE << std::endl;
+ oss << "JRNL_WMGR_PAGE_SIZE mismatch: " << _wmgr_page_size_dblks;
+ oss << "; required=" << JRNL_WMGR_PAGE_SIZE << std::endl;
err = true;
}
if (_wmgr_num_pages != JRNL_WMGR_PAGES)
{
- ss << "JRNL_WMGR_PAGES mismatch: " << _wmgr_num_pages;
- ss << "; required=" << JRNL_WMGR_PAGES << std::endl;
+ oss << "JRNL_WMGR_PAGES mismatch: " << _wmgr_num_pages;
+ oss << "; required=" << JRNL_WMGR_PAGES << std::endl;
err = true;
}
if (_rmgr_page_size_dblks != JRNL_RMGR_PAGE_SIZE)
{
- ss << "JRNL_RMGR_PAGE_SIZE mismatch: " << _rmgr_page_size_dblks;
- ss << "; required=" << JRNL_RMGR_PAGE_SIZE << std::endl;
+ oss << "JRNL_RMGR_PAGE_SIZE mismatch: " << _rmgr_page_size_dblks;
+ oss << "; required=" << JRNL_RMGR_PAGE_SIZE << std::endl;
err = true;
}
if (_rmgr_num_pages != JRNL_RMGR_PAGES)
{
- ss << "JRNL_RMGR_PAGES mismatch: " << _rmgr_num_pages;
- ss << "; required=" << JRNL_RMGR_PAGES << std::endl;
+ oss << "JRNL_RMGR_PAGES mismatch: " << _rmgr_num_pages;
+ oss << "; required=" << JRNL_RMGR_PAGES << std::endl;
err = true;
}
if (err)
- throw jexception(jerrno::JERR_JINF_CVALIDFAIL, ss.str().c_str(), "jinf", "validate");
+ throw jexception(jerrno::JERR_JINF_CVALIDFAIL, oss.str(), "jinf", "validate");
_valid_flag = true;
}
@@ -165,13 +165,13 @@
validate();
for (u_int16_t fnum=0; fnum < _num_jfiles; fnum++)
{
- std::stringstream ss;
- ss << _jdir << "/" << _base_filename << ".";
- ss << std::setw(4) << std::setfill('0') << std::hex << fnum;
- ss << "." << JRNL_DATA_EXTENSION;
- std::ifstream jifs(ss.str().c_str());
+ std::ostringstream oss;
+ oss << _jdir << "/" << _base_filename << ".";
+ oss << std::setw(4) << std::setfill('0') << std::hex << fnum;
+ oss << "." << JRNL_DATA_EXTENSION;
+ std::ifstream jifs(oss.str().c_str());
if (!jifs.good())
- throw jexception(jerrno::JERR__FILEIO, ss.str().c_str(), "jinf", "analyze");
+ throw jexception(jerrno::JERR__FILEIO, oss.str(), "jinf", "analyze");
file_hdr fhdr;
jifs.read((char*)&fhdr, sizeof(fhdr));
if (fhdr._magic != RHM_JDAT_FILE_MAGIC)
@@ -199,11 +199,11 @@
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);
+ std::ostringstream oss;
+ oss << _jdir << "/" << _base_filename << "." << JRNL_INFO_EXTENSION;
+ std::ofstream of(oss.str().c_str(), std::ofstream::out | std::ofstream::trunc);
if (!of.good())
- throw jexception(jerrno::JERR__FILEIO, fn.str().c_str(), "jcntl", "write_infofile");
+ throw jexception(jerrno::JERR__FILEIO, oss.str(), "jcntl", "write_infofile");
of << xml_str();
of.close();
}
@@ -227,64 +227,65 @@
const std::string
jinf::to_string() const
{
- std::stringstream ss;
- ss << std::setfill('0');
- ss << "Journal ID \"" << _jid << "\" initialized " << (_tm_ptr->tm_year + 1900) << "/";
- ss << std::setw(2) << (_tm_ptr->tm_mon + 1) << "/" << std::setw(2) << _tm_ptr->tm_mday << " ";
- ss << std::setw(2) << _tm_ptr->tm_hour << ":" << std::setw(2) << _tm_ptr->tm_min << ":";
- ss << std::setw(2) << _tm_ptr->tm_sec << "." << std::setw(9) << _ts.tv_nsec << ":" << std::endl;
- ss << " Journal directory: \"" << _jdir << "\"" << std::endl;
- ss << " Journal base filename: \"" << _base_filename << "\"" << std::endl;
- ss << " Journal version: " << (unsigned)_jver << std::endl;
- ss << " Number of journal files: " << _num_jfiles << std::endl;
- ss << " Journal file size: " << _jfsize_sblks << " sblks" << std::endl;
- ss << " Softblock size (JRNL_SBLK_SIZE): " << _sblk_size_dblks << " dblks" << std::endl;
- ss << " Datablock size (JRNL_DBLK_SIZE): " << _dblk_size << " bytes" << std::endl;
- ss << " Write page size (JRNL_WMGR_PAGE_SIZE): " << _wmgr_page_size_dblks << " dblks" <<
+ std::ostringstream oss;
+ oss << std::setfill('0');
+ oss << "Journal ID \"" << _jid << "\" initialized " << (_tm_ptr->tm_year + 1900) << "/";
+ oss << std::setw(2) << (_tm_ptr->tm_mon + 1) << "/" << std::setw(2) << _tm_ptr->tm_mday << " ";
+ oss << std::setw(2) << _tm_ptr->tm_hour << ":" << std::setw(2) << _tm_ptr->tm_min << ":";
+ oss << std::setw(2) << _tm_ptr->tm_sec << "." << std::setw(9) << _ts.tv_nsec << ":" <<
std::endl;
- ss << " Number of write pages (JRNL_WMGR_PAGES): " << _wmgr_num_pages << std::endl;
- ss << " Read page size (JRNL_RMGR_PAGE_SIZE): " << _rmgr_page_size_dblks << " dblks" <<
+ oss << " Journal directory: \"" << _jdir << "\"" << std::endl;
+ oss << " Journal base filename: \"" << _base_filename << "\"" << std::endl;
+ oss << " Journal version: " << (unsigned)_jver << std::endl;
+ oss << " Number of journal files: " << _num_jfiles << std::endl;
+ oss << " Journal file size: " << _jfsize_sblks << " sblks" << std::endl;
+ oss << " Softblock size (JRNL_SBLK_SIZE): " << _sblk_size_dblks << " dblks" << std::endl;
+ oss << " Datablock size (JRNL_DBLK_SIZE): " << _dblk_size << " bytes" << std::endl;
+ oss << " Write page size (JRNL_WMGR_PAGE_SIZE): " << _wmgr_page_size_dblks << " dblks" <<
std::endl;
- ss << " Number of read pages (JRNL_RMGR_PAGES): " << _rmgr_num_pages << std::endl;
- return ss.str();
+ oss << " Number of write pages (JRNL_WMGR_PAGES): " << _wmgr_num_pages << std::endl;
+ oss << " Read page size (JRNL_RMGR_PAGE_SIZE): " << _rmgr_page_size_dblks << " dblks" <<
+ std::endl;
+ oss << " Number of read pages (JRNL_RMGR_PAGES): " << _rmgr_num_pages << std::endl;
+ return oss.str();
}
const std::string
jinf::xml_str() const
{
- std::stringstream ss;
+ std::ostringstream oss;
// 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 << "<jrnl>" << 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;
- ss << " <base_filename value=\"" << _base_filename << "\" />" << std::endl;
- ss << " </journal_id>" << std::endl;
- ss << " <creation_time>" << std::endl;
- ss << " <seconds value=\"" << _ts.tv_sec << "\" />" << std::endl;
- ss << " <nanoseconds value=\"" << _ts.tv_nsec << "\" />" << std::endl;
- ss << " <string vlaue=\"" << (_tm_ptr->tm_year + 1900) << "/";
- ss << std::setw(2) << (_tm_ptr->tm_mon + 1) << "/" << std::setw(2) << _tm_ptr->tm_mday << " ";
- ss << std::setw(2) << _tm_ptr->tm_hour << ":" << std::setw(2) << _tm_ptr->tm_min << ":";
- ss << std::setw(2) << _tm_ptr->tm_sec << "." << std::setw(9) << _ts.tv_nsec;
- ss << "\" />" << std::endl;
- ss << " </creation_time>" << std::endl;
- ss << " <journal_file_geometry>" << std::endl;
- ss << " <number_jrnl_files value=\"" << _num_jfiles << "\" />" << std::endl;
- ss << " <jrnl_file_size_sblks value=\"" << _jfsize_sblks << "\" />" << std::endl;
- ss << " <JRNL_SBLK_SIZE value=\"" << _sblk_size_dblks << "\" />" << std::endl;
- ss << " <JRNL_DBLK_SIZE value=\"" << _dblk_size << "\" />" << std::endl;
- ss << " <JRNL_WMGR_PAGE_SIZE value=\"" << _wmgr_page_size_dblks << "\" />" << std::endl;
- ss << " <JRNL_WMGR_PAGES value=\"" << _wmgr_num_pages << "\" />" << std::endl;
- ss << " <JRNL_RMGR_PAGE_SIZE value=\"" << _rmgr_page_size_dblks << "\" />" << std::endl;
- ss << " <JRNL_RMGR_PAGES value=\"" << _rmgr_num_pages << "\" />" << std::endl;
- ss << " </journal_file_geometry>" << std::endl;
- ss << "</jrnl>" << std::endl;
- return ss.str();
+ oss << std::setfill('0');
+ oss << "<?xml version=\"1.0\" ?>" << std::endl;
+ oss << "<jrnl>" << std::endl;
+ oss << " <journal_version value=\"" << (unsigned)_jver << "\" />" << std::endl;
+ oss << " <journal_id>" << std::endl;
+ oss << " <id_string value=\"" << _jid << "\" />" << std::endl;
+ oss << " <directory value=\"" << _jdir << "\" />" << std::endl;
+ oss << " <base_filename value=\"" << _base_filename << "\" />" << std::endl;
+ oss << " </journal_id>" << std::endl;
+ oss << " <creation_time>" << std::endl;
+ oss << " <seconds value=\"" << _ts.tv_sec << "\" />" << std::endl;
+ oss << " <nanoseconds value=\"" << _ts.tv_nsec << "\" />" << std::endl;
+ oss << " <string vlaue=\"" << (_tm_ptr->tm_year + 1900) << "/";
+ oss << std::setw(2) << (_tm_ptr->tm_mon + 1) << "/" << std::setw(2) << _tm_ptr->tm_mday << " ";
+ oss << std::setw(2) << _tm_ptr->tm_hour << ":" << std::setw(2) << _tm_ptr->tm_min << ":";
+ oss << std::setw(2) << _tm_ptr->tm_sec << "." << std::setw(9) << _ts.tv_nsec;
+ oss << "\" />" << std::endl;
+ oss << " </creation_time>" << std::endl;
+ oss << " <journal_file_geometry>" << std::endl;
+ oss << " <number_jrnl_files value=\"" << _num_jfiles << "\" />" << std::endl;
+ oss << " <jrnl_file_size_sblks value=\"" << _jfsize_sblks << "\" />" << std::endl;
+ oss << " <JRNL_SBLK_SIZE value=\"" << _sblk_size_dblks << "\" />" << std::endl;
+ oss << " <JRNL_DBLK_SIZE value=\"" << _dblk_size << "\" />" << std::endl;
+ oss << " <JRNL_WMGR_PAGE_SIZE value=\"" << _wmgr_page_size_dblks << "\" />" << std::endl;
+ oss << " <JRNL_WMGR_PAGES value=\"" << _wmgr_num_pages << "\" />" << std::endl;
+ oss << " <JRNL_RMGR_PAGE_SIZE value=\"" << _rmgr_page_size_dblks << "\" />" << std::endl;
+ oss << " <JRNL_RMGR_PAGES value=\"" << _rmgr_num_pages << "\" />" << std::endl;
+ oss << " </journal_file_geometry>" << std::endl;
+ oss << "</jrnl>" << std::endl;
+ return oss.str();
}
void
Modified: store/trunk/cpp/lib/jrnl/jrec.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/jrec.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/jrec.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -51,19 +51,19 @@
{
if (hdr._magic == 0)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "enq magic NULL: rid=0x" << hdr._rid;
- throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "enq magic NULL: rid=0x" << hdr._rid;
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
}
if (hdr._version != RHM_JDAT_VERSION)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "version: rid=0x" << 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_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "version: rid=0x" << hdr._rid;
+ oss << ": expected=0x" << std::setw(2) << (int)RHM_JDAT_VERSION;
+ oss << " read=0x" << std::setw(2) << (int)hdr._version;
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
}
#if defined (JRNL_LITTLE_ENDIAN)
u_int8_t endian_flag = RHM_LENDIAN_FLAG;
@@ -72,12 +72,12 @@
#endif
if (hdr._eflag != endian_flag)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "endian_flag: rid=" << hdr._rid;
- ss << ": expected=0x" << std::setw(2) << (int)endian_flag;
- ss << " read=0x" << std::setw(2) << (int)hdr._eflag;
- throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "endian_flag: rid=" << hdr._rid;
+ oss << ": expected=0x" << std::setw(2) << (int)endian_flag;
+ oss << " read=0x" << std::setw(2) << (int)hdr._eflag;
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
}
}
@@ -86,11 +86,11 @@
{
if (hdr._rid != rid)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "rid mismatch: expected=0x" << rid;
- ss << " read=0x" << hdr._rid;
- throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "jrec", "chk_hdr");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "rid mismatch: expected=0x" << rid;
+ oss << " read=0x" << hdr._rid;
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "jrec", "chk_hdr");
}
}
@@ -99,20 +99,20 @@
{
if (tail._xmagic != ~hdr._magic)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "magic: rid=0x" << hdr._rid;
- ss << ": expected=0x" << ~hdr._magic;
- ss << " read=0x" << tail._xmagic;
- throw jexception(jerrno::JERR_JREC_BADRECTAIL, ss.str().c_str(), "jrec", "chk_tail");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "magic: rid=0x" << hdr._rid;
+ oss << ": expected=0x" << ~hdr._magic;
+ oss << " read=0x" << tail._xmagic;
+ throw jexception(jerrno::JERR_JREC_BADRECTAIL, oss.str(), "jrec", "chk_tail");
}
if (tail._rid != hdr._rid)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "rid: rid=0x" << hdr._rid;
- ss << ": read=0x" << tail._rid;
- throw jexception(jerrno::JERR_JREC_BADRECTAIL, ss.str().c_str(), "jrec", "chk_tail");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "rid: rid=0x" << hdr._rid;
+ oss << ": read=0x" << tail._rid;
+ throw jexception(jerrno::JERR_JREC_BADRECTAIL, oss.str(), "jrec", "chk_tail");
}
}
Modified: store/trunk/cpp/lib/jrnl/nlfh.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/nlfh.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/nlfh.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -95,13 +95,12 @@
nlfh::initialize(const std::string& fbasename, const u_int16_t fid,
const u_int32_t jfsize_sblks, const rcvdat* const ro)
{
- std::stringstream ss;
-
_fid = fid;
- ss << fbasename << ".";
- ss << std::setw(4) << std::setfill('0') << std::hex << fid;
- ss << "." << JRNL_DATA_EXTENSION;
- _fname = ss.str();
+ std::ostringstream oss;
+ oss << fbasename << ".";
+ oss << std::setw(4) << std::setfill('0') << std::hex << fid;
+ oss << "." << JRNL_DATA_EXTENSION;
+ _fname = oss.str();
#ifdef RHM_JOWRITE
// In test mode, only create file if it does not exist
@@ -144,9 +143,10 @@
void* nullbuf = NULL;
if (::posix_memalign(&nullbuf, sblksize, writesize))
{
- ss << ": posix_memalign() failed: size=" << writesize << " blk_size=" << sblksize;
- ss << " errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "nlfh", "initialize");
+ std::ostringstream oss;
+ oss << ": posix_memalign() failed: size=" << writesize << " blk_size=" << sblksize;
+ oss << " errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, oss.str(), "nlfh", "initialize");
}
::memset(nullbuf, 0, writesize);
@@ -154,9 +154,10 @@
S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); // 0644 -rw-r--r--
if (fh < 0)
{
- ss << ": open() failed:" << "\" errno=" << errno;
+ std::ostringstream oss;
+ oss << ": open() failed:" << "\" errno=" << errno;
::free(nullbuf);
- throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str().c_str(), "nlfh", "initialize");
+ throw jexception(jerrno::JERR_NLFH_OPENWR, oss.str(), "nlfh", "initialize");
}
while (nsblks > 0)
@@ -165,11 +166,11 @@
JRNL_WMGR_PAGE_SIZE : nsblks;
if (::write(fh, (void*)nullbuf, this_write_sblks * sblksize) == -1)
{
- std::stringstream ss;
- ss << ": wr_size=" << (this_write_sblks * sblksize) << " errno=" << errno;
+ std::ostringstream oss;
+ oss << ": wr_size=" << (this_write_sblks * sblksize) << " errno=" << errno;
::close(fh);
::free(nullbuf);
- throw jexception(jerrno::JERR_NLFH_WRITE, ss.str().c_str(), "nlfh",
+ throw jexception(jerrno::JERR_NLFH_WRITE, oss.str(), "nlfh",
"initialize");
}
nsblks -= this_write_sblks;
@@ -179,8 +180,9 @@
::free(nullbuf);
if (::close(fh))
{
- ss << ": errno=" << errno;
- throw jexception(jerrno::JERR_NLFH_CLOSE, ss.str().c_str(), "nlfh", "initialize");
+ std::ostringstream oss;
+ oss << ": errno=" << errno;
+ throw jexception(jerrno::JERR_NLFH_CLOSE, oss.str(), "nlfh", "initialize");
}
}
#ifdef RHM_JOWRITE
@@ -248,9 +250,9 @@
{
if (_rec_enqcnt < s)
{
- std::stringstream ss;
- ss << "_rec_enqcnt=" << _rec_enqcnt << " decr=" << s;
- throw jexception(jerrno::JERR__UNDERFLOW, ss.str().c_str(), "nlfh", "subtr_enqcnt");
+ std::ostringstream oss;
+ oss << "_rec_enqcnt=" << _rec_enqcnt << " decr=" << s;
+ throw jexception(jerrno::JERR__UNDERFLOW, oss.str(), "nlfh", "subtr_enqcnt");
}
_rec_enqcnt -= s;
return _rec_enqcnt;
@@ -261,11 +263,10 @@
{
if (_rd_subm_cnt_dblks + a > _wr_subm_cnt_dblks)
{
- 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().c_str(), "nlfh",
- "add_rd_subm_cnt_dblks");
+ std::ostringstream oss;
+ oss << "_rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks << " incr=" << a;
+ oss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_RDOFFSOVFL, oss.str(), "nlfh", "add_rd_subm_cnt_dblks");
}
_rd_subm_cnt_dblks += a;
return _rd_subm_cnt_dblks;
@@ -276,10 +277,10 @@
{
if (_rd_cmpl_cnt_dblks + a > _rd_subm_cnt_dblks)
{
- 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().c_str(), "nlfh",
+ std::ostringstream oss;
+ oss << "_rd_cmpl_cnt_dblks=" << _rd_cmpl_cnt_dblks << " incr=" << a;
+ oss << " _rd_subm_cnt_dblks=" << _rd_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, oss.str(), "nlfh",
"add_rd_cmpl_cnt_dblks");
}
_rd_cmpl_cnt_dblks += a;
@@ -291,10 +292,10 @@
{
if (_wr_subm_cnt_dblks + a > _ffull_dblks) // Allow for file header
{
- std::stringstream ss;
- ss << "_wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks << " incr=" << a;
- ss << " fsize=" << _ffull_dblks << " dblks";
- throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, ss.str().c_str(), "nlfh",
+ std::ostringstream oss;
+ oss << "_wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks << " incr=" << a;
+ oss << " fsize=" << _ffull_dblks << " dblks";
+ throw jexception(jerrno::JERR_NLFH_FILEOFFSOVFL, oss.str(), "nlfh",
"add_wr_subm_cnt_dblks");
}
_wr_subm_cnt_dblks += a;
@@ -306,10 +307,10 @@
{
if (_wr_cmpl_cnt_dblks + a > _wr_subm_cnt_dblks)
{
- 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().c_str(), "nlfh",
+ std::ostringstream oss;
+ oss << "_wr_cmpl_cnt_dblks=" << _wr_cmpl_cnt_dblks << " incr=" << a;
+ oss << " _wr_subm_cnt_dblks=" << _wr_subm_cnt_dblks;
+ throw jexception(jerrno::JERR_NFLH_CMPLOFFSOVFL, oss.str(), "nlfh",
"add_wr_cmpl_cnt_dblks");
}
_wr_cmpl_cnt_dblks += a;
@@ -320,10 +321,10 @@
const std::string&
nlfh::status_str(std::string& s) const
{
- std::stringstream ss;
- ss << "fid=" << _fid << " ws=" << _wr_subm_cnt_dblks << " wc=" << _wr_cmpl_cnt_dblks;
- ss << " rs=" << _rd_subm_cnt_dblks << " rc=" << _rd_cmpl_cnt_dblks;
- s.assign(ss.str());
+ std::ostringstream oss;
+ oss << "fid=" << _fid << " ws=" << _wr_subm_cnt_dblks << " wc=" << _wr_cmpl_cnt_dblks;
+ oss << " rs=" << _rd_subm_cnt_dblks << " rc=" << _rd_cmpl_cnt_dblks;
+ s.assign(oss.str());
return s;
}
@@ -335,17 +336,17 @@
_rd_fh = ::open(_fname.c_str(), O_RDONLY | O_DIRECT);
if (_rd_fh < 0)
{
- std::stringstream ss;
- ss << "file=\"" << _fname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_NLFH_OPENRD, ss.str().c_str(), "nlfh", "open");
+ std::ostringstream oss;
+ oss << "file=\"" << _fname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_NLFH_OPENRD, oss.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--
if (_wr_fh < 0)
{
- std::stringstream ss;
- ss << "file=\"" << _fname << "\" errno=" << errno;
- throw jexception(jerrno::JERR_NLFH_OPENWR, ss.str().c_str(), "nlfh", "open");
+ std::ostringstream oss;
+ oss << "file=\"" << _fname << "\" errno=" << errno;
+ throw jexception(jerrno::JERR_NLFH_OPENWR, oss.str(), "nlfh", "open");
}
}
Modified: store/trunk/cpp/lib/jrnl/pmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/pmgr.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -131,8 +131,6 @@
void
pmgr::initialize()
{
- std::stringstream ss;
-
// As static use of this class keeps old values around, clean up first...
_pg_index = 0;
_pg_cntr = 0;
@@ -145,9 +143,10 @@
if (::posix_memalign(&_page_base_ptr, _sblksize, pagesize))
{
clean();
- ss << "posix_memalign(): blksize=" << _sblksize << " size=" << pagesize;
- ss << " errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "pmgr", "initialize");
+ std::ostringstream oss;
+ oss << "posix_memalign(): blksize=" << _sblksize << " size=" << pagesize;
+ oss << " errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, oss.str(), "pmgr", "initialize");
}
// 2. Allocate array of page pointers
_page_ptr_arr = (void**)::malloc(_pages * sizeof(void*));
@@ -182,8 +181,9 @@
// 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().c_str(), "pmgr", "initialize");
+ std::ostringstream oss;
+ oss << "io_queue_init() failed: " << strerror(-ret) << " (" << ret << ")";
+ throw jexception(jerrno::JERR__AIO, oss.str(), "pmgr", "initialize");
}
}
Modified: store/trunk/cpp/lib/jrnl/rmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/rmgr.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -156,10 +156,10 @@
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");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
+ throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, oss.str(), "rmgr", "get");
} // switch(_hdr._magic)
} // while */
}
@@ -205,11 +205,10 @@
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");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
+ throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, oss.str(), "rmgr", "discard");
} // switch
} // while */
}
@@ -323,13 +322,13 @@
{
if (_hdr._rid != dtokp->rid())
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- 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().c_str(),
- "rmgr", "read");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "rid=0x" << std::setw(16) << _hdr._rid;
+ oss << "; dtok_rid=" << std::setw(16) << dtokp->rid();
+ oss << "; dtok_id=0x" << std::setw(8) << dtokp->id();
+ throw jexception(jerrno::JERR_RMGR_RIDMISMATCH, oss.str(), "rmgr",
+ "read");
}
}
else
@@ -340,12 +339,12 @@
// check:
// if (fid != _page_cb_arr[_pg_index]._fid)
// {
-// std::stringstream ss;
-// ss << std::hex << std::setfill('0');
-// 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().c_str(), "rmgr",
+// std::ostringstream oss;
+// oss << std::hex << std::setfill('0');
+// oss << "rid=0x" << std::setw(16) << _hdr._rid;
+// oss << "; emap_fid=0x" << std::setw(4) << fid;
+// oss << "; current_fid=" << _rrfc.fid();
+// throw jexception(jerrno::JERR_RMGR_FIDMISMATCH, oss.str(), "rmgr",
// "read");
// }
#endif
@@ -373,10 +372,10 @@
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", "read");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "Magic=0x" << std::setw(8) << _hdr._magic << std::dec;
+ throw jexception(jerrno::JERR_RMGR_UNKNOWNMAGIC, oss.str(), "rmgr", "read");
}
}
}
@@ -389,9 +388,9 @@
{
if (ret == -EINTR) // No events
return 0;
- std::stringstream ss;
- ss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
- throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "rmgr", "get_events");
+ std::ostringstream oss;
+ oss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
+ throw jexception(jerrno::JERR__AIO, oss.str(), "rmgr", "get_events");
}
u_int32_t tot_data_toks = 0;
@@ -399,9 +398,9 @@
{
if (_aio_evt_rem == 0)
{
- std::stringstream ss;
- ss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
- throw jexception(jerrno::JERR__UNDERFLOW, ss.str().c_str(), "rmgr", "get_events");
+ std::ostringstream oss;
+ oss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
+ throw jexception(jerrno::JERR__UNDERFLOW, oss.str(), "rmgr", "get_events");
}
_aio_evt_rem--;
iocb* iocbp = _ioevt_arr[i].obj; // This I/O control block (iocb)
@@ -409,13 +408,13 @@
long aioret = (long)_ioevt_arr[i].res;
if (aioret < 0)
{
- std::stringstream ss;
- ss << "AIO read operation failed: " << strerror(-aioret) << " (" << aioret << ")";
- ss << " [pg=" << pcbp->_index << " buf=" << iocbp->u.c.buf;
- ss << " rsize=0x" << std::hex << iocbp->u.c.nbytes;
- ss << " offset=0x" << iocbp->u.c.offset << std::dec;
- ss << " fh=" << iocbp->aio_fildes << "]";
- throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "rmgr", "get_events");
+ std::ostringstream oss;
+ oss << "AIO read operation failed: " << strerror(-aioret) << " (" << aioret << ")";
+ oss << " [pg=" << pcbp->_index << " buf=" << iocbp->u.c.buf;
+ oss << " rsize=0x" << std::hex << iocbp->u.c.nbytes;
+ oss << " offset=0x" << iocbp->u.c.offset << std::dec;
+ oss << " fh=" << iocbp->aio_fildes << "]";
+ throw jexception(jerrno::JERR__AIO, oss.str(), "rmgr", "get_events");
}
// Transfer all data tokens
@@ -473,13 +472,12 @@
{
if (!dtokp->is_readable())
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- 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().c_str(), "rmgr",
- "pre_read_check");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "dtok_id=0x" << std::setw(8) << dtokp->id();
+ oss << "; dtok_rid=0x" << std::setw(16) << dtokp->rid();
+ oss << "; dtok_wstate=" << dtokp->wstate_str();
+ throw jexception(jerrno::JERR_RMGR_ENQSTATE, oss.str(), "rmgr", "pre_read_check");
}
}
@@ -557,9 +555,9 @@
}
else
{
- std::stringstream ss;
- ss << "Record type found = \"" << (char*)&h._magic << "\"";
- throw jexception(jerrno::JERR_RMGR_BADRECTYPE, ss.str().c_str(), "rmgr", "consume_xid_rec");
+ std::ostringstream oss;
+ oss << "Record type found = \"" << (char*)&h._magic << "\"";
+ throw jexception(jerrno::JERR_RMGR_BADRECTYPE, oss.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-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/txn_map.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -90,9 +90,9 @@
pthread_mutex_unlock(&_mutex);
if (itr == _map.end()) // not found in map
{
- std::stringstream ss;
- ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "get_tdata_list");
+ std::ostringstream oss;
+ oss << std::hex << "xid=\"" << xid << "\"";
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map", "get_tdata_list");
}
return itr->second;
}
@@ -105,9 +105,9 @@
if (itr == _map.end()) // not found in map
{
pthread_mutex_unlock(&_mutex);
- std::stringstream ss;
- ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map",
+ std::ostringstream oss;
+ oss << std::hex << "xid=\"" << xid << "\"";
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map",
"get_remove_tdata_list");
}
txn_data_list list = itr->second;
@@ -135,9 +135,9 @@
pthread_mutex_unlock(&_mutex);
if (itr == _map.end()) // not found in map
{
- std::stringstream ss;
- ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "get_rid_count");
+ std::ostringstream oss;
+ oss << std::hex << "xid=\"" << xid << "\"";
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map", "get_rid_count");
}
return itr->second.size();
}
@@ -150,9 +150,9 @@
if (itr == _map.end()) // not found in map
{
pthread_mutex_unlock(&_mutex);
- std::stringstream ss;
- ss << std::hex << "xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "is_txn_synced");
+ std::ostringstream oss;
+ oss << std::hex << "xid=\"" << xid << "\"";
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "txn_map", "is_txn_synced");
}
bool is_synced = true;
for (tdl_itr litr = itr->second.begin(); litr < itr->second.end(); litr++)
@@ -191,9 +191,9 @@
pthread_mutex_unlock(&_mutex);
if (ok && !found)
{
- std::stringstream ss;
- ss << std::hex << "xid=\"" << xid << "\" rid=" << rid;
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "txn_map", "set_aio_compl");
+ std::ostringstream oss;
+ oss << std::hex << "xid=\"" << xid << "\" rid=" << rid;
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.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-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/txn_rec.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -375,15 +375,15 @@
std::string&
txn_rec::str(std::string& str) const
{
- std::stringstream ss;
+ std::ostringstream oss;
if (_txn_hdr._magic == RHM_JDAT_TXA_MAGIC)
- ss << "dtxa_rec: m=" << _txn_hdr._magic;
+ oss << "dtxa_rec: m=" << _txn_hdr._magic;
else
- ss << "dtxc_rec: m=" << _txn_hdr._magic;
- ss << " v=" << (int)_txn_hdr._version;
- ss << " rid=" << _txn_hdr._rid;
- ss << " xid=\"" << _xidp << "\"";
- str.append(ss.str());
+ oss << "dtxc_rec: m=" << _txn_hdr._magic;
+ oss << " v=" << (int)_txn_hdr._version;
+ oss << " rid=" << _txn_hdr._rid;
+ oss << " xid=\"" << _xidp << "\"";
+ str.append(oss.str());
return str;
}
@@ -405,13 +405,13 @@
jrec::chk_hdr(_txn_hdr);
if (_txn_hdr._magic != RHM_JDAT_TXA_MAGIC && _txn_hdr._magic != RHM_JDAT_TXC_MAGIC)
{
- std::stringstream ss;
- ss << std::hex << std::setfill('0');
- ss << "dtx magic: rid=0x" << std::setw(16) << _txn_hdr._rid;
- 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._magic;
- throw jexception(jerrno::JERR_JREC_BADRECHDR, ss.str().c_str(), "txn_rec", "chk_hdr");
+ std::ostringstream oss;
+ oss << std::hex << std::setfill('0');
+ oss << "dtx magic: rid=0x" << std::setw(16) << _txn_hdr._rid;
+ oss << ": expected=(0x" << std::setw(8) << RHM_JDAT_TXA_MAGIC;
+ oss << " or 0x" << RHM_JDAT_TXC_MAGIC;
+ oss << ") read=0x" << std::setw(2) << (int)_txn_hdr._magic;
+ throw jexception(jerrno::JERR_JREC_BADRECHDR, oss.str(), "txn_rec", "chk_hdr");
}
}
Modified: store/trunk/cpp/lib/jrnl/wmgr.cpp
===================================================================
--- store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/lib/jrnl/wmgr.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -133,9 +133,9 @@
cont = true;
else
{
- std::stringstream ss;
- ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_ENQDISCONT, ss.str().c_str(), "wmgr", "enqueue");
+ std::ostringstream oss;
+ oss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_ENQDISCONT, oss.str(), "wmgr", "enqueue");
}
}
else
@@ -269,9 +269,9 @@
cont = true;
else
{
- std::stringstream ss;
- ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str().c_str(), "wmgr", "dequeue");
+ std::ostringstream oss;
+ oss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_DEQDISCONT, oss.str(), "wmgr", "dequeue");
}
}
else
@@ -420,9 +420,9 @@
cont = true;
else
{
- std::stringstream ss;
- ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str().c_str(), "wmgr", "abort");
+ std::ostringstream oss;
+ oss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_DEQDISCONT, oss.str(), "wmgr", "abort");
}
}
else
@@ -481,9 +481,9 @@
std::pair<std::set<std::string>::iterator, bool> res = _txn_pending_set.insert(xid);
if (!res.second)
{
- std::stringstream ss;
- ss << std::hex << "_txn_pending_set: xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str().c_str(), "wmgr", "abort");
+ std::ostringstream oss;
+ oss << std::hex << "_txn_pending_set: xid=\"" << xid << "\"";
+ throw jexception(jerrno::JERR_MAP_DUPLICATE, oss.str(), "wmgr", "abort");
}
#endif
@@ -566,9 +566,9 @@
cont = true;
else
{
- std::stringstream ss;
- ss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_DEQDISCONT, ss.str().c_str(), "wmgr", "commit");
+ std::ostringstream oss;
+ oss << "This data_tok: id=" << dtokp->id() << " state=" << dtokp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_DEQDISCONT, oss.str(), "wmgr", "commit");
}
}
else
@@ -623,9 +623,9 @@
std::pair<std::set<std::string>::iterator, bool> res = _txn_pending_set.insert(xid);
if (!res.second)
{
- std::stringstream ss;
- ss << std::hex << "_txn_pending_set: xid=\"" << xid << "\"";
- throw jexception(jerrno::JERR_MAP_DUPLICATE, ss.str().c_str(), "wmgr", "commit");
+ std::ostringstream oss;
+ oss << std::hex << "_txn_pending_set: xid=\"" << xid << "\"";
+ throw jexception(jerrno::JERR_MAP_DUPLICATE, oss.str(), "wmgr", "commit");
}
#endif
@@ -714,9 +714,9 @@
{
if (_page_cb_arr[_pg_index]._state != IN_USE)
{
- std::stringstream ss;
- ss << "pg_index=" << _pg_index << " state=" << _page_cb_arr[_pg_index].state_str();
- throw jexception(jerrno::JERR_WMGR_BADPGSTATE, ss.str().c_str(), "wmgr",
+ std::ostringstream oss;
+ oss << "pg_index=" << _pg_index << " state=" << _page_cb_arr[_pg_index].state_str();
+ throw jexception(jerrno::JERR_WMGR_BADPGSTATE, oss.str(), "wmgr",
"write_flush");
}
@@ -768,9 +768,9 @@
{
if (ret == -EINTR) // No events
return 0;
- std::stringstream ss;
- ss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
- throw jexception(jerrno::JERR__AIO, ss.str().c_str(), "wmgr", "get_events");
+ std::ostringstream oss;
+ oss << "io_getevents() failed: " << strerror(-ret) << " (" << ret << ")";
+ throw jexception(jerrno::JERR__AIO, oss.str(), "wmgr", "get_events");
}
u_int32_t tot_data_toks = 0;
@@ -778,9 +778,9 @@
{
if (_aio_evt_rem == 0)
{
- std::stringstream ss;
- ss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
- throw jexception(jerrno::JERR__UNDERFLOW, ss.str().c_str(), "wmgr", "get_events");
+ std::ostringstream oss;
+ oss << "_aio_evt_rem; evt " << (i + 1) << " of " << ret;
+ throw jexception(jerrno::JERR__UNDERFLOW, oss.str(), "wmgr", "get_events");
}
_aio_evt_rem--;
iocb* iocbp = _ioevt_arr[i].obj; // This I/O control block (iocb)
@@ -788,11 +788,11 @@
long aioret = (long)_ioevt_arr[i].res;
if (aioret < 0)
{
- std::stringstream ss;
- 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().c_str(), "wmgr", "get_events");
+ std::ostringstream oss;
+ oss << "AIO write operation failed: " << strerror(-aioret) << " (" << aioret << ")";
+ oss << " [pg=" << pcbp->_index << " size=" << iocbp->u.c.nbytes;
+ oss << " offset=" << iocbp->u.c.offset << " fh=" << iocbp->aio_fildes << "]";
+ throw jexception(jerrno::JERR__AIO, oss.str(), "wmgr", "get_events");
}
if (pcbp) // Page writes have pcb
{
@@ -819,9 +819,9 @@
it = _txn_pending_set.find(dtp->xid());
if (it == _txn_pending_set.end())
{
- std::stringstream ss;
- ss << std::hex << "_txn_pending_set: abort xid=\"" << dtp->xid() << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "wmgr",
+ std::ostringstream oss;
+ oss << std::hex << "_txn_pending_set: abort xid=\"" << dtp->xid() << "\"";
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "wmgr",
"get_events");
}
_txn_pending_set.erase(it);
@@ -833,18 +833,18 @@
it = _txn_pending_set.find(dtp->xid());
if (it == _txn_pending_set.end())
{
- std::stringstream ss;
- ss << std::hex << "_txn_pending_set: commit xid=\"" << dtp->xid() << "\"";
- throw jexception(jerrno::JERR_MAP_NOTFOUND, ss.str().c_str(), "wmgr",
+ std::ostringstream oss;
+ oss << std::hex << "_txn_pending_set: commit xid=\"" << dtp->xid() << "\"";
+ throw jexception(jerrno::JERR_MAP_NOTFOUND, oss.str(), "wmgr",
"get_events");
}
_txn_pending_set.erase(it);
#endif
break;
default:
- std::stringstream ss;
- ss << "dtok_id=" << dtp->id() << "dtok_state=" << dtp->wstate_str();
- throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, ss.str().c_str(), "wmgr",
+ std::ostringstream oss;
+ oss << "dtok_id=" << dtp->id() << "dtok_state=" << dtp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, oss.str(), "wmgr",
"get_events");
}
_dtoklp->push_back(dtp);
@@ -904,10 +904,10 @@
if (::posix_memalign(&_fhdr_base_ptr, _sblksize, _sblksize * num_jfiles))
{
clean();
- std::stringstream ss;
- ss << "posix_memalign(): blksize=" << _sblksize << " size=" << _sblksize;
- ss << " errno=" << errno;
- throw jexception(jerrno::JERR__MALLOC, ss.str().c_str(), "wmgr", "initialize");
+ std::ostringstream oss;
+ oss << "posix_memalign(): blksize=" << _sblksize << " size=" << _sblksize;
+ oss << " errno=" << errno;
+ throw jexception(jerrno::JERR__MALLOC, oss.str(), "wmgr", "initialize");
}
_fhdr_ptr_arr = (void**)::malloc(_pages * sizeof(void*));
MALLOC_CHK(_fhdr_ptr_arr, "_fhdr_ptr_arr", "wmgr", "initialize");
@@ -944,11 +944,10 @@
return RHM_IORES_AIO_WAIT;
else
{
- 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().c_str(), "wmgr",
- "pre_write_check");
+ std::ostringstream oss;
+ oss << "op=" << _op_str[op] << " index=" << _pg_index << " state=";
+ oss << _page_cb_arr[_pg_index].state_str();
+ throw jexception(jerrno::JERR_WMGR_BADPGSTATE, oss.str(), "wmgr", "pre_write_check");
}
}
@@ -958,20 +957,20 @@
case WMGR_ENQUEUE:
if (!dtokp->is_writable())
{
- 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().c_str(), "wmgr",
+ std::ostringstream oss;
+ oss << "op=" << _op_str[op] << " dtok_id=" << dtokp->id();
+ oss << " dtok_state=" << dtokp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, oss.str(), "wmgr",
"pre_write_check");
}
break;
case WMGR_DEQUEUE:
if (!dtokp->is_dequeueable())
{
- 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().c_str(), "wmgr",
+ std::ostringstream oss;
+ oss << "op=" << _op_str[op] << " dtok_id=" << dtokp->id();
+ oss << " dtok_state=" << dtokp->wstate_str();
+ throw jexception(jerrno::JERR_WMGR_BADDTOKSTATE, oss.str(), "wmgr",
"pre_write_check");
}
break;
Modified: store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp
===================================================================
--- store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-12-11 22:41:25 UTC (rev 1459)
+++ store/trunk/cpp/tests/jrnl/unit_test_jexception.cpp 2007-12-11 23:20:58 UTC (rev 1460)
@@ -54,120 +54,192 @@
{
jexception e1;
BOOST_CHECK_EQUAL(e1.err_code(), (u_int32_t)0);
- BOOST_CHECK(::strlen(e1.additional_info()) == 0);
- BOOST_CHECK(::strlen(e1.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e1.throwing_fn()) == 0);
+ BOOST_CHECK(e1.additional_info().size() == 0);
+ BOOST_CHECK(e1.throwing_class().size() == 0);
+ BOOST_CHECK(e1.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e1.what()) > 0);
throw e1;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
- BOOST_CHECK(::strlen(e.additional_info()) == 0);
- BOOST_CHECK(::strlen(e.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(e.additional_info().size() == 0);
+ BOOST_CHECK(e.throwing_class().size() == 0);
+ BOOST_CHECK(e.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e.what()) > 0);
}
}
void test_constructor_2()
{
- u_int32_t err_code = 2;
+ const u_int32_t err_code = 2;
try
{
jexception e2(err_code);
BOOST_CHECK_EQUAL(e2.err_code(), err_code);
- BOOST_CHECK(::strlen(e2.additional_info()) == 0);
- BOOST_CHECK(::strlen(e2.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e2.throwing_fn()) == 0);
+ BOOST_CHECK(e2.additional_info().size() == 0);
+ BOOST_CHECK(e2.throwing_class().size() == 0);
+ BOOST_CHECK(e2.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e2.what()) > 0);
throw e2;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
- BOOST_CHECK(::strlen(e.additional_info()) == 0);
- BOOST_CHECK(::strlen(e.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(e.additional_info().size() == 0);
+ BOOST_CHECK(e.throwing_class().size() == 0);
+ BOOST_CHECK(e.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e.what()) > 0);
}
}
-void test_constructor_3()
+void test_constructor_3a()
{
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(::strlen(e3.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e3.throwing_fn()) == 0);
+ BOOST_CHECK(e3.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e3.throwing_class().size() == 0);
+ BOOST_CHECK(e3.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e3.what()) > 0);
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(::strlen(e.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e.throwing_class().size() == 0);
+ BOOST_CHECK(e.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e.what()) > 0);
}
}
-void test_constructor_4()
+void test_constructor_3b()
{
- u_int32_t err_code = 4;
+ const std::string err_msg("exception3");
+ try
+ {
+ jexception e3(err_msg);
+ BOOST_CHECK_EQUAL(e3.err_code(), (u_int32_t)0);
+ BOOST_CHECK(e3.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e3.throwing_class().size() == 0);
+ BOOST_CHECK(e3.throwing_fn().size() == 0);
+ BOOST_CHECK(::strlen(e3.what()) > 0);
+ throw e3;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), (u_int32_t)0);
+ BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e.throwing_class().size() == 0);
+ BOOST_CHECK(e.throwing_fn().size() == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
+ }
+}
+
+void test_constructor_4a()
+{
+ const 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(::strlen(e4.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e4.throwing_fn()) == 0);
+ BOOST_CHECK(e4.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e4.throwing_class().size() == 0);
+ BOOST_CHECK(e4.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e4.what()) > 0);
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(::strlen(e.throwing_class()) == 0);
- BOOST_CHECK(::strlen(e.throwing_fn()) == 0);
+ BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e.throwing_class().size() == 0);
+ BOOST_CHECK(e.throwing_fn().size() == 0);
BOOST_CHECK(::strlen(e.what()) > 0);
}
}
-void test_constructor_5()
+void test_constructor_4b()
{
- u_int32_t err_code = 5;
+ const u_int32_t err_code = 4;
+ const std::string err_msg("exception4");
+ try
+ {
+ jexception e4(err_code, err_msg);
+ BOOST_CHECK_EQUAL(e4.err_code(), err_code);
+ BOOST_CHECK(e4.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e4.throwing_class().size() == 0);
+ BOOST_CHECK(e4.throwing_fn().size() == 0);
+ BOOST_CHECK(::strlen(e4.what()) > 0);
+ throw e4;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), err_code);
+ BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e.throwing_class().size() == 0);
+ BOOST_CHECK(e.throwing_fn().size() == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
+ }
+}
+
+void test_constructor_5a()
+{
+ const 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(::strlen(e5.additional_info()) == 0);
- BOOST_CHECK(::strcmp(e5.throwing_class(), err_class) == 0);
- BOOST_CHECK(::strcmp(e5.throwing_fn(), err_fn) == 0);
+ BOOST_CHECK(e5.additional_info().size() == 0);
+ BOOST_CHECK(e5.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e5.throwing_fn().compare(err_fn) == 0);
BOOST_CHECK(::strlen(e5.what()) > 0);
throw e5;
}
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(e.err_code(), err_code);
- BOOST_CHECK(::strlen(e.additional_info()) == 0);
- BOOST_CHECK(::strcmp(e.throwing_class(), err_class) == 0);
- BOOST_CHECK(::strcmp(e.throwing_fn(), err_fn) == 0);
+ BOOST_CHECK(e.additional_info().size() == 0);
+ BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
BOOST_CHECK(::strlen(e.what()) > 0);
}
}
-void test_constructor_6()
+void test_constructor_5b()
{
- u_int32_t err_code = 6;
+ const u_int32_t err_code = 5;
+ const std::string err_class("class5");
+ const std::string 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().size() == 0);
+ BOOST_CHECK(e5.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e5.throwing_fn().compare(err_fn) == 0);
+ BOOST_CHECK(::strlen(e5.what()) > 0);
+ throw e5;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), err_code);
+ BOOST_CHECK(e.additional_info().size() == 0);
+ BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
+ }
+}
+
+void test_constructor_6a()
+{
+ const u_int32_t err_code = 6;
const char* err_msg = "exception6";
const char* err_class = "class6";
const char* err_fn = "fn6";
@@ -175,31 +247,57 @@
{
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.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e6.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e6.throwing_fn().compare(err_fn) == 0);
BOOST_CHECK(::strlen(e6.what()) > 0);
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.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
BOOST_CHECK(::strlen(e.what()) > 0);
}
}
+void test_constructor_6b()
+{
+ const u_int32_t err_code = 6;
+ const std::string err_msg("exception6");
+ const std::string err_class("class6");
+ const std::string err_fn("fn6");
+ try
+ {
+ jexception e6(err_code, err_msg, err_class, err_fn);
+ BOOST_CHECK_EQUAL(e6.err_code(), err_code);
+ BOOST_CHECK(e6.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e6.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e6.throwing_fn().compare(err_fn) == 0);
+ BOOST_CHECK(::strlen(e6.what()) > 0);
+ throw e6;
+ }
+ catch (const jexception& e)
+ {
+ BOOST_CHECK_EQUAL(e.err_code(), err_code);
+ BOOST_CHECK(e.additional_info().compare(err_msg) == 0);
+ BOOST_CHECK(e.throwing_class().compare(err_class) == 0);
+ BOOST_CHECK(e.throwing_fn().compare(err_fn) == 0);
+ BOOST_CHECK(::strlen(e.what()) > 0);
+ }
+}
+
void test_msg_scope()
{
try
{
// These will go out of scope as soon as jexception is thrown...
- std::string msg("Error message");
- std::string cls("class");
- std::string fn("function");
- throw jexception(100, msg.c_str(), cls.c_str(), fn.c_str());
+ const std::string msg("Error message");
+ const std::string cls("class");
+ const std::string fn("function");
+ throw jexception(100, msg, cls, fn);
}
catch (const jexception& e)
{
@@ -209,93 +307,6 @@
}
}
-void test_long_null_strings()
-{
- // msg 1500 chars long; every 50th char is a '*'
- const char* long_msg =
- "Long_message_456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*";
- // throwing class and function 250 chars long
- const char* long_throwing_class =
- "Long_throwing_class_12345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*";
- const char* long_throwing_fn =
- "Long_throwing_function_45678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*"
- "1234567890123456789012345678901234567890123456789*";
-
-
- throw_exception(jexception(long_msg), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1);
- throw_exception(jexception((const char*)NULL), 11, 0);
-
- throw_exception(jexception(0x1234, long_msg), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1);
- throw_exception(jexception(0x1234, NULL), 18 + ::strlen(jerrno::err_msg(0x1234)), 0);
-
- throw_exception(jexception(0x1234, long_throwing_class, long_throwing_fn),
- 29 + (2 * (MAX_THROWING_SIZE - 1)) + ::strlen(jerrno::err_msg(0x1234)),
- MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
- throw_exception(jexception(0x1234, long_throwing_class, NULL),
- 25 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), MAX_THROWING_SIZE - 1,
- 0);
- throw_exception(jexception(0x1234, NULL, long_throwing_fn),
- 27 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), 0,
- MAX_THROWING_SIZE - 1);
- throw_exception(jexception(0x1234, NULL, NULL), 18 + ::strlen(jerrno::err_msg(0x1234)), 0, 0);
-
- throw_exception(jexception(0x1234, long_msg, long_throwing_class, long_throwing_fn),
- MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1, MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
- throw_exception(jexception(0x1234, long_msg, long_throwing_class, NULL), MAX_MSG_SIZE - 1,
- MAX_MSG_SIZE - 1, MAX_THROWING_SIZE - 1, 0);
- throw_exception(jexception(0x1234, long_msg, NULL, long_throwing_fn), MAX_MSG_SIZE - 1,
- MAX_MSG_SIZE - 1, 0, MAX_THROWING_SIZE - 1);
- throw_exception(jexception(0x1234, long_msg, NULL, NULL), MAX_MSG_SIZE - 1, MAX_MSG_SIZE - 1, 0,
- 0);
- throw_exception(jexception(0x1234, NULL, long_throwing_class, long_throwing_fn),
- 29 + (2 * (MAX_THROWING_SIZE - 1)) + ::strlen(jerrno::err_msg(0x1234)), 0,
- MAX_THROWING_SIZE - 1, MAX_THROWING_SIZE - 1);
- throw_exception(jexception(0x1234, NULL, long_throwing_class, NULL),
- 25 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), 0,
- MAX_THROWING_SIZE - 1, 0);
- throw_exception(jexception(0x1234, NULL, NULL, long_throwing_fn),
- 27 + MAX_THROWING_SIZE - 1 + ::strlen(jerrno::err_msg(0x1234)), 0, 0,
- MAX_THROWING_SIZE - 1);
- throw_exception(jexception(0x1234, NULL, NULL, NULL), 18 + ::strlen(jerrno::err_msg(0x1234)),
- 0, 0, 0);
-}
-
// Helper functions
void throw_exception(const jexception& e, size_t what_len, size_t ai_len)
@@ -315,9 +326,9 @@
catch (const jexception& e)
{
BOOST_CHECK_EQUAL(::strlen(e.what()), what_len);
- BOOST_CHECK_EQUAL(::strlen(e.additional_info()), ai_len);
- BOOST_CHECK_EQUAL(::strlen(e.throwing_class()), tc_len);
- BOOST_CHECK_EQUAL(::strlen(e.throwing_fn()), tf_len);
+ BOOST_CHECK_EQUAL(e.additional_info().size(), ai_len);
+ BOOST_CHECK_EQUAL(e.throwing_class().size(), tc_len);
+ BOOST_CHECK_EQUAL(e.throwing_fn().size(), tf_len);
}
}
@@ -333,12 +344,15 @@
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));
+ ts->add(BOOST_TEST_CASE(&test_constructor_3a));
+ ts->add(BOOST_TEST_CASE(&test_constructor_3b));
+ ts->add(BOOST_TEST_CASE(&test_constructor_4a));
+ ts->add(BOOST_TEST_CASE(&test_constructor_4b));
+ ts->add(BOOST_TEST_CASE(&test_constructor_5a));
+ ts->add(BOOST_TEST_CASE(&test_constructor_5b));
+ ts->add(BOOST_TEST_CASE(&test_constructor_6a));
+ ts->add(BOOST_TEST_CASE(&test_constructor_6b));
ts->add(BOOST_TEST_CASE(&test_msg_scope));
- ts->add(BOOST_TEST_CASE(&test_long_null_strings));
return ts;
}
18 years, 4 months
rhmessaging commits: r1459 - in mgmt: notes and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-11 17:41:25 -0500 (Tue, 11 Dec 2007)
New Revision: 1459
Modified:
mgmt/cumin/python/cumin/__init__.py
mgmt/notes/justin-todo.txt
Log:
Improves the printlns for broker registration.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-12-11 22:21:52 UTC (rev 1458)
+++ mgmt/cumin/python/cumin/__init__.py 2007-12-11 22:41:25 UTC (rev 1459)
@@ -64,16 +64,18 @@
def run(self):
while True:
for reg in BrokerRegistration.select():
- print "reg", reg
-
if reg.broker is None or reg.broker.managedBroker not in \
self.model.data.connectedBrokers:
+ print "Trying to connect to broker '%s' at %s:%i" % \
+ (reg.name, reg.host, reg.port or 5672)
+
try:
self.model.data.connectToBroker \
(reg.host, reg.port or 5672)
+
+ print "Connection succeeded"
except socket.error:
- print "Failed connecting to broker '%s' at %s:%i" % \
- (reg.name, reg.host, reg.port or 5672)
+ print "Connection failed"
- sleep(15)
+ sleep(15)
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-11 22:21:52 UTC (rev 1458)
+++ mgmt/notes/justin-todo.txt 2007-12-11 22:41:25 UTC (rev 1459)
@@ -4,8 +4,6 @@
* Add legends to charts
- * Better demo data
-
* Make group slider in broker browser work
* Add a groups column to the browser broker list
@@ -29,6 +27,8 @@
Deferred
+ * Better demo data
+
* Make mini status tables a little prettier
* Add queue journal stats
18 years, 4 months
rhmessaging commits: r1458 - in mgmt: mint/python/mint and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-11 17:21:52 -0500 (Tue, 11 Dec 2007)
New Revision: 1458
Modified:
mgmt/cumin/python/cumin/__init__.py
mgmt/mint/python/mint/__init__.py
mgmt/notes/justin-todo.txt
Log:
Adds a broker connection thread to (a) avoid delaying mgmt daemon
startup and to periodically attempt to reconnect to brokers that may
have gone down.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2007-12-11 21:45:52 UTC (rev 1457)
+++ mgmt/cumin/python/cumin/__init__.py 2007-12-11 22:21:52 UTC (rev 1458)
@@ -8,6 +8,8 @@
from wooly.parameters import IntegerParameter
from mint import *
from sqlobject.main import *
+from time import sleep
+from threading import Thread
from model import CuminModel
from demo import DemoData
@@ -29,18 +31,8 @@
self.model = CuminModel()
- for reg in BrokerRegistration.select():
- try:
- self.model.data.connectToBroker(reg.host, reg.port or 5672)
- except socket.error:
- print "Failed connecting to broker '%s' at %s:%i" % \
- (reg.name, reg.host, reg.port or 5672)
+ BrokerConnectThread(self.model).start()
- if reg.broker is None:
- pass
- # wait for configCallback to create Broker in db, then
- # connect it to the reg
-
self.cumin_page = CuminPage(self, "cumin.html")
self.set_default_page(self.cumin_page)
@@ -61,3 +53,27 @@
app = Cumin(model)
super(CuminServer, self).__init__(app, port)
+
+class BrokerConnectThread(Thread):
+ def __init__(self, model):
+ super(BrokerConnectThread, self).__init__()
+
+ self.model = model
+ self.setDaemon(True)
+
+ def run(self):
+ while True:
+ for reg in BrokerRegistration.select():
+ print "reg", reg
+
+ if reg.broker is None or reg.broker.managedBroker not in \
+ self.model.data.connectedBrokers:
+
+ try:
+ self.model.data.connectToBroker \
+ (reg.host, reg.port or 5672)
+ except socket.error:
+ print "Failed connecting to broker '%s' at %s:%i" % \
+ (reg.name, reg.host, reg.port or 5672)
+
+ sleep(15)
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2007-12-11 21:45:52 UTC (rev 1457)
+++ mgmt/mint/python/mint/__init__.py 2007-12-11 22:21:52 UTC (rev 1458)
@@ -1,6 +1,8 @@
+import socket
from qpid.management import ManagedBroker
from datetime import *
from sqlobject import *
+from threading import Lock
from mint import schema
@@ -116,6 +118,7 @@
self.outstandingMethodCalls = dict()
self.connectedBrokers = dict()
self.debug = debug
+ self.lock = Lock()
def setDebug(self, debug=True):
self.debug = debug
@@ -193,13 +196,26 @@
return result
def connectToBroker(self, host, port):
- broker = ManagedBroker(host=host, port=port)
- label = "%s:%d" % (host, port)
- self.connectedBrokers[label] = ConnectedBroker(broker)
- broker.configListener(label, self.configCallback)
- broker.instrumentationListener(label, self.instCallback)
- broker.methodListener(label, self.methodCallback)
- broker.start()
+ self.lock.acquire()
+ try:
+ broker = ManagedBroker(host=host, port=port)
+ label = "%s:%d" % (host, port)
+ self.connectedBrokers[label] = ConnectedBroker(broker)
+ broker.configListener(label, self.configCallback)
+ broker.instrumentationListener(label, self.instCallback)
+ broker.methodListener(label, self.methodCallback)
+ try:
+ broker.start()
+ except socket.error:
+ # XXX this is not ideal. I'd prefer to avoid the dict
+ # assignment above until we can verify we can connect. That
+ # way we could avoid the locking as well.
+
+ del self.connectedBrokers[label]
+ raise
+ finally:
+ self.lock.release()
+
return label
def getConnectedBroker(self, label):
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-11 21:45:52 UTC (rev 1457)
+++ mgmt/notes/justin-todo.txt 2007-12-11 22:21:52 UTC (rev 1458)
@@ -17,17 +17,12 @@
* Add said cache to ChartPages as well, perhaps
- * Put broker connects on their own, separate thread so they do not
- delay startup
-
* Render stats without values as something other than 0, say a --
* Render the "" exchange as "Default"
* Add javascript for the check-all behavior
- * Find some way to reattach brokers that come back after being down
-
* Email amqp-list, Jonathan, and Lana with doc requirements for mgmt
* Paginate queue bindings in exchange view
18 years, 4 months
rhmessaging commits: r1457 - in mgmt: notes and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2007-12-11 16:45:52 -0500 (Tue, 11 Dec 2007)
New Revision: 1457
Modified:
mgmt/cumin/python/cumin/client.py
mgmt/cumin/python/cumin/client.strings
mgmt/cumin/python/cumin/exchange.py
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/formats.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/notes/justin-todo.txt
Log:
Connects q,e, and c timestamps to the real data. Makes their
rendering a little prettier and more straightforward.
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/cumin/python/cumin/client.py 2007-12-11 21:45:52 UTC (rev 1457)
@@ -123,13 +123,14 @@
return client.ipAddr
def render_auth_id(self, session, client):
- return "e50e7dcaa8d6a039a"
+ return "e50e7dcaa8d6a039a" #XXX get rid of this
- def render_created_deleted(self, session, queue):
- return "%s - %s" % (fmt_datetime(datetime.utcnow()), "")
+ def render_created_deleted(self, session, client):
+ return "%s – %s" % (fmt_datetime(client.creationTime),
+ fmt_datetime(client.deletionTime))
- def render_updated(self, session, queue):
- return fmt_datetime(datetime.utcnow())
+ def render_updated(self, session, client):
+ return fmt_datetime(client.recTime)
class ClientStatistics(TabSet):
def __init__(self, app, name):
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/cumin/python/cumin/client.strings 2007-12-11 21:45:52 UTC (rev 1457)
@@ -103,7 +103,7 @@
<table class="props">
<tr><th>Address</th><td>{address}</td></tr>
<tr><th>Auth. ID</th><td>{auth_id}</td></tr>
- <tr><th>Created - Deleted</th><td>{created_deleted}</td></tr>
+ <tr><th>Created – Deleted</th><td>{created_deleted}</td></tr>
<tr><th>Updated</th><td>{updated}</td></tr>
<tr>
<th class="actions" colspan="2">
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/cumin/python/cumin/exchange.py 2007-12-11 21:45:52 UTC (rev 1457)
@@ -197,11 +197,12 @@
else:
return exchange.type
- def render_created_deleted(self, session, queue):
- return "%s - %s" % (fmt_datetime(datetime.utcnow()), "")
+ def render_created_deleted(self, session, exchange):
+ return "%s – %s" % (fmt_datetime(exchange.creationTime),
+ fmt_datetime(exchange.deletionTime))
- def render_updated(self, session, queue):
- return fmt_datetime(datetime.utcnow())
+ def render_updated(self, session, exchange):
+ return fmt_datetime(exchange.recTime)
class ExchangeBindingSet(ItemSet):
def get_title(self, session, exchange):
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/cumin/python/cumin/exchange.strings 2007-12-11 21:45:52 UTC (rev 1457)
@@ -162,7 +162,7 @@
<table class="props">
<tr><th>Name</th><td>{name}</td></tr>
<tr><th>Type</th><td>{type}</td></tr>
- <tr><th>Created - Deleted</th><td>{created_deleted}</td></tr>
+ <tr><th>Created – Deleted</th><td>{created_deleted}</td></tr>
<tr><th>Updated</th><td>{updated}</td></tr>
</table>
Modified: mgmt/cumin/python/cumin/formats.py
===================================================================
--- mgmt/cumin/python/cumin/formats.py 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/cumin/python/cumin/formats.py 2007-12-11 21:45:52 UTC (rev 1457)
@@ -7,8 +7,13 @@
return "<span class=\"count\">(%i)</count>" % count
def fmt_datetime(dtime):
- return dtime.strftime("%d %b %Y %H:%M")
+ if dtime:
+ tstamp = dtime.strftime("%d %b %Y %H:%M")
+ else:
+ tstamp = fmt_none()
+ return tstamp
+
# XXX change this to millis or nanos? whatever python wants to give us
def fmt_duration(secs):
"""Takes a duration in seconds, which can be a float"""
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/cumin/python/cumin/queue.py 2007-12-11 21:45:52 UTC (rev 1457)
@@ -202,10 +202,11 @@
return fmt_predicate(queue.exclusive)
def render_created_deleted(self, session, queue):
- return "%s - %s" % (fmt_datetime(datetime.utcnow()), "")
+ return "%s – %s" % (fmt_datetime(queue.creationTime),
+ fmt_datetime(queue.deletionTime))
def render_updated(self, session, queue):
- return fmt_datetime(datetime.utcnow())
+ return fmt_datetime(queue.recTime)
def render_purge_href(self, session, queue):
branch = session.branch()
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/cumin/python/cumin/queue.strings 2007-12-11 21:45:52 UTC (rev 1457)
@@ -177,7 +177,7 @@
<tr><th>Name</th><td>{name}</td></tr>
<tr><th>Durable?</th><td>{durable}</td></tr>
<tr><th>Exclusive?</th><td>{exclusive}</td></tr>
- <tr><th>Created - Deleted</th><td>{created_deleted}</td></tr>
+ <tr><th>Created – Deleted</th><td>{created_deleted}</td></tr>
<tr><th>Updated</th><td>{updated}</td></tr>
<tr>
<th class="actions" colspan="2">
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2007-12-11 21:04:27 UTC (rev 1456)
+++ mgmt/notes/justin-todo.txt 2007-12-11 21:45:52 UTC (rev 1457)
@@ -2,14 +2,8 @@
* "purge messages from queues"
- * "purge messages from queue"
-
- * Make mini status tables a little prettier
-
* Add legends to charts
- * Make sure queue accel. a proper rate value
-
* Better demo data
* Make group slider in broker browser work
@@ -26,8 +20,6 @@
* Put broker connects on their own, separate thread so they do not
delay startup
- * Connect queue, exchange, and broker dates to the data
-
* Render stats without values as something other than 0, say a --
* Render the "" exchange as "Default"
@@ -42,6 +34,8 @@
Deferred
+ * Make mini status tables a little prettier
+
* Add queue journal stats
* Queue: Add a msg enq rate msg deq rate chart
18 years, 4 months