Esempio n. 1
0
def setup(configFile):
    """
    Given the configuration file, instantiate the proxy manager and setup the
    necessary services.
    """
    # get config object
    conf = config.Config(configFile)

    # instantiate the proxy manager (that which will direct the proxies)
    director = configuredProxyManagerFactory(conf)

    # set up the lb application
    application = service.Application(name)
    services = LoadBalancedService(director)
    services.setServiceParent(application)

    # set up the proxies
    services.proxiesFactory()

    # set up the control socket
    control = setupControlSocket(conf, director)
    control.setServiceParent(services)

    # set up the host checker service
    checker = setupHostChecker(conf, director)
    checker.setServiceParent(services)

    # set up the config checker service
    configer = setupConfigChecker(configFile, conf, director)
    configer.setServiceParent(services)

    # set up the admin web server
    # XXX need to test this for when no admin web UI is configured
    adminWeb = setupAdminWebUIServer(conf, director)
    adminWeb.setServiceParent(services)

    # set up the admin SSH server
    adminSSH = setupAdminSSHServer(conf, director, services)
    if adminSSH:
    	adminSSH.setServiceParent(services)

    # return the application object so that the .tac file can use it
    return application
Esempio n. 2
0
def setup(configFile):
    """
    Given the configuration file, instantiate the proxy manager and setup the
    necessary services.
    """
    # get config object
    conf = config.Config(configFile)

    # instantiate the proxy manager (that which will direct the proxies)
    director = configuredProxyManagerFactory(conf)

    # set up the lb application, and implicitly, the proxies
    application = service.Application(name)
    services = LoadBalancedService(director)
    services.setServiceParent(application)

    # set up the control socket
    control = setupControlSocket(conf, director)
    control.setServiceParent(services)

    # set up the host checker service
    checker = setupHostChecker(conf, director)
    checker.setServiceParent(services)

    # set up the config checker service
    configer = setupConfigChecker(conf, director)
    configer.setServiceParent(services)

    # set up the admin web server
    adminWeb = setupAdminWebUIServer(conf, director)
    if adminWeb:
        adminWeb.setServiceParent(services)

    # set up the RPC resources

    # set up the admin SSH server
    adminSSH = setupAdminSSHServer(conf, director, services)
    if adminSSH:
        adminSSH.setServiceParent(services)

    # return the application object so that the .tac file can use it
    return application
Esempio n. 3
0
def initApplication():
    global overlay
    application = service.Application('Demo LB Service')
    # This is because you have to add a first host. It will not be used for
    # anything.
    proxyServices = [HostMapper(proxy='0.0.0.0:8080', lbType=leastc, host='host0',
        address='127.0.0.1:10000'),]

    overlay = Overlay()
    overlay.init(12345, 12346)
    pm = manager.proxyManagerFactory(proxyServices)
    tr = pm.getTracker("proxy1", "group1")

    def start_workers(_):
        d = Deferred()
        # load number of workers
        f = open("config.yaml", "r")
        config = yaml.load(f)
        f.close()
        N = config["workers"]
        print "Start %i number of workers!" % N
        #N = 2

        def _start_worker(_):
            deferred = deferToThread(overlay.aws.start_worker)
            def _addHost(w):
                send_log("INFO", "Started new host %s:10000" %
                        str(w.instances[0].private_ip_address))
                tr.newHost((w.instances[0].private_ip_address, 3000), "host" + str(id))
                return w
            deferred.addCallback(_addHost)
            return deferred

        for id in range(1,N+1):
            d.addCallback(_start_worker)
        d.callback(0)
        return d

    def add_workers(_):
        for w in overlay.aws.workers:
            send_log("INFO", "Added host " +
                    str(w.instances[0].private_ip_address))
            tr.newHost((w.instances[0].private_ip_address, 3000), "host" + str(id))
            id += 1

    overlay.d.addCallbacks(add_workers, start_workers)

    def remove_default_worker(_):
        tr.delHost('127.0.0.1:10000')
    overlay.d.addBoth(remove_default_worker)

    for s in pm.services:
        print s
    lbs = LoadBalancedService(pm)
    #configuration = config.Config("config.xml")
    #print pm.trackers
    os = LoadBalanceService(pm.getTracker('proxy1', 'group1'), pm)
    os.setServiceParent(application)
    lbs.setServiceParent(application)

    atexit.register(before_exit)
    return application