[rhmessaging-commits] rhmessaging commits: r3248 - in mgmt/trunk: cumin and 13 other directories.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Wed Apr 1 15:21:13 EDT 2009
Author: justi9
Date: 2009-04-01 15:21:13 -0400 (Wed, 01 Apr 2009)
New Revision: 3248
Added:
mgmt/trunk/cumin/bin/cumin-server
mgmt/trunk/cumin/etc/module.profile
mgmt/trunk/cumin/instance/
mgmt/trunk/etc/module.profile
mgmt/trunk/mint/etc/module.profile
mgmt/trunk/mint/instance/
mgmt/trunk/mint/instance/etc/
mgmt/trunk/mint/instance/etc/mint.conf
mgmt/trunk/mint/instance/log/
mgmt/trunk/mint/python/mint/main.py
mgmt/trunk/wooly/etc/
mgmt/trunk/wooly/etc/module.profile
mgmt/trunk/wooly/instance/
Removed:
mgmt/trunk/cumin-test-0/
mgmt/trunk/wooly/wooly-demo-instance/
Modified:
mgmt/trunk/cumin/bin/cumin
mgmt/trunk/cumin/instance/bin
mgmt/trunk/cumin/instance/resources
mgmt/trunk/cumin/instance/resources-wooly
mgmt/trunk/cumin/instance/sql
mgmt/trunk/cumin/python/cumin/__init__.py
mgmt/trunk/cumin/python/cumin/model.py
mgmt/trunk/cumin/python/cumin/tools.py
mgmt/trunk/etc/devel.profile
mgmt/trunk/mint/python/mint/__init__.py
mgmt/trunk/mint/python/mint/dbexpire.py
mgmt/trunk/mint/python/mint/tools.py
mgmt/trunk/mint/python/mint/update.py
Log:
The big goal: Make mint-server and cumin-server independent.
- Make mint-server stand by itself, with its own config instead of
using cumin's. mint-server uses a MINT_HOME and looks for config
in $MINT_HOME/etc/mint.conf.
- Introduce cumin-server, which makes no attempt to start a mint
process.
- Change "cumin" to be a simple shell wrapper that starts both above
servers.
- Introduce Mint (a top level app thing) and MintConfig.
- Refactor expire thread params to support use of MintConfig.
- Reorganize mint-bench a little.
- Institute a new general pattern for devel instances of servers,
including mint-server, wooly-demo, and cumin-server.
Modified: mgmt/trunk/cumin/bin/cumin
===================================================================
--- mgmt/trunk/cumin/bin/cumin 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/cumin/bin/cumin 2009-04-01 19:21:13 UTC (rev 3248)
@@ -1,35 +1,6 @@
-#!/usr/bin/python
+#!/bin/bash
-import sys, os
+mint-server &
+trap "kill $!" EXIT
-from cumin.tools import CuminServerTool
-
-def main():
- CuminServerTool("cumin").main()
-
-if __name__ == "__main__":
- if "--profile" in sys.argv:
- from profile import Profile
- from pstats import Stats
-
- prof = Profile()
-
- try:
- prof.run("main()")
- except KeyboardInterrupt:
- pass
-
- file = "/tmp/cumin-stats"
- prof.dump_stats(file)
-
- stats = Stats(file)
-
- stats.sort_stats("cumulative").print_stats(15)
- stats.sort_stats("time").print_stats(15)
-
- stats.strip_dirs()
- else:
- try:
- main()
- except KeyboardInterrupt:
- pass
+cumin-server
Added: mgmt/trunk/cumin/bin/cumin-server
===================================================================
--- mgmt/trunk/cumin/bin/cumin-server (rev 0)
+++ mgmt/trunk/cumin/bin/cumin-server 2009-04-01 19:21:13 UTC (rev 3248)
@@ -0,0 +1,9 @@
+#!/usr/bin/python
+
+from cumin.tools import CuminServerTool
+
+if __name__ == "__main__":
+ try:
+ CuminServerTool("cumin-server").main()
+ except KeyboardInterrupt:
+ pass
Property changes on: mgmt/trunk/cumin/bin/cumin-server
___________________________________________________________________
Name: svn:executable
+ *
Added: mgmt/trunk/cumin/etc/module.profile
===================================================================
--- mgmt/trunk/cumin/etc/module.profile (rev 0)
+++ mgmt/trunk/cumin/etc/module.profile 2009-04-01 19:21:13 UTC (rev 3248)
@@ -0,0 +1,3 @@
+export PYTHONPATH="${PWD}/python:${PYTHONPATH}"
+export PATH="${PWD}/bin:${PATH}"
+export CUMIN_HOME="${PWD}/instance"
Copied: mgmt/trunk/cumin/instance (from rev 3246, mgmt/trunk/cumin-test-0)
Property changes on: mgmt/trunk/cumin/instance
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: mgmt/trunk/cumin/instance/bin
===================================================================
--- mgmt/trunk/cumin-test-0/bin 2009-03-31 14:07:45 UTC (rev 3246)
+++ mgmt/trunk/cumin/instance/bin 2009-04-01 19:21:13 UTC (rev 3248)
@@ -1 +1 @@
-link ../cumin/bin
\ No newline at end of file
+link ../bin
\ No newline at end of file
Modified: mgmt/trunk/cumin/instance/resources
===================================================================
--- mgmt/trunk/cumin-test-0/resources 2009-03-31 14:07:45 UTC (rev 3246)
+++ mgmt/trunk/cumin/instance/resources 2009-04-01 19:21:13 UTC (rev 3248)
@@ -1 +1 @@
-link ../cumin/resources
\ No newline at end of file
+link ../resources
\ No newline at end of file
Modified: mgmt/trunk/cumin/instance/resources-wooly
===================================================================
--- mgmt/trunk/cumin-test-0/resources-wooly 2009-03-31 14:07:45 UTC (rev 3246)
+++ mgmt/trunk/cumin/instance/resources-wooly 2009-04-01 19:21:13 UTC (rev 3248)
@@ -1 +1 @@
-link ../wooly/resources
\ No newline at end of file
+link ../../wooly/resources
\ No newline at end of file
Modified: mgmt/trunk/cumin/instance/sql
===================================================================
--- mgmt/trunk/cumin-test-0/sql 2009-03-31 14:07:45 UTC (rev 3246)
+++ mgmt/trunk/cumin/instance/sql 2009-04-01 19:21:13 UTC (rev 3248)
@@ -1 +1 @@
-link ../mint/sql
\ No newline at end of file
+link ../../mint/sql
\ No newline at end of file
Modified: mgmt/trunk/cumin/python/cumin/__init__.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/__init__.py 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/cumin/python/cumin/__init__.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -156,29 +156,15 @@
param = ConfigParameter(self, "user", str)
- param = ConfigParameter(self, "expire-frequency", int)
- param.default = 600 # 10 minutes
-
- param = ConfigParameter(self, "expire-threshold", int)
- param.default = 24 * 3600 # 1 day
-
param = ConfigParameter(self, "operator-email", str)
def init(self):
super(CuminConfig, self).init()
- handler = StreamHandler()
- log.addHandler(handler)
self.load_file(os.path.join(self.home, "etc", "cumin.conf"))
self.load_file(os.path.join(os.path.expanduser("~"), ".cumin.conf"))
- log.removeHandler(handler)
- self.init_logging()
-
- def init_logging(self):
- enable_logging("mint", self.log_level, self.log_file)
enable_logging("cumin", self.log_level, self.log_file)
if self.debug:
- enable_logging("mint", "debug", sys.stderr)
enable_logging("cumin", "debug", sys.stderr)
Modified: mgmt/trunk/cumin/python/cumin/model.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/model.py 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/cumin/python/cumin/model.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -21,13 +21,10 @@
class CuminModel(object):
def __init__(self, app, data_uri):
self.app = app
- self.data = MintModel(data_uri,
- dbExpireFrequency=app.config.expire_frequency,
- dbExpireThreshold=app.config.expire_threshold,
- debug=False)
+ self.data = MintModel(data_uri)
self.data.updateObjects = False
- self.data.dbExpiration = False
+ self.data.expireObjects = False
self.classes = list()
self.invocations = set()
Modified: mgmt/trunk/cumin/python/cumin/tools.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/tools.py 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/cumin/python/cumin/tools.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -4,6 +4,7 @@
from parsley.command import *
from wooly.devel import *
from mint import *
+from mint.tools import MintServerTool
from getpass import getpass
from psycopg2 import IntegrityError
from subprocess import Popen
@@ -162,15 +163,17 @@
if self.config.debug:
self.config.prt()
- args = sys.argv[1:]
-
try:
- opts, remaining = self.parse_options(args)
+ opts, remaining = self.parse_options(sys.argv[1:])
except CommandException, e:
print "Error: %s" % e.message
e.command.print_help()
sys.exit(1)
+ if "help" in opts:
+ self.print_help()
+ return
+
try:
scommand = remaining[0]
except IndexError:
@@ -187,10 +190,17 @@
try:
opts, args = command.parse(remaining)
- if "help" in opts:
- command.print_help()
- return
+ print opts, args, remaining
+ except CommandException, e:
+ print "Error: %s" % e.message
+ e.command.print_help()
+ sys.exit(1)
+ if "help" in opts:
+ command.print_help()
+ return
+
+ try:
command.run(opts, args)
except CommandException, e:
print "Error: %s" % e.message
@@ -224,6 +234,8 @@
name, url = args[1:]
except IndexError:
raise CommandException(self, "NAME and URL are required")
+ except ValueError:
+ raise CommandException(self, "NAME and URL are required")
for reg in BrokerRegistration.selectBy(name=name):
print "Error: a broker called '%s' already exists" % name
@@ -438,8 +450,6 @@
def __init__(self, name):
super(CuminServerTool, self).__init__(name)
- signal.signal(signal.SIGTERM, self.sigTermHandler)
-
self.description = "Cumin web server"
param = ConfigParameter(self.config, "addr", str)
@@ -462,44 +472,6 @@
opt = CommandOption(self, "ssl")
opt.description = "Serve web pages using SSL"
- def sigTermHandler(self, signum, frame):
- sys.exit(1)
-
- class MintProcess(object):
- def __init__(self):
- self.proc = None
-
- def start(self, config, opts):
- args = ["mint-server",
- "--data", config.data,
- "--log-file", config.log_file,
- "--log-level", config.log_level,
- "--expire-frequency", str(config.expire_frequency),
- "--expire-threshold", str(config.expire_threshold)]
-
- if "debug" in opts or config.debug:
- args.append("--debug")
-
- self.proc = Popen(args)
-
- def stop(self):
- if self.proc.poll is not None:
- os.kill(self.proc.pid, signal.SIGTERM)
-
- for i in range(30):
- code = self.proc.poll()
-
- if code is not None:
- log.debug("Mint subprocess %i terminated", self.proc.pid)
- return
-
- sleep(1)
-
- os.kill(self.proc.pid, signal.SIGKILL)
-
- log.warn("Mint subprocess %i wouldn't go gracefully, killed",
- self.proc.pid)
-
def do_run(self, opts, args):
self.config.load_dict(opts)
@@ -536,23 +508,15 @@
log.error("SSL key file '%s' not found" % kpath)
sys.exit(1)
- mint_proc = self.MintProcess()
+ app.start()
try:
try:
- mint_proc.start(self.config, opts)
- except:
- log.exception("Failed starting mint process")
-
- app.start()
-
- try:
- server.start()
+ server.start() # XXX fix the weird api here
finally:
server.stop()
finally:
app.stop()
- mint_proc.stop()
class CuminTestTool(BaseCuminTool):
def __init__(self, name):
Modified: mgmt/trunk/etc/devel.profile
===================================================================
--- mgmt/trunk/etc/devel.profile 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/etc/devel.profile 2009-04-01 19:21:13 UTC (rev 3248)
@@ -1,34 +1,28 @@
export DEVEL_HOME="$PWD"
export DEVEL_MODULES="mint cumin basil parsley wooly"
-# PYTHONPATH
+if [[ -z "$DEVEL_ORIGINAL_PATH" ]]; then
+ export DEVEL_ORIGINAL_PATH="$PATH"
+fi
-test -z "$DEVEL_ORIGINAL_PYTHONPATH" && {
+export PATH="${DEVEL_HOME}/bin:${DEVEL_ORIGINAL_PATH}"
+
+if [[ -z "$DEVEL_ORIGINAL_PYTHONPATH" ]]; then
export DEVEL_ORIGINAL_PYTHONPATH="$PYTHONPATH"
-}
+fi
-pypath="${DEVEL_HOME}/lib/python:${HOME}/lib/python:${DEVEL_ORIGINAL_PYTHONPATH}"
+export PYTHONPATH="${DEVEL_HOME}/lib/python:${HOME}/lib/python:${DEVEL_ORIGINAL_PYTHONPATH}"
for module in $DEVEL_MODULES; do
- pypath="$DEVEL_HOME"/"$module"/python:"$pypath"
-done
+ echo "Configuring module '${module}'"
-export PYTHONPATH="$pypath"
+ pushd "${DEVEL_HOME}/${module}" > /dev/null
-# PATH
+ if [[ -f "etc/module.profile" ]]; then
+ source "etc/module.profile"
+ else
+ source "../etc/module.profile"
+ fi
-test -z "$DEVEL_ORIGINAL_PATH" && {
- export DEVEL_ORIGINAL_PATH="$PATH"
-}
-
-path="${DEVEL_HOME}/bin:${DEVEL_ORIGINAL_PATH}"
-
-for module in $DEVEL_MODULES; do
- path="$DEVEL_HOME/${module}/bin:${path}"
+ popd > /dev/null
done
-
-export PATH="$path"
-
-# cumin test instance
-export CUMIN_HOME="${DEVEL_HOME}/cumin-test-0"
-export WOOLY_DEMO_HOME="${DEVEL_HOME}/wooly/wooly-demo-instance"
Added: mgmt/trunk/etc/module.profile
===================================================================
--- mgmt/trunk/etc/module.profile (rev 0)
+++ mgmt/trunk/etc/module.profile 2009-04-01 19:21:13 UTC (rev 3248)
@@ -0,0 +1,2 @@
+export PYTHONPATH="${PWD}/python:${PYTHONPATH}"
+export PATH="${PWD}/bin:${PATH}"
Added: mgmt/trunk/mint/etc/module.profile
===================================================================
--- mgmt/trunk/mint/etc/module.profile (rev 0)
+++ mgmt/trunk/mint/etc/module.profile 2009-04-01 19:21:13 UTC (rev 3248)
@@ -0,0 +1,3 @@
+export PYTHONPATH="${PWD}/python:${PYTHONPATH}"
+export PATH="${PWD}/bin:${PATH}"
+export MINT_HOME="${PWD}/instance"
Added: mgmt/trunk/mint/instance/etc/mint.conf
===================================================================
--- mgmt/trunk/mint/instance/etc/mint.conf (rev 0)
+++ mgmt/trunk/mint/instance/etc/mint.conf 2009-04-01 19:21:13 UTC (rev 3248)
@@ -0,0 +1,3 @@
+[main]
+data: postgresql://cumin@localhost/cumin
+debug: True
Modified: mgmt/trunk/mint/python/mint/__init__.py
===================================================================
--- mgmt/trunk/mint/python/mint/__init__.py 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/mint/python/mint/__init__.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -3,21 +3,25 @@
import pickle
import struct
import sys
+import os
import types
import socket
+
+from parsley.config import Config, ConfigParameter
+from psycopg2 import OperationalError
+from qmf.console import ClassKey
+from qpid.datatypes import UUID
+from qpid.util import URL
+from sqlobject import *
from threading import Lock, RLock
-from sqlobject import *
+from time import sleep
from traceback import print_exc
-from qpid.util import URL
-from qpid.datatypes import UUID
-from mint.schema import *
+
from mint import update
from mint.cache import MintCache
from mint.dbexpire import DBExpireThread
-from qmf.console import ClassKey
+from mint.schema import *
from util import *
-from time import sleep
-from psycopg2 import OperationalError
log = logging.getLogger("mint")
@@ -320,13 +324,18 @@
class MintModel(qmf.console.Console):
staticInstance = None
- def __init__(self, dataUri, dbExpireFrequency, dbExpireThreshold, debug=False):
+ def __init__(self, dataUri, debug=False):
self.dataUri = dataUri
self.debug = debug
+
self.updateObjects = True
+
self.pollRegistrations = True
- self.dbExpiration = True
+ self.expireObjects = True
+ self.expireFrequency = 600
+ self.expireThreshold = 24 * 3600
+
assert MintModel.staticInstance is None
MintModel.staticInstance = self
@@ -348,8 +357,7 @@
self.qmfSession = None
self.updateThread = update.ModelUpdateThread(self)
- self.dbExpireThread = dbexpire.DBExpireThread \
- (self, frequency=dbExpireFrequency, threshold=dbExpireThreshold)
+ self.expireThread = dbexpire.DBExpireThread(self)
self.registrationThread = RegistrationThread(self)
self.outstandingMethodCalls = dict()
@@ -376,7 +384,7 @@
self.pollRegistrations and "enabled" or "disabled")
log.info("Object expiration is %s",
- self.dbExpiration and "enabled" or "disabled")
+ self.expireObjects and "enabled" or "disabled")
sqlhub.processConnection = self.dbConn = connectionForURI(self.dataUri)
@@ -386,12 +394,13 @@
(self, manageConnections=True, rcvObjects=self.updateObjects)
self.updateThread.init()
+ self.expireThread.init()
def start(self):
self.updateThread.start()
- if self.dbExpiration:
- self.dbExpireThread.start()
+ if self.expireObjects:
+ self.expireThread.start()
if self.pollRegistrations:
self.registrationThread.start()
@@ -399,8 +408,8 @@
def stop(self):
self.updateThread.stop()
- if self.dbExpiration:
- self.dbExpireThread.stop()
+ if self.expireObjects:
+ self.expireThread.stop()
if self.pollRegistrations:
self.registrationThread.stop()
Modified: mgmt/trunk/mint/python/mint/dbexpire.py
===================================================================
--- mgmt/trunk/mint/python/mint/dbexpire.py 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/mint/python/mint/dbexpire.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -9,33 +9,38 @@
log = logging.getLogger("mint.dbexpire")
class DBExpireThread(MintDaemonThread):
- def __init__(self, model, frequency, threshold, keepCurrStats=False):
+ def __init__(self, model):
super(DBExpireThread, self).__init__(model)
- self.frequency = frequency
- self.threshold = threshold
- self.keepCurrStats = keepCurrStats
+ self.keepCurrStats = False
self.ops = []
+ self.attrs = dict()
+
+ def init(self):
+ frequency = self.model.expireFrequency
+ threshold = self.model.expireThreshold
+
for cls in mint.schema.statsClasses:
self.ops.append(SqlExpire(eval(cls), self.keepCurrStats))
self.ops.append(SqlExpire(Job, self.keepCurrStats))
- self.attrs = dict()
- self.attrs["threshold"] = self.threshold
-
+ self.attrs["threshold"] = threshold
+
frequency_out, frequency_unit = self.__convertTimeUnits(frequency)
threshold_out, threshold_unit = self.__convertTimeUnits(threshold)
- log.debug("Expiring database records older than %d %s, every %d %s" \
- % (threshold_out, threshold_unit, frequency_out, frequency_unit))
+ log.debug("Expiring database records older than %d %s, every %d %s" % \
+ (threshold_out, threshold_unit, frequency_out, frequency_unit))
def run(self):
+ frequency = self.model.expireFrequency
+
while True:
if self.stopRequested:
break
up = mint.update.DBExpireUpdate(self.model)
self.model.updateThread.enqueue(up)
- time.sleep(self.frequency)
+ time.sleep(frequency)
def __convertTimeUnits(self, t):
if t / (24*3600) >= 1:
Added: mgmt/trunk/mint/python/mint/main.py
===================================================================
--- mgmt/trunk/mint/python/mint/main.py (rev 0)
+++ mgmt/trunk/mint/python/mint/main.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -0,0 +1,63 @@
+import sys
+import os
+from parsley.config import Config, ConfigParameter
+from parsley.loggingex import enable_logging
+
+from mint import MintModel
+
+class Mint(object):
+ def __init__(self, config):
+ self.config = config
+
+ self.model = MintModel(self.config.data)
+ self.model.expireFrequency = self.config.expire_frequency
+ self.model.expireThreshold = self.config.expire_threshold
+
+ def check(self):
+ self.model.check()
+
+ def init(self):
+ self.model.init()
+
+ def start(self):
+ self.model.start()
+
+ def stop(self):
+ self.model.stop()
+
+class MintConfig(Config):
+ def __init__(self):
+ super(MintConfig, self).__init__()
+
+ hdef = os.path.normpath("/var/lib/mint")
+ self.home = os.environ.get("MINT_HOME", hdef)
+
+ param = ConfigParameter(self, "data", str)
+ param.default = "postgresql://mint@localhost/mint"
+
+ param = ConfigParameter(self, "log-file", str)
+ param.default = os.path.join(self.home, "log", "mint.log")
+
+ param = ConfigParameter(self, "log-level", str)
+ param.default = "warn"
+
+ param = ConfigParameter(self, "debug", bool)
+ param.default = False
+
+ param = ConfigParameter(self, "expire-frequency", int)
+ param.default = 600 # 10 minutes
+
+ param = ConfigParameter(self, "expire-threshold", int)
+ param.default = 24 * 3600 # 1 day
+
+ def init(self, opts):
+ super(MintConfig, self).init()
+
+ self.load_file(os.path.join(self.home, "etc", "mint.conf"))
+ self.load_file(os.path.join(os.path.expanduser("~"), ".mint.conf"))
+ self.load_dict(opts)
+
+ if self.debug:
+ enable_logging("mint", "debug", sys.stderr)
+ else:
+ enable_logging("mint", self.log_level, self.log_file)
Modified: mgmt/trunk/mint/python/mint/tools.py
===================================================================
--- mgmt/trunk/mint/python/mint/tools.py 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/mint/python/mint/tools.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -6,11 +6,15 @@
from parsley.loggingex import *
from mint import *
+from mint.main import *
+from util import *
class BaseMintTool(Command):
def __init__(self, name):
super(BaseMintTool, self).__init__(None, name)
+ self.config = MintConfig()
+
opt = CommandOption(self, "data")
opt.argument = "URI"
opt.description = "Connect to database at URI"
@@ -43,8 +47,6 @@
def init(self):
super(BaseMintTool, self).init()
- #self.config.init()
-
try:
import psyco
psyco.full()
@@ -63,25 +65,11 @@
self.print_help()
sys.exit(0)
- level = opts.get("log-level", "warn")
+ self.config.init(opts)
- if "debug" in opts:
- level = "debug"
- file = sys.stderr
- else:
- file = opts.get("log-file", sys.stderr)
+ self.do_run(opts, args)
- enable_logging("mint", level, file)
-
- data = opts.get("data", "postgresql://cumin@localhost/cumin")
- freq = int(opts.get("expire-frequency", 600))
- threshold = int(opts.get("expire-threshold", 24 * 3600))
-
- model = MintModel(data, freq, threshold, debug="debug" in opts)
-
- self.do_run(opts, args, model)
-
- def do_run(self, opts, args, model):
+ def do_run(self, opts, args):
raise Exception("Not implemented")
def main(self):
@@ -99,44 +87,47 @@
# get better thread switching performance
sys.setcheckinterval(200)
- def do_run(self, opts, args, model):
- model.check()
- model.init()
- model.start()
+ def do_run(self, opts, args):
+ app = Mint(self.config)
+ app.check()
+ app.init()
+ app.start()
try:
for arg in args[1:]:
- model.addBroker(arg)
+ app.model.addBroker(arg)
while True:
sleep(2)
finally:
- model.stop()
+ app.stop()
class MintTestTool(BaseMintTool):
def __init__(self, name):
super(MintTestTool, self).__init__(name)
- def do_run(self, opts, args, model):
- model.pollRegistrations = False
+ def do_run(self, opts, args):
+ app = Mint(self.config)
- model.check()
- model.init()
- model.start()
+ app.model.pollRegistrations = False
+ app.check()
+ app.init()
+ app.start()
+
added = list()
try:
for arg in args[1:]:
- added.append(model.addBroker(arg))
+ added.append(app.model.addBroker(arg))
while True:
sleep(2)
finally:
for broker in added:
- model.delBroker(broker)
+ app.model.delBroker(broker)
- model.stop()
+ app.stop()
class MintBenchTool(BaseMintTool):
def __init__(self, name):
@@ -148,93 +139,98 @@
# get better thread switching performance
sys.setcheckinterval(200)
- def do_run(self, opts, args, model):
- model.pollRegistrations = False
+ def do_run(self, opts, args):
+ app = Mint(self.config)
- model.check()
- model.init()
- model.start()
+ app.model.pollRegistrations = False
+ app.check()
+ app.init()
+ app.start()
+
added = list()
+ head = "%6s %6s %6s %6s %6s %6s %6s %6s %6s" % \
+ ("enqs", "deqs", "depth", "drop", "defer",
+ "prop", "stat", "meth", "exp")
+ row = "%6i %6i %6i %6i %6i %6i %6i %6i %6i"
+
try:
for arg in args[1:]:
- added.append(model.addBroker(arg))
+ try:
+ added.append(app.model.addBroker(arg))
+ except socket.error, e:
+ print "Warning: Failed connecting to broker at '%s'" % arg
- enq_last = 0
- deq_last = 0
- drp_last = 0
- dfr_last = 0
- prop_last = 0
- stat_last = 0
- meth_last = 0
- exp_last = 0
+ try:
+ enq_last = 0
+ deq_last = 0
+ drp_last = 0
+ dfr_last = 0
+ prop_last = 0
+ stat_last = 0
+ meth_last = 0
+ exp_last = 0
- head = "%6s %6s %6s %6s %6s %6s %6s %6s %6s" % \
- ("enqs", "deqs", "depth", "drop", "defer",
- "prop", "stat", "meth", "exp")
- row = "%6i %6i %6i %6i %6i %6i %6i %6i %6i"
+ samples = 0
- samples = 0
+ while True:
+ if samples % 24 == 0:
+ print head
- while True:
- if samples % 24 == 0:
- print head
+ samples += 1
- samples += 1
+ sleep(1)
- sleep(1)
+ ut = app.model.updateThread
- ut = model.updateThread
+ enq = ut.enqueueCount
+ deq = ut.dequeueCount
+ drp = ut.dropCount
+ dfr = ut.deferCount
- enq = ut.enqueueCount
- deq = ut.dequeueCount
- drp = ut.dropCount
- dfr = ut.deferCount
+ prop = ut.propUpdateCount
+ stat = ut.statUpdateCount
+ meth = ut.methUpdateCount
+ exp = ut.expireUpdateCount
- prop = ut.propUpdateCount
- stat = ut.statUpdateCount
- meth = ut.methUpdateCount
- exp = ut.expireUpdateCount
+ print row % (enq - enq_last,
+ deq - deq_last,
+ enq - deq,
+ drp - drp_last,
+ dfr - dfr_last,
+ prop - prop_last,
+ stat - stat_last,
+ meth - meth_last,
+ exp - exp_last)
- print row % (enq - enq_last,
- deq - deq_last,
- enq - deq,
- drp - drp_last,
- dfr - dfr_last,
- prop - prop_last,
- stat - stat_last,
- meth - meth_last,
- exp - exp_last)
+ enq_last = enq
+ deq_last = deq
+ drp_last = drp
+ dfr_last = dfr
- enq_last = enq
- deq_last = deq
- drp_last = drp
- dfr_last = dfr
+ prop_last = prop
+ stat_last = stat
+ meth_last = meth
+ exp_last = exp
+ finally:
+ print "Totals:"
- prop_last = prop
- stat_last = stat
- meth_last = meth
- exp_last = exp
+ print row % (enq,
+ deq,
+ enq - deq,
+ drp,
+ dfr,
+ prop,
+ stat,
+ meth,
+ exp)
finally:
-
- print "Totals:"
-
- print row % (enq,
- deq,
- enq - deq,
- drp,
- dfr,
- prop,
- stat,
- meth,
- exp)
-
#from threading import enumerate
#for item in enumerate():
# print item
for broker in added:
- model.delBroker(broker)
+ app.model.delBroker(broker)
- model.stop()
+ app.stop()
Modified: mgmt/trunk/mint/python/mint/update.py
===================================================================
--- mgmt/trunk/mint/python/mint/update.py 2009-04-01 19:08:41 UTC (rev 3247)
+++ mgmt/trunk/mint/python/mint/update.py 2009-04-01 19:21:13 UTC (rev 3248)
@@ -214,7 +214,7 @@
self.processTimestamp("qmfUpdateTime", timestamps[0], attrs)
- if cls is Job and attrs["qmfUpdateTime"] < datetime.now() - timedelta(seconds=thread.model.dbExpireThread.threshold):
+ if cls is Job and attrs["qmfUpdateTime"] < datetime.now() - timedelta(seconds=thread.model.expireThread.threshold):
# drop updates for Jobs that are older then the expiration threshold,
# since they would be deleted anyway in the next run of the db expiration thread
log.debug("Property update is older than expiration threshold; skipping it")
@@ -390,12 +390,12 @@
def process(self, thread):
cursor = thread.cursor()
- attrs = self.model.dbExpireThread.attrs
+ attrs = self.model.expireThread.attrs
total = 0
thread.commit()
- for op in self.model.dbExpireThread.ops:
+ for op in self.model.expireThread.ops:
log.debug("Running expire op %s", op)
count = op.execute(cursor, attrs)
Added: mgmt/trunk/wooly/etc/module.profile
===================================================================
--- mgmt/trunk/wooly/etc/module.profile (rev 0)
+++ mgmt/trunk/wooly/etc/module.profile 2009-04-01 19:21:13 UTC (rev 3248)
@@ -0,0 +1,3 @@
+export PYTHONPATH="${PWD}/python:${PYTHONPATH}"
+export PATH="${PWD}/bin:${PATH}"
+export WOOLY_DEMO_HOME="${PWD}/instance"
Copied: mgmt/trunk/wooly/instance (from rev 3246, mgmt/trunk/wooly/wooly-demo-instance)
Property changes on: mgmt/trunk/wooly/instance
___________________________________________________________________
Name: svn:mergeinfo
+
More information about the rhmessaging-commits
mailing list