Ejemplo n.º 1
0
def restart_name_server(node_id, working_dir, normalizing_constant, config_dir="/home/abhigyan/gnrs/configLocal/"):
    config_files = get_config_files(config_dir)
    f = open(config_files[0])
    for i, line in enumerate(f):
        tokens = line.split()
        id = tokens[0]
        hostname = tokens[2]
        if str(id) == node_id:
            assert tokens[1] == "yes"
            run_name_server(node_id, hostname, working_dir, get_config_file_name(config_dir, id), normalizing_constant)
            print "Restarted name server ", node_id
Ejemplo n.º 2
0
def restart_name_server(node_id, working_dir, normalizing_constant, config_dir='/home/abhigyan/gnrs/configLocal/'):
    config_files = get_config_files(config_dir)
    f = open(config_files[0])
    for i, line in enumerate(f):
        tokens = line.split()
        id = tokens[0]
        hostname = tokens[2]
        if str(id) == node_id:
            assert tokens[1] == 'yes'
            run_name_server(node_id, hostname, working_dir, get_config_file_name(config_dir, id), normalizing_constant)
            print "Restarted name server ", node_id
Ejemplo n.º 3
0
def run_all_experiments(working_dir, normalizing_constant, config_dir="/home/abhigyan/gnrs/configLocal/"):
    if not os.path.exists(config_dir):
        print "Config dir does not exist:", config_dir
        return

    if not os.path.exists(working_dir):
        os.system("mkdir -p " + working_dir)
    os.system("rm -rf " + working_dir + "/*")
    print "Working dir is:", working_dir

    # check if number of config files = numer of lines in each file
    config_files = get_config_files(config_dir)

    # print 'Config files are:', config_files
    if len(config_files) == 0:
        print "ERROR: No config files in config_dir:", config_dir
        sys.exit(1)

    if not file_len(config_files[0]) == len(config_files):
        print "ERROR: Number of config files:", len(config_files), "Number of lines in each file:", file_len(
            config_files[0]
        )
        sys.exit(1)
    else:
        print "Number of config files matches the number of lines:", len(config_files)

    # kill experiments running on same hosts.
    os.system('pssh -P -t 30 -h hosts_ns.txt  "killall -9 java"')
    os.system('pssh -P -t 30 -h hosts_lns.txt  "killall -9 java"')

    # os.system('./kill_mongodb.sh')
    # os.system('./run_mongodb.sh')
    # print 'Sleeping ...'
    # from time import sleep
    # sleep(mongo_sleep)

    # kill_experiments_at_given_hosts(get_hostnames(config_files[0]))
    # os.sytem('pssh -h hosts.txt "nohup ./mongod --dbpath /home/abhigyan/gnrs-db-mongodb/ & 1>/dev/null 2 > /dev/null
    # < /dev/null"')
    f = open(config_files[0])
    first_lns = True

    for i, line in enumerate(f):
        tokens = line.split()
        id = tokens[0]
        hostname = tokens[2]

        if tokens[1] == "yes":
            if is_failed_node(id):
                print "MESSAGE: Not running FAILED node: ", id
                continue
            run_name_server(id, hostname, working_dir, get_config_file_name(config_dir, id), normalizing_constant)
        else:
            if first_lns:
                first_lns = False
                from time import sleep

                print "sleep sleep ..."
                if ns_sleep < 10:
                    sleep(ns_sleep)
                    continue
                count = int(ns_sleep / 10)
                for j in range(count):
                    sleep(10)
                    print "Sleep ", str(j * 10), "sec"
            run_local_name_server(id, hostname, working_dir, get_config_file_name(config_dir, id))

    print "LOCAL NAME SERVERS running ...."
Ejemplo n.º 4
0
def run_all_experiments(working_dir, normalizing_constant, config_dir='/home/abhigyan/gnrs/configLocal/'):
    if not os.path.exists(config_dir):
        print 'Config dir does not exist:', config_dir
        return

    if not os.path.exists(working_dir):
        os.system('mkdir -p ' + working_dir)
    os.system('rm -rf ' + working_dir + '/*')
    print 'Working dir is:', working_dir

    # check if number of config files = numer of lines in each file
    config_files = get_config_files(config_dir)

    #print 'Config files are:', config_files
    if len(config_files) == 0:
        print 'ERROR: No config files in config_dir:', config_dir
        sys.exit(1)

    if not file_len(config_files[0]) == len(config_files):
        print 'ERROR: Number of config files:', len(config_files), 'Number of lines in each file:', \
            file_len(config_files[0])
        sys.exit(1)
    else:
        print 'Number of config files matches the number of lines:', len(config_files)

    # kill experiments running on same hosts.
    os.system('pssh -P -t 30 -h hosts_ns.txt  "killall -9 java"')
    os.system('pssh -P -t 30 -h hosts_lns.txt  "killall -9 java"')

    #os.system('./kill_mongodb.sh')
    #os.system('./run_mongodb.sh')
    #print 'Sleeping ...'
    #from time import sleep
    #sleep(mongo_sleep)

    #kill_experiments_at_given_hosts(get_hostnames(config_files[0]))
    #os.sytem('pssh -h hosts.txt "nohup ./mongod --dbpath /home/abhigyan/gnrs-db-mongodb/ & 1>/dev/null 2 > /dev/null
    # < /dev/null"')
    f = open(config_files[0])
    first_lns = True

    for i, line in enumerate(f):
        tokens = line.split()
        id = tokens[0]
        hostname = tokens[2]

        if tokens[1] == 'yes':
            if is_failed_node(id):
                print 'MESSAGE: Not running FAILED node: ', id
                continue
            run_name_server(id, hostname, working_dir, get_config_file_name(config_dir, id), normalizing_constant)
        else:
            if first_lns:
                first_lns = False
                from time import sleep

                print 'sleep sleep ...'
                if ns_sleep < 10:
                    sleep(ns_sleep)
                    continue
                count = int(ns_sleep / 10)
                for j in range(count):
                    sleep(10)
                    print 'Sleep ', str(j * 10), 'sec'
            run_local_name_server(id, hostname, working_dir, get_config_file_name(config_dir, id))

    print 'LOCAL NAME SERVERS running ....'