made iqmanager more complicated and better
This commit is contained in:
parent
c08504a089
commit
a1527b25c8
60
bin/iqmgr.py
60
bin/iqmgr.py
@ -4,26 +4,41 @@ import sys
|
|||||||
import time
|
import time
|
||||||
import interp.bootstrap
|
import interp.bootstrap
|
||||||
from interp.cluster import QueueManager, get_qs
|
from interp.cluster import QueueManager, get_qs
|
||||||
|
from optparse import OptionParser
|
||||||
|
|
||||||
m = QueueManager(address=('localhost', 6666), authkey='asdf')
|
if __name__ == '__main__':
|
||||||
|
parser = OptionParser(usage = "usage: %s [options] <status|watch|add|fresult #|slay|clear|clearall|clearresults>")
|
||||||
|
|
||||||
|
parser.add_option('-p', '--port',
|
||||||
|
type="int", dest="port", default=6666,
|
||||||
|
help="specify the port to use on the server (default: %default)")
|
||||||
|
|
||||||
|
parser.add_option('-a', '--auth-key',
|
||||||
|
type="str", dest="authkey", default='asdf',
|
||||||
|
help="authkey (default: %default)")
|
||||||
|
|
||||||
|
(options, args) = parser.parse_args()
|
||||||
|
|
||||||
|
if len(args) == 0:
|
||||||
|
cmd = 'status'
|
||||||
|
else:
|
||||||
|
cmd = args[0]
|
||||||
|
|
||||||
|
m = QueueManager(address=('', options.port), authkey=options.authkey)
|
||||||
m.connect()
|
m.connect()
|
||||||
|
|
||||||
tq,rq,mq,sq = get_qs(m)
|
tq,rq,mq,sq = get_qs(m)
|
||||||
|
|
||||||
if len(sys.argv) == 1:
|
if cmd.startswith("st"):
|
||||||
sys.argv.append("st")
|
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[1].startswith("st"):
|
|
||||||
print "interp queue status:"
|
print "interp queue status:"
|
||||||
print " tasksq : %d" % tq.qsize()
|
print " tasksq : %d" % tq.qsize()
|
||||||
print " resultsq : %d" % rq.qsize()
|
print " resultsq : %d" % rq.qsize()
|
||||||
print " masterq : %d" % mq.qsize()
|
print " masterq : %d" % mq.qsize()
|
||||||
print " minionsq : %d" % sq.qsize()
|
print " minionsq : %d" % sq.qsize()
|
||||||
|
|
||||||
if sys.argv[1].startswith("wa"):
|
if cmd.startswith("wa"):
|
||||||
if len(sys.argv) == 3:
|
if len(args) == 2:
|
||||||
sleeptime = float(sys.argv[2])
|
sleeptime = float(args[1])
|
||||||
else:
|
else:
|
||||||
sleeptime = 1
|
sleeptime = 1
|
||||||
|
|
||||||
@ -39,23 +54,34 @@ if sys.argv[1].startswith("wa"):
|
|||||||
sq.qsize(),)
|
sq.qsize(),)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
if sys.argv[1] == 'add':
|
if cmd == 'add':
|
||||||
for i in xrange(int(sys.argv[2])):
|
for i in xrange(int(args[1])):
|
||||||
mq.put('jane')
|
mq.put('jane%d' % i)
|
||||||
|
|
||||||
if sys.argv[1] == 'slay':
|
if cmd == 'fresult':
|
||||||
if len(sys.argv) == 2:
|
for i in xrange(int(args[1])):
|
||||||
|
rq.put('fake.%d' % i)
|
||||||
|
|
||||||
|
if cmd == 'slay':
|
||||||
|
if len(args) == 1:
|
||||||
for i in xrange(mq.qsize()):
|
for i in xrange(mq.qsize()):
|
||||||
print i, "killing", mq.get()
|
print i, "killing", mq.get()
|
||||||
sq.put("slay")
|
sq.put("slay")
|
||||||
elif len(sys.argv) == 3:
|
elif len(args) == 2:
|
||||||
for i in xrange(int(sys.argv[2])):
|
for i in xrange(int(args[1])):
|
||||||
print i, "killing", mq.get()
|
print i, "killing", mq.get()
|
||||||
sq.put("slay")
|
sq.put("slay")
|
||||||
|
|
||||||
|
|
||||||
if sys.argv[1] == 'clear':
|
if cmd == 'clear':
|
||||||
|
for i in xrange(tq.qsize()): print tq.get()
|
||||||
|
for i in xrange(rq.qsize()): print rq.get()
|
||||||
|
|
||||||
|
if cmd == 'clearall':
|
||||||
for i in xrange(tq.qsize()): print tq.get()
|
for i in xrange(tq.qsize()): print tq.get()
|
||||||
for i in xrange(rq.qsize()): print rq.get()
|
for i in xrange(rq.qsize()): print rq.get()
|
||||||
for i in xrange(mq.qsize()): print mq.get()
|
for i in xrange(mq.qsize()): print mq.get()
|
||||||
for i in xrange(sq.qsize()): print sq.get()
|
for i in xrange(sq.qsize()): print sq.get()
|
||||||
|
|
||||||
|
if cmd == 'clearresults':
|
||||||
|
for i in xrange(rq.qsize()): print rq.get()
|
||||||
|
Loading…
Reference in New Issue
Block a user