From a7a21d2049095e957e5b01ad493ae28346954410 Mon Sep 17 00:00:00 2001 From: Sree Kuchibhotla Date: Wed, 28 Sep 2016 12:38:01 -0700 Subject: [PATCH] Make sync server settings configurable --- src/cpp/server/server_builder.cc | 17 +++++++++++------ test/cpp/rpcmanager/grpc_rpc_manager_test.cc | 2 +- test/cpp/rpcmanager/grpc_rpc_manager_test.h | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cpp/server/server_builder.cc b/src/cpp/server/server_builder.cc index 1a27100be5f..59c40dedaf1 100644 --- a/src/cpp/server/server_builder.cc +++ b/src/cpp/server/server_builder.cc @@ -71,7 +71,6 @@ ServerBuilder::ServerBuilder() memset(&maybe_default_compression_algorithm_, 0, sizeof(maybe_default_compression_algorithm_)); - // Sync server setting defaults sync_server_settings_.min_pollers = 1; sync_server_settings_.max_pollers = INT_MAX; @@ -143,8 +142,8 @@ ServerBuilder& ServerBuilder::SetDefaultCompressionAlgorithm( return *this; } -void ServerBuilder:: SetSyncServerSettings(SyncServerSettings settings) { - sync_server_settings_ = settings; // copy the settings +void ServerBuilder::SetSyncServerSettings(SyncServerSettings settings) { + sync_server_settings_ = settings; // copy the settings } ServerBuilder& ServerBuilder::AddListeningPort( @@ -215,14 +214,20 @@ std::unique_ptr ServerBuilder::BuildAndStart() { new std::vector>()); if (has_sync_methods) { - // If the server has synchronous methods, it will need completion queues to - // handle those methods. + // This is a Sync server + gpr_log(GPR_INFO, + "Synchronous server. Num CQs: %d, Min pollers: %d, Max Pollers: " + "%d, CQ timeout (msec): %d", + sync_server_settings_.num_cqs, sync_server_settings_.min_pollers, + sync_server_settings_.max_pollers, + sync_server_settings_.cq_timeout_msec); + + // Create completion queues to listen to incoming rpc requests for (int i = 0; i < sync_server_settings_.num_cqs; i++) { sync_server_cqs->emplace_back(new ServerCompletionQueue()); } } - // TODO (sreek) Make the number of pollers configurable std::unique_ptr server(new Server( sync_server_cqs, max_receive_message_size_, &args, sync_server_settings_.min_pollers, sync_server_settings_.max_pollers, diff --git a/test/cpp/rpcmanager/grpc_rpc_manager_test.cc b/test/cpp/rpcmanager/grpc_rpc_manager_test.cc index f48ac2716b5..ce43b278560 100644 --- a/test/cpp/rpcmanager/grpc_rpc_manager_test.cc +++ b/test/cpp/rpcmanager/grpc_rpc_manager_test.cc @@ -81,7 +81,7 @@ void GrpcRpcManagerTest::DoWork(void *tag, bool ok) { int main(int argc, char **argv) { grpc::testing::InitTest(&argc, &argv, true); - GrpcRpcManagerTest test_rpc_manager(3, 15, 20); + GrpcRpcManagerTest test_rpc_manager(3, 15); test_rpc_manager.Initialize(); test_rpc_manager.Wait(); diff --git a/test/cpp/rpcmanager/grpc_rpc_manager_test.h b/test/cpp/rpcmanager/grpc_rpc_manager_test.h index 186da81f2fd..0f1d3b3ed2a 100644 --- a/test/cpp/rpcmanager/grpc_rpc_manager_test.h +++ b/test/cpp/rpcmanager/grpc_rpc_manager_test.h @@ -40,7 +40,7 @@ namespace testing { class GrpcRpcManagerTest GRPC_FINAL : public GrpcRpcManager { public: - GrpcRpcManagerTest(int min_pollers, int max_pollers, int max_threads) + GrpcRpcManagerTest(int min_pollers, int max_pollers) : GrpcRpcManager(min_pollers, max_pollers), num_calls_(0){}; grpc::GrpcRpcManager::WorkStatus PollForWork(void **tag,