[rhmessaging-commits] rhmessaging commits: r1997 - in mgmt: mint/python/mint and 1 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Mon May 5 16:39:53 EDT 2008
Author: justi9
Date: 2008-05-05 16:39:52 -0400 (Mon, 05 May 2008)
New Revision: 1997
Modified:
mgmt/cumin/python/cumin/model.py
mgmt/mint/python/mint/__init__.py
mgmt/mint/sql/schema.sql
Log:
This revision requires you to reload your database schema.
Changes the registration-broker association to be 1:1.
Also contains an initial and still non-functional implementation of
mgmt session protection.
Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py 2008-05-05 20:26:34 UTC (rev 1996)
+++ mgmt/cumin/python/cumin/model.py 2008-05-05 20:39:52 UTC (rev 1997)
@@ -13,7 +13,7 @@
class CuminModel(object):
def __init__(self, app, data_uri, spec_path):
self.app = app
- self.data = MintModel(data_uri, spec_path)
+ self.data = MintModel(data_uri, spec_path, debug=True)
self.classes = list()
self.invocations = set()
@@ -524,7 +524,7 @@
return "resource?name=broker-36.png"
def show_object(self, session, broker):
- reg = broker.registrations[0]
+ reg = broker.registration
return self.cumin_model.show_main(session).show_broker(session, reg)
def get_object_name(self, broker):
@@ -703,7 +703,7 @@
def show_object(self, session, queue):
frame = self.cumin_model.show_main(session)
- frame = frame.show_broker(session, queue.vhost.broker.registrations[0])
+ frame = frame.show_broker(session, queue.vhost.broker.registration)
return frame.show_queue(session, queue)
class Purge(CuminAction):
@@ -771,7 +771,7 @@
def show_object(self, session, exchange):
frame = self.cumin_model.show_main(session)
- frame = frame.show_broker(exchange.vhost.broker.registrations[0])
+ frame = frame.show_broker(exchange.vhost.broker.registration)
return frame.show_queue(session, exchange)
def get_title(self, session):
@@ -842,8 +842,7 @@
def show_object(self, session, client):
frame = self.cumin_model.show_main(session)
- frame = frame.show_broker(session,
- client.vhost.broker.registrations[0])
+ frame = frame.show_broker(session, client.vhost.broker.registration)
return frame.show_client(session, client)
def get_title(self, session):
@@ -864,6 +863,15 @@
return "Close"
def do_invoke(self, client, args, completion):
+ conn = self.cumin_model.data.getConnectionByObject(client)
+
+ # Does it contain a mgmt session?
+
+ for session in client.sessions:
+ if session.name == conn.getSessionId():
+ raise Exception \
+ ("Cannot close management client %s", client.address)
+
client.close(self.cumin_model.data, completion)
class CuminSession(RemoteClass):
@@ -906,6 +914,12 @@
return "Close"
def do_invoke(self, object, args, completion):
+ conn = self.cumin_model.data.getConnectionByObject(object)
+
+ if object.name == conn.getSessionId():
+ raise Exception \
+ ("Cannot close management session %s" % object.name)
+
object.close(self.cumin_model.data, completion)
class Detach(CuminAction):
@@ -913,6 +927,12 @@
return "Detach"
def do_invoke(self, object, args, completion):
+ conn = self.cumin_model.data.getConnectionByObject(object)
+
+ if object.name == conn.getSessionId():
+ raise Exception \
+ ("Cannot detach management session %s" % object.name)
+
object.detach(self.cumin_model.data, completion)
class ResetLifespan(CuminAction):
Modified: mgmt/mint/python/mint/__init__.py
===================================================================
--- mgmt/mint/python/mint/__init__.py 2008-05-05 20:26:34 UTC (rev 1996)
+++ mgmt/mint/python/mint/__init__.py 2008-05-05 20:39:52 UTC (rev 1997)
@@ -23,8 +23,9 @@
except TypeError:
pass
-Broker.sqlmeta.addJoin(SQLMultipleJoin("BrokerRegistration",
- joinMethodName="registrations"))
+Broker.sqlmeta.addColumn(ForeignKey("BrokerRegistration",
+ cascade="null", default=None,
+ name="registration"))
class MintInfo(SQLObject):
class sqlmeta:
@@ -149,14 +150,17 @@
if isinstance(obj, Broker) and obj.managedBroker:
host, port = obj.managedBroker.split(":")
port = int(port)
- existing = list(obj.registrations)
- regs = BrokerRegistration.selectBy(host=host, port=port)
- for reg in regs:
- if reg not in existing:
- log.info("Attaching broker to reg %s" % reg)
+ if not obj.registration:
+ try:
+ reg = BrokerRegistration.selectBy(host=host, port=port)[0]
+ except IndexError:
+ reg = None
+ if reg:
reg.broker = obj
+ obj.registration = reg
+
reg.syncUpdate()
obj.syncUpdate()
@@ -208,7 +212,7 @@
self.model.lock.release()
def getSessionId(self):
- if isOpen(self):
+ if self.isOpen():
return self.mchan.sessionId
else:
return None
@@ -397,6 +401,9 @@
self.outstandingMethodCalls[methodId] = callback
return methodId
+ def getConnectionByRegistration(self, reg):
+ return self.connections.get("%s:%i" % (reg.host, reg.port))
+
class MintDatabase(object):
def __init__(self, uri):
self.uri = uri
Modified: mgmt/mint/sql/schema.sql
===================================================================
--- mgmt/mint/sql/schema.sql 2008-05-05 20:26:34 UTC (rev 1996)
+++ mgmt/mint/sql/schema.sql 2008-05-05 20:39:52 UTC (rev 1997)
@@ -136,7 +136,8 @@
cluster_name VARCHAR(1000),
version VARCHAR(1000),
data_dir_enabled BOOL,
- data_dir VARCHAR(1000)
+ data_dir VARCHAR(1000),
+ registration_id INT
);
CREATE TABLE broker_stats (
@@ -480,6 +481,8 @@
ALTER TABLE broker ADD CONSTRAINT system_id_exists FOREIGN KEY (system_id) REFERENCES system (id) ON DELETE SET NULL;
+ALTER TABLE broker ADD CONSTRAINT registration_id_exists FOREIGN KEY (registration_id) REFERENCES broker_registration (id) ON DELETE SET NULL;
+
ALTER TABLE broker_stats ADD CONSTRAINT broker_id_exists FOREIGN KEY (broker_id) REFERENCES broker (id) ON DELETE SET NULL;
ALTER TABLE client ADD CONSTRAINT stats_curr_id_exists FOREIGN KEY (stats_curr_id) REFERENCES client_stats (id) ON DELETE SET NULL;
More information about the rhmessaging-commits
mailing list