Esempio n. 1
0
    def ClaimMessages(self):
        qname = ainput("Queue Name: ").getString()
        num_messages = ainput("Number of Messages: ").getInteger()

        queue = QUEUE()
        response, content = queue.ClaimMessages(qname, str(num_messages))
        print response
        print content

        return
Esempio n. 2
0
    def DeleteMessage(self):
        qname = ainput("Queue Name: ").getString()
        message_id = ainput("Message Id: ").getString()

        queue = QUEUE()
        response, content = queue.DeleteMessage(qname, message_id)
        print response
        print content

        return
Esempio n. 3
0
    def PostMessage(self):
        qname = ainput("Queue Name: ").getString()
        ttl = ainput("TTL: ").getInteger()
        body = ainput("Body: ").getString()

        queue = QUEUE()
        response, content = queue.PostMessage(qname, ttl, body)
        print response
        print content

        return
Esempio n. 4
0
def main():

    # keep track of the threads
    reader_threads = []
    writer_threads = []

    # get user input
    num_readers = ainput("Enter the number of readers: ").getInteger()
    num_writers = ainput("Enter the number of writers: ").getInteger()
    num_queues = ainput("Enter the number queues: ").getInteger()

    # create the queues
    create_queues(num_queues)

    # create the readers
    for x in range(num_readers):
        r = Reader(x, num_queues)
        reader_threads.append(r)
        r.daemon = True
        r.start()

    # create the writers
    for x in range(num_writers):
        w = Writer(x, num_queues)
        writer_threads.append(w)
        w.daemon = True
        w.start()

    # start the stats thread
    s = StatUpdater()
    s.daemon = True
    s.start()
    while True:
        try:
            # sleep a little to give other threads cpu
            # keyboard interrput will still break this
            time.sleep(100)
        except KeyboardInterrupt:
            print "Caught interrupt, terminating threads..."
            for t in reader_threads:
                print "Killing reader"
                t.kill_received = True
            for t in writer_threads:
                print "Killing writer"
                t.kill_received = True
            print "Killing Updater"
            s.kill_received = True
            time.sleep(15)
            break
    return
Esempio n. 5
0
    def GetMessages(self):
        qname = ainput("Queue Name: ").getString()

        queue = QUEUE()
        response, content = queue.GetMessages(qname)
        print response
        print content

        return
Esempio n. 6
0
    def DeleteQueue(self):
        name = ainput("Queue Name: ").getString()

        queue = QUEUE()
        response, content = queue.DeleteQueue(name)
        print response
        print content

        return
Esempio n. 7
0
    def GetQueueStats(self):
        name = ainput("Queue Name: ").getString()

        queue = QUEUE()
        stats = queue.GetQueueStats(name)
        labels = ('Queue', 'Free', 'Claimed')
        rows = []

        rows.append((name, str(stats['messages']['free']), str(stats['messages']['claimed'])))
        
        to = TableOutput()
        print to.indent([labels] + rows, hasHeader=True, separateRows=True, prefix='| ', postfix=' |')
    
        return
Esempio n. 8
0
def show_main_menu():
    print "\nRackspace Queuing\n"
    qcli = CloudQueueCLI()        
    
    print "\nChoose from an option below:\n\
        1. List Queues\n\
        2. Create Queue\n\
        3. Delete Queue\n\
        4. Post Message\n\
        5. Get Messages\n\
        6. Delete Message\n\
        7. Get Queue Stats\n\
        8. Claim Messages\n\
        9. Exit\n"

    option = ainput("Select a number from the menu above: ").getString()
    arguments = []
    
    if option == '1':
        qcli.ListQueues()
    elif option == '2':
        qcli.CreateQueue()
    elif option == '3':
        qcli.DeleteQueue()
    elif option == '4':
        qcli.PostMessage()
    elif option == '5':
        qcli.GetMessages()
    elif option == '6':
        qcli.DeleteMessage()
    elif option == '7':
        qcli.GetQueueStats()
    elif option == '8':
        qcli.ClaimMessages()
    elif option == '9':
        print "\n"
        exit()
                    
    return