[rhmessaging-commits] rhmessaging commits: r3671 - in mgmt/trunk: cumin/python/cumin and 1 other directory.
rhmessaging-commits at lists.jboss.org
rhmessaging-commits at lists.jboss.org
Fri Oct 16 12:56:18 EDT 2009
Author: justi9
Date: 2009-10-16 12:56:17 -0400 (Fri, 16 Oct 2009)
New Revision: 3671
Removed:
mgmt/trunk/bin/quirk
mgmt/trunk/cumin/python/cumin/quirk.py
Log:
Remove some unused code
Deleted: mgmt/trunk/bin/quirk
===================================================================
--- mgmt/trunk/bin/quirk 2009-10-09 16:32:27 UTC (rev 3670)
+++ mgmt/trunk/bin/quirk 2009-10-16 16:56:17 UTC (rev 3671)
@@ -1,140 +0,0 @@
-#!/usr/bin/env python
-
-import sys, qpid
-from time import sleep
-from random import random, sample, randint
-
-from cumin.quirk import *
-
-class TestCommand(object):
- def __init__(self, name):
- self.name = name
-
- def run(self, client):
- session = Session(client)
- session.open()
-
- try:
- q = Queue("quirk.test")
-
- if not q.exists(session):
- q.declare(session)
-
- s = Subscription(q)
- s.init(session)
-
- for i in range(0, 10):
- print i,
- m = Message("message %i" % i)
- m.send(session, q)
- print "Sent", m
-
- for i in range(0, 10):
- print i,
- m = s.get(session)
- print "Received", m
- finally:
- session.close()
-
-class BenchCommand(object):
- def __init__(self, name):
- self.name = name
-
- def run(self, client):
- session = Session(client)
- session.open()
-
- try:
- q = Queue("quirk.bench")
-
- if not q.exists(session):
- q.declare(session)
-
- s = Subscription(q)
-
- i = 0
-
- while True:
- m = Message(str(i))
- m.send(session, q)
-
- if i % 1000 == 0:
- print ".",
-
- i += 1
- finally:
- session.close()
-
-class DemoCommand(object):
- def __init__(self, name):
- self.name = name
-
- def run(self, client):
- session = Session(client)
- session.open()
-
- qs = list()
- es = list()
-
- try:
- for i in range(0, 30):
- name = "demo%02i" % (i + 1)
-
- q = Queue(name)
- q.declare(session)
-
- qs.append(q)
-
- e = Exchange(name)
- e.declare(session)
-
- es.append(e)
-
- while True:
- sqs = sample(qs, 5)
-
- for q in sqs:
- m = Message("test")
- m.send(session, q)
-
- sleep(1)
-
- finally:
- session.close()
-
-def usage():
- print "Usage: quirk COMMAND [IP:PORT]"
- sys.exit(2)
-
-commands = dict()
-commands["test"] = TestCommand("test")
-commands["bench"] = BenchCommand("bench")
-commands["demo"] = DemoCommand("demo")
-
-if __name__ == "__main__":
- if len(sys.argv) < 2:
- usage();
-
- command = sys.argv[1]
-
- if command not in commands:
- print "Unknown command '%s'" % command
- usage()
-
- try:
- addr = sys.argv[2].split(":")
-
- if len(addr) > 1:
- host, port = addr[0], int(addr[1])
- else:
- host, port = addr[0], 5672
- except IndexError:
- host, port = "localhost", 5672
-
- client = Client(host, port)
- client.login("guest", "guest")
-
- try:
- commands[command].run(client)
- except KeyboardInterrupt:
- pass
Deleted: mgmt/trunk/cumin/python/cumin/quirk.py
===================================================================
--- mgmt/trunk/cumin/python/cumin/quirk.py 2009-10-09 16:32:27 UTC (rev 3670)
+++ mgmt/trunk/cumin/python/cumin/quirk.py 2009-10-16 16:56:17 UTC (rev 3671)
@@ -1,116 +0,0 @@
-import sys, qpid
-from time import sleep
-from random import random, sample, randint
-
-class Exchange(object):
- def __init__(self, name, type="direct"):
- self.name = name
- self.type = type
-
- def declare(self, session):
- session.psession.exchange_declare(exchange=self.name, type=self.type)
-
- def exists(self, session):
- return False #XXX figure out how to do this
-
-class Queue(object):
- def __init__(self, name):
- self.name = name
-
- def declare(self, session):
- session.psession.queue_declare(queue=self.name)
-
- def exists(self, session):
- return False #XXX figure out how to do this
-
- def bind(self, session, exchange, key=None):
- if key is None:
- key = self.name
-
- session.psession.queue_bind(exchange=exchange.name,
- queue=self.name,
- routing_key=key)
-
-class Subscription(object):
- def __init__(self, queue):
- self.name = queue.name # XXX bad?
- self.queue = queue
- self.client_queue = None
-
- def init(self, session):
- session.psession.message_subscribe(queue=self.queue.name,
- destination=self.name)
-
- session.psession.message_flow(self.name, 0, 0xFFFFFFFF)
- session.psession.message_flow(self.name, 1, 0xFFFFFFFF)
-
- self.client_queue = session.client.pconn.queue(self.name)
-
- def get(self, session):
- if self.client_queue is None:
- raise Exception()
-
- m = Message()
- m.content = self.client_queue.get(timeout=10).content
-
- return m
-
-class Message(object):
- def __init__(self, payload=None):
- self.content = qpid.content.Content()
- self.content["content_type"] = "text/plain"
-
- if payload is not None:
- self.set_payload(payload)
-
- def set_payload(self, payload):
- self.content.body = payload
-
- def send(self, session, dest, key=None):
- if dest.__class__ is Queue:
- self.content["routing_key"] = dest.name
- session.psession.message_transfer(destination="",
- content=self.content)
- elif dest.__class__ is Exchange:
- if routing_key is None:
- raise Exception("Routing key not set")
-
- session.psession.message_transfer(destination=dest.name,
- content=self.content)
- else:
- raise Exception("Unknown destination object")
-
- def __str__(self):
- return self.content.body
-
-class Connection(object):
- def __init__(self, host, port, spec_path):
- self.host = host
- self.port = port
- self.spec = qpid.spec.load(spec_path)
-
- self.pconn = None
-
- def open(self):
- assert self.pconn is None
-
- sock = qpid.util.connect(self.host, self.port)
- self.pconn = qpid.connection.Connection(sock, self.spec)
- self.pconn.start()
-
- def close(self):
- assert self.pconn
-
- self.pconn.close()
-
-class Session(object):
- def __init__(self, conn, name):
- self.conn = conn
- self.name = name
- self.psession = conn.pconn.session(name)
-
- def open(self):
- pass
-
- def close(self):
- self.psession.close()
More information about the rhmessaging-commits
mailing list