示例#1
0
文件: arrow.py 项目: ssorj/quiver
    def compute_results(self):
        transfers = list()

        with open(self.transfers_file, "rb") as f:
            for line in f:
                try:
                    transfer = self.transfers_parse_func(line)
                except Exception as e:
                    _plano.error("Failed to parse line '{}': {}", line, e)
                    continue

                transfers.append(transfer)

        self.message_count = len(transfers)

        if self.message_count == 0:
            return

        if self.operation == "send":
            self.first_send_time = transfers[0][1]
            self.last_send_time = transfers[-1][1]

            duration = (self.last_send_time - self.first_send_time) / 1000
        elif self.operation == "receive":
            self.first_receive_time = transfers[0][2]
            self.last_receive_time = transfers[-1][2]

            duration = (self.last_receive_time - self.first_receive_time) / 1000

            self.compute_latencies(transfers)
        else:
            raise Exception()

        if duration > 0:
            self.message_rate = int(round(self.message_count / duration))
示例#2
0
    def capture_transfers(self, transfers_file):
        transfers = list()
        sample = 1000
        count = sample

        for line in _itertools.islice(transfers_file, sample, None, sample):
            count += sample

            try:
                record = self.command.transfers_parse_func(line)
            except Exception as e:
                _plano.error("Failed to parse line '{}': {}", line, e)
                continue

            transfers.append(record)

        self.period_count = count
        self.count = self.previous.count + self.period_count

        if self.period_count > 0 and self.command.operation == "receive":
            latencies = list()

            for send_time, receive_time in transfers:
                latency = receive_time - send_time
                latencies.append(latency)

            if latencies:
                self.latency = int(_numpy.mean(latencies))
示例#3
0
文件: arrow.py 项目: ajssmith/quiver
    def compute_results(self):
        transfers = list()

        with open(self.transfers_file, "rb") as f:
            for line in f:
                try:
                    transfer = self.transfers_parse_func(line)
                except Exception as e:
                    _plano.error("Failed to parse line '{}': {}", line, e)
                    continue

                transfers.append(transfer)

        self.message_count = len(transfers)

        if self.message_count == 0:
            return

        if self.operation == "send":
            self.first_send_time = transfers[0][1]
            self.last_send_time = transfers[-1][1]

            duration = (self.last_send_time - self.first_send_time) / 1000
        elif self.operation == "receive":
            self.first_receive_time = transfers[0][2]
            self.last_receive_time = transfers[-1][2]

            duration = (self.last_receive_time - self.first_receive_time) / 1000

            self.compute_latencies(transfers)
        else:
            raise Exception()

        if duration > 0:
            self.message_rate = int(round(self.message_count / duration))
示例#4
0
文件: arrow.py 项目: tabish121/quiver
    def capture_transfers(self, transfers_file):
        transfers = list()
        count = 0

        for count, line in enumerate(_read_lines(transfers_file)):
            if count % 33 != 0:
                continue

            try:
                record = self.command.transfers_parse_func(line)
            except Exception as e:
                _plano.error("Failed to parse line '{}': {}", line, e)
                continue

            transfers.append(record)

        self.period_count = count
        self.count = self.previous.count + self.period_count

        if self.period_count > 0 and self.command.operation == "receive":
            latencies = list()

            for id_, send_time, receive_time in transfers:
                latency = receive_time - send_time
                latencies.append(latency)

            self.latency = int(_numpy.mean(latencies))
示例#5
0
 def read_transfers():
     with open(self.transfers_file, "rb") as f:
         for line in f:
             try:
                 yield self.transfers_parse_func(line)
             except Exception as e:
                 _plano.error("Failed to parse line '{}': {}", line, e)
                 continue
示例#6
0
文件: arrow.py 项目: ssorj/quiver
    def capture_transfers(self, transfers_file):
        transfers = list()

        for line in _read_lines(transfers_file):
            try:
                record = self.command.transfers_parse_func(line)
            except Exception as e:
                _plano.error("Failed to parse line '{}': {}", line, e)
                continue

            transfers.append(record)

        self.period_count = len(transfers)
        self.count = self.previous.count + self.period_count

        if self.period_count > 0 and self.command.operation == "receive":
            latencies = list()

            for id_, send_time, receive_time in transfers:
                latency = receive_time - send_time
                latencies.append(latency)

            self.latency = int(_numpy.mean(latencies))
示例#7
0
文件: bench.py 项目: kgiusti/quiver
    def run_test(self, sender_impl, server_impl, receiver_impl):
        peer_to_peer = server_impl is None
        port = _plano.random_port()
        server = None

        if server_impl == "activemq":
            if sender_impl == "activemq-jms" and receiver_impl == "activemq-jms":
                port = 61616
            else:
                port = 5672

        if peer_to_peer:
            summary = "{} -> {} ".format(sender_impl, receiver_impl)
            server_name = "none"
        else:
            summary = "{} -> {} -> {} ".format(sender_impl, server_impl,
                                               receiver_impl)
            server_name = server_impl

        test_dir = _plano.join(self.output_dir, sender_impl, server_name,
                               receiver_impl)
        pair_dir = _plano.join(test_dir, "pair")
        server_dir = _plano.join(test_dir, "server")

        pair = _TestPair(self, pair_dir, sender_impl, receiver_impl,
                         peer_to_peer)

        if not peer_to_peer:
            server = _TestServer(server_dir, server_impl)

        if not self.verbose and not self.quiet:
            print("{:.<111} ".format(summary), end="")
            _plano.flush()

        if server is not None:
            try:
                server.start(port)
            except _Timeout as e:
                self.failures.append(str(e))  # XXX capture the combo

                if self.verbose:
                    _plano.error(str(e))
                else:
                    print("FAILED")

                if server is not None:
                    server.print_summary()

        try:
            pair.run(port, self.args)

            if not self.verbose and not self.quiet:
                print("PASSED")
        except KeyboardInterrupt:
            raise
        except _plano.CalledProcessError as e:
            self.failures.append(str(e))  # XXX capture the combo

            if self.verbose:
                _plano.error(str(e))
            elif not self.quiet:
                print("FAILED")

            pair.print_summary()

            if server is not None:
                server.print_summary()
        except:
            _traceback.print_exc()
        finally:
            _plano.flush()

            if server is not None:
                server.stop()

        self.report(pair, server)
示例#8
0
    def run(self):
        args = list()

        if self.duration == 0:
            args += ["--count", self.args.count]
        else:
            args += ["--duration", self.args.duration]

        args += [
            "--body-size",
            self.args.body_size,
            "--credit",
            self.args.credit,
            "--transaction-size",
            self.args.transaction_size,
            "--timeout",
            self.args.timeout,
        ]

        if self.durable:
            args += ["--durable"]

        if self.quiet:
            args += ["--quiet"]

        if self.verbose:
            args += ["--verbose"]

        if self.username:
            args.append("username={}".format(self.username))

        if self.password:
            args.append("password={}".format(self.password))

        if self.args.cert and self.args.key:
            args += ["--key", self.args.key]
            args += ["--cert", self.args.cert]

        args += ["--output", self.output_dir]

        sender_args = [
            "quiver-arrow", "send", self.url, "--impl", self.sender_impl.name
        ] + args
        receiver_args = [
            "quiver-arrow", "receive", self.url, "--impl",
            self.receiver_impl.name
        ] + args

        if self.peer_to_peer:
            receiver_args += ["--server", "--passive"]

        self.start_time = now()

        #_os.environ["DEBUG"] = "*"
        receiver = _plano.start_process(receiver_args)
        #del _os.environ["DEBUG"]

        if self.peer_to_peer:
            _plano.wait_for_port(self.port, host=self.host)

        #_os.environ["PN_TRACE_FRM"] = "1"
        sender = _plano.start_process(sender_args)
        #del _os.environ["PN_TRACE_FRM"]

        try:
            if not self.quiet:
                self.print_status(sender, receiver)

            _plano.check_process(receiver)
            _plano.check_process(sender)
        except _plano.CalledProcessError as e:
            _plano.error(e)
        finally:
            _plano.stop_process(sender)
            _plano.stop_process(receiver)

        if (sender.returncode, receiver.returncode) != (0, 0):
            _plano.exit(1)

        if not self.quiet:
            self.print_summary()
示例#9
0
文件: server.py 项目: ssorj/quiver
 def error(self, message, *args):
     _plano.error(message, *args)
示例#10
0
文件: bench.py 项目: ssorj/quiver
    def run_test(self, sender_impl, server_impl, receiver_impl):
        peer_to_peer = server_impl is None
        port = _plano.random_port()
        server = None

        if server_impl == "activemq":
            if sender_impl == "activemq-jms" and receiver_impl == "activemq-jms":
                port = 61616
            else:
                port = 5672

        if peer_to_peer:
            summary = "{} -> {} ".format(sender_impl, receiver_impl)
            server_name = "none"
        else:
            summary = "{} -> {} -> {} ".format(sender_impl, server_impl, receiver_impl)
            server_name = server_impl

        test_dir = _plano.join(self.output_dir, sender_impl, server_name, receiver_impl)
        pair_dir = _plano.join(test_dir, "pair")
        server_dir = _plano.join(test_dir, "server")

        pair = _TestPair(self, pair_dir, sender_impl, receiver_impl, peer_to_peer)

        if not peer_to_peer:
            server = _TestServer(server_dir, server_impl)

        if not self.verbose and not self.quiet:
            print("{:.<111} ".format(summary), end="")
            _plano.flush()

        if server is not None:
            try:
                server.start(port)
            except _Timeout as e:
                self.failures.append(str(e)) # XXX capture the combo

                if self.verbose:
                    _plano.error(str(e))
                else:
                    print("FAILED")

                if server is not None:
                    server.print_summary()

        try:
            pair.run(port, self.args)

            if not self.verbose and not self.quiet:
                print("PASSED")
        except KeyboardInterrupt:
            raise
        except _plano.CalledProcessError as e:
            self.failures.append(str(e)) # XXX capture the combo

            if self.verbose:
                _plano.error(str(e))
            elif not self.quiet:
                print("FAILED")

            pair.print_summary()

            if server is not None:
                server.print_summary()
        except:
            _traceback.print_exc()
        finally:
            _plano.flush()

            if server is not None:
                server.stop()

        self.report(pair, server)
示例#11
0
 def error(self, message, *args):
     _plano.error(message, *args)
示例#12
0
文件: pair.py 项目: ssorj/quiver
    def run(self):
        args = list()

        if self.duration == 0:
            args += ["--count", self.args.count]
        else:
            args += ["--duration", self.args.duration]

        args += [
            "--body-size", self.args.body_size,
            "--credit", self.args.credit,
            "--transaction-size", self.args.transaction_size,
            "--timeout", self.args.timeout,
        ]

        if self.durable:
            args += ["--durable"]

        if self.quiet:
            args += ["--quiet"]

        if self.verbose:
            args += ["--verbose"]

        if self.args.cert and self.args.key:
            args += ["--key", self.args.key]
            args += ["--cert", self.args.cert]

        args += ["--output", self.output_dir]

        sender_args = ["quiver-arrow", "send", self.url, "--impl", self.sender_impl.name] + args
        receiver_args = ["quiver-arrow", "receive", self.url, "--impl", self.receiver_impl.name] + args

        if self.peer_to_peer:
            receiver_args += ["--server", "--passive"]

        self.start_time = now()

        #_os.environ["DEBUG"] = "*"
        receiver = _plano.start_process(receiver_args)
        #del _os.environ["DEBUG"]

        if self.peer_to_peer:
            _plano.wait_for_port(self.port, host=self.host)

        #_os.environ["PN_TRACE_FRM"] = "1"
        sender = _plano.start_process(sender_args)
        #del _os.environ["PN_TRACE_FRM"]

        try:
            if not self.quiet:
                self.print_status(sender, receiver)

            _plano.check_process(receiver)
            _plano.check_process(sender)
        except _plano.CalledProcessError as e:
            _plano.error(e)
        finally:
            _plano.stop_process(sender)
            _plano.stop_process(receiver)

        if (sender.returncode, receiver.returncode) != (0, 0):
            _plano.exit(1)

        if not self.quiet:
            self.print_summary()