Exemple #1
0
def main():
    print 'defining a launch plan'
    t = Troop(clobber=True)
    t.configure('resources/three-containers.trp')
    t.create_launch_plan()
    print 'created a launch plan with %d containers' % t.get_container_count()
    print 'now starting nodes\n\n-----------------------------------------------'

    try:
        t.start_nodes()

        broker_config = t.get_nodes_broker()
#        broker_config = { 'broker_hostname': 'ec2-50-17-108-226.compute-1.amazonaws.com',
#                                    'broker_username': '******',
#                                    'broker_password': '******' }
        m = SimpleManager(**broker_config)

        l = InventoryListener()
        m.add_listener(l)

        while True:
        # get inventory -- see what agents we have running
            m.send_request(InventoryRequest())
            print '-----------------------------------------------\n\nrequested inventory -- waiting for reply messages'
            sleep(5)

            print 'inventory after nodes have started: '
            show_inventory(l.inventory)
            wait(5)

    finally:
        print 'now stopping nodes'
Exemple #2
0
def main():
    t = Troop(clobber=True)
    t.configure(TROOP_CONFIGURATION_FILE)
    print 'have troop: ' + repr(t)
    print '# services: %d' % len(t.services)
    print '# node types: %d' % len(t.node_types)
    print '--------------------------'
    for node_type in t.node_types:
        print 'type: %s\n' % str(node_type)
    print '--------------------------'

    print '\n\n\ncreating launch plan'
    t.create_launch_plan()

    agent_name = t.configuration['agent-service']['name']
    print 'agent service name: %s' % agent_name
    print 'agent service: %s' % repr(t.service_by_name[agent_name])

    print 'starting troop'
    t.start_nodes()
    print 'stopping troop'
    t.stop_nodes()
Exemple #3
0
def main():
    print 'defining a launch plan'
    t = Troop(clobber=True)
    t.configure('resources/one-container-ec2.trp')
    t.create_launch_plan()
    print 'created a launch plan with %d containers' % t.get_container_count()

    # start cloudinitd launch
    print '''NOTICE: an EC2 launch takes about 20min to start the first pycc instance
If interrupted, make sure to stop EC2 instances with the command: cloudinitd terminate %s

now starting launch: %s
-----------------------------------------------''' % (t.launch_name, strftime('%l:%M'))

    try:
        t.start_nodes()
        print '-----------------------------------------------\n\completed launch: %s' % strftime('%l:%M')

        # get manager configured to use rabbitMQ started by launch plan
        m = t.get_manager()

        l = InventoryListener()
        m.add_listener(l)

        keep_waiting = True
        while keep_waiting:
            # shouldn't need to keep requesting each time,
            # but first request could be lost if agent had not yet connected to rabbitmq
            m.send_request(InventoryRequest())
            sleep(5)
            if l.inventory:
                show_inventory(l.inventory)
                keep_waiting = False
            else:
                sleep(10)

    finally:
        print 'now stopping nodes'
        try:
            m.close()
        except:
            print 'failed to close manager connection'
        t.stop_nodes()
Exemple #4
0
def main():


#log.setLevel(DEBUG)
    t = Troop(clobber=True)
    t.configure('resources/one-container-ec2.trp')
    t.set_name('load-test')
    print 'before:\nconfig: %s\ntypes: %s' % (repr(t.configuration), repr(t.node_types))
    t.change_count('container-with-services', AGENT_CONTAINERS)
    print 'after:\nconfig: %s\ntypes: %s' % (repr(t.configuration), repr(t.node_types))
    t.create_launch_plan()

    m = None
    try:
        log.info('now starting nodes\n\n-----------------------------------------------') # bracket STDOUT of cloudinitd
        t.start_nodes()
        log.info('\n-----------------------------------------------\n\n')

        i_listener = InventoryListener()
        p_listener = PerformanceListener()
        m = t.get_manager()
        m.add_listener(i_listener)
        m.add_listener(p_listener)

        # TODO: troop should start agent with configuration setting for name of container type,
        #       so here we call can target only the non-service containers:
        # m.send_request(InventoryRequest(), agent_filter=container_type('container-without-services'))
        #       without this ability, we run producer/consumer on container with services which has other overhead
        log.info('requested inventory -- waiting for reply messages')
        max_wait=9999999999 #sec
        for n in xrange(max_wait/30):
            m.send_request(InventoryRequest(), component_filter=component_id('AGENT'))
            sleep(30)
            reply_count = len(i_listener.inventory)
            log.info('requested %d containers, have replies from %d containers' % (AGENT_CONTAINERS, reply_count))
            if AGENT_CONTAINERS<reply_count:
                log.warn('have more containers than requested?')
                break
            elif AGENT_CONTAINERS==reply_count:
                break
        log.debug('found %d containers', len(i_listener.inventory))
        if len(i_listener.inventory)<AGENT_CONTAINERS:
            raise ApeException('failed to start requested number of containers')

        # determine reasonable rate for nodes
        any_agent = i_listener.inventory.keys()[0]
        max_node_rate = find_node_max(m, p_listener, any_agent, 1000)
        log.debug('max rate %.2e', max_node_rate)

        if not max_node_rate:
            raise ApeException('failed to get max rate from first VM')
        target_node_rate = max_node_rate * TARGET_RATE_PORTION_OF_MAX
        log.debug('max rate for one node is %.2f msgs/sec, target rate is %.2f msgs/sec', max_node_rate, target_node_rate)

        # create producers/consumers on remaining agents
        index=2
        max_broker_rate = max_node_rate
        max_index=1
        for agent in i_listener.inventory.keys()[1:]:
            add_node_traffic(m, p_listener, agent, target_node_rate, 'agent%d'%index)

            # make sure have fresh measurement from each node
            # b/c node that was going faster may have slowed down
            # now that latest node has pushed broker to saturation
            sleep(10)
            p_listener.clear()
            for n in xrange(60/5):
                if len(p_listener.latest_data)>=index:
                    break
                sleep(5)
            measured_broker_rate = p_listener.get_rate()
            log.debug('broker passing %.2e msgs/sec with %d producers', measured_broker_rate, index)
            if measured_broker_rate>max_broker_rate:
                max_broker_rate = measured_broker_rate
                max_index = index
            index+=1
        log.info('max rate was %.2e msgs/sec with %d producers', max_broker_rate, max_index)

    finally:
        log.info('now stopping nodes')
        if m:
            m.send_request(StopRequest(), component_filter=component_type(InstrumentSimulator))
            m.send_request(StopRequest(), component_filter=component_type(DataProductConsumer))
            m.close()