示例#1
0
def start_cpu_bench(nb_hosts, runtime, cores):
    global hosts_state
    msg = HM(HM.MODULE, HM.CPU, HM.START)
    msg.cpu_instances = cores
    msg.running_time = runtime
    for host in hosts.keys():
        if nb_hosts == 0:
            break
        if not host in get_host_list(CPU_RUN).keys():
            hosts_state[host] |= CPU_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#2
0
def start_cpu_bench(nb_hosts, runtime, cores):
    global hosts_state
    msg = HM(HM.MODULE, HM.CPU, HM.START)
    msg.cpu_instances = cores
    msg.running_time = runtime
    for host in hosts.keys():
        if nb_hosts == 0:
            break
        if not host in get_host_list(CPU_RUN).keys():
            hosts_state[host] |= CPU_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#3
0
def connect_to_server(hostname):
    global s
    global connected
    try:
        s.connect((hostname, 20000))
    except:
        HP.logger.error("Server %s is not available, exiting" % hostname)
        sys.exit(1)

    connected = True

    msg = HM(HM.CONNECT)
    msg.hw = eval(open(sys.argv[1]).read(-1))

    HP.send_hm_message(s, msg, True)
    while True:
        try:
            msg = HP.recv_hm_message(s)
        except:
            HP.logger.error("Broken socket, exiting !")
            break

        if not msg:
            continue

        if msg.message == HM.INVALID:
            HP.logger.error("Ignoring invalid message")
            continue

        if msg.message == HM.DISCONNECTED:
            connected = False
            HP.logger.error("Got disconnected from server, exiting")
            return True
            break

        msg.hw = eval(open(sys.argv[1]).read(-1))

        handlers = {
            HM.NONE: none,
            HM.CONNECT: connect,
            HM.DISCONNECT: disconnect,
            HM.ACK: ack,
            HM.NACK: nack,
            HM.MODULE: module,
        }

        HP.logger.info("Received %d" % msg.message)
        HP.logger.info(handlers)
        handlers[msg.message](s, msg)
示例#4
0
def connect_to_server(hostname):
    global s
    global connected
    try:
        s.connect((hostname, 20000))
    except:
        HP.logger.error("Server %s is not available, exiting" % hostname)
        sys.exit(1)

    connected = True

    msg = HM(HM.CONNECT)
    msg.hw = eval(open(sys.argv[1]).read(-1))

    HP.send_hm_message(s, msg, True)
    while True:
        try:
            msg = HP.recv_hm_message(s)
        except:
            HP.logger.error("Broken socket, exiting !")
            break

        if not msg:
            continue

        if msg.message == HM.INVALID:
            HP.logger.error("Ignoring invalid message")
            continue

        if msg.message == HM.DISCONNECTED:
            connected = False
            HP.logger.error("Got disconnected from server, exiting")
            return True
            break

        msg.hw = eval(open(sys.argv[1]).read(-1))

        handlers = {HM.NONE: none,
                    HM.CONNECT: connect,
                    HM.DISCONNECT: disconnect,
                    HM.ACK: ack,
                    HM.NACK: nack,
                    HM.MODULE: module,
                    }

        HP.logger.info("Received %d" % msg.message)
        HP.logger.info(handlers)
        handlers[msg.message](s, msg)
示例#5
0
def start_cpu_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.CPU, HM.START)
    msg.cpu_instances = bench['cores']
    msg.running_time = bench['runtime']

    for host in bench['hosts-list']:
        if nb_hosts == 0:
            break
        if host not in get_host_list(CPU_RUN).keys():
            hosts_state[host] |= CPU_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            start_time(host)
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#6
0
def start_cpu_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.CPU, HM.START)
    msg.cpu_instances = bench['cores']
    msg.running_time = bench['runtime']

    for host in bench['hosts-list']:
        if nb_hosts == 0:
            break
        if host not in get_host_list(CPU_RUN).keys():
            hosts_state[host] |= CPU_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            start_time(host)
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#7
0
def start_memory_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.MEMORY, HM.START)
    msg.cpu_instances = bench['cores']
    msg.block_size = bench['block-size']
    msg.running_time = bench['runtime']
    msg.parallel_mode = bench['mode']

    for host in bench['hosts-list']:
        if nb_hosts == 0:
            break
        if host not in get_host_list(MEMORY_RUN).keys():
            hosts_state[host] |= MEMORY_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            start_time(host)
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#8
0
def start_memory_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.MEMORY, HM.START)
    msg.cpu_instances = bench['cores']
    msg.block_size = bench['block-size']
    msg.running_time = bench['runtime']
    msg.parallel_mode = bench['mode']

    for host in bench['hosts-list']:
        if nb_hosts == 0:
            break
        if host not in get_host_list(MEMORY_RUN).keys():
            hosts_state[host] |= MEMORY_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            start_time(host)
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#9
0
def prepare_network_bench(bench, mode):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.NETWORK, mode)
    msg.network_test = bench['mode']
    msg.network_connection = bench['connection']
    msg.peer_servers = bench['ip-list'].items()
    msg.ports_list = bench['port-list']

    for hv in bench['hosts-list']:
        for host in bench['hosts-list'][hv]:
            if nb_hosts == 0:
                break
            if host not in get_host_list(NETWORK_RUN).keys():
                hosts_state[host] |= NETWORK_RUN
                nb_hosts = nb_hosts - 1
                lock_socket_list.acquire()
                msg.my_peer_name = bench['ip-list'][host]
                HP.send_hm_message(socket_list[host], msg)
                lock_socket_list.release()

    string_mode = ""
    if mode == HM.INIT:
        string_mode = "Initialisation"
    else:
        string_mode = "Cleaning"

    HP.logger.info("NETWORK: %s in progress" % string_mode)
    while (get_host_list(NETWORK_RUN).keys()):
        time.sleep(1)
示例#10
0
def prepare_network_bench(bench, mode):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.NETWORK, mode)
    msg.network_test = bench['mode']
    msg.network_connection = bench['connection']
    msg.peer_servers = bench['ip-list'].items()
    msg.ports_list = bench['port-list']

    for hv in bench['hosts-list']:
        for host in bench['hosts-list'][hv]:
            if nb_hosts == 0:
                break
            if host not in get_host_list(NETWORK_RUN).keys():
                hosts_state[host] |= NETWORK_RUN
                nb_hosts = nb_hosts - 1
                lock_socket_list.acquire()
                msg.my_peer_name = bench['ip-list'][host]
                HP.send_hm_message(socket_list[host], msg)
                lock_socket_list.release()

    string_mode = ""
    if mode == HM.INIT:
        string_mode = "Initialisation"
    else:
        string_mode = "Cleaning"

    HP.logger.info("NETWORK: %s in progress" % string_mode)
    while (get_host_list(NETWORK_RUN).keys()):
        time.sleep(1)
示例#11
0
def start_network_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.NETWORK, HM.START)
    msg.block_size = bench['block-size']
    msg.running_time = bench['runtime']
    msg.network_test = bench['mode']
    msg.network_connection = bench['connection']
    msg.ports_list = bench['port-list']
    bench['arity_groups'] = []
    arity_group = []
    used_hosts = []
    ip_list = {}

    while nb_hosts > 0:
        for hv in bench['hosts-list']:
            for host in bench['hosts-list'][hv]:
                if nb_hosts == 0:
                    break
                # We shall not use the same host twice
                if host in used_hosts:
                    continue
                used_hosts.append(host)
                arity_group.append(host)
                ip_list[host] = bench['ip-list'][host]
                nb_hosts = nb_hosts - 1
                if len(arity_group) == bench['arity']:
                    bench['arity_groups'].append(arity_group)
                    msg.peer_servers = ip_list.items()
                    for peer_server in arity_group:
                        if peer_server not in get_host_list(
                                NETWORK_RUN).keys():
                            msg.my_peer_name = bench['ip-list'][peer_server]
                            hosts_state[peer_server] |= NETWORK_RUN
                            lock_socket_list.acquire()
                            start_time(peer_server)
                            HP.send_hm_message(socket_list[peer_server], msg)
                            lock_socket_list.release()
                    arity_group = []
                    ip_list = {}
                # We shall break to switch to another hypervisor
                break
        if nb_hosts == 0:
            return
示例#12
0
def start_network_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.NETWORK, HM.START)
    msg.block_size = bench['block-size']
    msg.running_time = bench['runtime']
    msg.network_test = bench['mode']
    msg.network_connection = bench['connection']
    msg.ports_list = bench['port-list']
    bench['arity_groups'] = []
    arity_group = []
    used_hosts = []
    ip_list = {}

    while nb_hosts > 0:
        for hv in bench['hosts-list']:
            for host in bench['hosts-list'][hv]:
                if nb_hosts == 0:
                    break
                # We shall not use the same host twice
                if host in used_hosts:
                    continue
                used_hosts.append(host)
                arity_group.append(host)
                ip_list[host] = bench['ip-list'][host]
                nb_hosts = nb_hosts - 1
                if len(arity_group) == bench['arity']:
                    bench['arity_groups'].append(arity_group)
                    msg.peer_servers = ip_list.items()
                    for peer_server in arity_group:
                        if peer_server not in get_host_list(NETWORK_RUN).keys():
                            msg.my_peer_name = bench['ip-list'][peer_server]
                            hosts_state[peer_server] |= NETWORK_RUN
                            lock_socket_list.acquire()
                            start_time(peer_server)
                            HP.send_hm_message(socket_list[peer_server], msg)
                            lock_socket_list.release()
                    arity_group = []
                    ip_list = {}
                # We shall break to switch to another hypervisor
                break
        if nb_hosts == 0:
            return
示例#13
0
def start_storage_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.STORAGE, HM.START)
    msg.block_size = bench['block-size']
    msg.access = bench['access']
    msg.running_time = bench['runtime']
    msg.mode = bench['mode']
    msg.device = bench['device']
    msg.rampup_time = bench['rampup-time']

    for host in bench['hosts-list']:
        if nb_hosts == 0:
            break
        if host not in get_host_list(STORAGE_RUN).keys():
            hosts_state[host] |= STORAGE_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            start_time(host)
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#14
0
def start_storage_bench(bench):
    global hosts_state
    nb_hosts = bench['nb-hosts']
    msg = HM(HM.MODULE, HM.STORAGE, HM.START)
    msg.block_size = bench['block-size']
    msg.access = bench['access']
    msg.running_time = bench['runtime']
    msg.mode = bench['mode']
    msg.device = bench['device']
    msg.rampup_time = bench['rampup-time']

    for host in bench['hosts-list']:
        if nb_hosts == 0:
            break
        if host not in get_host_list(STORAGE_RUN).keys():
            hosts_state[host] |= STORAGE_RUN
            nb_hosts = nb_hosts - 1
            lock_socket_list.acquire()
            start_time(host)
            HP.send_hm_message(socket_list[host], msg)
            lock_socket_list.release()
示例#15
0
        return HM(HM.INVALID)

    msg = pickle.loads(zlib.decompress(recvall(sock, int(length[0]))))
    if msg.is_valid() is False:
        logger.error("Message %d is not part of the valid message_list" %
                     msg.message)
        if (msg.need_ack is True) and (msg.message != HM.DISCONNECT):
            send_hm_message(sock, HM(HM.NACK), False)
        msg.message = HM.INVALID
    else:
        logger.debug("Received %s/%s/%s from %s (need_ack=%r)" %
                     (msg.get_message_type(), msg.get_module_type(),
                      msg.get_action_type(), sock.getpeername(),
                      msg.need_ack))
        if (msg.need_ack is True) and (msg.message != HM.DISCONNECT):
            message = HM(HM.ACK)
            message.module = msg.module
            message.action = msg.action
            send_hm_message(sock, message, False)
    return msg


def recvall(sock, count):
    buf = b''
    while count:
        newbuf = sock.recv(count)
        if not newbuf:
            return None
        buf += newbuf
        count -= len(newbuf)
    return buf