log = logging.getLogger("_tear_down")

    log.debug("stopping server")
    state["resilient-server"].close()

    log.debug("stopping anti entropy clients")
    state["pull-server"].close()
    for anti_entropy_client in state["anti-entropy-clients"]:
        anti_entropy_client.close()

    state["event-push-client"].close()

    state["zmq-context"].term()
    state["local-database-connection"].close()
    state["central-database-connection"].close()

    log.debug("teardown complete")

if __name__ == "__main__":
    state = _create_state()
    sys.exit(
        time_queue_driven_process.main(
            _log_path,
            state,
            pre_loop_actions=[_setup, ],
            post_loop_actions=[_tear_down, ],
            exception_action=exception_event
        )
    )

Exemplo n.º 2
0

def _tear_down(_state):
    log = logging.getLogger("_tear_down")

    log.debug("stopping anti entropy client")
    state["pull-server"].close()
    state["anti-entropy-client"].close()

    state["zmq-context"].term()

    log.debug("teardown complete")


_dispatch_table = {
    "anti-entropy-audit-reply": _handle_anti_entropy_audit_reply,
}

if __name__ == "__main__":
    state = _create_state()
    sys.exit(
        time_queue_driven_process.main(_log_path,
                                       state,
                                       pre_loop_actions=[
                                           _setup,
                                       ],
                                       post_loop_actions=[
                                           _tear_down,
                                       ],
                                       halt_event=state["halt-event"]))
Exemplo n.º 3
0
        (state["anti-entropy-client"].run, time.time(), ),
    ] 

def _tear_down(_state):
    log = logging.getLogger("_tear_down")

    log.debug("stopping anti entropy client")
    state["pull-server"].close()
    state["anti-entropy-client"].close()

    state["zmq-context"].term()

    log.debug("teardown complete")

_dispatch_table = {
    "anti-entropy-audit-reply"    : _handle_anti_entropy_audit_reply,
}

if __name__ == "__main__":
    state = _create_state()
    sys.exit(
        time_queue_driven_process.main(
            _log_path,
            state,
            pre_loop_actions=[_setup, ],
            post_loop_actions=[_tear_down, ],
            halt_event=state["halt-event"]
        )
    )

Exemplo n.º 4
0
            state["callback-dispatcher"].run,
            time.time(),
        ),
    ]


def _tear_down(_state):
    log = logging.getLogger("_tear_down")

    log.debug("stopping sub client")
    state["sub-client"].close()

    state["zmq-context"].term()

    log.debug("teardown complete")


if __name__ == "__main__":
    state = _create_state()
    sys.exit(
        time_queue_driven_process.main(
            _log_path,
            state,
            pre_loop_actions=[
                _setup,
            ],
            post_loop_actions=[
                _tear_down,
            ],
        ))
    log.info("connecting sub-client to %s" % (_event_aggregator_pub_address,))
    state["sub-client"] = SUBClient(
        state["zmq-context"], _event_aggregator_pub_address, _sub_topics, state["receive-queue"]
    )
    state["sub-client"].register(state["pollster"])

    state["queue-dispatcher"] = DequeDispatcher(state, state["receive-queue"], _dispatch_table)

    # hand the pollster and the queue-dispatcher to the time-queue
    return [(state["pollster"].run, time.time()), (state["queue-dispatcher"].run, time.time())]


def _tear_down(_state):
    log = logging.getLogger("_tear_down")

    log.debug("stopping sub client")
    state["sub-client"].close()

    log.debug("stopping zeromq context")
    state["zmq-context"].term()

    log.debug("teardown complete")


if __name__ == "__main__":
    state = _create_state()
    sys.exit(
        time_queue_driven_process.main(_log_path, state, pre_loop_actions=[_setup], post_loop_actions=[_tear_down])
    )