[rhmessaging-commits] rhmessaging commits: r2125 - in mgmt/mint: python/mint and 1 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Wed Jun 4 11:48:32 EDT 2008
Author: nunofsantos
Date: 2008-06-04 11:48:32 -0400 (Wed, 04 Jun 2008)
New Revision: 2125
Modified:
mgmt/mint/Makefile
mgmt/mint/python/mint/schema.py
mgmt/mint/python/mint/schemaparser.py
mgmt/mint/sql/schema.sql
Log:
add support for store schema
Modified: mgmt/mint/Makefile
===================================================================
--- mgmt/mint/Makefile 2008-06-04 15:39:43 UTC (rev 2124)
+++ mgmt/mint/Makefile 2008-06-04 15:48:32 UTC (rev 2125)
@@ -31,8 +31,7 @@
schema-python:
@if [ -z "$$MINT_SCHEMA_XML" ]; then echo "MINT_SCHEMA_XML is not set"; exit 1; fi
python python/mint/schemaparser.py ${MINT_SCHEMA_XML} python/mint/schema.py ${dsn}
-# ignore the store schema for now
-# @if [ -z "$$STORE_SCHEMA_XML" ]; then echo "Warning: STORE_SCHEMA_XML is not set, skipping store schema generation"; else python python/mint/schemaparser.py ${STORE_SCHEMA_XML} python/mint/schema-store.py ${dsn}; cat python/mint/schema-store.py >> python/mint/schema.py; rm python/mint/schema-store.py; fi
+ @if [ -z "$$STORE_SCHEMA_XML" ]; then echo "Warning: STORE_SCHEMA_XML is not set, skipping store schema generation"; else python python/mint/schemaparser.py ${STORE_SCHEMA_XML} python/mint/schema.py ${dsn} append; fi
schema-sql:
sqlobject-admin sql -m mint -m mint.schema -c ${dsn} | sed -e '1,2d' > sql/schema.sql
Modified: mgmt/mint/python/mint/schema.py
===================================================================
--- mgmt/mint/python/mint/schema.py 2008-06-04 15:39:43 UTC (rev 2124)
+++ mgmt/mint/python/mint/schema.py 2008-06-04 15:48:32 UTC (rev 2125)
@@ -590,3 +590,72 @@
schemaNameToClassMap['Bridge'] = Bridge
classToSchemaNameMap['Session'] = 'Session'
schemaNameToClassMap['Session'] = Session
+
+
+
+class Store(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ idOriginal = BigIntCol(default=None)
+ recTime = TimestampCol(default=None)
+ creationTime = TimestampCol(default=None)
+ deletionTime = TimestampCol(default=None)
+ managedBroker = StringCol(length=1000, default=None)
+ statsCurr = ForeignKey('StoreStats', cascade='null', default=None)
+ statsPrev = ForeignKey('StoreStats', cascade='null', default=None)
+
+ classInfos = dict() # brokerId => classInfo
+
+class StoreStats(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ idOriginal = BigIntCol(default=None)
+ recTime = TimestampCol(default=None)
+ store = ForeignKey('Store', cascade='null', default=None)
+
+ classInfos = dict() # brokerId => classInfo
+
+Store.sqlmeta.addJoin(SQLMultipleJoin('StoreStats', joinMethodName='stats'))
+
+
+class Journal(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ idOriginal = BigIntCol(default=None)
+ recTime = TimestampCol(default=None)
+ creationTime = TimestampCol(default=None)
+ deletionTime = TimestampCol(default=None)
+ managedBroker = StringCol(length=1000, default=None)
+ statsCurr = ForeignKey('JournalStats', cascade='null', default=None)
+ statsPrev = ForeignKey('JournalStats', cascade='null', default=None)
+
+ classInfos = dict() # brokerId => classInfo
+
+ def expand(self, model, callback, by):
+ """Increase number of files allocated for this journal"""
+ actualArgs = dict()
+ actualArgs["by"] = by
+ conn = model.connections[self.managedBroker]
+ classInfo = self.classInfos[self.managedBroker]
+ conn.callMethod(self.idOriginal, classInfo, "expand",
+ callback, args=actualArgs)
+
+class JournalStats(SQLObject):
+ class sqlmeta:
+ lazyUpdate = True
+
+ idOriginal = BigIntCol(default=None)
+ recTime = TimestampCol(default=None)
+ journal = ForeignKey('Journal', cascade='null', default=None)
+
+ classInfos = dict() # brokerId => classInfo
+
+Journal.sqlmeta.addJoin(SQLMultipleJoin('JournalStats', joinMethodName='stats'))
+
+classToSchemaNameMap['Store'] = 'store'
+schemaNameToClassMap['store'] = Store
+classToSchemaNameMap['Journal'] = 'journal'
+schemaNameToClassMap['journal'] = Journal
Modified: mgmt/mint/python/mint/schemaparser.py
===================================================================
--- mgmt/mint/python/mint/schemaparser.py 2008-06-04 15:39:43 UTC (rev 2124)
+++ mgmt/mint/python/mint/schemaparser.py 2008-06-04 15:48:32 UTC (rev 2125)
@@ -4,18 +4,25 @@
class SchemaParser:
"""parses broker XML schema"""
- def __init__(self, xmlSchemaPath, pythonFilePath, dsn):
+ def __init__(self, xmlSchemaPath, pythonFilePath, dsn, append=""):
self.xmlSchemaPath = xmlSchemaPath
self.pythonFilePath = pythonFilePath
self.dsn = dsn
self.style = MixedCaseUnderscoreStyle()
- self.pythonOutput = "import mint\n"
- self.pythonOutput += "from sqlobject import *\n"
- self.pythonOutput += "from datetime import datetime\n"
self.additionalPythonOutput = ""
self.currentClass = ""
- self.finalPythonOutput = "\nclassToSchemaNameMap = dict()\n"
- self.finalPythonOutput += "schemaNameToClassMap = dict()\n"
+ self.pythonOutput = ""
+ self.finalPythonOutput = ""
+ if (append == ""):
+ self.pythonOutput += "import mint\n"
+ self.pythonOutput += "from sqlobject import *\n"
+ self.pythonOutput += "from datetime import datetime\n"
+ self.finalPythonOutput += "\nclassToSchemaNameMap = dict()\n"
+ self.finalPythonOutput += "schemaNameToClassMap = dict()\n"
+ self.append = False
+ else:
+ self.pythonOutput += "\n\n"
+ self.append = True
# mapping between xml schema types and database column types
# see xml/MintTypes.xml
self.dataTypesMap = dict()
@@ -162,7 +169,11 @@
self.currentClass = ""
def generateCode(self):
- outputFile = open(self.pythonFilePath, "w")
+ if (self.append):
+ fileFlag = "a"
+ else:
+ fileFlag = "w"
+ outputFile = open(self.pythonFilePath, fileFlag)
schema = mllib.xml_parse(self.xmlSchemaPath)
classes = schema.query["schema/class"]
for cls in classes:
@@ -180,8 +191,8 @@
if __name__ == "__main__":
import sys
- if len(sys.argv) != 4:
- print "Usage: schemaparser.py INPUT-XML-SCHEMA OUTPUT-PYTHON-FILE DSN"
+ if len(sys.argv) not in (4,5):
+ print "Usage: schemaparser.py INPUT-XML-SCHEMA OUTPUT-PYTHON-FILE DSN [APPEND]"
sys.exit(1)
else:
parser = SchemaParser(*sys.argv[1:])
Modified: mgmt/mint/sql/schema.sql
===================================================================
--- mgmt/mint/sql/schema.sql 2008-06-04 15:39:43 UTC (rev 2124)
+++ mgmt/mint/sql/schema.sql 2008-06-04 15:48:32 UTC (rev 2125)
@@ -215,6 +215,24 @@
byte_routes BIGINT
);
+CREATE TABLE journal (
+ id SERIAL PRIMARY KEY,
+ id_original BIGINT,
+ rec_time TIMESTAMP,
+ creation_time TIMESTAMP,
+ deletion_time TIMESTAMP,
+ managed_broker VARCHAR(1000),
+ stats_curr_id INT,
+ stats_prev_id INT
+);
+
+CREATE TABLE journal_stats (
+ id SERIAL PRIMARY KEY,
+ id_original BIGINT,
+ rec_time TIMESTAMP,
+ journal_id INT
+);
+
CREATE TABLE link (
id SERIAL PRIMARY KEY,
id_original BIGINT,
@@ -329,6 +347,24 @@
frames_outstanding INT
);
+CREATE TABLE store (
+ id SERIAL PRIMARY KEY,
+ id_original BIGINT,
+ rec_time TIMESTAMP,
+ creation_time TIMESTAMP,
+ deletion_time TIMESTAMP,
+ managed_broker VARCHAR(1000),
+ stats_curr_id INT,
+ stats_prev_id INT
+);
+
+CREATE TABLE store_stats (
+ id SERIAL PRIMARY KEY,
+ id_original BIGINT,
+ rec_time TIMESTAMP,
+ store_id INT
+);
+
CREATE TABLE system (
id SERIAL PRIMARY KEY,
id_original BIGINT,
@@ -433,6 +469,12 @@
ALTER TABLE exchange_stats ADD CONSTRAINT exchange_id_exists FOREIGN KEY (exchange_id) REFERENCES exchange (id) ON DELETE SET NULL;
+ALTER TABLE journal ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id) REFERENCES journal_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE journal ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES journal_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE journal_stats ADD CONSTRAINT journal_id_exists FOREIGN KEY (journal_id) REFERENCES journal (id) ON DELETE SET NULL;
+
ALTER TABLE link ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id) REFERENCES link_stats (id) ON DELETE SET NULL;
ALTER TABLE link ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES link_stats (id) ON DELETE SET NULL;
@@ -459,6 +501,12 @@
ALTER TABLE session_stats ADD CONSTRAINT session_id_exists FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE SET NULL;
+ALTER TABLE store ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id) REFERENCES store_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE store ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES store_stats (id) ON DELETE SET NULL;
+
+ALTER TABLE store_stats ADD CONSTRAINT store_id_exists FOREIGN KEY (store_id) REFERENCES store (id) ON DELETE SET NULL;
+
ALTER TABLE system ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id) REFERENCES system_stats (id) ON DELETE SET NULL;
ALTER TABLE system ADD CONSTRAINT stats_prev_id_exists FOREIGN KEY (stats_prev_id) REFERENCES system_stats (id) ON DELETE SET NULL;
More information about the rhmessaging-commits
mailing list