rhmessaging commits: r1710 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-20 09:55:14 -0500 (Wed, 20 Feb 2008)
New Revision: 1710
Modified:
mgmt/cumin/python/cumin/broker.py
Log:
Rename BrokerForm to BrokerSetForm
Modified: mgmt/cumin/python/cumin/broker.py
===================================================================
--- mgmt/cumin/python/cumin/broker.py 2008-02-20 10:19:32 UTC (rev 1709)
+++ mgmt/cumin/python/cumin/broker.py 2008-02-20 14:55:14 UTC (rev 1710)
@@ -516,9 +516,9 @@
return fmt_link(href, name, class_)
-class BrokerForm(CuminForm, Frame):
+class BrokerSetForm(CuminForm, Frame):
def __init__(self, app, name):
- super(BrokerForm, self).__init__(app, name)
+ super(BrokerSetForm, self).__init__(app, name)
self.name_param = Parameter(app, "name_param");
self.add_parameter(self.name_param)
@@ -612,7 +612,7 @@
def render_content(self, session, model):
return "More Entries"
-class BrokerSetAdd(BrokerForm):
+class BrokerSetAdd(BrokerSetForm):
def get_title(self, session, object):
return "Register New Brokers"
18 years, 2 months
rhmessaging commits: r1709 - in store/branches/java/M2.1/java/bdbstore/src: test/java/org/apache/qpid/server/store/berkeleydb and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: godfrer
Date: 2008-02-20 05:19:32 -0500 (Wed, 20 Feb 2008)
New Revision: 1709
Modified:
store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/MessageMetaDataTupleBinding.java
store/branches/java/M2.1/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java
Log:
Fixed compilation issues against Apache M2.1 codebase
Modified: store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java
===================================================================
--- store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2008-02-20 04:38:03 UTC (rev 1708)
+++ store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java 2008-02-20 10:19:32 UTC (rev 1709)
@@ -1243,7 +1243,7 @@
public void process() throws AMQException
{
- _queue.process(_context, _message, false);
+ _queue.process(_context, _queue.createEntry(_message), false);
}
}
Modified: store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/MessageMetaDataTupleBinding.java
===================================================================
--- store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/MessageMetaDataTupleBinding.java 2008-02-20 04:38:03 UTC (rev 1708)
+++ store/branches/java/M2.1/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/MessageMetaDataTupleBinding.java 2008-02-20 10:19:32 UTC (rev 1709)
@@ -84,6 +84,11 @@
return exchange;
}
+ public void setExchange(AMQShortString exchange)
+ {
+
+ }
+
public boolean isImmediate()
{
return immediate;
Modified: store/branches/java/M2.1/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java
===================================================================
--- store/branches/java/M2.1/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java 2008-02-20 04:38:03 UTC (rev 1708)
+++ store/branches/java/M2.1/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBStoreTest.java 2008-02-20 10:19:32 UTC (rev 1709)
@@ -115,6 +115,11 @@
return MYEXCHANGE;
}
+ public void setExchange(AMQShortString exchange)
+ {
+
+ }
+
public boolean isImmediate()
{
return false;
@@ -169,10 +174,9 @@
private ContentHeaderBody createContentHeaderBody(BasicContentHeaderProperties props, int length)
{
- // TODO: fix hardcoded 8,0
- return new ContentHeaderBody(BasicConsumeBody.getClazz((byte) 8,
- (byte) 0), 1,
- props, length);
+ MethodRegistry methodRegistry = MethodRegistry.getMethodRegistry(ProtocolVersion.v8_0);
+ int classForBasic = methodRegistry.createBasicQosOkBody().getClazz();
+ return new ContentHeaderBody(classForBasic, 1, props, length);
}
public void testMessagePersistence() throws DatabaseException, AMQException
18 years, 2 months
rhmessaging commits: r1708 - in mgmt: basil and 4 other directories.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-19 23:38:03 -0500 (Tue, 19 Feb 2008)
New Revision: 1708
Added:
mgmt/basil/
mgmt/basil/bin/
mgmt/basil/bin/basil
mgmt/basil/python/
mgmt/basil/python/basil/
mgmt/basil/python/basil/__init__.py
mgmt/basil/python/basil/__init__.strings
mgmt/basil/python/basil/util.py
Modified:
mgmt/etc/devel.profile
Log:
Introduces a new module, basil, for generating client-side mgmt models.
Added: mgmt/basil/bin/basil
===================================================================
--- mgmt/basil/bin/basil (rev 0)
+++ mgmt/basil/bin/basil 2008-02-20 04:38:03 UTC (rev 1708)
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+
+import sys
+
+from basil import *
+
+def usage():
+ print "Usage: basil SCHEMA-XML"
+ sys.exit(1)
+
+def main():
+ if len(sys.argv) != 2:
+ usage()
+
+ xml = sys.argv[1]
+ maker = ClassMaker(xml)
+
+ print maker.make()
+
+if __name__ == "__main__":
+ main()
Property changes on: mgmt/basil/bin/basil
___________________________________________________________________
Name: svn:executable
+ *
Added: mgmt/basil/python/basil/__init__.py
===================================================================
--- mgmt/basil/python/basil/__init__.py (rev 0)
+++ mgmt/basil/python/basil/__init__.py 2008-02-20 04:38:03 UTC (rev 1708)
@@ -0,0 +1,74 @@
+import mllib
+from string import Template
+
+from util import *
+
+strings = StringCatalog(__file__)
+
+class ClassMaker(object):
+ def __init__(self, schema_xml):
+ self.schema_xml = schema_xml
+ self.main_tmpl = Template(strings.get("main"))
+ self.class_tmpl = Template(strings.get("class"))
+ self.constructor_tmpl = Template(strings.get("constructor"))
+ self.attribute_tmpl = Template(strings.get("attribute"))
+ self.method_tmpl = Template(strings.get("method"))
+
+ def make(self):
+ schema = mllib.xml_parse(self.schema_xml)
+
+ args = dict()
+
+ l = list()
+ for cls in schema.query["schema/class"]:
+ l.append(self.make_class(cls))
+ args["classes"] = "\n\n".join(l)
+
+ return self.main_tmpl.substitute(args)
+
+ def make_class(self, node):
+ args = dict()
+ args["name"] = node["@name"].capitalize()
+ args["constructor"] = self.make_constructor(node)
+
+ l = list()
+ for meth in node.query["method"]:
+ l.append(self.make_method(meth))
+ args["methods"] = "\n\n".join(l)
+
+ return self.class_tmpl.substitute(args)
+
+ def make_constructor(self, node):
+ args = dict()
+ args["mgmt_name"] = node["@name"]
+
+ l = list()
+ for attr in node.query["configElement"]:
+ l.append(self.make_attribute(attr))
+ for attr in node.query["instElement"]:
+ l.append(self.make_attribute(attr))
+ args["attributes"] = "\n".join(l)
+
+ return self.constructor_tmpl.substitute(args)
+
+ def make_attribute(self, node):
+ args = dict()
+ args["name"] = node["@name"]
+
+ return self.attribute_tmpl.substitute(args)
+
+ def make_method(self, node):
+ args = dict()
+ args["name"] = node["@name"]
+
+ pl, al = list(), list()
+ pl.append("self")
+ for arg in node.query["arg"]:
+ name = arg["@name"]
+ pl.append(name)
+ al.append("\"%s\": %s" % (name, name))
+ pl.append("callback")
+ args["parameters"] = ", ".join(pl)
+ args["args"] = ", ".join(al)
+
+ return self.method_tmpl.substitute(args)
Added: mgmt/basil/python/basil/__init__.strings
===================================================================
--- mgmt/basil/python/basil/__init__.strings (rev 0)
+++ mgmt/basil/python/basil/__init__.strings 2008-02-20 04:38:03 UTC (rev 1708)
@@ -0,0 +1,68 @@
+[main]
+import sys, os
+
+class Model(object):
+ def __init__(self, broker):
+ self.broker = broker
+ self.broker_id = "%s:%i" % (broker.host, broker.port)
+ self.broker.configListener(self.broker_id, self.__config_callback)
+
+ self.method_sequence = 1
+ self.outstanding_calls = dict()
+
+ self.classes = list()
+ self.classes_by_mgmt_name = dict()
+
+ def call_method(self, obj, name, args, callback):
+ method_sequence += 1
+ self.outstanding_calls[self.method_sequence] = callback
+
+ self.broker.method(id, obj.mgmt_id, obj.mgmt_name, name, args=args,
+ packageName=obj.mgmt_package)
+
+ def __config_callback(self, broker_id, object_name, values, timestamps):
+ if broker_id != self.broker_id:
+ raise Exception("Unexpected broker")
+
+ print broker_id, object_name, values, timestamps
+
+${classes}
+
+if __name__ == "__main__":
+ from qpid.management import ManagedBroker
+ from time import sleep
+
+ host = "localhost"
+ port = 5672
+ spec = os.environ.get("AMQP_SPEC", "/usr/share/amqp/amqp.0-10-preview.xml")
+
+ broker = ManagedBroker(host, port, spec)
+ model = Model(broker)
+
+ broker.start()
+
+ while True:
+ sleep(5)
+
+[class]
+class ${name}(object):
+${constructor}
+
+${methods}
+
+[constructor]
+ def __init__(self, model, id):
+ self.mgmt_model = model
+ self.mgmt_id = id
+ self.mgmt_name = "${mgmt_name}"
+ self.mgmt_package = "qpid"
+
+${attributes}
+
+[attribute]
+ self.${name} = None
+
+[method]
+ def ${name}(${parameters}):
+ args = {${args}}
+ self.mgmt_model.call_method(self, ${name}, args, callback)
Added: mgmt/basil/python/basil/util.py
===================================================================
--- mgmt/basil/python/basil/util.py (rev 0)
+++ mgmt/basil/python/basil/util.py 2008-02-20 04:38:03 UTC (rev 1708)
@@ -0,0 +1,39 @@
+import os
+from StringIO import StringIO
+
+class StringCatalog(object):
+ def __init__(self, filename):
+ self.__strings = dict()
+
+ path = os.path.splitext(filename)[0] + ".strings"
+
+ try:
+ file = open(path)
+ self.parse(file)
+ finally:
+ file.close()
+
+ def get(self, key):
+ return self.__strings.get(key)
+
+ def parse(self, file):
+ key = None
+ writer = StringIO()
+
+ for line in file:
+ line = line[0:-1]
+
+ if line.startswith("[") and line.endswith("]"):
+ if key:
+ self.__strings[key] = writer.getvalue().rstrip()
+
+ writer = StringIO()
+
+ key = line[1:-1]
+
+ continue
+
+ writer.write(line)
+ writer.write("\n")
+
+ self.__strings[key] = writer.getvalue().rstrip()
Modified: mgmt/etc/devel.profile
===================================================================
--- mgmt/etc/devel.profile 2008-02-19 22:44:00 UTC (rev 1707)
+++ mgmt/etc/devel.profile 2008-02-20 04:38:03 UTC (rev 1708)
@@ -2,7 +2,7 @@
export DEVEL_HOME="$PWD"
fi
-export DEVEL_MODULES="mint cumin"
+export DEVEL_MODULES="basil mint cumin"
# PYTHONPATH
18 years, 2 months
rhmessaging commits: r1707 - mgmt/notes.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-19 17:44:00 -0500 (Tue, 19 Feb 2008)
New Revision: 1707
Modified:
mgmt/notes/justin-todo.txt
Log:
Misc updates.
Modified: mgmt/notes/justin-todo.txt
===================================================================
--- mgmt/notes/justin-todo.txt 2008-02-19 20:18:49 UTC (rev 1706)
+++ mgmt/notes/justin-todo.txt 2008-02-19 22:44:00 UTC (rev 1707)
@@ -1,32 +1,35 @@
Current
- * Bulk actions: Add javascript for the check-all behavior
+ * Add simple user auth
- * Handle other exception conditions on broker connect more gracefully
+ * Move to cherrypy web server
- * Unregistering a broker doesn't disconnect it
+ * Bulk actions: Add javascript for the check-all behavior
* Tables: Add sort direction icon
* Tables: Make null values in tables dashes, not zeroes
- * Validate paginator current page and reset as necessary
-
- * Don't let anyone close mgmt clients
-
- * Group form submit has different behaviors between hitting enter and
- clicking submit
-
* Get rid of single object confirms
* No way to ungroupify a broker
- * No group edit form
+ * No broker edit form
* Add examples of legit broker addresses in broker add form
+ * Validate broker and group names in forms
+
Deferred
+ * Unregistering a broker doesn't disconnect it
+
+ * Don't let anyone close mgmt clients
+
+ - Waiting on an api change from Ted
+
+ * Validate paginator current page and reset as necessary
+
* Tables: Make column sort disableable
* Tables: Change first-click sort to desc for number fields
@@ -43,8 +46,6 @@
* Add ability to clear action history
- * Validate broker and group names in forms
-
* Gray out old rates
* Duration formatter has problems with very short durations
18 years, 2 months
rhmessaging commits: r1706 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-19 15:18:49 -0500 (Tue, 19 Feb 2008)
New Revision: 1706
Modified:
mgmt/cumin/python/cumin/broker.strings
mgmt/cumin/python/cumin/brokercluster.strings
mgmt/cumin/python/cumin/brokergroup.strings
mgmt/cumin/python/cumin/brokerprofile.strings
mgmt/cumin/python/cumin/exchange.strings
mgmt/cumin/python/cumin/queue.strings
mgmt/cumin/python/cumin/widgets.strings
Log:
Because of a bad behavior in HTML, I am forced to reorder submit
buttons ahead of cancel buttons in document order.
Modified: mgmt/cumin/python/cumin/broker.strings
===================================================================
--- mgmt/cumin/python/cumin/broker.strings 2008-02-19 11:22:32 UTC (rev 1705)
+++ mgmt/cumin/python/cumin/broker.strings 2008-02-19 20:18:49 UTC (rev 1706)
@@ -108,8 +108,8 @@
</div>
<div class="foot">
<div style="float: left;"><button>Help</button></div>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
@@ -230,8 +230,8 @@
</div>
<div class="foot">
<a class="help action" href="{href}" target="help">Help</a>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
Modified: mgmt/cumin/python/cumin/brokercluster.strings
===================================================================
--- mgmt/cumin/python/cumin/brokercluster.strings 2008-02-19 11:22:32 UTC (rev 1705)
+++ mgmt/cumin/python/cumin/brokercluster.strings 2008-02-19 20:18:49 UTC (rev 1706)
@@ -92,8 +92,8 @@
</div>
<div class="foot">
<a class="help action" href="{href}" target="help">Help</a>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
Modified: mgmt/cumin/python/cumin/brokergroup.strings
===================================================================
--- mgmt/cumin/python/cumin/brokergroup.strings 2008-02-19 11:22:32 UTC (rev 1705)
+++ mgmt/cumin/python/cumin/brokergroup.strings 2008-02-19 20:18:49 UTC (rev 1706)
@@ -56,8 +56,8 @@
</div>
<div class="foot">
<a class="help action" href="{href}" target="help">Help</a>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
Modified: mgmt/cumin/python/cumin/brokerprofile.strings
===================================================================
--- mgmt/cumin/python/cumin/brokerprofile.strings 2008-02-19 11:22:32 UTC (rev 1705)
+++ mgmt/cumin/python/cumin/brokerprofile.strings 2008-02-19 20:18:49 UTC (rev 1706)
@@ -88,8 +88,8 @@
</div>
<div class="foot">
<a class="help action" href="{href}" target="help">Help</a>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
Modified: mgmt/cumin/python/cumin/exchange.strings
===================================================================
--- mgmt/cumin/python/cumin/exchange.strings 2008-02-19 11:22:32 UTC (rev 1705)
+++ mgmt/cumin/python/cumin/exchange.strings 2008-02-19 20:18:49 UTC (rev 1706)
@@ -96,8 +96,8 @@
</div>
<div class="foot">
<div style="display: block; float: left;"><button>Help</help></div>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
Modified: mgmt/cumin/python/cumin/queue.strings
===================================================================
--- mgmt/cumin/python/cumin/queue.strings 2008-02-19 11:22:32 UTC (rev 1705)
+++ mgmt/cumin/python/cumin/queue.strings 2008-02-19 20:18:49 UTC (rev 1706)
@@ -91,8 +91,8 @@
</div>
<div class="foot">
<div style="display: block; float: left;"><button>Help</button></div>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
@@ -240,8 +240,8 @@
</div>
<div class="foot">
<a class="help action" href="{help_href}" target="help">Help</a>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script defer="defer">
Modified: mgmt/cumin/python/cumin/widgets.strings
===================================================================
--- mgmt/cumin/python/cumin/widgets.strings 2008-02-19 11:22:32 UTC (rev 1705)
+++ mgmt/cumin/python/cumin/widgets.strings 2008-02-19 20:18:49 UTC (rev 1706)
@@ -29,8 +29,8 @@
</div>
<div class="foot">
<div style="display: block; float: left;"><button>Help</button></div>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script>
@@ -55,8 +55,8 @@
</div>
<div class="foot">
<div style="display: block; float: left;"><button>Help</button></div>
+ {submit}
{cancel}
- {submit}
</div>
</form>
<script>
18 years, 2 months
rhmessaging commits: r1705 - store/trunk/cpp/lib.
by rhmessaging-commits@lists.jboss.org
Author: gordonsim
Date: 2008-02-19 06:22:32 -0500 (Tue, 19 Feb 2008)
New Revision: 1705
Modified:
store/trunk/cpp/lib/BdbMessageStore.cpp
Log:
Log warning (rather than throwing exception) when a mapping is found for a deleted queue on recovery.
Modified: store/trunk/cpp/lib/BdbMessageStore.cpp
===================================================================
--- store/trunk/cpp/lib/BdbMessageStore.cpp 2008-02-18 22:15:06 UTC (rev 1704)
+++ store/trunk/cpp/lib/BdbMessageStore.cpp 2008-02-19 11:22:32 UTC (rev 1705)
@@ -25,6 +25,7 @@
#include <qpid/broker/RecoveryManager.h>
#include <qpid/broker/Message.h>
#include <qpid/framing/Buffer.h>
+#include <qpid/log/Statement.h>
#include <algorithm>
#include <iomanip>
#include <sstream>
@@ -677,15 +678,15 @@
for (int status = mappings->get(&msgId, &value, DB_SET); status == 0; status = mappings->get(&msgId, &value, DB_NEXT_DUP)) {
RecoverableQueue::shared_ptr queue = index[value.id];
if (!queue) {
- THROW_STORE_EXCEPTION("Missing queue");
+ QPID_LOG(warning, "Recovered message for queue that no longer exists");
+ } else {
+ if (PreparedTransaction::isLocked(locked, value.id, msgId.id)) {
+ prepared[msgId.id] = msg;
+ } else {
+ queue->recover(msg);
+ }
+ count++;
}
-
- if (PreparedTransaction::isLocked(locked, value.id, msgId.id)) {
- prepared[msgId.id] = msg;
- } else {
- queue->recover(msg);
- }
- count++;
}
return count;
}
18 years, 2 months
rhmessaging commits: r1704 - mgmt/mint/bin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-18 17:15:06 -0500 (Mon, 18 Feb 2008)
New Revision: 1704
Modified:
mgmt/mint/bin/mint-test
Log:
Updates mint-test to use the new connection api.
Modified: mgmt/mint/bin/mint-test
===================================================================
--- mgmt/mint/bin/mint-test 2008-02-18 21:26:00 UTC (rev 1703)
+++ mgmt/mint/bin/mint-test 2008-02-18 22:15:06 UTC (rev 1704)
@@ -1,42 +1,38 @@
#!/usr/bin/env python
import sys
+from qpid.management import ManagedBroker
+from time import sleep
+from mint import *
+
def usage():
print "Usage: mint-test DATABASE-URI BROKER-ADDRESS"
- print "Example: mint-test postgresql://who@where/dbname example.com:10001"
+ print "Example: mint-test postgresql://cumin@postgresql/cumin localhost:5672"
sys.exit(1)
-from sqlobject import *
+def do_main(uri, host, port):
+ model = MintModel(uri)
+ model.init()
-try:
- connuri = sys.argv[1]
- conn = connectionForURI(connuri)
- sqlhub.processConnection = conn
-except IndexError:
- usage()
+ conn = BrokerConnection(model, host, port)
+ conn.open()
-from qpid.management import ManagedBroker
-from time import sleep
+ try:
+ while (True):
+ sleep(5)
+ finally:
+ conn.close()
-from mint import *
-
-def do_main(dburi, brokerhost, brokerport):
- model = MintModel()
- model.addManagedBroker(brokerhost, brokerport)
-
- while (True):
- sleep(5)
-
def main():
if len(sys.argv) != 3:
usage()
- dburi, brokeraddr = sys.argv[1:]
- brokerhost, brokerport = brokeraddr.split(":")
+ uri, addr = sys.argv[1:]
+ host, port = addr.split(":")
try:
- do_main(dburi, brokerhost, int(brokerport))
+ do_main(uri, host, int(port))
except KeyboardInterrupt:
pass
18 years, 2 months
rhmessaging commits: r1703 - mgmt/cumin/bin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-18 16:26:00 -0500 (Mon, 18 Feb 2008)
New Revision: 1703
Modified:
mgmt/cumin/bin/cumin-database
Log:
Clarify in printed messages that "--force yes" is required, not just
--force.
Modified: mgmt/cumin/bin/cumin-database
===================================================================
--- mgmt/cumin/bin/cumin-database 2008-02-18 21:18:21 UTC (rev 1702)
+++ mgmt/cumin/bin/cumin-database 2008-02-18 21:26:00 UTC (rev 1703)
@@ -13,7 +13,7 @@
-h, --help Print this message
--data URL Connect to database at URL
(default postgesql://cumin@localhost/cumin)
- --force Don't complain and just do it
+ --force yes Don't complain and just do it
Commands:
create-schema Create the database schema; requires --force
drop-schema Drop the database schema; requires --force
@@ -68,13 +68,13 @@
database.createSchema((main, indexes))
else:
- print "Command create-schema requires --force"
+ print "Command create-schema requires --force yes"
sys.exit(1)
elif command == "drop-schema":
if force:
database.dropSchema()
else:
- print "Command create-schema requires --force"
+ print "Command create-schema requires --force yes"
sys.exit(1)
else:
print "Error: command '%s' not recognized" % command
18 years, 2 months
rhmessaging commits: r1702 - mgmt/cumin/python/cumin.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-18 16:18:21 -0500 (Mon, 18 Feb 2008)
New Revision: 1702
Modified:
mgmt/cumin/python/cumin/__init__.py
Log:
Removes an unused class.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2008-02-18 20:37:30 UTC (rev 1701)
+++ mgmt/cumin/python/cumin/__init__.py 2008-02-18 21:18:21 UTC (rev 1702)
@@ -51,13 +51,6 @@
self.model.init()
self.broker_connect_thread.start()
-class CuminServer(WebServer):
- def __init__(self, port):
- model = DummyModel()
- app = Cumin(model)
-
- super(CuminServer, self).__init__(app, port)
-
class BrokerConnectThread(Thread):
def __init__(self, model):
super(BrokerConnectThread, self).__init__()
18 years, 2 months
rhmessaging commits: r1701 - in mgmt: mint/python/mint and 1 other directory.
by rhmessaging-commits@lists.jboss.org
Author: justi9
Date: 2008-02-18 15:37:30 -0500 (Mon, 18 Feb 2008)
New Revision: 1701
Modified:
mgmt/cumin/python/cumin/__init__.py
mgmt/mint/python/mint/__init__.py
Log:
Introduces a BrokerConnection object for keeping track of the state of
connections. This replaces model.connectToBroker. Adds a connect
method directly on BrokerRegistration that connects using
BrokerConnection.
Also some minor cleanups.
Modified: mgmt/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/cumin/python/cumin/__init__.py 2008-02-18 20:35:12 UTC (rev 1700)
+++ mgmt/cumin/python/cumin/__init__.py 2008-02-18 20:37:30 UTC (rev 1701)
@@ -9,6 +9,7 @@
from mint import *
from time import sleep
from threading import Thread, Event
+from traceback import print_exc
from model import CuminModel, ModelPage
from demo import DemoData
@@ -75,9 +76,8 @@
def run(self):
try:
self.do_run()
- except Exception, e:
- # XXX add print_exc
- print e
+ except:
+ print_exc()
def do_run(self):
while True:
@@ -90,22 +90,10 @@
self.attempts[reg] = attempts
if attempts < 10:
- self.connect(reg)
+ reg.connect(self.model.data)
elif attempts < 100 and attempts % 10 == 0:
- self.connect(reg)
+ reg.connect(self.model.data)
elif attempts % 100 == 0:
- self.connect(reg)
+ reg.connect(self.model.data)
self.event.wait(10)
-
- def connect(self, reg):
- print "Trying to connect to broker '%s' at %s:%i" % \
- (reg.name, reg.host, reg.port or 5672)
-
- try:
- self.model.data.connectToBroker \
- (reg.host, reg.port or 5672)
-
- print "Connection succeeded"
- except socket.error:
- print "Connection failed"
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2008-02-18 20:35:12 UTC (rev 1700)
+++ mgmt/mint/python/mint/__init__.py 2008-02-18 20:37:30 UTC (rev 1701)
@@ -3,6 +3,7 @@
from datetime import *
from sqlobject import *
from threading import Lock
+from traceback import print_exc
from mint import schema
@@ -31,6 +32,19 @@
cluster = ForeignKey("BrokerCluster", cascade="null", default=None)
profile = ForeignKey("BrokerProfile", cascade="null", default=None)
+ def connect(self, model):
+ print "Connecting to broker '%s' at %s:%i" % \
+ (self.name, self.host, self.port or 5672)
+
+ conn = BrokerConnection(model, self.host, self.port or 5672)
+
+ try:
+ conn.open()
+ print "Connection succeeded"
+ except:
+ print "Connection failed: " + str(conn.exception)
+ print_exc()
+
class BrokerGroup(SQLObject):
name = StringCol(length=1000, default=None)
brokers = SQLRelatedJoin("BrokerRegistration",
@@ -105,8 +119,63 @@
def getByIndexAttrib(self, objType, indexAttrib, indexValue, create=False, args={}):
###FIX
return None
-
+class BrokerConnection(object):
+ def __init__(self, model, host, port):
+ self.model = model
+ self.key = "%s:%i" % (host, port)
+ self.broker = ManagedBroker(host=host, port=port)
+ self.state = None # in (None, "opening", "opened", "closing", "closed")
+ self.exception = None
+
+ self.broker.configListener(self.key, self.model.configCallback)
+ self.broker.instrumentationListener(self.key, self.model.instCallback)
+ self.broker.methodListener(self.key, self.model.methodCallback)
+
+ def isOpen(self):
+ return self.state == "opened"
+
+ def open(self):
+ self.state = "opening"
+
+ try:
+ self.model.lock.acquire()
+ try:
+ # XXX I want this to happen after broker start, but the
+ # callbacks rely on the broker being in the connectedBrokers
+ # dict
+ self.model.connectedBrokers[self.key] = ConnectedBroker(self.broker)
+
+ self.broker.start()
+
+ #self.model.connections[self.key] = self
+
+ self.state = "opened"
+ except Exception, e:
+ self.exception = e
+ raise e
+ finally:
+ self.model.lock.release()
+
+ def close(self):
+ self.state = "closing"
+
+ try:
+ self.model.lock.acquire()
+ try:
+ if not self.broker.isConnected():
+ raise Exception("Broker not connected")
+
+ self.broker.stop()
+ #del self.model.connections[self.key]
+ del self.model.connectedBrokers[self.key]
+ self.state = "closed"
+ except Exception, e:
+ self.exception = e
+ raise e
+ finally:
+ self.model.lock.release()
+
class ConnectedBroker:
def __init__(self, managedBroker):
self.managedBroker = managedBroker
@@ -118,10 +187,9 @@
def getByIndexAttrib(self, objType, indexAttrib, indexValue, parent, create=False, args={}):
return self.objs.getByIndexAttrib(objType, indexAttrib, indexValue, create, args)
-
class MintModel:
- def __init__(self, data_url, debug=False):
- self.data_url = data_url
+ def __init__(self, dataUri, debug=False):
+ self.dataUri = dataUri
self.currentMethodId = 1
self.outstandingMethodCalls = dict()
self.connectedBrokers = dict()
@@ -130,7 +198,7 @@
def check(self):
try:
- connectionForURI(self.data_url)
+ connectionForURI(self.dataUri)
except Exception, e:
if hasattr(e, "message") and e.message.find("does not exist"):
print "Database not found; run cumin-database-init"
@@ -138,7 +206,7 @@
raise e
def init(self):
- conn = connectionForURI(self.data_url)
+ conn = connectionForURI(self.dataUri)
sqlhub.processConnection = conn
def setDebug(self, debug=True):
@@ -165,7 +233,7 @@
if (key.endswith("Ref")):
keys.append(key)
return keys
-
+
def configCallback(self, broker, objectName, list, timestamps):
self.log("\nCONFIG---------------------------------------------------")
self.log(objectName)
@@ -234,29 +302,6 @@
self.log("END METHOD---------------------------------------------------\n")
return result
- def connectToBroker(self, host, port):
- self.lock.acquire()
- try:
- broker = ManagedBroker(host=host, port=port)
- label = "%s:%d" % (host, port)
- self.connectedBrokers[label] = ConnectedBroker(broker)
- broker.configListener(label, self.configCallback)
- broker.instrumentationListener(label, self.instCallback)
- broker.methodListener(label, self.methodCallback)
- try:
- broker.start()
- except socket.error:
- # XXX this is not ideal. I'd prefer to avoid the dict
- # assignment above until we can verify we can connect. That
- # way we could avoid the locking as well.
-
- del self.connectedBrokers[label]
- raise
- finally:
- self.lock.release()
-
- return label
-
def registerCallback(self, callback):
self.currentMethodId += 1
methodId = self.currentMethodId
@@ -331,4 +376,4 @@
conn.commit()
finally:
- conn.close()
+ conn.close()
18 years, 2 months