Beispiel #1
0
def main():
    """ Main function """

    # Generate the master log
    master_log_create()

    # Generate the list of already available logs
    gen_logs_avl()

    trace_path = '../cooked_traces/'

    with open('./chrome_retry_log', 'wb') as retry_log:
        retry_log.write('chrome retry log\n')

    os.system('sudo sysctl -w net.ipv4.ip_forward=1')

    if not os.path.exists("./locks"):
        os.makedirs("./locks")

    # ipaddr_data = json.loads(urllib.urlopen("http://ip.jsontest.com/").read())
    # ipaddr = str(ipaddr_data['ip'])
    ipaddr = "10.5.20.129"
    cmd = "python run_traces.py {} {} {} {}"
    if HOTSPOT_AWARE:
        ABR_ALGO_CLUSTER.extend(["NPF", "PFN", "PFL"])

    # Generate commands for execution for each ABR_ALGO
    commands = {}
    for process_id, abr_algo in enumerate(ABR_ALGO_CLUSTER):
        commands[abr_algo] = cmd.format(trace_path, abr_algo, process_id,
                                        ipaddr)

    # Execute subprocesses for each ABR_ALGO
    processes = {}
    for abr_algo in ABR_ALGO_CLUSTER:
        processes[abr_algo] = subprocess.Popen(commands[abr_algo],
                                               stdout=subprocess.PIPE,
                                               shell=True)
        mlog(msg="Command {} exec: {}".format(abr_algo, commands[abr_algo]))
        time.sleep(0.1)

    # Wait for each subprocess to complete
    for abr_algo in ABR_ALGO_CLUSTER:
        processes[abr_algo].wait()

    # Completion message
    mlog(msg="Execution complete for all ABR algorithms. Exiting process.")
Beispiel #2
0
######################################################################

def main():
    try:
        if len(sys.argv) == 3:
            abr_algo = sys.argv[1]
            trace_file = sys.argv[2]
            mlog(fnc="main()", msg="Starting server for trace: {}".format(trace_file))
            run(log_file_path=LOG_FILE + '_' + abr_algo + '_' + trace_file)
        else:
            run()
    except Exception as e:
        mlog(fnc="main()", msg="Server function stopped. Trace: {}, Exception: {}".format(
            trace_file, e))
        raise e

######################################################################

if __name__ == "__main__":
    try:
        if len(sys.argv) < 2:
            master_log_create()
        main()
    except KeyboardInterrupt:
        mlog(msg="Keyboard interrupted")
        try:
            sys.exit(0)
        except SystemExit:
            os._exit(0)

######################################################################