예제 #1
0
    local_script_path = combo[1][0]
    file_name = local_script_path.split("/")[-1]
    project_name = combo[2]

    client_script_path = "~/distsys/bin/" + project_name + "/" + file_name

    if remote_file_exists(ip_addr, client_script_path):
        pass
    else:
        os.system('scp ' + local_script_path + ' ' + ip_addr + ':' + client_script_path)

    run_script(ip_addr, client_script_path)

    collect_results(ip_addr, project_name)


if __name__ == "__main__":
    s = services(localhost=False)
    num_clients = len(s.clients)

    ## Distribute script only if it hasnt yet.    
    client_files = distribute_data(num_clients, script_path, job=True)

    combo = []
    for i in range(num_clients):
        combo.append([s.clients[i], client_files[i], project_name])

    print "Distributing data..."
    pool = Pool(processes=num_clients)
    pool.map(run_job, combo)
예제 #2
0
## Setup function to set global variables for shared state
def setup(to, tr, fail):
    global total
    global transfer
    global failed
    total = to
    transfer = tr
    failed = fail

if __name__ == "__main__":
    ## Get client ips
    s = services(localhost=False)
    num_clients = len(s.clients)

    client_files, total = distribute_data(num_clients, path)

    ## Setup shared state variable
    total_files = Value('i', total)
    transfer_files = Value('i', 0)
    failed_files = Value('i', 0)

    combo = []
    for i in range(num_clients):
        combo.append([s.clients[i],client_files[i]])

    print "Distributing data..."
    pool = Pool(processes=num_clients, initializer=setup, initargs=[total_files, transfer_files, failed_files])
    pool.map(transfer_data, combo)
    print "\033[92m" + "transfer complete!" + "\033[0m\n"