Beispiel #1
0
def start(benchmark=False):
    # Clients and servers connect to the Proxy through different URLs
    logging.config.fileConfig("proxy_logging.conf")
    tornado.options.parse_command_line()
    """ 
    TODO: As new options are available, parse them and standardize the options dictionary.
    Current options are:
    
    DISTRIBUTION: 
    Description: Defines how messages are distributed from proxy to app servers.
    Options: Round-robin or sticky (messages from a client always hit the same app server)
    """
    proxy = proxymod.Proxy()
    proxy_options = {}
    proxy_options["DISTRIBUTION"] = PROXY_DISTRIBUTION.STICKY

    logging.debug("[proxy]: Loading proxy, please wait..")

    proxy.front = front.ClientLayer(proxy, proxy_options)
    proxy.back = back.ServerLayer(proxy, proxy_options)
    proxy.port = options.port

    logging.info("[proxy]: Proxy Started!")

    static_path = os.path.join("..", os.path.join("bin", "static"))
    logging.info("[proxy]: static path is " + static_path)

    if benchmark:
        filename = "proxy_resmon_" + str(uuid.uuid4())[:8] + ".csv"
        resmon = ResourceMonitor(filename,
                                 metrics=[('numUsers',
                                           proxy.front.get_num_users)])
        resmon.start()

    application = tornado.web.Application([(r"/", front.HTTPHandler),
                                           (r"/static/(.*)",
                                            tornado.web.StaticFileHandler, {
                                                'path': static_path
                                            }),
                                           (r"/client", front.ClientHandler),
                                           (r"/server", back.ServerHandler),
                                           (r"/admin", back.AdminHandler)])
    application.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
Beispiel #2
0
def start(benchmark=False):
    # Clients and servers connect to the Proxy through different URLs
    logging.config.fileConfig("proxy_logging.conf")
    tornado.options.parse_command_line()
    """ 
    TODO: As new options are available, parse them and standardize the options dictionary.
    Current options are:
    
    DISTRIBUTION: 
    Description: Defines how messages are distributed from proxy to app servers.
    Options: Round-robin or sticky (messages from a client always hit the same app server)
    """
    proxy = proxymod.Proxy()
    proxy_options = {}
    proxy_options["DISTRIBUTION"] = PROXY_DISTRIBUTION.STICKY

    logging.debug("[proxy]: Loading proxy, please wait..")
    
    proxy.front = front.ClientLayer(proxy, proxy_options)
    proxy.back = back.ServerLayer(proxy, proxy_options)
    proxy.port = options.port

    logging.info("[proxy]: Proxy Started!")
    
    static_path = os.path.join("..", os.path.join("bin", "static"))
    logging.info("[proxy]: static path is " + static_path)
    
    if benchmark:
        filename = "proxy_resmon_" + str(uuid.uuid4())[:8] + ".csv"
        resmon = ResourceMonitor(filename, 
                                 metrics=[('numUsers', proxy.front.get_num_users)])
        resmon.start()

    application = tornado.web.Application([
    (r"/", front.HTTPHandler),
    (r"/static/(.*)", tornado.web.StaticFileHandler, {'path': static_path}),
    (r"/client", front.ClientHandler),
    (r"/server", back.ServerHandler),
    (r"/admin", back.AdminHandler)
    ])
    application.listen(options.port)
    tornado.ioloop.IOLoop.instance().start()
Beispiel #3
0
class RCAT():
    application = None
    pc = None
    datacon = None
    resmon = None
    def __init__(self,handler,db=None,mapper=None,obm=None):
        handlers = []
        handlers.append((r"/", handler))
        rcat_config = helper.parse_input('rcat.cfg')
        ip = rcat_config["ip"]
        port = rcat_config["port"]
        proxies = rcat_config["proxies"]
        plugins = rcat_config["plugins"]
        if "benchmark" in plugins:
            filename = "rcat_resmon_" + str(uuid.uuid4())[:8] + ".csv"
            self.resmon = ResourceMonitor(filename)
            self.resmon.start()
        if obm:
            handlers.append((r"/obm", OBMHandler))
        
        logging.debug('[rcat]: Starting app in ' + ip + ":" + port)
        
        application = tornado.web.Application(handlers)
        application.listen(port)
        
        t = Thread(target=tornado.ioloop.IOLoop.instance().start)
        t.daemon = True
        t.start()
        
        self.pc = ProxyConnector(proxies, "ws://" + ip + ':' + port) # app server
        self.datacon = DataConnector("RCAT",self.pc.adm_id)
        self.datacon.host = ip+":"+port
        if db:
            if "persist_timer" in rcat_config and rcat_config["persist_timer"]:
                self.datacon.db = db(self.datacon,rcat_config["persist_timer"])
            else:
                self.datacon.db = db(self.datacon)
            
        if mapper:
            self.datacon.mapper = mapper(self.datacon)
        if obm:
            self.datacon.obm = obm(self.datacon)