rhmessaging commits: r1795 - mgmt/bin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-25 16:23:42 -0400 (Tue, 25 Mar 2008)
New Revision: 1795
Added:
mgmt/bin/reschema
Log:
A quick script to reload the schema; for devel purposes
Added: mgmt/bin/reschema
===================================================================
--- mgmt/bin/reschema (rev 0)
+++ mgmt/bin/reschema 2008-03-25 20:23:42 UTC (rev 1795)
@@ -0,0 +1,5 @@
+#!/bin/bash -ex
+
+cumin-admin drop-schema --force
+cumin-admin create-schema --force
+cumin-admin add-…
[View More]user guest
Property changes on: mgmt/bin/reschema
___________________________________________________________________
Name: svn:executable
+ *
[View Less]
16 years, 9 months
rhmessaging commits: r1794 - in mgmt: mint/python/mint and 1 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-25 15:32:12 -0400 (Tue, 25 Mar 2008)
New Revision: 1794
Added:
mgmt/cumin/bin/cumin-database-destroy
Modified:
mgmt/cumin/bin/cumin-admin
mgmt/cumin/bin/cumin-database-init
mgmt/mint/python/mint/__init__.py
mgmt/mint/sql/schema.sql
Log:
Changes to the way databases are initially configured. This is in
preparation for a more secure default database config.
* Adds a cli tool cumin-database-destroy for getting rid of all
database state associated …
[View More]with cumin.
* Adds a mint_info table with a version and a db.checkSchema method.
* Makes cumin-database-init use the cumin-admin schema commands.
Modified: mgmt/cumin/bin/cumin-admin
===================================================================
--- mgmt/cumin/bin/cumin-admin 2008-03-25 18:47:35 UTC (rev 1793)
+++ mgmt/cumin/bin/cumin-admin 2008-03-25 19:32:12 UTC (rev 1794)
@@ -76,6 +76,8 @@
print "Error: command create-schema requires --force yes"
print_usage(config)
sys.exit(1)
+ elif command == "check-schema":
+ database.checkSchema()
elif command == "add-user":
if len(args) != 2:
print "Error: no user name given"
Added: mgmt/cumin/bin/cumin-database-destroy
===================================================================
--- mgmt/cumin/bin/cumin-database-destroy (rev 0)
+++ mgmt/cumin/bin/cumin-database-destroy 2008-03-25 19:32:12 UTC (rev 1794)
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+# This script assumes that postgresql is configured and running
+
+if [ "$EUID" -ne "0" ]; then
+ echo "This script must be run as root"
+ exit 2
+fi
+
+su - postgres -c "dropdb cumin"
+su - postgres -c "dropuser cumin"
Property changes on: mgmt/cumin/bin/cumin-database-destroy
___________________________________________________________________
Name: svn:executable
+ *
Modified: mgmt/cumin/bin/cumin-database-init
===================================================================
--- mgmt/cumin/bin/cumin-database-init 2008-03-25 18:47:35 UTC (rev 1793)
+++ mgmt/cumin/bin/cumin-database-init 2008-03-25 19:32:12 UTC (rev 1794)
@@ -2,43 +2,18 @@
# This script assumes that postgresql is configured and running
-if [ "$1" = "-h" -o "$1" = "--help" ]; then
- echo "Usage: cumin-database-init [USER-NAME] [DATABASE-NAME] [SCHEMA-FILE]"
- exit 2
-fi
-
if [ "$EUID" -ne "0" ]; then
echo "This script must be run as root"
exit 2
fi
-user="$1"
+su - postgres -c "createuser --superuser cumin"
+su - postgres -c "createdb --owner=cumin cumin"
-if [ -z "$user" -o "$user" = "-" ]; then
- user="cumin"
-fi
+cumin-admin check-schema | grep -e '^OK '
-db="$2"
-
-if [ -z "$db" -o "$db" = "-" ]; then
- db="cumin"
+if [ "$?" = 0 ]; then
+ echo "Not creating schema; it already exists"
+else
+ cumin-admin --force 1 create-schema
fi
-
-schema="$3"
-
-if [ -z "$schema" -o "$schema" = "-" ]; then
- if [ -z "$CUMIN_HOME" ]; then
- CUMIN_HOME=/usr/share/cumin
- fi
-
- schema="${CUMIN_HOME}/sql/schema.sql"
-fi
-
-if [ ! -f "$schema" ]; then
- echo "Schema file '$schema' not found"
- exit 2
-fi
-
-su postgres -c "createuser --superuser ${user}"
-su postgres -c "createdb --owner=${user} ${db}"
-psql -U "$user" -d "$db" -f "$schema"
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2008-03-25 18:47:35 UTC (rev 1793)
+++ mgmt/mint/python/mint/__init__.py 2008-03-25 19:32:12 UTC (rev 1794)
@@ -23,6 +23,12 @@
Broker.sqlmeta.addJoin(SQLMultipleJoin("BrokerRegistration",
joinMethodName="registrations"))
+class MintInfo(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ version = StringCol(length=1000, default="0.1", notNone=True)
+
class BrokerRegistration(SQLObject):
class sqlmeta:
lazyUpdate = True
@@ -407,6 +413,7 @@
conn = self.getConnection()
try:
cursor = conn.cursor()
+
cursor.execute("drop schema public cascade")
conn.commit()
@@ -428,7 +435,10 @@
try:
cursor = conn.cursor()
- cursor.execute("create schema public")
+ try:
+ cursor.execute("create schema public");
+ except:
+ pass
for path, text in scripts:
stmts = text.split(";")
@@ -450,6 +460,24 @@
print "Executed %i statements from file '%s'" % (count, path)
+ cursor.execute("insert into mint_info (version) values ('0.1')")
+
conn.commit()
finally:
conn.close()
+
+ def checkSchema(self):
+ conn = self.getConnection()
+
+ try:
+ cursor = conn.cursor()
+ cursor.execute("select version from mint_info");
+
+ for rec in cursor:
+ print "OK (version %s)" % rec[0]
+ return;
+
+ print "No schema present"
+
+ finally:
+ conn.close()
Modified: mgmt/mint/sql/schema.sql
===================================================================
--- mgmt/mint/sql/schema.sql 2008-03-25 18:47:35 UTC (rev 1793)
+++ mgmt/mint/sql/schema.sql 2008-03-25 19:32:12 UTC (rev 1794)
@@ -45,6 +45,11 @@
last_logged_out TIMESTAMP
);
+CREATE TABLE mint_info (
+ id SERIAL PRIMARY KEY,
+ version VARCHAR(1000) NOT NULL
+);
+
CREATE TABLE binding (
id SERIAL PRIMARY KEY,
id_original BIGINT,
[View Less]
16 years, 9 months
rhmessaging commits: r1793 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-25 14:47:35 -0400 (Tue, 25 Mar 2008)
New Revision: 1793
Modified:
mgmt/cumin/python/cumin/brokergroup.py
Log:
Fix a typo
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-03-25 18:39:50 UTC (rev 1792)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-03-25 18:47:35 UTC (rev 1793)
@@ -105,7 +105,7 @@
def render_href(self, session, group):
…
[View More] if group:
- return super(BrokerGroupFrame, self).render_href(sesion, group)
+ return super(BrokerGroupFrame, self).render_href(session, group)
class BrokerGroupStatus(CuminStatus):
pass
[View Less]
16 years, 9 months
rhmessaging commits: r1792 - mgmt/mint.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-25 14:39:50 -0400 (Tue, 25 Mar 2008)
New Revision: 1792
Modified:
mgmt/mint/Makefile
Log:
Repair makefile syntax
Modified: mgmt/mint/Makefile
===================================================================
--- mgmt/mint/Makefile 2008-03-24 21:32:40 UTC (rev 1791)
+++ mgmt/mint/Makefile 2008-03-25 18:39:50 UTC (rev 1792)
@@ -29,9 +29,9 @@
schema: schema-python schema-sql
schema-python:
- ifndef MINT_SCHEMA_XML
- $(error "MINT_SCHEMA_XML is not set")
-…
[View More] endif
+ifndef MINT_SCHEMA_XML
+ $(error "MINT_SCHEMA_XML is not set")
+endif
python python/mint/schemaparser.py ${MINT_SCHEMA_XML} python/mint/schema.py ${dsn}
schema-sql:
[View Less]
16 years, 9 months
rhmessaging commits: r1791 - in mgmt: notes and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-24 17:32:40 -0400 (Mon, 24 Mar 2008)
New Revision: 1791
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/model.py
mgmt/cumin/python/cumin/queue.py
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/widgets.py
mgmt/notes/justin-todo.txt
Log:
bz435989 - Don't display stale rate data in tables or …
[View More]stat readouts.
Introduces a reusable column object, FreshDataOnlyColumn, to implement
this behavior in tables.
Modified: mgmt/cumin/python/cumin/client.py
===================================================================
--- mgmt/cumin/python/cumin/client.py 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/client.py 2008-03-24 21:32:40 UTC (rev 1791)
@@ -99,7 +99,7 @@
#return fmt_link(branch.marshal(), client.sessions.count())
return "XXX"
- class SentColumn(NullSortColumn):
+ class SentColumn(NullSortColumn, FreshDataOnlyColumn):
def render_title(self, session, data):
return "%s Sent" % self.parent.get_unit_plural(session)
@@ -110,7 +110,7 @@
def render_value(self, session, value):
return fmt_rate(value, "", "sec")
- class ReceivedColumn(NullSortColumn):
+ class ReceivedColumn(NullSortColumn, FreshDataOnlyColumn):
def render_title(self, session, data):
return "%s Received" % self.parent.get_unit_plural(session)
Modified: mgmt/cumin/python/cumin/client.strings
===================================================================
--- mgmt/cumin/python/cumin/client.strings 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/client.strings 2008-03-24 21:32:40 UTC (rev 1791)
@@ -13,7 +13,8 @@
case when p.bytes_to_client is null then true else false end as br_is_null,
(c.frames_to_client - p.frames_to_client)
/ (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as fr,
- case when p.frames_to_client is null then true else false end as fr_is_null
+ case when p.frames_to_client is null then true else false end as fr_is_null,
+ c.rec_time
from client as l
left outer join client_stats as c on c.id = l.stats_curr_id
left outer join client_stats as p on p.id = l.stats_prev_id
Modified: mgmt/cumin/python/cumin/exchange.py
===================================================================
--- mgmt/cumin/python/cumin/exchange.py 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/exchange.py 2008-03-24 21:32:40 UTC (rev 1791)
@@ -116,7 +116,7 @@
frame.show_view(branch).show_bindings(branch)
return fmt_link(branch.marshal(), data["bindings"])
- class ReceivedColumn(NullSortColumn):
+ class ReceivedColumn(NullSortColumn, FreshDataOnlyColumn):
def render_title(self, session, data):
return "%s Received" % self.parent.unit.get_brief_plural(session)
@@ -127,7 +127,7 @@
def render_value(self, session, value):
return fmt_rate(value, "", "sec")
- class RoutedColumn(NullSortColumn):
+ class RoutedColumn(NullSortColumn, FreshDataOnlyColumn):
def render_title(self, session, data):
return "%s Routed" % self.parent.unit.get_brief_plural(session)
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/exchange.strings 2008-03-24 21:32:40 UTC (rev 1791)
@@ -23,7 +23,8 @@
/ (extract(epoch from (c.rec_time - p.rec_time)) + 0.0001) as brouted,
case when p.byte_routes is null then true else false end as brouted_is_null,
c.msg_drops as mdropped,
- c.byte_drops as bdropped
+ c.byte_drops as bdropped,
+ c.rec_time
from exchange as e
left outer join exchange_stats as c on c.id = e.stats_curr_id
left outer join exchange_stats as p on p.id = e.stats_prev_id
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/model.py 2008-03-24 21:32:40 UTC (rev 1791)
@@ -220,8 +220,10 @@
return text
def rate(self, object):
+ threshold = datetime.now() - timedelta(minutes=10)
+
try:
- if object.statsCurr:
+ if object.statsCurr and object.statsCurr.recTime > threshold:
curr = getattr(object.statsCurr, self.name)
ctime = object.statsCurr.recTime
csecs = mktime(ctime.timetuple())
Modified: mgmt/cumin/python/cumin/queue.py
===================================================================
--- mgmt/cumin/python/cumin/queue.py 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/queue.py 2008-03-24 21:32:40 UTC (rev 1791)
@@ -123,7 +123,7 @@
frame.show_view(branch).show_bindings(branch)
return fmt_link(branch.marshal(), data["bindings"])
- class EnqueuedColumn(NullSortColumn):
+ class EnqueuedColumn(NullSortColumn, FreshDataOnlyColumn):
def render_title(self, session, data):
return "%s Enqueued" % self.parent.unit.get_brief_plural(session)
@@ -134,7 +134,7 @@
def render_value(self, session, value):
return fmt_rate(value, "", "sec")
- class DequeuedColumn(NullSortColumn):
+ class DequeuedColumn(NullSortColumn, FreshDataOnlyColumn):
def render_title(self, session, data):
return "%s Dequeued" % self.parent.unit.get_brief_plural(session)
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/queue.strings 2008-03-24 21:32:40 UTC (rev 1791)
@@ -19,7 +19,8 @@
c.msg_depth as mdepth,
c.byte_depth as bdepth,
1 as mdepthaccel,
- 1 as bdepthaccel
+ 1 as bdepthaccel,
+ c.rec_time
from queue as q
left outer join queue_stats as c on c.id = q.stats_curr_id
left outer join queue_stats as p on p.id = q.stats_prev_id
Modified: mgmt/cumin/python/cumin/widgets.py
===================================================================
--- mgmt/cumin/python/cumin/widgets.py 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/cumin/python/cumin/widgets.py 2008-03-24 21:32:40 UTC (rev 1791)
@@ -1,3 +1,4 @@
+from datetime import datetime, timedelta
from math import ceil
from sqlobject import sqlhub
from sqlobject.sresults import SelectResults
@@ -444,6 +445,27 @@
dir = self.parent.is_reversed(session) and "desc" or "asc"
return "order by %s_is_null asc, %s %s" % (key, key, dir)
+class FreshDataOnlyColumn(SqlTableColumn):
+ def __init__(self, app, name):
+ super(FreshDataOnlyColumn, self).__init__(app, name)
+
+ self.__ago = self.TimeAgo(app, "ago")
+ self.add_attribute(self.__ago)
+
+ def render_content(self, session, data):
+ key = self.get_column_key(session)
+
+ if data["rec_time"] > self.__ago.get(session):
+ html = self.render_value(session, data[key])
+ else:
+ html = fmt_none_brief()
+
+ return html
+
+ class TimeAgo(Attribute):
+ def get_default(self, session):
+ return datetime.now() - timedelta(minutes=10)
+
class PaginatedItemSet(ItemSet):
def __init__(self, app, name):
super(PaginatedItemSet, self).__init__(app, name)
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2008-03-24 21:28:20 UTC (rev 1790)
+++ mgmt/notes/justin-todo.txt 2008-03-24 21:32:40 UTC (rev 1791)
@@ -8,14 +8,14 @@
* Don't let anyone close mgmt clients
- - Waiting on an api change from Ted
-
* Put some kind of status on broker
- * Gray out old rates
-
* Make it possible to navigate from broker to system
+ * Update the README
+
+ * Fix the status box updates, to avoid the "/sec" display
+
Deferred
* Blow up if we try to call set_redirect_url twice in a session
[View Less]
16 years, 9 months
rhmessaging commits: r1790 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-24 17:28:20 -0400 (Mon, 24 Mar 2008)
New Revision: 1790
Modified:
mgmt/cumin/python/cumin/brokergroup.py
Log:
Fix a crasher link
Modified: mgmt/cumin/python/cumin/brokergroup.py
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.py 2008-03-24 19:54:24 UTC (rev 1789)
+++ mgmt/cumin/python/cumin/brokergroup.py 2008-03-24 21:28:20 UTC (rev 1790)
@@ -103,6 +103,10 @@
return title
+ def …
[View More]render_href(self, session, group):
+ if group:
+ return super(BrokerGroupFrame, self).render_href(sesion, group)
+
class BrokerGroupStatus(CuminStatus):
pass
[View Less]
16 years, 9 months
rhmessaging commits: r1789 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-24 15:54:24 -0400 (Mon, 24 Mar 2008)
New Revision: 1789
Modified:
mgmt/cumin/python/cumin/formats.py
Log:
Fix a mismatched tag error
Modified: mgmt/cumin/python/cumin/formats.py
===================================================================
--- mgmt/cumin/python/cumin/formats.py 2008-03-24 18:15:01 UTC (rev 1788)
+++ mgmt/cumin/python/cumin/formats.py 2008-03-24 19:54:24 UTC (rev 1789)
@@ -4,7 +4,7 @@
from util import *
def fmt_count(count):
- …
[View More]return "<span class=\"count\">(%i)</count>" % count
+ return "<span class=\"count\">(%i)</span>" % count
def fmt_datetime(dtime):
if dtime:
[View Less]
16 years, 9 months
rhmessaging commits: r1788 - mgmt/cumin/bin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-24 14:15:01 -0400 (Mon, 24 Mar 2008)
New Revision: 1788
Modified:
mgmt/cumin/bin/cumin-admin
Log:
Fix cumin-admin after the config changes.
Modified: mgmt/cumin/bin/cumin-admin
===================================================================
--- mgmt/cumin/bin/cumin-admin 2008-03-24 17:40:53 UTC (rev 1787)
+++ mgmt/cumin/bin/cumin-admin 2008-03-24 18:15:01 UTC (rev 1788)
@@ -9,24 +9,19 @@
from mint import MintDatabase, ConsoleUser
from psycopg2 import …
[View More]IntegrityError
+from cumin import CuminConfig
from cumin.util import *
-def usage():
- print """Usage: cumin-admin [OPTIONS...] COMMAND
-Options:
- -h, --help Print this message
- --data URL Connect to database at URL
- (default postgesql://cumin@localhost/cumin)
- --force yes Don't complain and just do it
-Commands:
+def print_usage(config):
+ config.print_usage("cumin-admin")
+
+ print """Commands:
create-schema Create the database schema
- drop-schema Drop the database schema; requires "--force yes"
+ drop-schema Drop the database schema; requires --force yes
add-user NAME Add user called NAME
- remove-user NAME Remove user called NAME; requires "--force yes"
- list-users List existing users
-"""
- sys.exit(1)
+ remove-user NAME Remove user called NAME; requires --force yes
+ list-users List existing users"""
def parse_command_args():
args = list()
@@ -41,55 +36,51 @@
return args
def main():
- if "-h" in sys.argv or "--help" in sys.argv:
- usage()
+ config = CuminConfig()
+ config.add_param("force", bool, False, "Don't complain and just do it")
- home = os.environ.get("CUMIN_HOME")
+ # XXX I think we need to avoid using sys.argv inside of CuminConfig
- if not home:
- home = os.path.normpath("/usr/share/cumin")
+ config.init()
- config = Config()
- config.add_param("data", str, "postgresql://cumin@localhost/cumin")
- config.add_param("force", bool, False)
+ if "-h" in sys.argv or "--help" in sys.argv:
+ print_usage(config)
+ sys.exit(0)
+
- config.load_file(os.path.join(home, "etc", "cumin.conf"))
- config.load_file(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
- config.load_args(sys.argv)
+ if config.debug:
+ config.prt()
- config.prt()
-
- home = os.environ["CUMIN_HOME"]
- data = config.get("data")
- force = config.get("force")
-
args = parse_command_args()
if not args:
print "Error: no command found"
- usage()
+ print_usage(config)
+ sys.exit(1)
command = args[0]
- database = MintDatabase(data)
+ database = MintDatabase(config.data)
database.check()
database.init()
if command == "create-schema":
- main = os.path.join(home, "sql", "schema.sql")
- indexes = os.path.join(home, "sql", "indexes.sql")
+ main = os.path.join(config.home, "sql", "schema.sql")
+ indexes = os.path.join(config.home, "sql", "indexes.sql")
database.createSchema((main, indexes))
elif command == "drop-schema":
- if force:
+ if config.force:
database.dropSchema()
else:
print "Error: command create-schema requires --force yes"
- usage()
+ print_usage(config)
+ sys.exit(1)
elif command == "add-user":
if len(args) != 2:
print "Error: no user name given"
- usage()
+ print_usage(config)
+ sys.exit(1)
name = args[1]
@@ -111,7 +102,7 @@
if force:
if len(args) != 2:
print "Error: no user name given"
- usage()
+ sys.exit(1)
accounts = ConsoleUser.selectBy(name=args[1])
@@ -123,11 +114,14 @@
print "Error: no such user '%s'" % args[1]
else:
print "Error: command remove-user requires --force yes"
- usage()
+ sys.exit(1)
elif command == "list-users":
accounts = ConsoleUser.select(orderBy='name')
+ print " id name"
+ print "---- " + ("-" * 20)
+
for account in accounts:
print "%4i %s" % (account.id, account.name)
@@ -135,7 +129,8 @@
print "(%i user%s found)" % (count, ess(count))
else:
print "Error: command '%s' not recognized" % command
- usage()
+ print_usage(config)
+ sys.exit(1)
if __name__ == "__main__":
try:
[View Less]
16 years, 9 months
rhmessaging commits: r1787 - store/trunk/cpp/lib.
by rhmessaging-commits@lists.jboss.org
Author: astitcher
Date: 2008-03-24 13:40:53 -0400 (Mon, 24 Mar 2008)
New Revision: 1787
Modified:
store/trunk/cpp/lib/JournalImpl.h
Log:
Small fix for refactored RefCounted class
Modified: store/trunk/cpp/lib/JournalImpl.h
===================================================================
--- store/trunk/cpp/lib/JournalImpl.h 2008-03-21 20:54:51 UTC (rev 1786)
+++ store/trunk/cpp/lib/JournalImpl.h 2008-03-24 17:40:53 UTC (rev 1787)
@@ -69,12 +69,12 @@
static qpid::broker::…
[View More]Timer journalTimer;
bool getEventsTimerSetFlag;
- qpid::intrusive_ptr<qpid::broker::TimerTask> getEventsFireEventsPtr;
+ boost::intrusive_ptr<qpid::broker::TimerTask> getEventsFireEventsPtr;
pthread_mutex_t _getf_mutex; // getEventsTimerSetFlag mutex
bool writeActivityFlag;
bool flushTriggeredFlag;
- qpid::intrusive_ptr<qpid::broker::TimerTask> inactivityFireEventPtr;
+ boost::intrusive_ptr<qpid::broker::TimerTask> inactivityFireEventPtr;
// temp local vars for loadMsgContent below
void* _xidp;
[View Less]
16 years, 9 months
rhmessaging commits: r1786 - in mgmt/cumin: python/cumin and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-03-21 16:54:51 -0400 (Fri, 21 Mar 2008)
New Revision: 1786
Modified:
mgmt/cumin/bin/cumin
mgmt/cumin/bin/cumin-admin
mgmt/cumin/bin/cumin-bench
mgmt/cumin/bin/cumin-test
mgmt/cumin/python/cumin/__init__.py
mgmt/cumin/python/cumin/util.py
Log:
Clean up the command-line option and config file parser. Add support
for option summaries. Use this to generate consistent command line
usage.
Take profiling out of cumin-test, since we don't need it there.
…
[View More]
Modified: mgmt/cumin/bin/cumin
===================================================================
--- mgmt/cumin/bin/cumin 2008-03-21 18:49:34 UTC (rev 1785)
+++ mgmt/cumin/bin/cumin 2008-03-21 20:54:51 UTC (rev 1786)
@@ -5,25 +5,11 @@
from cumin import *
from cumin.util import *
-def usage():
- print """Usage: cumin OPTIONS...
-Options:
- -h, --help Print this message
- --data URI Connect to database at URI
- (default postgesql://cumin@localhost/cumin)
- --spec PATH Use AMQP spec file at PATH
- --addr ADDR Run web server at address ADDR (default localhost)
- --port PORT Run web server on port PORT (default 8080)
- --ssl yes Serve pages using SSL (default no)
- --debug Enable debugging"""
-
- sys.exit(1)
-
-def do_main(home, data, spec, addr, port, ssl, debug):
- app = Cumin(home, data, spec)
+def do_main(config):
+ app = Cumin(config.home, config.data, config.spec)
log = logging.getLogger("cumin.config")
- if debug:
+ if config.debug:
app.enable_debug()
try:
@@ -36,9 +22,9 @@
app.init()
- server = CuminServer(app, addr, port)
+ server = CuminServer(app, config.addr, config.port)
- if ssl:
+ if config.ssl:
cpath = os.path.join(home, "etc", "cumin.crt")
kpath = os.path.join(home, "etc", "cumin.key")
@@ -61,27 +47,27 @@
raise
def main():
- if "-h" in sys.argv or "--help" in sys.argv:
- usage()
-
config = CuminConfig()
- config.add_param("addr", "s", "localhost")
- config.add_param("port", "i", 8080)
- config.add_param("ssl", "b", False)
+
+ summ = ("ADDR", "Run web server at address ADDR")
+ config.add_param("addr", str, "localhost", summ)
+
+ summ = ("PORT", "Run web server on port PORT")
+ config.add_param("port", int, 8080, summ)
+
+ summ = "Serve web pages using SSL"
+ config.add_param("ssl", bool, False, summ)
+
config.init()
- home = config.home
- data = config.get("data")
- spec = config.get("spec")
- addr = config.get("addr")
- port = config.get("port")
- ssl = config.get("ssl")
- debug = config.get("debug")
+ if "-h" in sys.argv or "--help" in sys.argv:
+ config.print_usage("cumin")
+ sys.exit(0)
- if debug:
+ if config.debug:
config.prt()
- do_main(home, data, spec, addr, port, ssl, debug)
+ do_main(config)
if __name__ == "__main__":
try:
Modified: mgmt/cumin/bin/cumin-admin
===================================================================
--- mgmt/cumin/bin/cumin-admin 2008-03-21 18:49:34 UTC (rev 1785)
+++ mgmt/cumin/bin/cumin-admin 2008-03-21 20:54:51 UTC (rev 1786)
@@ -50,8 +50,8 @@
home = os.path.normpath("/usr/share/cumin")
config = Config()
- config.add_param("data", "s", "postgresql://cumin@localhost/cumin")
- config.add_param("force", "b", False)
+ config.add_param("data", str, "postgresql://cumin@localhost/cumin")
+ config.add_param("force", bool, False)
config.load_file(os.path.join(home, "etc", "cumin.conf"))
config.load_file(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
Modified: mgmt/cumin/bin/cumin-bench
===================================================================
--- mgmt/cumin/bin/cumin-bench 2008-03-21 18:49:34 UTC (rev 1785)
+++ mgmt/cumin/bin/cumin-bench 2008-03-21 20:54:51 UTC (rev 1786)
@@ -8,16 +8,6 @@
from cumin.test import *
from cumin.util import *
-def usage():
- print """Usage: cumin-bench OPTIONS...
-Options:
- -h, --help Print this message
- --data URL Connect to database at URL
- (default postgesql://cumin@localhost/cumin)
- --hits HITS Stop at HITS page hits (default 1000)
- --profile"""
- sys.exit(1)
-
def do_main(home, data, spec, hits):
app = Cumin(home, data, spec)
@@ -41,24 +31,30 @@
pass
def main():
- if "-h" in sys.argv or "--help" in sys.argv:
- usage()
-
config = CuminConfig()
- config.add_param("hits", "i", 1000)
- config.add_param("profile", "b", False)
+
+ summ = ("COUNT", "Stop after COUNT page hits")
+ config.add_param("hits", int, 1000, summ)
+
+ summ = "Enable profiling"
+ config.add_param("profile", bool, False, summ)
+
config.init()
- if config.get("debug"):
+ if "-h" in sys.argv or "--help" in sys.argv:
+ config.print_usage("cumin-bench")
+ sys.exit(0)
+
+ if config.debug:
config.prt()
home = config.home
- data = config.get("data")
- spec = config.get("spec")
- hits = config.get("hits")
- profile = config.get("profile")
+ data = config.data
+ spec = config.spec
+ hits = config.hits
+ profile = config.profile
- if profile:
+ if config.profile:
from profile import Profile
from pstats import Stats
Modified: mgmt/cumin/bin/cumin-test
===================================================================
--- mgmt/cumin/bin/cumin-test 2008-03-21 18:49:34 UTC (rev 1785)
+++ mgmt/cumin/bin/cumin-test 2008-03-21 20:54:51 UTC (rev 1786)
@@ -2,29 +2,15 @@
import sys, os
from time import time
-from wooly.devel import BenchmarkHarness
from cumin import *
from cumin.test import *
from cumin.util import *
-def usage():
- print """Usage: cumin-test OPTIONS...
-Options:
- -h, --help Print this message
- --data URI Connect to database at URI
- (default postgesql://cumin@localhost/cumin)
- --spec PATH Use AMQP spec file at PATH
- --broker ADDRESS Register new test broker at ADDRESS
- (default localhost:5672)
- --profile yes Enable profiling
- --debug yes Enable debugging"""
- sys.exit(1)
+def do_main(config):
+ app = Cumin(config.home, config.data, config.spec)
-def do_main(home, data, spec, broker_host, broker_port, debug):
- app = Cumin(home, data, spec)
-
- if debug or bench:
+ if config.debug:
app.enable_debug()
try:
@@ -37,64 +23,30 @@
app.init()
- env = TestEnvironment(app, broker_host, broker_port)
+ host, port = parse_broker_addr(config.broker)
+
+ env = TestEnvironment(app, host, port)
env.init();
session = env.run_test(MainTest(env))
session.report(sys.stdout)
def main():
- if "-h" in sys.argv or "--help" in sys.argv:
- usage()
-
config = CuminConfig()
- config.add_param("broker", "s", "localhost:5672")
- config.add_param("profile", "b", False)
- config.init()
- if config.get("debug"):
- config.prt()
+ summ = ("ADDR", "Register new test broker at ADDR")
+ config.add_param("broker", str, "localhost:5672", summ)
- home = config.home
- data = config.get("data")
- spec = config.get("spec")
- broker = config.get("broker")
- debug = config.get("debug")
- profile = config.get("profile")
+ config.init()
- host, port = parse_broker_addr(broker)
+ if "-h" in sys.argv or "--help" in sys.argv:
+ config.print_usage("cumin-test")
+ sys.exit(0)
- if profile:
- from profile import Profile
- from pstats import Stats
+ if config.debug:
+ config.prt()
- prof = Profile()
+ do_main(config)
- try:
- statement = "do_main('%s', '%s', '%s', %s, %i, %r)" \
- % (home, data, host, port, debug)
-
- prof.run(statement)
-
- raise KeyboardInterrupt()
- except KeyboardInterrupt:
- file = "/tmp/cumin-test-stats"
-
- prof.dump_stats(file)
-
- stats = Stats(file)
-
- stats.sort_stats("cumulative").print_stats(15)
- stats.sort_stats("time").print_stats(15)
-
- stats.print_callees("wooly/__init__.*\\(marshal_url_vars\\)")
- stats.print_callees("wooly/__init__.*\\(path\\)")
- stats.print_callees("wooly/__init__.*\\(get\\)")
- stats.print_callees("wooly/__init__.*\\(render\\)")
-
- stats.strip_dirs()
- else:
- do_main(home, data, spec, host, port, debug)
-
if __name__ == "__main__":
main()
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2008-03-21 18:49:34 UTC (rev 1785)
+++ mgmt/cumin/python/cumin/__init__.py 2008-03-21 20:54:51 UTC (rev 1786)
@@ -141,15 +141,27 @@
sdef = os.path.normpath("/usr/share/amqp/amqp.0-10-preview.xml")
spec = os.environ.get("AMQP_SPEC", sdef)
- self.add_param("debug", "b", False)
- self.add_param("data", "s", "postgresql://cumin@localhost/cumin")
- self.add_param("spec", "s", spec)
- self.add_param("log", "s", os.path.join(self.home, "log", "cumin.log"))
+ summ = "Print this message"
+ self.add_param("help", bool, False, summ)
+ summ = ("URI", "Connect to database at URI")
+ self.add_param("data", str, "postgresql://cumin@localhost/cumin", summ)
+
+ summ = ("PATH", "Use AMQP spec file at PATH")
+ self.add_param("spec", str, spec, summ)
+
+ lpath = os.path.join(self.home, "log", "cumin.log")
+ summ = ("PATH", "Log to file at PATH")
+ self.add_param("log", str, lpath, summ)
+
+ summ = "Enable debug mode"
+ self.add_param("debug", bool, False, summ)
+
def init(self):
root = logging.getLogger()
root.setLevel(logging.NOTSET)
+ self.load_defaults()
self.load_args(sys.argv)
h = self.get_console_handler()
@@ -162,8 +174,8 @@
h = self.get_console_handler()
root.addHandler(h)
- h = logging.FileHandler(self.get("log"))
- if self.get("debug"):
+ h = logging.FileHandler(self.log)
+ if self.debug:
h.setLevel(logging.DEBUG)
else:
h.setLevel(logging.INFO)
@@ -171,7 +183,7 @@
def get_console_handler(self):
h = logging.StreamHandler()
- if self.get("debug"):
+ if self.debug:
h.setLevel(logging.DEBUG)
else:
h.setLevel(logging.ERROR)
Modified: mgmt/cumin/python/cumin/util.py
===================================================================
--- mgmt/cumin/python/cumin/util.py 2008-03-21 18:49:34 UTC (rev 1785)
+++ mgmt/cumin/python/cumin/util.py 2008-03-21 20:54:51 UTC (rev 1786)
@@ -39,57 +39,45 @@
self.id = id
class Config(object):
- log = getLogger("cumin.config")
+ __log = getLogger("cumin.config")
def __init__(self):
self.__params = list()
- self.__param_specs = dict() # param name => (type, default)
- self.__values = dict()
+ self.__params_by_name = dict()
- def add_param(self, name, type, default):
- self.__params.append(name)
- self.__param_specs[name] = (type, default)
+ def add_param(self, name, type, default=None, summary=None):
+ param = self.Parameter(name, type, default, summary)
+ self.__params.append(param)
+ self.__params_by_name[name] = param
- def set(self, name, value):
- self.__values[name] = value
- return value
-
- def unmarshal(self, name, string):
- type, default = self.__param_specs[name]
-
- if type == "i":
+ def unmarshal(self, param, string):
+ if param.type is int:
value = int(string)
- elif type == "b":
+ elif param.type is bool:
value = string is None or \
string.lower() in ("y", "yes", "t", "true", "1")
- elif type == "s":
+ elif param.type is str:
value = string
else:
- raise Exception("Invalid type '%s'" % type)
+ raise Exception("Invalid type %s" % type)
return value
- def get(self, name):
- if name not in self.__params:
- raise Exception("Parameter '%s' not found" % name)
+ def load_defaults(self):
+ for param in self.__params:
+ if hasattr(self, param.name):
+ raise Exception("Parameter '%s' already present" % name)
- type, default = self.__param_specs[name]
+ setattr(self, param.name, param.default)
- if name in self.__values:
- value = self.__values.get(name)
- else:
- value = default
-
- return value
-
def load_file(self, file):
conf = SafeConfigParser()
found = conf.read(file)
if found:
- self.log.info("Found config file '%s' and read it" % file)
+ self.__log.info("Read config file '%s'" % file)
else:
- self.log.info("Config file '%s' not found" % file)
+ self.__log.info("Config file '%s' not found" % file)
params = dict()
@@ -115,30 +103,54 @@
def load_string_params(self, params):
for name, value in params.items():
- if name in self.__params:
- self.set(name, self.unmarshal(name, value))
+ param = self.__params_by_name.get(name)
+
+ if param:
+ setattr(self, param.name, self.unmarshal(param, value))
else:
- self.log.info("Ignoring unrecognized parameter '%s'" % name)
+ self.__log.info("Ignoring unrecognized parameter '%s'" % name)
- def require(self, params):
- missing = list()
+ def print_usage(self, cmd):
+ print "Usage: %s OPTIONS..." % cmd
+ print "Options:"
- for param in params:
- if param not in self.__values:
- missing.append(param)
+ for param in self.__params:
+ if param.summary:
+ if type(param.summary) is str:
+ opt = "--%s" % param.name
+ text = param.summary
+ else:
+ opt = "--%s %s" % (param.name, param.summary[0])
+ text = param.summary[1]
- return missing
+ main = " %-15s %s" % (opt, text)
+ extra = ""
+ if param.default not in (None, False):
+ extra = "(default %s)" % param.default
+
+ if len(main) + len(extra) > 79:
+ print main
+ print " %15s %s" % ("", extra)
+ else:
+ print main, extra
+
def prt(self):
print "Configuration:"
for param in self.__params:
- type, default = self.__param_specs[param]
- value = self.get(param)
+ value = getattr(self, param.name)
- if param in self.__values:
+ if value == param.default:
+ flag = " [default]"
+ else:
flag = ""
- else:
- flag = " [default]"
- print " %s = %s%s" % (param, value, flag)
+ print " %s = %s%s" % (param.name, value, flag)
+
+ class Parameter(object):
+ def __init__(self, name, type, default=None, summary=None):
+ self.name = name
+ self.type = type
+ self.default = default
+ self.summary = summary
[View Less]
16 years, 9 months