コード例 #1
0
ファイル: servers.py プロジェクト: c0ntrol-x/OldSpeak
def execute_command_run_bundle():
    from oldspeak.console.parsers.bundle import parser

    args = parser.parse_args(get_sub_parser_argv())
    bootstrap_conf_with_gevent(args, loglevel=logging.DEBUG)

    module_name = ".".join([
        "oldspeak",
        "pipelines",
        sanitize_name(args.name).replace('-', '_'),
    ])

    module = imp.load_source(module_name, args.path)
    all_members = dict(
        map(
            lambda (name, member): (member.name, member),
            filter(
                lambda (name, member): (hasattr(member, 'name') and isinstance(
                    member, type) and issubclass(member, Pipeline)),
                inspect.getmembers(module))))

    PipelineClass = all_members.get(args.name)

    if not PipelineClass:
        print "invalid job type \033[1;32m'{0}'\033[0m at \033[1;34m{1}\033[0m, but I found these \033[1;33m{2}\033[0m".format(
            args.name, args.path,
            ", ".join([x.name for x in all_members.values()]))
        raise SystemExit(1)

    server = PipelineClass(args.name, concurrency=args.concurrency)
    server.run_bundle(args.sub_bind, args.pull_bind)
コード例 #2
0
ファイル: servers.py プロジェクト: c0ntrol-x/OldSpeak
def execute_command_run_phase():
    from oldspeak.console.parsers.phase import parser
    args = parser.parse_args(get_sub_parser_argv())
    bootstrap_conf_with_gevent(args)

    pull_connect_addresses = list(args.pull_connect or [])
    push_connect_addresses = list(args.push_connect or [])

    module_name = ".".join([
        "oldspeak",
        "phases",
        sanitize_name(args.job_type).replace('-', '_'),
    ])
    module = imp.load_source(module_name, args.path)
    all_members = dict(
        map(
            lambda (name, member): (member.job_type, member),
            filter(
                lambda
                (name, member): (hasattr(member, 'job_type') and isinstance(
                    member, type) and issubclass(member, Phase)),
                inspect.getmembers(module))))

    PhaseClass = all_members.get(args.job_type)

    if not PhaseClass:
        print "invalid job type \033[1;32m'{0}'\033[0m at \033[1;34m{1}\033[0m, but I found these \033[1;33m{2}\033[0m".format(
            args.job_type, args.path,
            ", ".join([x.job_type for x in all_members.values()]))
        raise SystemExit(1)

    server = PhaseClass(
        pull_bind_address=args.pull_bind,
        pub_connect_address=args.pub_connect,
        concurrency=args.concurrency,
        push_connect_addresses=push_connect_addresses,
        pull_connect_addresses=pull_connect_addresses,
    )

    try:
        server.run()
    except KeyboardInterrupt:
        logging.info('exiting')
コード例 #3
0
ファイル: servers.py プロジェクト: c0ntrol-x/OldSpeak
def execute_command_streamer():
    from oldspeak.console.parsers.streamer import parser

    args = parser.parse_args(get_sub_parser_argv())
    bootstrap_conf_with_gevent(args)

    device = Device(zmq.STREAMER, zmq.PULL, zmq.PUSH)

    device.bind_in(args.pull)
    device.bind_out(args.push)
    if args.pull_hwm:
        device.setsockopt_in(zmq.RCVHWM, args.pull_hwm)

    if args.push_hwm:
        device.setsockopt_out(zmq.SNDHWM, args.push_hwm)

    print "oldspeak streamer started"
    print "date", datetime.utcnow().isoformat()
    print "pull", (getattr(args, 'pull'))
    print "push", (getattr(args, 'push'))
    device.start()
コード例 #4
0
ファイル: servers.py プロジェクト: c0ntrol-x/OldSpeak
def execute_command_forwarder():
    from oldspeak.console.parsers.streamer import parser

    args = parser.parse_args(get_sub_parser_argv())
    bootstrap_conf_with_gevent(args)

    device = Device(zmq.FORWARDER, zmq.SUB, zmq.PUB)

    device.bind_in(args.subscriber)
    device.bind_out(args.publisher)
    device.setsockopt_in(zmq.SUBSCRIBE, b'')
    if args.subscriber_hwm:
        device.setsockopt_in(zmq.RCVHWM, args.subscriber_hwm)

    if args.publisher_hwm:
        device.setsockopt_out(zmq.SNDHWM, args.publisher_hwm)

    print "oldspeak forwarder started"
    print "date", datetime.utcnow().isoformat()
    print "subscriber", (getattr(args, 'subscriber'))
    print "publisher", (getattr(args, 'publisher'))
    device.start()