Esempio n. 1
0
def get_table_info(master, connect, args):
    if len(args) != 1:
        raise IncorrectMessageError()
    table_name = args[0]
    table_info = master.get_table_info(table_name)
    if table_info is None:
        raise ServerError('Requested table does not exist')
    connect.send_once(str(table_info))
Esempio n. 2
0
def list_dir(master, connect, args):
    if len(args) != 1:
        raise IncorrectMessageError()
    cluster_path = args[0]
    cluster_info = master.get_cluster_info(cluster_path)
    if not cluster_info:
        raise ServerError('Cluster not found')
    connect.send_once(line_packing(*cluster_info))
Esempio n. 3
0
def map_request(master, connect, args):
    if len(args) != 2:
        raise IncorrectMessageError()
    table_in, table_out = args
    map_info = mapper.create_map(table_in, table_out)
    table_nodes = master.get_table_nodes(table_in)
    table_nodes = map(lambda node: node.url, table_nodes)
    connect.send_once(line_packing(map_info.id, *table_nodes))
Esempio n. 4
0
def add_table(master, connect, args):
    if len(args) < 2:
        raise IncorrectMessageError()
    node = master.get_node((args[0], args[1]))
    if node is None:
        raise ServerError('Requested node does not exist')
    new_table_args = args[2:] + [node]
    master.add_table_node(*new_table_args)
Esempio n. 5
0
def delete_table_request(master, connect, args):
    if len(args) != 1:
        raise IncorrectMessageError()
    table_path = args[0]
    table_info = master.get_table_info(table_path)
    if table_info is None:
        raise ServerError('Requested table does not exist')
    table_nodes = table_info.nodes
    nodes_addr = map(lambda node: node.url, table_nodes)
    connect.send_once(line_packing(*nodes_addr))
Esempio n. 6
0
def remove_node_table(master, connect, args):
    if len(args) < 2:
        raise IncorrectMessageError()
    node = master.get_node((args[0], args[1]))
    remove_table_args = args[2:] + [node]
    master.remove_table_node(*remove_table_args)
Esempio n. 7
0
def add_slave(master, connect, args):
    if len(args) != 3:
        raise IncorrectMessageError()
    master.add_node(*args)