[rhmessaging-commits] rhmessaging commits: r4045 - in mgmt/newdata: mint/python/mint and 1 other directory.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Mon Jun 21 15:15:25 EDT 2010
Author: justi9
Date: 2010-06-21 15:15:25 -0400 (Mon, 21 Jun 2010)
New Revision: 4045
Modified:
mgmt/newdata/cumin/bin/cumin-data
mgmt/newdata/mint/python/mint/main.py
mgmt/newdata/mint/python/mint/model.py
mgmt/newdata/mint/python/mint/session.py
mgmt/newdata/mint/python/mint/update.py
Log:
Add an event printing option to cumin-data
Modified: mgmt/newdata/cumin/bin/cumin-data
===================================================================
--- mgmt/newdata/cumin/bin/cumin-data 2010-06-21 15:24:54 UTC (rev 4044)
+++ mgmt/newdata/cumin/bin/cumin-data 2010-06-21 19:15:25 UTC (rev 4045)
@@ -16,6 +16,7 @@
parser = CuminOptionParser(values.data)
parser.add_option("--print-stats", action="store_true")
+ parser.add_option("--print-events", type="int", default=0, metavar="LEVEL")
opts, args = parser.parse_args()
@@ -25,6 +26,8 @@
mint = Mint(model_dir, opts.broker, opts.database)
+ mint.print_event_level = opts.print_events
+
mint.check()
mint.init()
@@ -41,7 +44,7 @@
print "[Starred columns are the number of events per second]"
while True:
- if count % 24 == 0:
+ if count % 20 == 0:
stats.print_headings()
count += 1
Modified: mgmt/newdata/mint/python/mint/main.py
===================================================================
--- mgmt/newdata/mint/python/mint/main.py 2010-06-21 15:24:54 UTC (rev 4044)
+++ mgmt/newdata/mint/python/mint/main.py 2010-06-21 19:15:25 UTC (rev 4045)
@@ -28,6 +28,8 @@
self.vacuum_enabled = True
self.vacuum_thread = VacuumThread(self)
+ self.print_event_level = 0
+
def check(self):
log.info("Checking %s", self)
Modified: mgmt/newdata/mint/python/mint/model.py
===================================================================
--- mgmt/newdata/mint/python/mint/model.py 2010-06-21 15:24:54 UTC (rev 4044)
+++ mgmt/newdata/mint/python/mint/model.py 2010-06-21 19:15:25 UTC (rev 4045)
@@ -42,6 +42,12 @@
finally:
self.lock.release()
+ def print_event(self, level, message, *args):
+ log.info(message, *args)
+
+ if self.app.print_event_level >= level:
+ print datetime.now(), message % args
+
def __repr__(self):
return "%s(%s)" % (self.__class__.__name__, self.model_dir)
Modified: mgmt/newdata/mint/python/mint/session.py
===================================================================
--- mgmt/newdata/mint/python/mint/session.py 2010-06-21 15:24:54 UTC (rev 4044)
+++ mgmt/newdata/mint/python/mint/session.py 2010-06-21 19:15:25 UTC (rev 4045)
@@ -54,23 +54,24 @@
self.model = model
def brokerConnected(self, qmf_broker):
- log.info("Broker at %s:%i is connected",
- qmf_broker.host, qmf_broker.port)
+ message = "Broker %s:%i is connected"
+ self.model.print_event(1, message, qmf_broker.host, qmf_broker.port)
def brokerInfo(self, qmf_broker):
- log.info("Broker info from %s", qmf_broker)
+ message = "Broker info from %s:%i"
+ self.model.print_event(1, message, qmf_broker.host, qmf_broker.port)
def brokerDisconnected(self, qmf_broker):
- log.info("Broker at %s:%i is disconnected",
- qmf_broker.host, qmf_broker.port)
+ message = "Broker %s:%i is disconnected"
+ self.model.print_event(1, message, qmf_broker.host, qmf_broker.port)
def newAgent(self, qmf_agent):
- log.info("Creating %s", qmf_agent)
+ self.model.print_event(3, "Creating %s", qmf_agent)
MintAgent(self.model, qmf_agent)
def delAgent(self, qmf_agent):
- log.info("Deleting %s", qmf_agent)
+ self.model.print_event(3, "Deleting %s", qmf_agent)
try:
agent = self.model.get_agent(qmf_agent)
@@ -79,11 +80,16 @@
agent.delete()
- if self.model.app.update_thread.isAlive():
- up = AgentDelete(self.model, agent)
- self.model.app.update_thread.enqueue(up)
+ if not self.model.app.update_thread.isAlive():
+ return
+ up = AgentDelete(self.model, agent)
+ self.model.app.update_thread.enqueue(up)
+
def heartbeat(self, qmf_agent, timestamp):
+ message = "Heartbeat from %s at %s"
+ self.model.print_event(5, message, qmf_agent, timestamp)
+
timestamp = timestamp / 1000000000
try:
@@ -94,10 +100,10 @@
agent.last_heartbeat = datetime.fromtimestamp(timestamp)
def newPackage(self, name):
- log.info("New package %s", name)
+ self.model.print_event(2, "New package %s", name)
def newClass(self, kind, classKey):
- log.info("New class %s", classKey)
+ self.model.print_event(2, "New class %s", classKey)
def objectProps(self, broker, obj):
agent = self.model.get_agent(obj.getAgent())
@@ -122,12 +128,12 @@
self.model.app.update_thread.enqueue(up)
def event(self, broker, event):
- """ Invoked when an event is raised. """
- pass
+ self.model.print_event(4, "New event %s from %s", broker, event)
def methodResponse(self, broker, seq, response):
- log.info("Method response for request %i received from %s",
- seq, broker)
+ message = "Method response for request %i received from %s"
+ self.model.print_event(3, message, seq, broker)
+
log.debug("Response: %s", response)
self.model.lock.acquire()
Modified: mgmt/newdata/mint/python/mint/update.py
===================================================================
--- mgmt/newdata/mint/python/mint/update.py 2010-06-21 15:24:54 UTC (rev 4044)
+++ mgmt/newdata/mint/python/mint/update.py 2010-06-21 19:15:25 UTC (rev 4045)
@@ -147,7 +147,6 @@
class Update(object):
def __init__(self, model):
self.model = model
- self.thread = None
def process(self, thread):
log.debug("Processing %s", self)
@@ -227,10 +226,15 @@
if obj._sync_time:
sql = cls.sql_update.emit(object_columns)
stats.updated += 1
+
+ self.model.print_event(4, "Updating %s", obj)
else:
sql = cls.sql_insert.emit(object_columns)
stats.created += 1
+ message = "Creating %s, from %s"
+ self.model.print_event(3, message, obj, self.agent)
+
statements.append(sql)
obj._sync_time = now
@@ -449,6 +453,8 @@
cls = self.get_class()
obj = self.get_object(cls, self.object.getObjectId().objectName)
+ self.model.print_event(3, "Deleting %s, from %s", obj, self.agent)
+
obj.delete(cursor)
try:
@@ -470,8 +476,13 @@
for pkg in self.model._packages:
for cls in pkg._classes:
for obj in cls.get_selection(cursor, _qmf_agent_id=id):
+ message = "Deleting %s, from %s"
+ self.model.print_event(3, message, obj, self.agent)
+
obj.delete(cursor)
+ stats.deleted += 1
+
class UpdateException(Exception):
def __init__(self, name):
self.name = name
More information about the rhmessaging-commits
mailing list