From da39514071a1445605cd61f7e255bbc51f8c64ab Mon Sep 17 00:00:00 2001 From: Kirill Shvakov Date: Fri, 8 Dec 2017 17:02:17 +0200 Subject: [PATCH] client #1600: add network-bandwidth option --- dbms/src/Server/Client.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/dbms/src/Server/Client.cpp b/dbms/src/Server/Client.cpp index 0ca44da6db0..6b41df1ef9c 100644 --- a/dbms/src/Server/Client.cpp +++ b/dbms/src/Server/Client.cpp @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -113,6 +114,7 @@ private: size_t format_max_block_size = 0; /// Max block size for console output. String insert_format; /// Format of INSERT data that is read from stdin in batch mode. size_t insert_format_max_block_size = 0; /// Max block size when reading INSERT data. + size_t network_bandwidth = 0; /// The maximum speed of data exchange over the network for the client in bytes per second. bool has_vertical_output_suffix = false; /// Is \G present at the end of the query string? @@ -408,6 +410,12 @@ private: UInt64 server_version_minor = 0; UInt64 server_revision = 0; + if (network_bandwidth) + { + ThrottlerPtr throttler = std::make_shared(network_bandwidth, 0, ""); + connection->setThrottler(throttler); + } + connection->getServerVersion(server_name, server_version_major, server_version_minor, server_revision); server_version = toString(server_version_major) + "." + toString(server_version_minor) + "." + toString(server_revision); @@ -1266,6 +1274,7 @@ public: ("progress", "print progress even in non-interactive mode") ("version,V", "print version information and exit") ("echo", "in batch mode, print query before execution") + ("network-bandwidth", boost::program_options::value(), "the maximum speed of data exchange over the network for the client in bytes per second.") ("compression", boost::program_options::value(), "enable or disable compression") APPLY_FOR_SETTINGS(DECLARE_SETTING) APPLY_FOR_LIMITS(DECLARE_LIMIT) @@ -1375,6 +1384,8 @@ public: config().setBool("echo", true); if (options.count("time")) print_time_to_stderr = true; + if (options.count("network-bandwidth")) + network_bandwidth = options["network-bandwidth"].as(); if (options.count("compression")) config().setBool("compression", options["compression"].as()); }