2011-04-01 23:34:33 -07:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
import sys
|
2011-05-24 12:45:08 -07:00
|
|
|
import time
|
2011-04-01 23:34:33 -07:00
|
|
|
import interp.bootstrap
|
|
|
|
from interp.cluster import QueueManager, get_qs
|
|
|
|
|
|
|
|
m = QueueManager(address=('localhost', 6666), authkey='asdf')
|
|
|
|
m.connect()
|
|
|
|
|
|
|
|
tq,rq,mq,sq = get_qs(m)
|
|
|
|
|
|
|
|
if len(sys.argv) == 1:
|
|
|
|
sys.argv.append("st")
|
|
|
|
|
|
|
|
|
|
|
|
if sys.argv[1].startswith("st"):
|
|
|
|
print "interp queue status:"
|
|
|
|
print " tasksq : %d" % tq.qsize()
|
|
|
|
print " resultsq : %d" % rq.qsize()
|
|
|
|
print " masterq : %d" % mq.qsize()
|
2011-05-08 12:36:06 -07:00
|
|
|
print " minionsq : %d" % sq.qsize()
|
2011-04-01 23:34:33 -07:00
|
|
|
|
2011-05-24 12:45:08 -07:00
|
|
|
if sys.argv[1].startswith("wa"):
|
|
|
|
if len(sys.argv) == 3:
|
|
|
|
sleeptime = float(sys.argv[2])
|
|
|
|
else:
|
|
|
|
sleeptime = 1
|
|
|
|
|
|
|
|
i = 0
|
|
|
|
while True:
|
|
|
|
time.sleep(sleeptime)
|
|
|
|
if i % 20 == 0:
|
|
|
|
print "tasksq resultsq masterq minionsq"
|
|
|
|
print "%d %d %d %d" % \
|
|
|
|
(tq.qsize(),
|
|
|
|
rq.qsize(),
|
|
|
|
mq.qsize(),
|
|
|
|
sq.qsize(),)
|
|
|
|
i += 1
|
|
|
|
|
2011-04-02 00:40:23 -07:00
|
|
|
if sys.argv[1] == 'add':
|
|
|
|
for i in xrange(int(sys.argv[2])):
|
|
|
|
mq.put('jane')
|
|
|
|
|
2011-04-02 00:20:59 -07:00
|
|
|
if sys.argv[1] == 'slay':
|
2011-04-02 00:32:39 -07:00
|
|
|
if len(sys.argv) == 2:
|
|
|
|
for i in xrange(mq.qsize()):
|
|
|
|
print i, "killing", mq.get()
|
|
|
|
sq.put("slay")
|
|
|
|
elif len(sys.argv) == 3:
|
|
|
|
for i in xrange(int(sys.argv[2])):
|
2011-05-24 12:45:08 -07:00
|
|
|
print i, "killing", mq.get()
|
2011-04-02 00:32:39 -07:00
|
|
|
sq.put("slay")
|
|
|
|
|
2011-04-01 23:34:33 -07:00
|
|
|
|
|
|
|
if sys.argv[1] == 'clear':
|
|
|
|
for i in xrange(tq.qsize()): print tq.get()
|
|
|
|
for i in xrange(rq.qsize()): print rq.get()
|
|
|
|
for i in xrange(mq.qsize()): print mq.get()
|
|
|
|
for i in xrange(sq.qsize()): print sq.get()
|