Changeset - 649d482737e0
[Not reviewed]
default
0 2 0
Drew Perttula - 9 years ago 2016-06-13 17:36:38
drewp@bigasterisk.com
start of a collector --loadtest mode
Ignore-this: be1e42cfb4c30f2467e429da1b4a05e0
2 files changed with 29 insertions and 3 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -56,13 +56,13 @@ def startZmq(port, collector):
 
            # front and then use small ints to refer to devices and
 
            # attributes in subsequent requests.
 
            message[0]
 
            collector.setAttrs()
 
    s.onPull = onPull
 

	
 
def launch(graph):
 
def launch(graph, doLoadTest=False):
 

	
 
    # todo: drive outputs with config files
 
    outputs = [
 
        EnttecDmx(L9['output/dmx0/'], '/dev/dmx0', 80),
 
        Udmx(L9['output/udmx/'], 510),
 
    ]
 
@@ -73,22 +73,46 @@ def launch(graph):
 
    
 
    reactor.listenTCP(networking.collector.port,
 
                      Site(server.app.resource()),
 
                      interface='::')
 
    log.info('serving http on %s, zmq on %s', networking.collector.port,
 
             networking.collectorZmq.port)
 
    if doLoadTest:
 
        loadTest()
 
    
 
    
 
def loadTest():
 
    from light9.effect.sequencer import sendToCollector
 
    import time
 
    session = "loadtest%s" % time.time()
 
    offset = 0
 
    for i in range(2000):
 
        reactor.callLater(offset, sendToCollector, "http://dash:8200/live/", session,
 
                    [["http://light9.bigasterisk.com/device/backlight1","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/backlight2","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/backlight3","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/backlight4","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/backlight5","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/down2","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/down3","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/down4","http://light9.bigasterisk.com/color","#ffffff"],
 
                     ["http://light9.bigasterisk.com/device/backlight5","http://light9.bigasterisk.com/uv",0.011]])
 
        offset += .005
 

	
 
    reactor.callLater(offset, reactor.stop)
 
    
 
def main():
 
    parser = optparse.OptionParser()
 
    parser.add_option("-v", "--verbose", action="store_true",
 
                      help="logging.DEBUG")
 
    parser.add_option("--loadtest", action="store_true",
 
                      help="call myself with some synthetic load then exit")
 
    (options, args) = parser.parse_args()
 
    log.setLevel(logging.DEBUG if options.verbose else logging.INFO)
 

	
 
    graph = SyncedGraph(networking.rdfdb.url, "collector")
 

	
 
    graph.initiallySynced.addCallback(lambda _: launch(graph))
 
    graph.initiallySynced.addCallback(lambda _: launch(graph, options.loadtest))
 
    reactor.run()
 

	
 
if __name__ == '__main__':
 
    main()
light9/effect/sequencer.py
Show inline comments
 
@@ -26,13 +26,15 @@ stats = scales.collection('/sequencer/',
 

	
 
                                       )
 
def sendToCollector(client, session, settings):
 
    return treq.put(networking.collector.path('attrs'),
 
                    data=json.dumps({'settings': settings,
 
                                     'client': client,
 
                                     'clientSession': session}))
 
                                     'clientSession': session,
 
                                     'sendTime': time.time(),
 
                                 }))
 

	
 

	
 
class Note(object):
 
    def __init__(self, graph, uri, effectevalModule, sharedEffectOutputs):
 
        g = self.graph = graph
 
        self.uri = uri
0 comments (0 inline, 0 general)