Ejemplo n.º 1
0
def run_backdoor(finished):
    global BACKDOOR_PORT

    try:
        while 1:
            try:
                greenhouse.run_backdoor(("127.0.0.1", BACKDOOR_PORT),
                        {'greenhouse': greenhouse, 'junction': junction})
            except EnvironmentError, exc:
                if exc.args[0] != errno.EADDRINUSE:
                    raise
                BACKDOOR_PORT += 1
    finally:
        finished.set()
Ejemplo n.º 2
0
    def func():
        pass
    code = type(load_func.func_code)(*mummy.loads(s))
    func.func_code = code
    return func


if __name__ == '__main__':
    greenhouse.global_exception_handler(traceback.print_exception)
    junction.configure_logging(level=1)

    if sys.argv[1] == "mapper":
        hub = junction.Hub(("", 9090), [("", 9091), ("", 9092)])
        hub.start()
        mapper = Mapper(hub, 'map-reduce', 1)
        greenhouse.run_backdoor(("", 8090), locals())
    elif sys.argv[1] == "reducer":
        hub = junction.Hub(("", 9091), [("", 9090), ("", 9092)])
        hub.start()
        reducer = Reducer(hub, 'map-reduce', 0, 0)
        greenhouse.run_backdoor(("", 8091), locals())
    elif sys.argv[1] == "coordinator":
        hub = junction.Hub(("", 9092), [("", 9090), ("", 9091)])
        hub.start()
        coord = Coordinator(hub, 'map-reduce', 0, 0, 1)
        greenhouse.run_backdoor(("", 8092), locals())
    elif sys.argv[1] == "client":
        cli = junction.Client(("", 9092)) # only need the coordinator
        cli.connect()
        cli.wait_connected()
        result = map_reduce(cli, 'map-reduce',
Ejemplo n.º 3
0

if __name__ == '__main__':
    greenhouse.global_exception_handler(traceback.print_exception)
    level = 1
    if sys.argv[1] == 'client':
        level = logging.ERROR
        if '-v' in sys.argv:
            level = 1
    junction.configure_logging(level=level)

    if sys.argv[1] == "mapper":
        hub = junction.Hub(("", 9090), [("", 9091), ("", 9092)])
        hub.start()
        mapper = Mapper(hub, 'map-reduce', 1)
        greenhouse.run_backdoor(("", 8090), locals())
    elif sys.argv[1] == "reducer":
        hub = junction.Hub(("", 9091), [("", 9090), ("", 9092)])
        hub.start()
        reducer = Reducer(hub, 'map-reduce', 0, 0)
        greenhouse.run_backdoor(("", 8091), locals())
    elif sys.argv[1] == "coordinator":
        hub = junction.Hub(("", 9092), [("", 9090), ("", 9091)])
        hub.start()
        coord = Coordinator(hub, 'map-reduce', 0, 0, 1)
        greenhouse.run_backdoor(("", 8092), locals())
    elif sys.argv[1] == "client":
        cli = junction.Client(("", 9092))  # only need the coordinator
        cli.connect()
        cli.wait_connected()
        result = map_reduce(cli, 'map-reduce', lambda i: range(1, 8),