Exemplo n.º 1
0
            format=LOG_FORMAT, level=logging.DEBUG,
            filename=config_parser.get('logging', 'log_file'),
            datefmt='%d-%m %H:%M', filemode='w')
        # si verbose está activo, mostrar la información por pantalla
        if args.verbose:
            console = logging.StreamHandler()
            console.setLevel(logging.DEBUG)
            formatter = logging.Formatter(LOG_CONSOLE_FORMAT)
            console.setFormatter(formatter)
            logging.getLogger('').addHandler(console)
    else:
        if args.verbose:
            level = logging.DEBUG
        else:
            level = logging.WARNING
        logging.basicConfig(
            format=LOG_FORMAT, datefmt='%d-%m %H:%M', level=level)

    # correr nodo
    mappers = config_parser.get('nodes', 'mappers').split(',')
    mappers = map(lambda m: m.strip().split(':'), mappers)
    mappers = map(lambda m: (m[0], int(m[1])), mappers)
    reducer = config_parser.get('nodes', 'reducer').split(':')
    reducer[1] = int(reducer[1])
    master = NodoMaster(
        config_parser.get('connection', 'host'),
        config_parser.getint('connection', 'port'),
        mappers, reducer,
        args.out_file)
    master.iniciar(args.text_file)
Exemplo n.º 2
0
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
import argparse, ConfigParser, sys
from lib.NodoMaster import NodoMaster

if __name__ == "__main__":

    parser = argparse.ArgumentParser(description='Ejecucion de nodo master - Es necesario que se encuentren activo los nodos mappers y nodo reducer')
    parser.add_argument('in_file', help='archivo de entrada a procesar.')
    parser.add_argument('out_file', help='archivo donde devolver el resultado del proceso.')
    args = parser.parse_args(sys.argv[1:])

    config_parser = ConfigParser.SafeConfigParser()
    config_parser.read('config.ini')
    
    #recuperamos configuraciones
    #nodo master
    host = config_parser.get('master', 'host')
    port = config_parser.getint('master', 'port')
    
    #nodo reducer
    reducer = [config_parser.get('reducer', 'host'),  config_parser.getint('reducer', 'port')]
    
    #nodos mappers
    mappers = config_parser.get('mappers', 'mappers').split(',')
    mappers = map(lambda m: m.strip().split(':'), mappers)
    mappers = map(lambda m: (m[0], int(m[1])), mappers)
    
    master = NodoMaster( host, port, mappers, reducer, args.out_file)
    master.iniciar(args.in_file)
Exemplo n.º 3
0
            filemode="w",
        )
        # si verbose está activo, mostrar la información por pantalla
        if args.verbose:
            console = logging.StreamHandler()
            console.setLevel(logging.DEBUG)
            formatter = logging.Formatter(LOG_CONSOLE_FORMAT)
            console.setFormatter(formatter)
            logging.getLogger("").addHandler(console)
    else:
        if args.verbose:
            level = logging.DEBUG
        else:
            level = logging.WARNING
        logging.basicConfig(format=LOG_FORMAT, datefmt="%d-%m %H:%M", level=level)

    # correr nodo
    mappers = config_parser.get("nodes", "mappers").split(",")
    mappers = map(lambda m: m.strip().split(":"), mappers)
    mappers = map(lambda m: (m[0], int(m[1])), mappers)
    reducer = config_parser.get("nodes", "reducer").split(":")
    reducer[1] = int(reducer[1])
    master = NodoMaster(
        config_parser.get("connection", "host"),
        config_parser.getint("connection", "port"),
        mappers,
        reducer,
        args.out_file,
    )
    master.start_job(args.text_file)