rhmessaging commits: r3850 - in mgmt/trunk/cumin/python/cumin: grid and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: eallen
Date: 2010-02-11 14:38:10 -0500 (Thu, 11 Feb 2010)
New Revision: 3850
Modified:
mgmt/trunk/cumin/python/cumin/grid/slot.py
mgmt/trunk/cumin/python/cumin/grid/slot.strings
mgmt/trunk/cumin/python/cumin/model.py
Log:
Added job info to slot page.
Modified: mgmt/trunk/cumin/python/cumin/grid/slot.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/slot.py 2010-02-11 15:25:37 UTC (rev 3849)
+++ mgmt/trunk/cumin/python/cumin/grid/slot.py 2010-02-11 19:38:10 UTC (rev 3850)
@@ -128,6 +128,9 @@
stats = StatSet(app, "general", slot, "load")
self.add_child(stats)
+ job_info = SlotJobInfo(app, "job_info", slot, "JobInfo")
+ self.add_child(job_info)
+
chart = self.LoadChart(app, "chart", slot)
chart.stats = ("LoadAvg", "CondorLoadAvg")
chart.duration.param.default = "3600"
@@ -140,6 +143,22 @@
def render_title(self, session):
return "Load"
+class SlotJobInfo(PropertySet):
+ def __init__(self, app, name, slot, category):
+ super(SlotJobInfo, self).__init__(app, name)
+
+ #self.defer_enabled = True
+ self.update_enabled = True
+ self.category = category
+ self.object = slot
+
+ def do_get_items(self, session):
+ obj = self.object.get(session)
+ cls = self.app.model.get_class_by_object(obj)
+
+ return [(x.get_title(session), x.value(session, obj), x.escape)
+ for x in cls.properties if x.category == self.category]
+
class SlotMapPage(Page):
""" handles the slots.vis request """
Modified: mgmt/trunk/cumin/python/cumin/grid/slot.strings
===================================================================
--- mgmt/trunk/cumin/python/cumin/grid/slot.strings 2010-02-11 15:25:37 UTC (rev 3849)
+++ mgmt/trunk/cumin/python/cumin/grid/slot.strings 2010-02-11 19:38:10 UTC (rev 3850)
@@ -51,6 +51,8 @@
<td>
<h2>General</h2>
{general}
+ <h2>Job Info</h2>
+ {job_info}
</td>
<td>
{chart}
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2010-02-11 15:25:37 UTC (rev 3849)
+++ mgmt/trunk/cumin/python/cumin/model.py 2010-02-11 19:38:10 UTC (rev 3850)
@@ -981,7 +981,12 @@
prop = CuminProperty(self, "JobId")
prop.title = "Current Job Id"
+ prop.category = "JobInfo"
+ prop = CuminProperty(self, "GlobalJobId")
+ prop.title = "Global Job Id"
+ prop.category = "JobInfo"
+
prop = CuminProperty(self, "AccountingGroup")
prop.title = "Accounting Group"
@@ -1008,10 +1013,18 @@
prop = CuminProperty(self, "JobStart")
prop.title = "JobStart"
+ prop.category = "JobInfo"
- stat = CuminStat(self, "Activity")
- stat.title = "Activity"
+ """
+ prop = CuminProperty(self, "Activity")
+ prop.title = "Activity"
+ prop.category = "JobInfo"
+ prop = CuminProperty(self, "State")
+ prop.title = "State"
+ prop.category = "JobInfo"
+ """
+
stat = CuminStat(self, "CondorLoadAvg")
stat.title = "Condor Load Avg"
stat.format = "%2.02f"
14 years, 10 months
rhmessaging commits: r3849 - in mgmt/trunk/rosemary: python/rosemary and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-02-11 10:25:37 -0500 (Thu, 11 Feb 2010)
New Revision: 3849
Added:
mgmt/trunk/rosemary/python/rosemary/sqltype.py
Removed:
mgmt/trunk/rosemary/python/rosemary/types.py
Modified:
mgmt/trunk/rosemary/bin/rosemary-test
mgmt/trunk/rosemary/python/rosemary/model.py
mgmt/trunk/rosemary/python/rosemary/sqlmodel.py
mgmt/trunk/rosemary/python/rosemary/sqloperation.py
Log:
* Improve modeling of sql types
* Correct the string interpolation syntax in sql operations
* Add some sql debugging
* On References, save the referenced class
Modified: mgmt/trunk/rosemary/bin/rosemary-test
===================================================================
--- mgmt/trunk/rosemary/bin/rosemary-test 2010-02-11 15:22:21 UTC (rev 3848)
+++ mgmt/trunk/rosemary/bin/rosemary-test 2010-02-11 15:25:37 UTC (rev 3849)
@@ -74,7 +74,7 @@
if __name__ == "__main__":
model = RosemaryModel()
- model.load_qmf_dir(os.path.join(os.environ["ROSEMARY_HOME"], "xml"))
+ model.load_xml_dir(os.path.join(os.environ["ROSEMARY_HOME"], "xml"))
model.init()
if len(sys.argv) == 1:
Modified: mgmt/trunk/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-11 15:22:21 UTC (rev 3848)
+++ mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-11 15:25:37 UTC (rev 3849)
@@ -1,6 +1,6 @@
from sqloperation import *
from sqlmodel import *
-from types import *
+from sqltype import *
from util import *
log = logging.getLogger("rosemary.model")
@@ -12,16 +12,16 @@
self.sql_model = SqlModel()
- def load_qmf_dir(self, dir):
- assert os.path.isdir(dir)
+ def load_xml_dir(self, path):
+ assert os.path.isdir(path)
- for name in os.listdir(dir):
- path = os.path.join(dir, name)
+ for name in os.listdir(path):
+ file_path = os.path.join(path, name)
- if path.endswith(".xml") and os.path.isfile(path):
- self.load_qmf_metadata(path)
+ if file_path.endswith(".xml") and os.path.isfile(file_path):
+ self.load_xml_file(file_path)
- def load_qmf_metadata(self, path):
+ def load_xml_file(self, path):
tree = ElementTree()
file = open(path, "r")
@@ -93,9 +93,13 @@
self.sql_table = SqlTable(self.package.sql_schema, self.name)
+ self.sql_qmf_columns = None
+
self.sql_select = SqlSelectItem(self.sql_table)
+ self.sql_select_by_object_id = SqlSelectItemByObjectId(self.sql_table)
self.sql_insert = SqlInsertItem(self.sql_table)
self.sql_update = SqlUpdateItem(self.sql_table)
+ self.sql_delete = SqlDeleteItem(self.sql_table)
name = "%sStats" % self.name
@@ -150,39 +154,40 @@
meth.init()
def add_id_columns(self):
- id_col = SqlColumn(self.sql_table, "_id", "serial")
+ id_col = SqlColumn(self.sql_table, "_id", sql_serial8)
self.sql_table.key_column = id_col
name = "%s_pk" % self.name
SqlPrimaryKeyConstraint(self.sql_table, name, (id_col,))
- stats_id_col = SqlColumn(self.sql_stats_table, "_id", "serial")
+ stats_id_col = SqlColumn(self.sql_stats_table, "_id", sql_serial8)
self.sql_stats_table.key_column = stats_id_col
name = "%s_pk" % self.sql_stats_table.name
SqlPrimaryKeyConstraint(self.sql_stats_table, name, (stats_id_col,))
- parent_col = SqlColumn(self.sql_stats_table, "_parent_id", "int4")
+ parent_col = SqlColumn(self.sql_stats_table, "_parent_id", sql_int8)
parent_col.foreign_key_column = id_col
def add_qmf_columns(self):
- agent_col = SqlColumn(self.sql_table, "_qmf_agent_id", "text")
- object_col = SqlColumn(self.sql_table, "_qmf_object_id", "text")
+ agent = SqlColumn(self.sql_table, "_qmf_agent_id", sql_text)
+ object = SqlColumn(self.sql_table, "_qmf_object_id", sql_text)
name = "%s_qmf_ids_uq" % self.name
- SqlUniqueConstraint(self.sql_table, name, (agent_col, object_col))
+ SqlUniqueConstraint(self.sql_table, name, (agent, object))
- SqlColumn(self.sql_table, "_qmf_session_id", "text")
- SqlColumn(self.sql_table, "_qmf_update_time", "timestamp")
- SqlColumn(self.sql_table, "_qmf_create_time", "timestamp")
+ session = SqlColumn(self.sql_table, "_qmf_session_id", sql_text)
+ session.nullable = True
- col = SqlColumn(self.sql_table, "_qmf_delete_time", "timestamp")
- col.nullable = True
+ update = SqlColumn(self.sql_table, "_qmf_update_time", sql_timestamp)
+ create = SqlColumn(self.sql_table, "_qmf_create_time", sql_timestamp)
- update_col = SqlColumn \
- (self.sql_stats_table, "_qmf_update_time", "timestamp")
+ delete = SqlColumn(self.sql_table, "_qmf_delete_time", sql_timestamp)
+ delete.nullable = True
+ self.sql_qmf_columns = (agent, object, session, update, create, delete)
+
def load_object(self, cursor, id):
self.sql_select.execute(cursor, self.sql_table.columns, {"id": id})
@@ -239,11 +244,13 @@
self.cls.references.append(self)
self.cls.references_by_name[self.name] = self
+ self.that_cls = None
+
def init(self):
assert self.references
try:
- that_cls = self.cls.package.classes_by_name[self.references]
+ self.that_cls = self.cls.package.classes_by_name[self.references]
except KeyError:
log.warn("Reference to '%s' invalid", self.references)
@@ -251,8 +258,8 @@
name = "_%s_id" % self.name
- self.sql_column = SqlColumn(self.cls.sql_table, name, "int4")
- self.sql_column.foreign_key_column = that_cls.sql_table.key_column
+ self.sql_column = SqlColumn(self.cls.sql_table, name, sql_int4)
+ self.sql_column.foreign_key_column = self.that_cls.sql_table.key_column
self.sql_column.nullable = self.is_optional
class RosemaryProperty(RosemaryAttribute):
@@ -265,7 +272,7 @@
def init(self):
assert not self.references
- type = sql_types_by_qmf_type[self.type]
+ type = sql_types_by_qmf_type_string[self.type]
self.sql_column = SqlColumn(self.cls.sql_table, self.name, type)
self.sql_column.nullable = self.is_optional
@@ -280,7 +287,7 @@
def init(self):
assert not self.references
- type = sql_types_by_qmf_type[self.type]
+ type = sql_types_by_qmf_type_string[self.type]
self.sql_column = SqlColumn(self.cls.sql_stats_table, self.name, type)
Modified: mgmt/trunk/rosemary/python/rosemary/sqlmodel.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqlmodel.py 2010-02-11 15:22:21 UTC (rev 3848)
+++ mgmt/trunk/rosemary/python/rosemary/sqlmodel.py 2010-02-11 15:25:37 UTC (rev 3849)
@@ -98,15 +98,15 @@
tokens = list()
tokens.append("\"%s\"" % self.name)
- tokens.append(self.type)
+ tokens.append(self.type.literal)
if not self.nullable:
tokens.append("not null")
if self.foreign_key_column:
- table = self.foreign_key_column.table.name
+ table = self.foreign_key_column.table.identifier
col = self.foreign_key_column.name
- expr = "references \"%s\"(\"%s\")"
+ expr = "references %s(\"%s\")"
tokens.append(expr % (table, col))
@@ -149,11 +149,3 @@
args = (self.name, self.columns[0].table.name, cols)
out.write(" create index \"%s\" on \"%s\"(%s)\n" % args)
-
-class SqlRelation(object):
- def __init__(self, model, name, columns):
- self.name = name
- self.columns = columns
-
- self.model.relations.append(self)
- self.model.relations_by_name[self.name] = self
Modified: mgmt/trunk/rosemary/python/rosemary/sqloperation.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqloperation.py 2010-02-11 15:22:21 UTC (rev 3848)
+++ mgmt/trunk/rosemary/python/rosemary/sqloperation.py 2010-02-11 15:25:37 UTC (rev 3849)
@@ -1,42 +1,55 @@
from sqlmodel import *
from util import *
+log = logging.getLogger("rosemary.sqloperation")
+
class SqlOperation(object):
def __init__(self, table):
self.table = table
def execute(self, cursor, columns, values):
- text = self.emit(names)
- results = cursor.execute(text, values)
- return results
+ text = self.emit(columns)
+ log.debug("Sql text: %s", text)
+ log.debug("Sql values: %s", values)
+
+ cursor.execute(text, values)
+
class SqlSelectItem(SqlOperation):
def emit(self, columns):
cols = ", ".join([x.identifier for x in columns])
args = (cols, self.table.identifier)
- return "select %s from %s where _id = %%(id)" % args
+ return "select %s from %s where _id = %%(id)s" % args
+class SqlSelectItemByObjectId(SqlOperation):
+ def emit(self, columns):
+ cols = ", ".join([x.identifier for x in columns])
+ args = (cols, self.table.identifier)
+
+ return "select %s from %s where _qmf_object_id = %%(_qmf_object_id)s" \
+ % args
+
class SqlInsertItem(SqlOperation):
def emit(self, columns):
names = [x.name for x in columns]
cols = ", ".join(["\"%s\"" % x for x in names])
- vals = ", ".join(["%%(%s)" % x for x in names])
+ vals = ", ".join(["%%(%s)s" % x for x in names])
args = (self.table.identifier, cols, vals)
return "insert into %s (%s) values (%s)" % args
class SqlUpdateItem(SqlOperation):
def emit(self, columns):
- exprs = ["\"%s\" = %%(%s)" % (x.name, x.name) for x in columns]
+ exprs = ["\"%s\" = %%(%s)s" % (x.name, x.name) for x in columns]
exprs = ", ".join(exprs)
args = (self.table.identifier, exprs)
- return "update %s set %s where _id = %%(id)" % args
+ return "update %s set %s where _id = %%(id)s" % args
class SqlDeleteItem(SqlOperation):
def emit(self, columns):
- return "delete from %s where _id = %%(id)" % self.table.identifier
+ return "delete from %s where _id = %%(id)s" % self.table.identifier
class SqlQuery(SqlOperation):
def __init__(self, table):
Added: mgmt/trunk/rosemary/python/rosemary/sqltype.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqltype.py (rev 0)
+++ mgmt/trunk/rosemary/python/rosemary/sqltype.py 2010-02-11 15:25:37 UTC (rev 3849)
@@ -0,0 +1,76 @@
+import pickle
+
+from psycopg2 import TimestampFromTicks
+from util import *
+
+class SqlType(object):
+ def __init__(self, literal):
+ self.literal = literal
+
+ def adapt_value(self, value):
+ return value
+
+class TimestampType(SqlType):
+ def adapt_value(self, value):
+ if value is not None:
+ return TimestampFromTicks(value / 1000000000)
+
+class PickleType(SqlType):
+ def adapt_value(self, value):
+ if value is not None:
+ return pickle.dumps(value)
+
+class StringType(SqlType):
+ def adapt_value(self, value):
+ if value is not None:
+ return str(value)
+
+sql_bool = SqlType("bool")
+sql_float4 = SqlType("float4")
+sql_float8 = SqlType("float8")
+sql_int2 = SqlType("int2")
+sql_int4 = SqlType("int4")
+sql_int8 = SqlType("int8")
+sql_numeric_19 = SqlType("numeric(19)")
+sql_serial4 = SqlType("serial4")
+sql_serial8 = SqlType("serial8")
+sql_text = SqlType("text")
+sql_timestamp = TimestampType("timestamp")
+
+sql_pickle = PickleType("text")
+sql_string = StringType("text")
+
+__mappings = (
+ (sql_bool, 11, "bool"),
+ (sql_float4, 12, "float"),
+ (sql_float8, 13, "double"),
+ (sql_int2, 1, "count8"),
+ (sql_int2, 1, "hilo8"),
+ (sql_int2, 1, "uint8"),
+ (sql_int2, 16,"int8"),
+ (sql_int2, 17, "int16"),
+ (sql_int4, 18, "int32"),
+ (sql_int4, 2, "count16"),
+ (sql_int4, 2, "hilo16"),
+ (sql_int4, 2, "uint16"),
+ (sql_int8, 19, "int64"),
+ (sql_int8, 3, "count32"),
+ (sql_int8, 3, "hilo32"),
+ (sql_int8, 3, "mma32"),
+ (sql_int8, 3, "uint32"),
+ (sql_numeric_19, 4, "count64"),
+ (sql_numeric_19, 4, "hilo64"),
+ (sql_numeric_19, 4, "mma64"),
+ (sql_numeric_19, 4, "mmaTime"),
+ (sql_numeric_19, 4, "uint64"),
+ (sql_numeric_19, 9, "deltaTime"),
+ (sql_string, 10, "objId"),
+ (sql_string, 14, "uuid"),
+ (sql_pickle, 15, "map"),
+ (sql_text, 6, "sstr"),
+ (sql_text, 7, "lstr"),
+ (sql_timestamp, 8, "absTime"),
+ )
+
+sql_types_by_qmf_type_code = dict([(x[1], x[0]) for x in __mappings])
+sql_types_by_qmf_type_string = dict([(x[2], x[0]) for x in __mappings])
Deleted: mgmt/trunk/rosemary/python/rosemary/types.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/types.py 2010-02-11 15:22:21 UTC (rev 3848)
+++ mgmt/trunk/rosemary/python/rosemary/types.py 2010-02-11 15:25:37 UTC (rev 3849)
@@ -1,33 +0,0 @@
-from util import *
-
-sql_types_by_qmf_type = {
- "int8": "int2",
- "int16": "int2",
- "int32": "int4",
- "int64": "int8",
- "uint8": "int2",
- "uint16": "int4",
- "uint32": "int8",
- "uint64": "numeric(19)",
- "count8": "int2",
- "count16": "int4",
- "count32": "int8",
- "count64": "numeric(19)",
- "hilo8": "int2",
- "hilo16": "int4",
- "hilo32": "int8",
- "hilo64": "numeric(19)",
- "mma32": "int8",
- "mma64": "numeric(19)",
- "float": "float4",
- "double": "float8",
- "bool": "bool",
- "sstr": "text",
- "lstr": "text",
- "absTime": "timestamp",
- "deltaTime": "numeric(19)",
- "mmaTime": "numeric(19)",
- "map": "text",
- "objId": "text",
- "uuid": "text",
- }
14 years, 10 months
rhmessaging commits: r3848 - mgmt/trunk/parsley/python/parsley.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-02-11 10:22:21 -0500 (Thu, 11 Feb 2010)
New Revision: 3848
Modified:
mgmt/trunk/parsley/python/parsley/collectionsex.py
Log:
Add a missing import
Modified: mgmt/trunk/parsley/python/parsley/collectionsex.py
===================================================================
--- mgmt/trunk/parsley/python/parsley/collectionsex.py 2010-02-09 17:17:57 UTC (rev 3847)
+++ mgmt/trunk/parsley/python/parsley/collectionsex.py 2010-02-11 15:22:21 UTC (rev 3848)
@@ -15,3 +15,5 @@
raise
else:
return self.default_factory()
+
+from collections import *
14 years, 10 months
rhmessaging commits: r3847 - store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb.
by rhmessaging-commits@lists.jboss.org
Author: ritchiem
Date: 2010-02-09 12:17:57 -0500 (Tue, 09 Feb 2010)
New Revision: 3847
Modified:
store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
Log:
Update to add deadlock debug options and to disable the LOWERING of the LockTimeout set in r2624. The default is 500000 r2624 set it to 15000. It is believed that this will address the current Deadlock issue that can be seen with simultaneous QueueBind calls. This is committed for testing purposes only on the multicore servers where this failure is currently manifesting.
Modified: store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
===================================================================
--- store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2010-02-05 20:25:05 UTC (rev 3846)
+++ store/branches/java/0.5.x-dev/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2010-02-09 17:17:57 UTC (rev 3847)
@@ -348,7 +348,18 @@
envConfig.setAllowCreate(false);
envConfig.setTransactional(true);
envConfig.setConfigParam("je.lock.nLockTables", "7");
- envConfig.setLockTimeout(15000);
+
+ // Restore 500,000 default timeout.
+ //envConfig.setLockTimeout(15000);
+
+ // Added to help diagnosis of Deadlock issue
+ //
+ // http://www.oracle.com/technology/products/berkeley-db/faq/je_faq.html#23
+ if (Boolean.getBoolean("qpid.bdb.lock.debug"))
+ {
+ envConfig.setConfigParam("je.txn.deadlockStackTrace", "true");
+ envConfig.setConfigParam("je.txn.dumpLocks", "true");
+ }
// Set transaction mode
_transactionConfig.setReadCommitted(true);
14 years, 10 months
rhmessaging commits: r3846 - mgmt/trunk/wooly/python/wooly.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-02-05 15:25:05 -0500 (Fri, 05 Feb 2010)
New Revision: 3846
Modified:
mgmt/trunk/wooly/python/wooly/server.py
Log:
Wait a little longer
Modified: mgmt/trunk/wooly/python/wooly/server.py
===================================================================
--- mgmt/trunk/wooly/python/wooly/server.py 2010-02-05 20:22:38 UTC (rev 3845)
+++ mgmt/trunk/wooly/python/wooly/server.py 2010-02-05 20:25:05 UTC (rev 3846)
@@ -41,14 +41,14 @@
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
- for i in range(10):
+ for i in range(60):
try:
s.bind((self.addr, self.port))
return
except socket.error:
log.warn("Address %s:%i is taken; retrying",
self.addr, self.port)
- time.sleep(1)
+ time.sleep(5)
finally:
s.close()
14 years, 10 months
rhmessaging commits: r3845 - in mgmt/trunk/rosemary: python/rosemary and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-02-05 15:22:38 -0500 (Fri, 05 Feb 2010)
New Revision: 3845
Modified:
mgmt/trunk/rosemary/bin/rosemary-test
mgmt/trunk/rosemary/python/rosemary/model.py
mgmt/trunk/rosemary/python/rosemary/sqloperation.py
Log:
Fix test tool and sql item operations
Modified: mgmt/trunk/rosemary/bin/rosemary-test
===================================================================
--- mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 20:08:12 UTC (rev 3844)
+++ mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 20:22:38 UTC (rev 3845)
@@ -10,11 +10,14 @@
for cls in package.classes:
print " class %s" % cls.name
+ for ref in cls.references:
+ print " ref %s %s" % (ref.name, ref.title or "")
+
for prop in cls.properties:
print " prop %s %s" % (prop.name, prop.title or "")
for stat in cls.statistics:
- print " stat %s" % stat.name
+ print " stat %s %s" % (stat.name, stat.title or "")
for meth in cls.methods:
print " meth %s" % meth.name
@@ -54,14 +57,14 @@
query = SqlQuery(table)
- stats_col = stats_table.columns_by_name["parent_id"]
+ stats_col = stats_table.columns_by_name["_parent_id"]
- SqlOuterJoin(query, table.id_column, stats_col)
- SqlInnerJoin(query, table.id_column, vhost_table.id_column)
+ SqlOuterJoin(query, table.key_column, stats_col)
+ SqlInnerJoin(query, table.key_column, vhost_table.key_column)
- broker_col = vhost_table.columns_by_name["brokerRef"]
+ broker_col = vhost_table.columns_by_name["_brokerRef_id"]
- SqlInnerJoin(query, broker_col, broker_table.id_column)
+ SqlInnerJoin(query, broker_col, broker_table.key_column)
cols = table.columns + vhost_table.columns + broker_table.columns + \
stats_table.columns
Modified: mgmt/trunk/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 20:08:12 UTC (rev 3844)
+++ mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 20:22:38 UTC (rev 3845)
@@ -134,13 +134,12 @@
meth.extend(child)
def init(self):
+ self.add_qmf_columns()
self.add_id_columns()
for ref in self.references:
ref.init()
- self.add_qmf_columns()
-
for prop in self.properties:
prop.init()
Modified: mgmt/trunk/rosemary/python/rosemary/sqloperation.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqloperation.py 2010-02-05 20:08:12 UTC (rev 3844)
+++ mgmt/trunk/rosemary/python/rosemary/sqloperation.py 2010-02-05 20:22:38 UTC (rev 3845)
@@ -15,7 +15,7 @@
cols = ", ".join([x.identifier for x in columns])
args = (cols, self.table.identifier)
- return "select %s from %s where id = %%(id)" % args
+ return "select %s from %s where _id = %%(id)" % args
class SqlInsertItem(SqlOperation):
def emit(self, columns):
@@ -32,11 +32,11 @@
exprs = ", ".join(exprs)
args = (self.table.identifier, exprs)
- return "update %s set %s where id = %%(id)" % args
+ return "update %s set %s where _id = %%(id)" % args
class SqlDeleteItem(SqlOperation):
def emit(self, columns):
- return "delete from %s where id = %%(id)" % self.table.identifier
+ return "delete from %s where _id = %%(id)" % self.table.identifier
class SqlQuery(SqlOperation):
def __init__(self, table):
14 years, 10 months
rhmessaging commits: r3844 - in mgmt/trunk/rosemary: python/rosemary and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-02-05 15:08:12 -0500 (Fri, 05 Feb 2010)
New Revision: 3844
Modified:
mgmt/trunk/rosemary/bin/rosemary-test
mgmt/trunk/rosemary/python/rosemary/model.py
mgmt/trunk/rosemary/python/rosemary/sqlmodel.py
mgmt/trunk/rosemary/python/rosemary/sqloperation.py
Log:
* Separate modeling of references
* Name internal and qmf metadata columns in the data to avoid
collisions with primary qmf data
* Reorganize how columns are added
* Store a sql identifier literal with sql objects
* Add the first part of a flexible query operation
Modified: mgmt/trunk/rosemary/bin/rosemary-test
===================================================================
--- mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 16:05:34 UTC (rev 3843)
+++ mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 20:08:12 UTC (rev 3844)
@@ -45,6 +45,29 @@
print delete.emit(table.columns)
print
+def do_query(args):
+ schema = model.sql_model.schemas_by_name["org.apache.qpid.broker"]
+ table = schema.tables_by_name["Queue"]
+ stats_table = schema.tables_by_name["QueueStats"]
+ vhost_table = schema.tables_by_name["Vhost"]
+ broker_table = schema.tables_by_name["Broker"]
+
+ query = SqlQuery(table)
+
+ stats_col = stats_table.columns_by_name["parent_id"]
+
+ SqlOuterJoin(query, table.id_column, stats_col)
+ SqlInnerJoin(query, table.id_column, vhost_table.id_column)
+
+ broker_col = vhost_table.columns_by_name["brokerRef"]
+
+ SqlInnerJoin(query, broker_col, broker_table.id_column)
+
+ cols = table.columns + vhost_table.columns + broker_table.columns + \
+ stats_table.columns
+
+ print query.emit(cols)
+
if __name__ == "__main__":
model = RosemaryModel()
Modified: mgmt/trunk/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 16:05:34 UTC (rev 3843)
+++ mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 20:08:12 UTC (rev 3844)
@@ -79,6 +79,9 @@
self.package.classes.append(self)
self.package.classes_by_name[self.name] = self
+ self.references = list()
+ self.references_by_name = dict()
+
self.properties = list()
self.properties_by_name = dict()
@@ -98,51 +101,17 @@
self.sql_stats_table = SqlTable(self.package.sql_schema, name)
- self.add_columns()
+ def load(self, elem):
+ for child in elem.findall("property"):
+ name = child.get("name")
- def add_columns(self):
- id_col = SqlColumn(self.sql_table, "id", "serial")
+ if child.get("references"):
+ attr = RosemaryReference(self, name)
+ else:
+ attr = RosemaryProperty(self, name)
- name = "%s_pk" % self.name
+ attr.load(child)
- SqlPrimaryKeyConstraint(self.sql_table, name, (id_col,))
-
- agent_col = SqlColumn(self.sql_table, "qmf_agent_id", "text")
- object_col = SqlColumn(self.sql_table, "qmf_object_id", "text")
-
- name = "%s_qmf_ids_uq" % self.name
-
- SqlUniqueConstraint(self.sql_table, name, (agent_col, object_col))
-
- SqlColumn(self.sql_table, "qmf_session_id", "text")
- SqlColumn(self.sql_table, "qmf_update_time", "timestamp")
- SqlColumn(self.sql_table, "qmf_create_time", "timestamp")
-
- col = SqlColumn(self.sql_table, "qmf_delete_time", "timestamp")
- col.nullable = True
-
- stats_id_col = SqlColumn(self.sql_stats_table, "id", "serial")
-
- name = "%s_pk" % self.sql_stats_table.name
-
- SqlPrimaryKeyConstraint(self.sql_stats_table, name, (stats_id_col,))
-
- parent_col = SqlColumn(self.sql_stats_table, "parent_id", "int4")
- parent_col.foreign_key_column = id_col
-
- update_col = SqlColumn \
- (self.sql_stats_table, "qmf_update_time", "timestamp")
-
- name = "%s_%s_uq" % (self.sql_stats_table.name, update_col.name)
-
- SqlUniqueConstraint \
- (self.sql_stats_table, name, (parent_col, update_col))
-
- def load(self, elem):
- for child in elem.findall("property"):
- prop = RosemaryProperty(self, child.get("name"))
- prop.load(child)
-
for child in elem.findall("statistic"):
stat = RosemaryStatistic(self, child.get("name"))
stat.load(child)
@@ -165,6 +134,13 @@
meth.extend(child)
def init(self):
+ self.add_id_columns()
+
+ for ref in self.references:
+ ref.init()
+
+ self.add_qmf_columns()
+
for prop in self.properties:
prop.init()
@@ -174,6 +150,40 @@
for meth in self.methods:
meth.init()
+ def add_id_columns(self):
+ id_col = SqlColumn(self.sql_table, "_id", "serial")
+ self.sql_table.key_column = id_col
+
+ name = "%s_pk" % self.name
+ SqlPrimaryKeyConstraint(self.sql_table, name, (id_col,))
+
+ stats_id_col = SqlColumn(self.sql_stats_table, "_id", "serial")
+ self.sql_stats_table.key_column = stats_id_col
+
+ name = "%s_pk" % self.sql_stats_table.name
+ SqlPrimaryKeyConstraint(self.sql_stats_table, name, (stats_id_col,))
+
+ parent_col = SqlColumn(self.sql_stats_table, "_parent_id", "int4")
+ parent_col.foreign_key_column = id_col
+
+ def add_qmf_columns(self):
+ agent_col = SqlColumn(self.sql_table, "_qmf_agent_id", "text")
+ object_col = SqlColumn(self.sql_table, "_qmf_object_id", "text")
+
+ name = "%s_qmf_ids_uq" % self.name
+
+ SqlUniqueConstraint(self.sql_table, name, (agent_col, object_col))
+
+ SqlColumn(self.sql_table, "_qmf_session_id", "text")
+ SqlColumn(self.sql_table, "_qmf_update_time", "timestamp")
+ SqlColumn(self.sql_table, "_qmf_create_time", "timestamp")
+
+ col = SqlColumn(self.sql_table, "_qmf_delete_time", "timestamp")
+ col.nullable = True
+
+ update_col = SqlColumn \
+ (self.sql_stats_table, "_qmf_update_time", "timestamp")
+
def load_object(self, cursor, id):
self.sql_select.execute(cursor, self.sql_table.columns, {"id": id})
@@ -194,21 +204,19 @@
self.sql_delete.execute(cursor, (), {"id": object.id})
-class RosemaryProperty(object):
+class RosemaryAttribute(object):
def __init__(self, cls, name):
self.cls = cls
self.name = name
- self.cls.properties.append(self)
- self.cls.properties_by_name[self.name] = self
-
- self.title = None
self.type = None
self.references = None
self.access = None
self.unit = None
self.is_index = None
self.is_optional = None
+
+ self.title = None
self.description = None
self.sql_column = None
@@ -225,46 +233,54 @@
def extend(self, elem):
self.title = elem.findtext("title")
+class RosemaryReference(RosemaryAttribute):
+ def __init__(self, cls, name):
+ super(RosemaryReference, self).__init__(cls, name)
+
+ self.cls.references.append(self)
+ self.cls.references_by_name[self.name] = self
+
def init(self):
- type = sql_types_by_qmf_type[self.type]
+ assert self.references
- self.sql_column = SqlColumn(self.cls.sql_table, self.name, type)
+ try:
+ that_cls = self.cls.package.classes_by_name[self.references]
+ except KeyError:
+ log.warn("Reference to '%s' invalid", self.references)
+
+ return
+
+ name = "_%s_id" % self.name
+
+ self.sql_column = SqlColumn(self.cls.sql_table, name, "int4")
+ self.sql_column.foreign_key_column = that_cls.sql_table.key_column
self.sql_column.nullable = self.is_optional
+
+class RosemaryProperty(RosemaryAttribute):
+ def __init__(self, cls, name):
+ super(RosemaryProperty, self).__init__(cls, name)
- if self.references:
- try:
- cls = self.cls.package.classes_by_name[self.references]
- except KeyError:
- log.warn("Reference to '%s' invalid", self.references)
- return
+ self.cls.properties.append(self)
+ self.cls.properties_by_name[self.name] = self
- col = cls.sql_table.columns_by_name["id"]
+ def init(self):
+ assert not self.references
- self.sql_column.foreign_key_column = col
+ type = sql_types_by_qmf_type[self.type]
-class RosemaryStatistic(object):
+ self.sql_column = SqlColumn(self.cls.sql_table, self.name, type)
+ self.sql_column.nullable = self.is_optional
+
+class RosemaryStatistic(RosemaryAttribute):
def __init__(self, cls, name):
- self.cls = cls
+ super(RosemaryStatistic, self).__init__(cls, name)
- self.name = name
- self.type = None
- self.unit = None
- self.description = None
-
self.cls.statistics.append(self)
self.cls.statistics_by_name[self.name] = self
- self.sql_column = None
+ def init(self):
+ assert not self.references
- def load(self, elem):
- self.type = elem.get("type")
- self.unit = elem.get("unit")
- self.description = elem.get("desc")
-
- def extend(self, elem):
- pass
-
- def init(self):
type = sql_types_by_qmf_type[self.type]
self.sql_column = SqlColumn(self.cls.sql_stats_table, self.name, type)
Modified: mgmt/trunk/rosemary/python/rosemary/sqlmodel.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqlmodel.py 2010-02-05 16:05:34 UTC (rev 3843)
+++ mgmt/trunk/rosemary/python/rosemary/sqlmodel.py 2010-02-05 20:08:12 UTC (rev 3844)
@@ -24,6 +24,8 @@
self.model.schemas.append(self)
self.model.schemas_by_name[self.name] = self
+ self.identifier = "\"%s\"" % self.name
+
self.tables = list()
self.tables_by_name = dict()
@@ -31,7 +33,7 @@
self.indexes_by_name = dict()
def write_create_ddl(self, out):
- out.write("create schema \"%s\"\n" % self.name)
+ out.write("create schema %s\n" % self.identifier)
for table in self.tables:
table.write_create_ddl(out)
@@ -42,7 +44,7 @@
out.write(" ;\n")
def write_drop_ddl(self, out):
- out.write("drop schema \"%s\" cascade;\n" % self.name)
+ out.write("drop schema %s cascade;\n" % self.identifier)
class SqlTable(object):
def __init__(self, schema, name):
@@ -52,6 +54,9 @@
self.schema.tables.append(self)
self.schema.tables_by_name[self.name] = self
+ self.identifier = "%s.\"%s\"" % (self.schema.identifier, self.name)
+ self.key_column = None
+
self.columns = list()
self.columns_by_name = dict()
@@ -84,6 +89,8 @@
self.table.columns.append(self)
self.table.columns_by_name[self.name] = self
+ self.identifier = "\"%s\".\"%s\"" % (self.table.name, self.name)
+
self.nullable = False
self.foreign_key_column = None
Modified: mgmt/trunk/rosemary/python/rosemary/sqloperation.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqloperation.py 2010-02-05 16:05:34 UTC (rev 3843)
+++ mgmt/trunk/rosemary/python/rosemary/sqloperation.py 2010-02-05 20:08:12 UTC (rev 3844)
@@ -12,30 +12,75 @@
class SqlSelectItem(SqlOperation):
def emit(self, columns):
- cols = ", ".join(["\"%s\"" % x.name for x in columns])
- args = (cols, self.table.schema.name, self.table.name)
+ cols = ", ".join([x.identifier for x in columns])
+ args = (cols, self.table.identifier)
- return "select %s from \"%s\".\"%s\" where id = %%(id)" % args
+ return "select %s from %s where id = %%(id)" % args
class SqlInsertItem(SqlOperation):
def emit(self, columns):
names = [x.name for x in columns]
cols = ", ".join(["\"%s\"" % x for x in names])
vals = ", ".join(["%%(%s)" % x for x in names])
- args = (self.table.schema.name, self.table.name, cols, vals)
+ args = (self.table.identifier, cols, vals)
- return "insert into \"%s\".\"%s\" (%s) values (%s)" % args
+ return "insert into %s (%s) values (%s)" % args
class SqlUpdateItem(SqlOperation):
def emit(self, columns):
exprs = ["\"%s\" = %%(%s)" % (x.name, x.name) for x in columns]
exprs = ", ".join(exprs)
- args = (self.table.schema.name, self.table.name, exprs)
+ args = (self.table.identifier, exprs)
- return "update \"%s\".\"%s\" set %s where id = %%(id)" % args
+ return "update %s set %s where id = %%(id)" % args
class SqlDeleteItem(SqlOperation):
def emit(self, columns):
- args = (self.table.schema.name, self.table.name)
+ return "delete from %s where id = %%(id)" % self.table.identifier
+
+class SqlQuery(SqlOperation):
+ def __init__(self, table):
+ super(SqlQuery, self).__init__(table)
+
+ self.joins = list()
+
+ def emit(self, columns, parameters=None):
+ tokens = list()
+
+ cols = ",".join(["\n %s" % x.identifier for x in columns])
+ tokens.append("select %s" % cols)
+
+ tokens.append("from %s" % self.table.identifier)
+
+ for join in self.joins:
+ tokens.append(join.emit())
+
+ return "%s\n" % "\n".join(tokens)
- return "delete from \"%s\".\"%s\" where id = %%(id)" % args
+class SqlQueryJoin(object):
+ def __init__(self, query, this_column, that_column):
+ self.query = query
+ self.this_column = this_column
+ self.that_column = that_column
+
+ assert self not in self.query.joins
+
+ self.query.joins.append(self)
+
+class SqlInnerJoin(SqlQueryJoin):
+ def emit(self):
+ table = self.that_column.table.identifier
+ this = self.this_column.identifier
+ that = self.that_column.identifier
+ args = (table, this, that)
+
+ return "inner join %s on %s = %s" % args
+
+class SqlOuterJoin(SqlQueryJoin):
+ def emit(self):
+ table = self.that_column.table.identifier
+ this = self.this_column.identifier
+ that = self.that_column.identifier
+ args = (table, this, that)
+
+ return "left outer join %s on %s = %s" % args
14 years, 10 months
rhmessaging commits: r3843 - in mgmt/trunk/rosemary: bin and 2 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-02-05 11:05:34 -0500 (Fri, 05 Feb 2010)
New Revision: 3843
Modified:
mgmt/trunk/rosemary/Makefile
mgmt/trunk/rosemary/bin/rosemary-test
mgmt/trunk/rosemary/python/rosemary/model.py
mgmt/trunk/rosemary/python/rosemary/util.py
mgmt/trunk/rosemary/xml/Makefile
mgmt/trunk/rosemary/xml/condor.xml
mgmt/trunk/rosemary/xml/qpid.xml
Log:
Fix imports; update schema xml
Modified: mgmt/trunk/rosemary/Makefile
===================================================================
--- mgmt/trunk/rosemary/Makefile 2010-02-05 15:53:42 UTC (rev 3842)
+++ mgmt/trunk/rosemary/Makefile 2010-02-05 16:05:34 UTC (rev 3843)
@@ -1,4 +1,4 @@
-.PHONY: build install schema clean
+.PHONY: build install clean schema schema-clean
include ../etc/Makefile.common
@@ -24,12 +24,10 @@
install -d ${etc}
install -pm 0644 etc/* ${etc}
-schema:
+schema: schema-clean
$(MAKE) schema -C xml
- $(MAKE) schema -C python/rosemary
- $(MAKE) schema -C sql
-clean:
+schema-clean:
$(MAKE) clean -C xml
- $(MAKE) clean -C python/rosemary
- $(MAKE) clean -C sql
+
+clean: clean-python-files
Modified: mgmt/trunk/rosemary/bin/rosemary-test
===================================================================
--- mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 15:53:42 UTC (rev 3842)
+++ mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 16:05:34 UTC (rev 3843)
@@ -1,7 +1,7 @@
#!/usr/bin/python
from rosemary.model import *
-from rosemary.sql import *
+from rosemary.sqloperation import *
def do_model(args):
for package in model.packages:
Modified: mgmt/trunk/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 15:53:42 UTC (rev 3842)
+++ mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 16:05:34 UTC (rev 3843)
@@ -1,4 +1,4 @@
-from sql import *
+from sqloperation import *
from sqlmodel import *
from types import *
from util import *
Modified: mgmt/trunk/rosemary/python/rosemary/util.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/util.py 2010-02-05 15:53:42 UTC (rev 3842)
+++ mgmt/trunk/rosemary/python/rosemary/util.py 2010-02-05 16:05:34 UTC (rev 3843)
@@ -6,22 +6,3 @@
from xml.etree.ElementTree import *
except ImportError:
from elementtree.ElementTree import *
-
-def unstudly(name):
- chars = list()
-
- curr = name[0]
- prev = None
-
- chars.append(curr.lower())
-
- for i in range(1, len(name)):
- prev = curr
- curr = name[i]
-
- if curr.isupper() and not prev.isupper():
- chars.append("_")
-
- chars.append(curr.lower())
-
- return "".join(chars)
Modified: mgmt/trunk/rosemary/xml/Makefile
===================================================================
--- mgmt/trunk/rosemary/xml/Makefile 2010-02-05 15:53:42 UTC (rev 3842)
+++ mgmt/trunk/rosemary/xml/Makefile 2010-02-05 16:05:34 UTC (rev 3843)
@@ -20,7 +20,7 @@
svn export http://svn.apache.org/repos/asf/qpid/trunk/qpid/cpp/src/qpid/cluster/mana... qpid-cluster.xml
condor.xml:
- wget "http://git.et.redhat.com/?p=mrg-grid.git;a=blob_plain;f=src/management/co..." -O condor.xml
+ wget "http://git.fedorahosted.org/git/grid.git?p=grid.git;a=blob_plain;f=src/ma..." -O condor.xml
sesame.xml:
svn export http://anonsvn.jboss.org/repos/rhmessaging/mgmt/trunk/sesame/cpp/src/qmfg... sesame.xml
Modified: mgmt/trunk/rosemary/xml/condor.xml
===================================================================
--- mgmt/trunk/rosemary/xml/condor.xml 2010-02-05 15:53:42 UTC (rev 3842)
+++ mgmt/trunk/rosemary/xml/condor.xml 2010-02-05 16:05:34 UTC (rev 3843)
@@ -85,7 +85,7 @@
qualified with a UidDomain, UidDomain taken from
RemoteUser, only present when a job is
executing"/>
- <statistic name="Activity"
+ <property name="Activity"
type="sstr"
desc="One of: Idle, No job activity; Busy, Job is
running; Suspended, Job is suspended; Vacating,
@@ -133,7 +133,6 @@
<property name="Cpus"
type="uint32"
desc="Number of CPUs in slot"/>
- <!-- XXX: CurrentRank could quite possibly be a statistic -->
<property name="CurrentRank"
type="double"
optional="y"
@@ -143,11 +142,11 @@
<property name="Disk"
type="uint32" unit="KiB"
desc="Amount of disk space in KiB available in the slot"/>
- <statistic name="EnteredCurrentActivity"
+ <property name="EnteredCurrentActivity"
type="absTime" unit="nanosecond"
desc="Time at which current Activity was entered,
number of nanoseconds since Unix epoch"/>
- <statistic name="EnteredCurrentState"
+ <property name="EnteredCurrentState"
type="absTime" unit="nanosecond"
desc="Time at which current State was entered,
number of seconds since Unix epoch"/>
@@ -160,10 +159,8 @@
optional="y"
desc="The running job's GlobalJobId, only present when
a job is executing"/>
- <!-- XXX: ImageSize could quite possibly be a statistic -->
- <property name="ImageSize"
+ <statistic name="ImageSize"
type="uint32" unit="KiB"
- optional="y"
desc="Estimate of the memory image size, in KiB, of the
running job, only present when a job is
executing, pulled by STARTD_JOB_EXPRS"/>
@@ -173,8 +170,6 @@
checkpointed job can run on the slot, part of the
slot's Requirements along with the Start
expression"/>
- <!-- XXX: JobId could quite possibly be a statistic, snapshots
- would show use over time -->
<property name="JobId"
type="sstr"
optional="y"
@@ -196,20 +191,20 @@
type="uint32"
desc="Relative floating point performance on a Linpack
benchmark"/>
- <statistic name="LastBenchmark"
+ <property name="LastBenchmark"
type="absTime" unit="nanosecond"
desc="Number of nanoseconds since epoch when the last
benchmark was run"/>
- <statistic name="LastFetchWorkCompleted"
+ <property name="LastFetchWorkCompleted"
type="absTime" unit="nanosecond"
desc="Number of nanoseconds since epoch when the
FetchWork Hook returned"/>
- <statistic name="LastFetchWorkSpawned"
+ <property name="LastFetchWorkSpawned"
type="absTime" unit="nanosecond"
desc="Number of nanoseconds since epoch when the
FetchWork Hook was invoked"/>
- <statistic name="LastPeriodicCheckpoint"
+ <property name="LastPeriodicCheckpoint"
type="absTime" unit="nanosecond"
desc="The number of nanoseconds since epoch when the
job last performed a periodic checkpoint, only
@@ -258,7 +253,7 @@
index="y"
desc="Name of the slot, either the same as Machine,
slot#@Machine, or a configured value"/>
- <statistic name="NextFetchWorkDelay"
+ <property name="NextFetchWorkDelay"
type="int32" unit="second"
desc="Number of seconds until the next FetchWork
Hook will be invoked, -1 means never"/>
@@ -285,7 +280,6 @@
desc="The name of the user originally preempting the
current job, i.e. the incoming user, only present
when slot is claimed"/>
- <!-- XXX: PreemptingUser could quite possibly be a statistic -->
<property name="PreemptingUser"
type="sstr"
optional="y"
@@ -293,7 +287,6 @@
different from PreemptingOwner only if the claim
was given to another user who is using it to
preempt, only present when slot is claimed"/>
- <!-- XXX: PreemptingRank could quite possibly be a statistic -->
<property name="PreemptingRank"
type="double"
optional="y"
@@ -301,15 +294,11 @@
preempting, job, calculated as Rank expression
evaluated in context of the incoming job's ad,
only present when slot is claimed"/>
- <!-- XXX: RemoteOwner could quite possibly be a statistic, showing
- use over time -->
<property name="RemoteOwner"
type="sstr"
optional="y"
desc="The name of the user who originally claimed the
slot, only present when slot is claimed"/>
- <!-- XXX: RemoteUser could quite possibly be a statistic, showing
- use over time -->
<property name="RemoteUser"
type="sstr"
optional="y"
@@ -321,9 +310,6 @@
type="lstr"
desc="Expression evaluated in the context of a job ad
to determine if the slot will run a job"/>
- <property name="PublicNetworkIpAddr"
- type="sstr"
- desc="IP:Port used to communicate with the slot"/>
<property name="Rank"
type="lstr"
desc="Configured expression representing how the slot
@@ -341,7 +327,7 @@
slot has, i.e. HasFileTransfer,HasJava,HasVM,
query with stringListMember('Element',
StarterAbilityList)"/>
- <statistic name="State"
+ <property name="State"
type="sstr"
desc="One of: Owner, unavailable to Condor; Unclaimed,
available to Condor, but no job match yet;
@@ -354,18 +340,16 @@
type="sstr"
desc="Always 'Job'"/>
-->
- <statistic name="TimeToLive"
+ <property name="TimeToLive"
type="uint32" unit="second"
desc="Number of second until StartD managing the slot
has until it will exit"/>
- <!-- XXX: TotalClaimRunTime is a statistic -->
<property name="TotalClaimRunTime"
type="uint32" unit="second"
optional="y"
desc="Number of seconds the current claim has spent
running jobs, only present when slot is
claimed"/>
- <!-- XXX: TotalClaimSuspendTime is a statistic -->
<property name="TotalClaimSuspendTime"
type="uint32" unit="second"
optional="y"
@@ -384,14 +368,12 @@
type="uint32" unit="KiB"
desc="Amount of disk space available on the slot's host
machine"/>
- <!-- XXX: TotalJobRunTime is a statistic -->
<property name="TotalJobRunTime"
type="uint32" unit="second"
optional="y"
desc="Number of seconds the current job has spent
running, i.e. Claimed/Busy, only present when
slot is claimed"/>
- <!-- XXX: TotalJobSuspendTime is a statistic -->
<property name="TotalJobSuspendTime"
type="uint32" unit="second"
optional="y"
@@ -511,6 +493,7 @@
<!--
Exec Host, Order(Rank?), StartTime, TotalTime (Sys, User), Project, AccountingGroup
-->
+<!--
<class name="Job">
<property name="schedulerRef" type="objId" parentRef="y" index="y" references="mrg.grid.Scheduler"/>
<property name="submitterRef" type="objId" references="mrg.grid.Submitter"/>
@@ -559,11 +542,11 @@
desc="The number of nanoseconds since epoch when the
job was submitted."/>
-<!--
- <property name="Requirements" type="lstr" desc=""/>
- <property name="Scheduler" type="sstr" desc=""/>
--->
+// <property name="Requirements" type="lstr" desc=""/>
+// <property name="Scheduler" type="sstr" desc=""/>
+
+
<property name="JobUniverse"
type="uint32"
desc=""/>
@@ -617,6 +600,7 @@
<arg name="Data" dir="O" type="lstr"/>
</method>
</class>
+-->
<class name="Scheduler">
<group name="daemon-stats"/>
@@ -630,7 +614,6 @@
<property name="MyAddress" type="sstr" desc=""/>
<statistic name="NumUsers" type="uint32"/>
<property name="Name" type="sstr" index="y" desc=""/>
- <property name="PublicNetworkIpAddr" type="sstr" desc=""/>
<statistic name="TotalHeldJobs" type="uint32"/>
<statistic name="TotalIdleJobs" type="uint32"/>
<statistic name="TotalJobAds" type="uint32"/>
@@ -641,6 +624,65 @@
<arg name="Ad" dir="I" type="map"/>
<arg name="Id" dir="O" type="sstr"/>
</method>
+
+ <method name="GetAd">
+ <arg name="Id" dir="I" type="sstr"
+ desc="Job's Id, the string ClusterId.ProcId"/>
+ <arg name="JobAd" dir="O" type="map"
+ desc="(name,value,type) tuples; Values are INTEGER, FLOAT,
+ STRING and EXPR. The EXPR value is not first class,
+ it is an unquoted, with double quotes, string"/>
+ </method>
+
+ <method name="SetAttribute">
+ <arg name="Id" dir="I" type="sstr"
+ desc="Job's Id, the string ClusterId.ProcId"/>
+ <arg name="Name" dir="I" type="sstr"/>
+ <arg name="Value" dir="I" type="lstr"/>
+ </method>
+
+ <method name="Hold">
+ <arg name="Id" dir="I" type="sstr"
+ desc="Job's Id, the string ClusterId.ProcId"/>
+ <arg name="Reason" dir="I" type="sstr"/>
+ </method>
+
+ <method name="Release">
+ <arg name="Id" dir="I" type="sstr"
+ desc="Job's Id, the string ClusterId.ProcId"/>
+ <arg name="Reason" dir="I" type="sstr"/>
+ </method>
+
+ <method name="Remove">
+ <arg name="Id" dir="I" type="sstr"
+ desc="Job's Id, the string ClusterId.ProcId"/>
+ <arg name="Reason" dir="I" type="sstr"/>
+ </method>
+
+ <method name="Fetch">
+ <arg name="Id" dir="I" type="sstr"
+ desc="Job's Id, the string ClusterId.ProcId"/>
+ <arg name="File" dir="I" type="sstr"/>
+ <arg name="Start" dir="I" type="int32"/>
+ <arg name="End" dir="I" type="int32"/>
+ <arg name="Data" dir="O" type="lstr"/>
+ </method>
+
+ <method name="GetStates">
+ <arg name="Submission" dir="I" type="sstr"/>
+ <arg name="State" dir="I" type="uint32"/>
+ <arg name="Count" dir="O" type="uint32"/>
+ </method>
+
+ <method name="GetJobs">
+ <arg name="Submission" dir="I" type="sstr"/>
+ <arg name="Jobs" dir="O" type="map"/>
+ </method>
+
+ <method name="echo">
+ <arg name="sequence" dir="IO" type="uint32"/>
+ <arg name="body" dir="IO" type="lstr"/>
+ </method>
</class>
<class name="Submitter">
@@ -744,7 +786,7 @@
<property name="CondorPlatform" type="sstr"/>
<property name="CondorVersion" type="sstr"/>
<property name="Name" type="sstr" index="y"/>
- <property name="PublicNetworkIpAddr" type="sstr"/>
+ <property name="MyAddress" type="sstr"/>
<statistic name="RunningJobs" type="uint32"/>
<statistic name="IdleJobs" type="uint32"/>
@@ -763,7 +805,6 @@
<property name="Name" type="sstr" index="y"/>
<property name="Machine" type="sstr"/>
- <property name="PublicNetworkIpAddr" type="sstr"/>
<property name="MyAddress" type="sstr"/>
<property name="RealUid" type="int32"/>
@@ -813,4 +854,18 @@
<statistic name="RunningJobs" type="uint32"/>
<statistic name="IdleJobs" type="uint32"/>
</class>
+
+ <class name="Submission">
+ <property name="schedulerRef" type="objId" parentRef="y" index="y" references="mrg.grid.Scheduler"/>
+
+ <property name="Name" type="sstr" index="y"/>
+ <property name="Owner" type="sstr" index="y"/>
+
+ <statistic name="Idle" type="count32"/>
+ <statistic name="Running" type="count32"/>
+ <statistic name="Removed" type="count32"/>
+ <statistic name="Completed" type="count32"/>
+ <statistic name="Held" type="count32"/>
+ </class>
+
</schema>
Modified: mgmt/trunk/rosemary/xml/qpid.xml
===================================================================
--- mgmt/trunk/rosemary/xml/qpid.xml 2010-02-05 15:53:42 UTC (rev 3842)
+++ mgmt/trunk/rosemary/xml/qpid.xml 2010-02-05 16:05:34 UTC (rev 3843)
@@ -129,10 +129,11 @@
<property name="vhostRef" type="objId" references="Vhost" access="RC" index="y" parentRef="y"/>
<property name="name" type="sstr" access="RC" index="y"/>
- <property name="durable" type="bool" access="RC"/>
- <property name="autoDelete" type="bool" access="RC"/>
- <property name="exclusive" type="bool" access="RC"/>
- <property name="arguments" type="map" access="RO" desc="Arguments supplied in queue.declare"/>
+ <property name="durable" type="bool" access="RC"/>
+ <property name="autoDelete" type="bool" access="RC"/>
+ <property name="exclusive" type="bool" access="RC"/>
+ <property name="arguments" type="map" access="RO" desc="Arguments supplied in queue.declare"/>
+ <property name="altExchange" type="objId" references="Exchange" access="RO" optional="y"/>
<statistic name="msgTotalEnqueues" type="count64" unit="message" desc="Total messages enqueued"/>
<statistic name="msgTotalDequeues" type="count64" unit="message" desc="Total messages dequeued"/>
@@ -154,8 +155,14 @@
<statistic name="messageLatency" type="mmaTime" unit="nanosecond" desc="Broker latency through this queue"/>
<method name="purge" desc="Discard all or some messages on a queue">
- <arg name="request" dir="I" type="uint32" desc="0 for all messages or n>0 for n messages"/>
+ <arg name="request" dir="I" type="uint32" desc="0 for all messages or n>0 for n messages"/>
</method>
+
+ <method name="reroute" desc="Remove all or some messages on this queue and route them to an exchange">
+ <arg name="request" dir="I" type="uint32" desc="0 for all messages or n>0 for n messages"/>
+ <arg name="useAltExchange" dir="I" type="bool" desc="Iff true, use the queue's configured alternate exchange; iff false, use exchange named in the 'exchange' argument"/>
+ <arg name="exchange" dir="I" type="sstr" desc="Name of the exchange to route the messages through"/>
+ </method>
</class>
<!--
@@ -164,11 +171,13 @@
===============================================================
-->
<class name="Exchange">
- <property name="vhostRef" type="objId" references="Vhost" access="RC" index="y" parentRef="y"/>
- <property name="name" type="sstr" access="RC" index="y"/>
- <property name="type" type="sstr" access="RO"/>
- <property name="durable" type="bool" access="RC"/>
- <property name="arguments" type="map" access="RO" desc="Arguments supplied in exchange.declare"/>
+ <property name="vhostRef" type="objId" references="Vhost" access="RC" index="y" parentRef="y"/>
+ <property name="name" type="sstr" access="RC" index="y"/>
+ <property name="type" type="sstr" access="RO"/>
+ <property name="durable" type="bool" access="RO"/>
+ <property name="autoDelete" type="bool" access="RO"/>
+ <property name="altExchange" type="objId" references="Exchange" access="RO" optional="y"/>
+ <property name="arguments" type="map" access="RO" desc="Arguments supplied in exchange.declare"/>
<statistic name="producerCount" type="hilo32" desc="Current producers on exchange"/>
<statistic name="bindingCount" type="hilo32" desc="Current bindings"/>
@@ -197,6 +206,23 @@
<!--
===============================================================
+ Subscription
+ ===============================================================
+ -->
+ <class name="Subscription">
+ <property name="sessionRef" type="objId" references="Session" access="RC" index="y" parentRef="y"/>
+ <property name="queueRef" type="objId" references="Queue" access="RC" index="y"/>
+ <property name="name" type="sstr" access="RC" index="y"/>
+ <property name="browsing" type="bool" access="RC"/>
+ <property name="acknowledged" type="bool" access="RC"/>
+ <property name="exclusive" type="bool" access="RC"/>
+ <property name="creditMode" type="sstr" access="RO" desc="WINDOW or CREDIT"/>
+ <property name="arguments" type="map" access="RC"/>
+ <statistic name="delivered" type="count64" unit="message" desc="Messages delivered"/>
+ </class>
+
+ <!--
+ ===============================================================
Connection
===============================================================
-->
@@ -306,6 +332,27 @@
<method name="close"/>
</class>
+ <!--
+ ===============================================================
+ ManagementSetupState
+ ===============================================================
+
+ This thing is used during cluster recovery operations (and maybe
+ eventually elsewhere) to transmit assorted state from one broker to
+ another. At present, the two data propagated are the object number
+ counter and boot sequence, both of which are used for creating
+ object ids for newly-created objects.
+
+ -->
+ <class name="ManagementSetupState">
+ <!-- for reasons that aren't clear (to me, anyhow) you have to say
+ access="RO" to get accessor methods defined. RC or RW don't do
+ it. Probably this is documented someplace, but I couldn't find
+ it. -jrd -->
+ <property name="objectNum" type="uint64" access="RO"/>
+ <property name="bootSequence" type="uint16" access="RO"/>
+ </class>
+
<eventArguments>
<arg name="altEx" type="sstr" desc="Name of the alternate exchange"/>
<arg name="args" type="map" desc="Supplemental arguments or parameters supplied"/>
14 years, 10 months
rhmessaging commits: r3842 - in mgmt/trunk/rosemary: python/rosemary and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2010-02-05 10:53:42 -0500 (Fri, 05 Feb 2010)
New Revision: 3842
Added:
mgmt/trunk/rosemary/python/rosemary/sqloperation.py
mgmt/trunk/rosemary/python/rosemary/types.py
Removed:
mgmt/trunk/rosemary/python/rosemary/sql.py
Modified:
mgmt/trunk/rosemary/bin/rosemary-test
mgmt/trunk/rosemary/python/rosemary/model.py
mgmt/trunk/rosemary/python/rosemary/sqlmodel.py
mgmt/trunk/rosemary/python/rosemary/util.py
Log:
* Flesh out the sql modeling of qmf classes, adding constraints and
indexes and correct types
* Remove old sql operations in favor of the new ones that use the sql
metadata
* Improve the test tool
* Consolidate util code
Modified: mgmt/trunk/rosemary/bin/rosemary-test
===================================================================
--- mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 11:17:08 UTC (rev 3841)
+++ mgmt/trunk/rosemary/bin/rosemary-test 2010-02-05 15:53:42 UTC (rev 3842)
@@ -1,6 +1,5 @@
#!/usr/bin/python
-import sys, os, logging
from rosemary.model import *
from rosemary.sql import *
@@ -11,12 +10,6 @@
for cls in package.classes:
print " class %s" % cls.name
- select = SelectObject(cls)
- #print select.emit()
-
- update = UpdateObject(cls)
- #print update.emit()
-
for prop in cls.properties:
print " prop %s %s" % (prop.name, prop.title or "")
@@ -29,12 +22,37 @@
for arg in meth.arguments:
print " arg %s" % arg.name
-def do_schema(args):
- model.sql_model.write_ddl(sys.stdout)
+def do_ddl(args):
+ model.sql_model.write_drop_ddl(sys.stdout)
+ model.sql_model.write_create_ddl(sys.stdout)
+def do_dml(args):
+ for schema in model.sql_model.schemas:
+ for table in schema.tables:
+ select = SqlSelectItem(table)
+ insert = SqlInsertItem(table)
+ update = SqlUpdateItem(table)
+ delete = SqlDeleteItem(table)
+
+ print "---", table.name, "---"
+ print
+ print insert.emit(table.columns)
+ print
+ print select.emit(table.columns)
+ print
+ print update.emit(table.columns)
+ print
+ print delete.emit(table.columns)
+ print
+
if __name__ == "__main__":
model = RosemaryModel()
+
model.load_qmf_dir(os.path.join(os.environ["ROSEMARY_HOME"], "xml"))
+ model.init()
- #do_model(sys.argv)
- do_schema(sys.argv)
+ if len(sys.argv) == 1:
+ print "model, ddl, dml"
+ sys.exit(1)
+
+ globals()["do_%s" % sys.argv[1]](sys.argv[2:])
Modified: mgmt/trunk/rosemary/python/rosemary/model.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 11:17:08 UTC (rev 3841)
+++ mgmt/trunk/rosemary/python/rosemary/model.py 2010-02-05 15:53:42 UTC (rev 3842)
@@ -1,16 +1,10 @@
-import sys
-import os
-
-from string import Template
-
-try:
- from xml.etree.ElementTree import *
-except ImportError:
- from elementtree.ElementTree import *
-
from sql import *
from sqlmodel import *
+from types import *
+from util import *
+log = logging.getLogger("rosemary.model")
+
class RosemaryModel(object):
def __init__(self):
self.packages = list()
@@ -46,6 +40,10 @@
pkg = self.packages_by_name[child.get("name")]
pkg.extend(child)
+ def init(self):
+ for pkg in self.packages:
+ pkg.init()
+
class RosemaryPackage(object):
def __init__(self, model, name):
self.model = model
@@ -70,7 +68,8 @@
cls.extend(child)
def init(self):
- pass
+ for cls in self.classes:
+ cls.init()
class RosemaryClass(object):
def __init__(self, package, name):
@@ -89,11 +88,56 @@
self.methods = list()
self.methods_by_name = dict()
- stats_name = "%s_stats" % self.name
-
self.sql_table = SqlTable(self.package.sql_schema, self.name)
- self.sql_stats_table = SqlTable(self.package.sql_schema, stats_name)
+ self.sql_select = SqlSelectItem(self.sql_table)
+ self.sql_insert = SqlInsertItem(self.sql_table)
+ self.sql_update = SqlUpdateItem(self.sql_table)
+
+ name = "%sStats" % self.name
+
+ self.sql_stats_table = SqlTable(self.package.sql_schema, name)
+
+ self.add_columns()
+
+ def add_columns(self):
+ id_col = SqlColumn(self.sql_table, "id", "serial")
+
+ name = "%s_pk" % self.name
+
+ SqlPrimaryKeyConstraint(self.sql_table, name, (id_col,))
+
+ agent_col = SqlColumn(self.sql_table, "qmf_agent_id", "text")
+ object_col = SqlColumn(self.sql_table, "qmf_object_id", "text")
+
+ name = "%s_qmf_ids_uq" % self.name
+
+ SqlUniqueConstraint(self.sql_table, name, (agent_col, object_col))
+
+ SqlColumn(self.sql_table, "qmf_session_id", "text")
+ SqlColumn(self.sql_table, "qmf_update_time", "timestamp")
+ SqlColumn(self.sql_table, "qmf_create_time", "timestamp")
+
+ col = SqlColumn(self.sql_table, "qmf_delete_time", "timestamp")
+ col.nullable = True
+
+ stats_id_col = SqlColumn(self.sql_stats_table, "id", "serial")
+
+ name = "%s_pk" % self.sql_stats_table.name
+
+ SqlPrimaryKeyConstraint(self.sql_stats_table, name, (stats_id_col,))
+
+ parent_col = SqlColumn(self.sql_stats_table, "parent_id", "int4")
+ parent_col.foreign_key_column = id_col
+
+ update_col = SqlColumn \
+ (self.sql_stats_table, "qmf_update_time", "timestamp")
+
+ name = "%s_%s_uq" % (self.sql_stats_table.name, update_col.name)
+
+ SqlUniqueConstraint \
+ (self.sql_stats_table, name, (parent_col, update_col))
+
def load(self, elem):
for child in elem.findall("property"):
prop = RosemaryProperty(self, child.get("name"))
@@ -120,6 +164,36 @@
meth = self.methods_by_name[child.get("name")]
meth.extend(child)
+ def init(self):
+ for prop in self.properties:
+ prop.init()
+
+ for stat in self.statistics:
+ stat.init()
+
+ for meth in self.methods:
+ meth.init()
+
+ def load_object(self, cursor, id):
+ self.sql_select.execute(cursor, self.sql_table.columns, {"id": id})
+
+ return object # XXX
+
+ def save_object(self, cursor, object):
+ assert isinstance(object, RosemaryObject)
+
+ values = object.__dict__
+
+ try:
+ self.sql_update.execute(cursor, self.sql_table.columns, values)
+ except: # XXX need better exception
+ self.sql_insert.execute(cursor, self.sql_table.columns, values)
+
+ def delete_object(self, cursor, object):
+ assert isinstance(object, RosemaryObject)
+
+ self.sql_delete.execute(cursor, (), {"id": object.id})
+
class RosemaryProperty(object):
def __init__(self, cls, name):
self.cls = cls
@@ -137,7 +211,7 @@
self.is_optional = None
self.description = None
- self.sql_column = SqlColumn(self.cls.sql_table, self.name)
+ self.sql_column = None
def load(self, elem):
self.type = elem.get("type")
@@ -152,8 +226,22 @@
self.title = elem.findtext("title")
def init(self):
- pass
+ type = sql_types_by_qmf_type[self.type]
+ self.sql_column = SqlColumn(self.cls.sql_table, self.name, type)
+ self.sql_column.nullable = self.is_optional
+
+ if self.references:
+ try:
+ cls = self.cls.package.classes_by_name[self.references]
+ except KeyError:
+ log.warn("Reference to '%s' invalid", self.references)
+ return
+
+ col = cls.sql_table.columns_by_name["id"]
+
+ self.sql_column.foreign_key_column = col
+
class RosemaryStatistic(object):
def __init__(self, cls, name):
self.cls = cls
@@ -166,7 +254,7 @@
self.cls.statistics.append(self)
self.cls.statistics_by_name[self.name] = self
- self.sql_column = SqlColumn(self.cls.sql_stats_table, self.name)
+ self.sql_column = None
def load(self, elem):
self.type = elem.get("type")
@@ -177,21 +265,23 @@
pass
def init(self):
- self.column = SqlColumn(self.cls.stats_table, self.name)
+ type = sql_types_by_qmf_type[self.type]
+ self.sql_column = SqlColumn(self.cls.sql_stats_table, self.name, type)
+
class RosemaryMethod(object):
def __init__(self, cls, name):
self.cls = cls
+ self.name = name
- self.name = name
+ self.cls.methods.append(self)
+ self.cls.methods_by_name[self.name] = self
+
self.description = None
self.arguments = list()
self.arguments_by_name = dict()
- self.cls.methods.append(self)
- self.cls.methods_by_name[self.name] = self
-
def load(self, elem):
self.description = elem.get("desc")
@@ -202,6 +292,10 @@
def extend(self, elem):
pass
+ def init(self):
+ for arg in self.arguments:
+ arg.init()
+
def call(self, console, object, callback, **kwargs):
pass
@@ -225,23 +319,24 @@
def extend(self, elem):
pass
+ def init(self):
+ pass
+
class RosemaryObject(object):
def __init__(self, cls):
self.cls = cls
self.id = None
- self.qmf_broker_id = None
+ self.qmf_agent_id = None
self.qmf_object_id = None
for name in self.cls.properties:
setattr(name, None)
- self.__select = SelectObject(self.cls)
- self.__update = UpdateObject(self.cls)
- self.__insert = InsertObject(self.cls)
+ self.sql_insert = SqlInsert(self.cls.sql_table)
def load(self, cursor, id):
- self.__select.execute(cursor, {"id": id})
+ pass # XXX self.__select.execute(cursor, {"id": id})
def save(self, cursor):
assert self.id is not None
Deleted: mgmt/trunk/rosemary/python/rosemary/sql.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sql.py 2010-02-05 11:17:08 UTC (rev 3841)
+++ mgmt/trunk/rosemary/python/rosemary/sql.py 2010-02-05 15:53:42 UTC (rev 3842)
@@ -1,50 +0,0 @@
-from model import *
-from util import *
-
-class Operation(object):
- def __init__(self, cls):
- self.cls = cls
-
- def execute(self, cursor, args):
- text = self.emit()
- results = cursor.execute(text, args)
- return results
-
-class SelectOperation(Operation):
- def emit_columns(self):
- names = [x.name for x in self.cls.properties]
- cols = map(translate_column, names)
- return ", ".join(cols)
-
-class SelectObject(SelectOperation):
- def emit(self):
- cols = self.emit_columns()
- table = translate_table(self.cls.name)
- return "select %s from %s where id = %%(id)" % (cols, table)
-
-class UpdateOperation(Operation):
- def emit_exprs(self):
- names = [x.name for x in self.cls.properties]
- exprs = list()
-
- for name in names:
- exprs.append("%s = %%(%s)" % (translate_column(name), name))
-
- return ", ".join(exprs)
-
-class UpdateObject(UpdateOperation):
- def emit(self):
- exprs = self.emit_exprs()
- table = translate_table(self.cls.name)
- return "update %s set %s where id = %%(id)" % (table, exprs)
-
-def translate_column(name):
- name = unstudly(name)
-
- if name.endswith("_ref"):
- name = "%s_id" % name[:-4]
-
- return name
-
-def translate_table(name):
- return unstudly(name)
Modified: mgmt/trunk/rosemary/python/rosemary/sqlmodel.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqlmodel.py 2010-02-05 11:17:08 UTC (rev 3841)
+++ mgmt/trunk/rosemary/python/rosemary/sqlmodel.py 2010-02-05 15:53:42 UTC (rev 3842)
@@ -8,10 +8,14 @@
self.relations = list()
self.relations_by_name = dict()
- def write_ddl(self, out):
+ def write_create_ddl(self, out):
for schema in self.schemas:
- schema.write_ddl(out)
+ schema.write_create_ddl(out)
+ def write_drop_ddl(self, out):
+ for schema in self.schemas:
+ schema.write_drop_ddl(out)
+
class SqlSchema(object):
def __init__(self, model, name):
self.model = model
@@ -23,15 +27,23 @@
self.tables = list()
self.tables_by_name = dict()
- def write_ddl(self, out):
+ self.indexes = list()
+ self.indexes_by_name = dict()
+
+ def write_create_ddl(self, out):
out.write("create schema \"%s\"\n" % self.name)
for table in self.tables:
- if table.columns:
- table.write_ddl(out)
+ table.write_create_ddl(out)
+ for index in self.indexes:
+ index.write_create_ddl(out)
+
out.write(" ;\n")
+ def write_drop_ddl(self, out):
+ out.write("drop schema \"%s\" cascade;\n" % self.name)
+
class SqlTable(object):
def __init__(self, schema, name):
self.schema = schema
@@ -43,26 +55,94 @@
self.columns = list()
self.columns_by_name = dict()
- def write_ddl(self, out):
- out.write(" create table \"%s\" (\n" % self.name)
+ self.constraints = list()
+ self.constraints_by_name = dict()
+ def write_create_ddl(self, out):
+ out.write(" create table \"%s\" (" % self.name)
+
exprs = list()
- for column in self.columns:
- exprs.append("\"%s\" text" % column.name)
+ for col in self.columns:
+ exprs.append(col.get_ddl())
- out.write(" ")
- out.write(",\n ".join(exprs))
+ for constraint in self.constraints:
+ exprs.append(constraint.get_ddl())
+
+ exprs = ["\n %s" % x.strip() for x in exprs]
+
+ out.write(",".join(exprs))
+
out.write("\n )\n")
class SqlColumn(object):
- def __init__(self, table, name):
+ def __init__(self, table, name, type):
self.table = table
self.name = name
+ self.type = type
self.table.columns.append(self)
self.table.columns_by_name[self.name] = self
+ self.nullable = False
+ self.foreign_key_column = None
+
+ def get_ddl(self):
+ tokens = list()
+
+ tokens.append("\"%s\"" % self.name)
+ tokens.append(self.type)
+
+ if not self.nullable:
+ tokens.append("not null")
+
+ if self.foreign_key_column:
+ table = self.foreign_key_column.table.name
+ col = self.foreign_key_column.name
+ expr = "references \"%s\"(\"%s\")"
+
+ tokens.append(expr % (table, col))
+
+ return " ".join(tokens)
+
+class SqlTableConstraint(object):
+ def __init__(self, table, name, columns):
+ self.table = table
+ self.name = name
+ self.columns = columns
+
+ self.table.constraints.append(self)
+ self.table.constraints_by_name[self.name] = name
+
+class SqlPrimaryKeyConstraint(SqlTableConstraint):
+ def get_ddl(self):
+ cols = "\"%s\"" % "\", \"".join([x.name for x in self.columns])
+
+ return "constraint \"%s\" primary key (%s)" % (self.name, cols)
+
+class SqlUniqueConstraint(SqlTableConstraint):
+ def get_ddl(self):
+ cols = "\"%s\"" % "\", \"".join([x.name for x in self.columns])
+
+ return "constraint \"%s\" unique (%s)" % (self.name, cols)
+
+class SqlIndex(object):
+ def __init__(self, schema, name, columns):
+ assert len(set([x.table for x in columns])) == 1
+
+ self.schema = schema
+ self.name = name
+ self.columns = columns
+
+ self.schema.indexes.append(self)
+ self.schema.indexes_by_name[self.name] = self
+
+ def write_create_ddl(self, out):
+ cols = "\"%s\"" % "\", \"".join([x.name for x in self.columns])
+ args = (self.name, self.columns[0].table.name, cols)
+
+ out.write(" create index \"%s\" on \"%s\"(%s)\n" % args)
+
class SqlRelation(object):
def __init__(self, model, name, columns):
self.name = name
Added: mgmt/trunk/rosemary/python/rosemary/sqloperation.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/sqloperation.py (rev 0)
+++ mgmt/trunk/rosemary/python/rosemary/sqloperation.py 2010-02-05 15:53:42 UTC (rev 3842)
@@ -0,0 +1,41 @@
+from sqlmodel import *
+from util import *
+
+class SqlOperation(object):
+ def __init__(self, table):
+ self.table = table
+
+ def execute(self, cursor, columns, values):
+ text = self.emit(names)
+ results = cursor.execute(text, values)
+ return results
+
+class SqlSelectItem(SqlOperation):
+ def emit(self, columns):
+ cols = ", ".join(["\"%s\"" % x.name for x in columns])
+ args = (cols, self.table.schema.name, self.table.name)
+
+ return "select %s from \"%s\".\"%s\" where id = %%(id)" % args
+
+class SqlInsertItem(SqlOperation):
+ def emit(self, columns):
+ names = [x.name for x in columns]
+ cols = ", ".join(["\"%s\"" % x for x in names])
+ vals = ", ".join(["%%(%s)" % x for x in names])
+ args = (self.table.schema.name, self.table.name, cols, vals)
+
+ return "insert into \"%s\".\"%s\" (%s) values (%s)" % args
+
+class SqlUpdateItem(SqlOperation):
+ def emit(self, columns):
+ exprs = ["\"%s\" = %%(%s)" % (x.name, x.name) for x in columns]
+ exprs = ", ".join(exprs)
+ args = (self.table.schema.name, self.table.name, exprs)
+
+ return "update \"%s\".\"%s\" set %s where id = %%(id)" % args
+
+class SqlDeleteItem(SqlOperation):
+ def emit(self, columns):
+ args = (self.table.schema.name, self.table.name)
+
+ return "delete from \"%s\".\"%s\" where id = %%(id)" % args
Added: mgmt/trunk/rosemary/python/rosemary/types.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/types.py (rev 0)
+++ mgmt/trunk/rosemary/python/rosemary/types.py 2010-02-05 15:53:42 UTC (rev 3842)
@@ -0,0 +1,33 @@
+from util import *
+
+sql_types_by_qmf_type = {
+ "int8": "int2",
+ "int16": "int2",
+ "int32": "int4",
+ "int64": "int8",
+ "uint8": "int2",
+ "uint16": "int4",
+ "uint32": "int8",
+ "uint64": "numeric(19)",
+ "count8": "int2",
+ "count16": "int4",
+ "count32": "int8",
+ "count64": "numeric(19)",
+ "hilo8": "int2",
+ "hilo16": "int4",
+ "hilo32": "int8",
+ "hilo64": "numeric(19)",
+ "mma32": "int8",
+ "mma64": "numeric(19)",
+ "float": "float4",
+ "double": "float8",
+ "bool": "bool",
+ "sstr": "text",
+ "lstr": "text",
+ "absTime": "timestamp",
+ "deltaTime": "numeric(19)",
+ "mmaTime": "numeric(19)",
+ "map": "text",
+ "objId": "text",
+ "uuid": "text",
+ }
Modified: mgmt/trunk/rosemary/python/rosemary/util.py
===================================================================
--- mgmt/trunk/rosemary/python/rosemary/util.py 2010-02-05 11:17:08 UTC (rev 3841)
+++ mgmt/trunk/rosemary/python/rosemary/util.py 2010-02-05 15:53:42 UTC (rev 3842)
@@ -1,3 +1,12 @@
+import logging
+import os
+import sys
+
+try:
+ from xml.etree.ElementTree import *
+except ImportError:
+ from elementtree.ElementTree import *
+
def unstudly(name):
chars = list()
14 years, 10 months
rhmessaging commits: r3841 - store/branches/java/0.5.x-dev/etc.
by rhmessaging-commits@lists.jboss.org
Author: rgemmell
Date: 2010-02-05 06:17:08 -0500 (Fri, 05 Feb 2010)
New Revision: 3841
Modified:
store/branches/java/0.5.x-dev/etc/config-systests-bdb-settings.xml
Log:
Update the systest configuration to provide seperate directories for each virtualhost
Modified: store/branches/java/0.5.x-dev/etc/config-systests-bdb-settings.xml
===================================================================
--- store/branches/java/0.5.x-dev/etc/config-systests-bdb-settings.xml 2010-02-04 18:02:05 UTC (rev 3840)
+++ store/branches/java/0.5.x-dev/etc/config-systests-bdb-settings.xml 2010-02-05 11:17:08 UTC (rev 3841)
@@ -28,7 +28,7 @@
<localhost>
<store>
<class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdb-store/</environment-path>
+ <environment-path>${work}/bdbstore/localhost-store</environment-path>
</store>
</localhost>
</virtualhost>
@@ -38,7 +38,7 @@
<development>
<store>
<class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdb-store/</environment-path>
+ <environment-path>${work}/bdbstore/development-store</environment-path>
</store>
</development>
</virtualhost>
@@ -48,7 +48,7 @@
<test>
<store>
<class>org.apache.qpid.server.store.berkeleydb.BDBMessageStore</class>
- <environment-path>${work}/bdb-store/</environment-path>
+ <environment-path>${work}/bdbstore/test-store</environment-path>
</store>
</test>
</virtualhost>
14 years, 10 months