From 63d24f1c7db322d4e0e90dd6b682cef80cc98b1e Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 13 May 2016 14:36:09 -0700 Subject: [PATCH 1/2] Make qps workers connect before even warmup stage begins --- include/grpc++/impl/codegen/channel_interface.h | 9 +++++++++ test/cpp/qps/client.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/include/grpc++/impl/codegen/channel_interface.h b/include/grpc++/impl/codegen/channel_interface.h index 6fcd5c315ca..b45d803b81f 100644 --- a/include/grpc++/impl/codegen/channel_interface.h +++ b/include/grpc++/impl/codegen/channel_interface.h @@ -85,6 +85,15 @@ class ChannelInterface { return WaitForStateChangeImpl(last_observed, deadline_tp.raw_time()); } + /// Wait for this channel to be connected + template bool WaitForConnected(T deadline) { + grpc_connectivity_state state; + while ((state = GetState(true)) != GRPC_CHANNEL_READY) { + if (!WaitForStateChange(state, deadline)) return false; + } + return true; + } + private: template friend class ::grpc::ClientReader; diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 175529f01b2..f4292d89113 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -41,6 +41,7 @@ #include #include #include +#include #include #include @@ -315,6 +316,8 @@ class ClientImpl : public Client { target, config.security_params().server_host_override(), config.has_security_params(), !config.security_params().use_test_ca(), std::shared_ptr(), args); + gpr_log(GPR_INFO, "Connecting to %s", target.c_str()); + GPR_ASSERT(channel_->WaitForConnected(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(30, GPR_TIMESPAN)))); stub_ = create_stub(channel_); } Channel* get_channel() { return channel_.get(); } From 52237e3a961e3b4a025399ec7a0abe57a16331d6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 13 May 2016 14:37:25 -0700 Subject: [PATCH 2/2] clang-format --- include/grpc++/impl/codegen/channel_interface.h | 3 ++- test/cpp/qps/client.h | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/grpc++/impl/codegen/channel_interface.h b/include/grpc++/impl/codegen/channel_interface.h index b45d803b81f..cf784381173 100644 --- a/include/grpc++/impl/codegen/channel_interface.h +++ b/include/grpc++/impl/codegen/channel_interface.h @@ -86,7 +86,8 @@ class ChannelInterface { } /// Wait for this channel to be connected - template bool WaitForConnected(T deadline) { + template + bool WaitForConnected(T deadline) { grpc_connectivity_state state; while ((state = GetState(true)) != GRPC_CHANNEL_READY) { if (!WaitForStateChange(state, deadline)) return false; diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index f4292d89113..2a89eb80182 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -38,10 +38,10 @@ #include #include +#include #include #include #include -#include #include #include @@ -317,7 +317,9 @@ class ClientImpl : public Client { config.has_security_params(), !config.security_params().use_test_ca(), std::shared_ptr(), args); gpr_log(GPR_INFO, "Connecting to %s", target.c_str()); - GPR_ASSERT(channel_->WaitForConnected(gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), gpr_time_from_seconds(30, GPR_TIMESPAN)))); + GPR_ASSERT(channel_->WaitForConnected( + gpr_time_add(gpr_now(GPR_CLOCK_REALTIME), + gpr_time_from_seconds(30, GPR_TIMESPAN)))); stub_ = create_stub(channel_); } Channel* get_channel() { return channel_.get(); }