From 00f2c93460a333c5951bef5de4d097b27407e5e7 Mon Sep 17 00:00:00 2001 From: "Nicolas \"Pixel\" Noble" Date: Tue, 4 Apr 2017 20:38:14 +0200 Subject: [PATCH 01/69] Avoid pollution from ares.h into the global space. --- src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h | 2 -- src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h index 334feaa2aba..fa22e11be4d 100644 --- a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h +++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h @@ -34,8 +34,6 @@ #ifndef GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H #define GRPC_CORE_EXT_RESOLVER_DNS_C_ARES_GRPC_ARES_EV_DRIVER_H -#include - #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/iomgr/pollset_set.h" diff --git a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c index fab4f0c9772..dd102e5dd6b 100644 --- a/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c +++ b/src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver_posix.c @@ -34,6 +34,8 @@ #include "src/core/lib/iomgr/port.h" #if GRPC_ARES == 1 && defined(GRPC_POSIX_SOCKET) +#include + #include "src/core/ext/resolver/dns/c_ares/grpc_ares_ev_driver.h" #include From 91455a9915df5f0663abe4aaed05a529ab2d1d35 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 3 May 2017 09:14:10 -0700 Subject: [PATCH 02/69] Apply a few recent changes from the wire guide on grpc.io. --- doc/PROTOCOL-HTTP2.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/doc/PROTOCOL-HTTP2.md b/doc/PROTOCOL-HTTP2.md index 68af1f2ca19..29d3cc2e767 100644 --- a/doc/PROTOCOL-HTTP2.md +++ b/doc/PROTOCOL-HTTP2.md @@ -24,7 +24,8 @@ Request-Headers are delivered as HTTP2 headers in HEADERS + CONTINUATION frames. * **Call-Definition** → Method Scheme Path TE [Authority] [Timeout] Content-Type [Message-Type] [Message-Encoding] [Message-Accept-Encoding] [User-Agent] * **Method** → ":method POST" * **Scheme** → ":scheme " ("http" / "https") -* **Path** → ":path" {_path identifying method within exposed API_} +* **Path** → ":path" "/" Service-Name "/" {_method name_} +* **Service-Name** → {_IDL-specific service name_} * **Authority** → ":authority" {_virtual host name of authority_} * **TE** → "te" "trailers" # Used to detect incompatible proxies * **Timeout** → "grpc-timeout" TimeoutValue TimeoutUnit @@ -51,6 +52,13 @@ Request-Headers are delivered as HTTP2 headers in HEADERS + CONTINUATION frames. HTTP2 requires that reserved headers, ones starting with ":" appear before all other headers. Additionally implementations should send **Timeout** immediately after the reserved headers and they should send the **Call-Definition** headers before sending **Custom-Metadata**. +Some gRPC implementations may allow the **Path** format shown above +to be overridden, but this functionality is strongly discouraged. +gRPC does not go out of its way to break users that are using this kind +of override, but we do not actively support it, and some functionality +(e.g., service config support) will not work when the path is not of +the form shown above. + If **Timeout** is omitted a server should assume an infinite timeout. Client implementations are free to send a default minimum timeout based on their deployment requirements. **Custom-Metadata** is an arbitrary set of key-value pairs defined by the application layer. Header names starting with "grpc-" but not listed here are reserved for future GRPC use and should not be used by applications as **Custom-Metadata**. @@ -238,10 +246,10 @@ If a detectable connection failure occurs on the client all calls will be closed ### Appendix A - GRPC for Protobuf -The service interfaces declared by protobuf are easily mapped onto GRPC by code generation extensions to protoc. The following defines the mapping to be used - +The service interfaces declared by protobuf are easily mapped onto GRPC by +code generation extensions to protoc. The following defines the mapping +to be used. -* **Path** → / Service-Name / {_method name_} * **Service-Name** → ?( {_proto package name_} "." ) {_service name_} * **Message-Type** → {_fully qualified proto message name_} * **Content-Type** → "application/grpc+proto" From 837375048400372ffb97c06a5da16ec515cdd118 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 9 Jun 2017 07:27:16 -0700 Subject: [PATCH 03/69] Change default for SETTINGS_MAX_HEADER_LIST_SIZE from 16KiB to 8KiB. --- src/core/ext/transport/chttp2/transport/chttp2_transport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index bdebc8eeecf..ca82d4d818c 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -52,7 +52,7 @@ #define DEFAULT_CONNECTION_WINDOW_TARGET (1024 * 1024) #define MAX_WINDOW 0x7fffffffu #define MAX_WRITE_BUFFER_SIZE (64 * 1024 * 1024) -#define DEFAULT_MAX_HEADER_LIST_SIZE (16 * 1024) +#define DEFAULT_MAX_HEADER_LIST_SIZE (8 * 1024) #define DEFAULT_CLIENT_KEEPALIVE_TIME_MS INT_MAX #define DEFAULT_CLIENT_KEEPALIVE_TIMEOUT_MS 20000 /* 20 seconds */ From 9f639871cc26b7f5bfb87fc8951c2249977913e5 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 9 Jun 2017 14:19:35 -0700 Subject: [PATCH 04/69] s/CURRENT_TIMESTAMP/_DATE/ in BQ, for caching --- tools/run_tests/run_tests.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/run_tests/run_tests.py b/tools/run_tests/run_tests.py index 35fe42c6b79..7bb668ac628 100755 --- a/tools/run_tests/run_tests.py +++ b/tools/run_tests/run_tests.py @@ -81,7 +81,7 @@ def get_flaky_tests(limit=None): FROM [grpc-testing:jenkins_test_results.aggregate_results] WHERE - timestamp >= DATE_ADD(DATE(CURRENT_TIMESTAMP()), -1, "WEEK") + timestamp >= DATE_ADD(CURRENT_DATE(), -1, "WEEK") AND NOT REGEXP_MATCH(job_name, '.*portability.*') AND REGEXP_MATCH(job_name, '.*master.*') GROUP BY From 1d8e46559bc109e3108063e98e48e8011d552958 Mon Sep 17 00:00:00 2001 From: Makarand Dharmapurikar Date: Mon, 12 Jun 2017 13:18:17 -0700 Subject: [PATCH 05/69] fixes #11473 --- third_party/cares/cares.BUILD | 1 + 1 file changed, 1 insertion(+) diff --git a/third_party/cares/cares.BUILD b/third_party/cares/cares.BUILD index 3583720ef3d..978e9b1ed9d 100644 --- a/third_party/cares/cares.BUILD +++ b/third_party/cares/cares.BUILD @@ -78,6 +78,7 @@ cc_library( "cares/ares_version.h", "cares/bitncmp.h", "cares/config-win32.h", + "cares/nameser.h", "cares/setup_once.h", ] + select({ ":darwin": ["config_darwin/ares_config.h"], From 0d8b988fbb7d4546675ff3417f2ec27edf5ef70a Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Fri, 16 Jun 2017 15:59:12 -0700 Subject: [PATCH 06/69] Update PHP protoc plugin generation - Use docblocks instead of single line comments - Escape '*/' - Indent 4 spaces to match protobuf - Use single line namespace to match protobuf --- src/compiler/php_generator.cc | 40 ++++++++++++++++------------ src/compiler/php_generator_helpers.h | 15 ++++++++++- 2 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/compiler/php_generator.cc b/src/compiler/php_generator.cc index a7387d7223f..6d34761fdfd 100644 --- a/src/compiler/php_generator.cc +++ b/src/compiler/php_generator.cc @@ -52,14 +52,16 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) { vars["input_type_id"] = MessageIdentifierName(input_type->full_name()); vars["output_type_id"] = MessageIdentifierName(output_type->full_name()); - out->Print(GetPHPComments(method, " //").c_str()); + out->Print("/**\n"); + out->Print(GetPHPComments(method, " *").c_str()); if (method->client_streaming()) { out->Print(vars, - " // @param array $$metadata metadata\n" - " // @param array $$options call options\n" + " * @param array $$metadata metadata\n" + " * @param array $$options call options\n */\n" "public function $name$($$metadata = [], " "$$options = []) {\n"); out->Indent(); + out->Indent(); if (method->server_streaming()) { out->Print("return $$this->_bidiRequest("); } else { @@ -71,12 +73,13 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) { "$$metadata, $$options);\n"); } else { out->Print(vars, - " // @param \\$input_type_id$ $$argument input argument\n" - " // @param array $$metadata metadata\n" - " // @param array $$options call options\n" + " * @param \\$input_type_id$ $$argument input argument\n" + " * @param array $$metadata metadata\n" + " * @param array $$options call options\n */\n" "public function $name$(\\$input_type_id$ $$argument,\n" " $$metadata = [], $$options = []) {\n"); out->Indent(); + out->Indent(); if (method->server_streaming()) { out->Print("return $$this->_serverStreamRequest("); } else { @@ -89,26 +92,32 @@ void PrintMethod(const MethodDescriptor *method, Printer *out) { "$$metadata, $$options);\n"); } out->Outdent(); + out->Outdent(); out->Print("}\n\n"); } // Prints out the service descriptor object void PrintService(const ServiceDescriptor *service, Printer *out) { map vars; - out->Print(GetPHPComments(service, "//").c_str()); + out->Print("/**\n"); + out->Print(GetPHPComments(service, " *").c_str()); + out->Print(" */\n"); vars["name"] = service->name(); out->Print(vars, "class $name$Client extends \\Grpc\\BaseStub {\n\n"); out->Indent(); + out->Indent(); out->Print( - " // @param string $$hostname hostname\n" - " // @param array $$opts channel options\n" - " // @param \\Grpc\\Channel $$channel (optional) re-use channel " - "object\n" + "/**\n * @param string $$hostname hostname\n" + " * @param array $$opts channel options\n" + " * @param \\Grpc\\Channel $$channel (optional) re-use channel " + "object\n */\n" "public function __construct($$hostname, $$opts, " "$$channel = null) {\n"); out->Indent(); + out->Indent(); out->Print("parent::__construct($$hostname, $$opts, $$channel);\n"); out->Outdent(); + out->Outdent(); out->Print("}\n\n"); for (int i = 0; i < service->method_count(); i++) { grpc::string method_name = @@ -116,7 +125,8 @@ void PrintService(const ServiceDescriptor *service, Printer *out) { PrintMethod(service->method(i), out); } out->Outdent(); - out->Print("}\n\n"); + out->Outdent(); + out->Print("}\n"); } } @@ -138,13 +148,9 @@ grpc::string GenerateFile(const FileDescriptor *file, map vars; vars["package"] = MessageIdentifierName(file->package()); - out.Print(vars, "namespace $package$ {\n\n"); - out.Indent(); + out.Print(vars, "namespace $package$;\n\n"); PrintService(service, &out); - - out.Outdent(); - out.Print("}\n"); } return output; } diff --git a/src/compiler/php_generator_helpers.h b/src/compiler/php_generator_helpers.h index 8e358093579..8f59b90d049 100644 --- a/src/compiler/php_generator_helpers.h +++ b/src/compiler/php_generator_helpers.h @@ -39,12 +39,25 @@ inline grpc::string GetPHPServiceFilename( return oss.str() + "/" + service->name() + "Client.php"; } +// ReplaceAll replaces all instances of search with replace in s. +inline grpc::string ReplaceAll(grpc::string s, const grpc::string &search, + const grpc::string &replace) { + size_t pos = 0; + while ((pos = s.find(search, pos)) != grpc::string::npos) { + s.replace(pos, search.length(), replace); + pos += replace.length(); + } + return s; +} + // Get leading or trailing comments in a string. Comment lines start with "// ". // Leading detached comments are put in in front of leading comments. template inline grpc::string GetPHPComments(const DescriptorType *desc, grpc::string prefix) { - return grpc_generator::GetPrefixedComments(desc, true, prefix); + return ReplaceAll(grpc_generator::GetPrefixedComments(desc, true, prefix), + "*/", + "*/"); } } // namespace grpc_php_generator From e48949f0b44d0f8755cbbc3837a2b591867cd0bf Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 19 Jun 2017 13:57:32 -0700 Subject: [PATCH 07/69] Make grpc::Alarm non-copyable --- include/grpc++/alarm.h | 21 +++++++++++++++++++-- test/cpp/common/alarm_cpp_test.cc | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/include/grpc++/alarm.h b/include/grpc++/alarm.h index bd000cf4f79..ed8dacbc944 100644 --- a/include/grpc++/alarm.h +++ b/include/grpc++/alarm.h @@ -52,8 +52,25 @@ class Alarm : private GrpcLibraryCodegen { alarm_(grpc_alarm_create(cq->cq(), TimePoint(deadline).raw_time(), static_cast(&tag_))) {} + /// Alarms aren't copyable. + Alarm(const Alarm&) = delete; + Alarm& operator=(const Alarm&) = delete; + + /// Alarms are movable. + Alarm(Alarm&& rhs) : tag_(rhs.tag_), alarm_(rhs.alarm_) { + rhs.alarm_ = nullptr; + } + Alarm& operator=(Alarm&& rhs) { + tag_ = rhs.tag_; + alarm_ = rhs.alarm_; + rhs.alarm_ = nullptr; + return *this; + } + /// Destroy the given completion queue alarm, cancelling it in the process. - ~Alarm() { grpc_alarm_destroy(alarm_); } + ~Alarm() { + if (alarm_ != nullptr) grpc_alarm_destroy(alarm_); + } /// Cancel a completion queue alarm. Calling this function over an alarm that /// has already fired has no effect. @@ -73,7 +90,7 @@ class Alarm : private GrpcLibraryCodegen { }; AlarmEntry tag_; - grpc_alarm* const alarm_; // owned + grpc_alarm* alarm_; // owned }; } // namespace grpc diff --git a/test/cpp/common/alarm_cpp_test.cc b/test/cpp/common/alarm_cpp_test.cc index 3e4999994a1..760dd7b956a 100644 --- a/test/cpp/common/alarm_cpp_test.cc +++ b/test/cpp/common/alarm_cpp_test.cc @@ -40,6 +40,25 @@ TEST(AlarmTest, RegularExpiry) { EXPECT_EQ(junk, output_tag); } +TEST(AlarmTest, Move) { + CompletionQueue cq; + void* junk = reinterpret_cast(1618033); + Alarm first(&cq, grpc_timeout_seconds_to_deadline(1), junk); + // Move constructor. + Alarm second(std::move(first)); + // Moving assignment. + first = std::move(second); + + void* output_tag; + bool ok; + const CompletionQueue::NextStatus status = cq.AsyncNext( + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2)); + + EXPECT_EQ(status, CompletionQueue::GOT_EVENT); + EXPECT_TRUE(ok); + EXPECT_EQ(junk, output_tag); +} + TEST(AlarmTest, RegularExpiryChrono) { CompletionQueue cq; void* junk = reinterpret_cast(1618033); From fc539eb19334bdfde8bc798d94ccb56b686e5193 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 21 Jun 2017 16:17:35 -0700 Subject: [PATCH 08/69] Re-enable public constructor for ClientAsyncResponseReader to avoid busting client that bypassed code generator. This code is deprecated-on-arrival as it is a performance pessimization. This code path should not be used. --- .../grpc++/impl/codegen/async_unary_call.h | 90 ++++++++++++++----- include/grpc++/impl/codegen/call.h | 20 +++++ 2 files changed, 89 insertions(+), 21 deletions(-) diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h index 4aa4e25a9e9..de0ab2372a6 100644 --- a/include/grpc++/impl/codegen/async_unary_call.h +++ b/include/grpc++/impl/codegen/async_unary_call.h @@ -87,6 +87,28 @@ class ClientAsyncResponseReader final ClientAsyncResponseReader(call, context, request); } + /// TODO(vjpai): Delete the below constructor + /// PLEASE DO NOT USE THIS CONSTRUCTOR IN NEW CODE + /// This code is only present as a short-term workaround + /// for users that bypassed the code-generator and directly + /// created this struct rather than properly using a stub. + /// This code will not remain a valid public constructor for long. + template + ClientAsyncResponseReader(ChannelInterface* channel, CompletionQueue* cq, + const RpcMethod& method, ClientContext* context, + const W& request) + : context_(context), + call_(channel->CreateCall(method, context, cq)), + collection_(std::make_shared()) { + collection_->init_buf_.SetCollection(collection_); + collection_->init_buf_.SendInitialMetadata( + context->send_initial_metadata_, context->initial_metadata_flags()); + // TODO(ctiller): don't assert + GPR_CODEGEN_ASSERT(collection_->init_buf_.SendMessage(request).ok()); + collection_->init_buf_.ClientSendClose(); + call_.PerformOps(&collection_->init_buf_); + } + // always allocated against a call arena, no memory free required static void operator delete(void* ptr, std::size_t size) { assert(size == sizeof(ClientAsyncResponseReader)); @@ -101,9 +123,18 @@ class ClientAsyncResponseReader final void ReadInitialMetadata(void* tag) { GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - meta_buf_.set_output_tag(tag); - meta_buf_.RecvInitialMetadata(context_); - call_.PerformOps(&meta_buf_); + Ops& o = ops; + + // TODO(vjpai): Remove the collection_ specialization as soon + // as the public constructor is deleted + if (collection_) { + o = *collection_; + collection_->meta_buf_.SetCollection(collection_); + } + + o.meta_buf_.set_output_tag(tag); + o.meta_buf_.RecvInitialMetadata(context_); + call_.PerformOps(&o.meta_buf_); } /// See \a ClientAysncResponseReaderInterface::Finish for semantics. @@ -112,14 +143,23 @@ class ClientAsyncResponseReader final /// - the \a ClientContext associated with this call is updated with /// possible initial and trailing metadata sent from the server. void Finish(R* msg, Status* status, void* tag) { - finish_buf_.set_output_tag(tag); + Ops& o = ops; + + // TODO(vjpai): Remove the collection_ specialization as soon + // as the public constructor is deleted + if (collection_) { + o = *collection_; + collection_->finish_buf_.SetCollection(collection_); + } + + o.finish_buf_.set_output_tag(tag); if (!context_->initial_metadata_received_) { - finish_buf_.RecvInitialMetadata(context_); + o.finish_buf_.RecvInitialMetadata(context_); } - finish_buf_.RecvMessage(msg); - finish_buf_.AllowNoMessage(); - finish_buf_.ClientRecvStatus(context_, status); - call_.PerformOps(&finish_buf_); + o.finish_buf_.RecvMessage(msg); + o.finish_buf_.AllowNoMessage(); + o.finish_buf_.ClientRecvStatus(context_, status); + call_.PerformOps(&o.finish_buf_); } private: @@ -129,25 +169,33 @@ class ClientAsyncResponseReader final template ClientAsyncResponseReader(Call call, ClientContext* context, const W& request) : context_(context), call_(call) { - init_buf_.SendInitialMetadata(context->send_initial_metadata_, - context->initial_metadata_flags()); + ops.init_buf_.SendInitialMetadata(context->send_initial_metadata_, + context->initial_metadata_flags()); // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(init_buf_.SendMessage(request).ok()); - init_buf_.ClientSendClose(); - call_.PerformOps(&init_buf_); + GPR_CODEGEN_ASSERT(ops.init_buf_.SendMessage(request).ok()); + ops.init_buf_.ClientSendClose(); + call_.PerformOps(&ops.init_buf_); } // disable operator new static void* operator new(std::size_t size); static void* operator new(std::size_t size, void* p) { return p; } - SneakyCallOpSet - init_buf_; - CallOpSet meta_buf_; - CallOpSet, - CallOpClientRecvStatus> - finish_buf_; + // TODO(vjpai): Remove the reference to CallOpSetCollectionInterface + // as soon as the related workaround (public constructor) is deleted + struct Ops : public CallOpSetCollectionInterface { + SneakyCallOpSet + init_buf_; + CallOpSet meta_buf_; + CallOpSet, + CallOpClientRecvStatus> + finish_buf_; + } ops; + + // TODO(vjpai): Remove the collection_ as soon as the related workaround + // (public constructor) is deleted + std::shared_ptr collection_; }; /// Async server-side API for handling unary calls, where the single diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index 2ded2d97762..dba53bc4273 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -544,6 +544,11 @@ class CallOpClientRecvStatus { grpc_slice error_message_; }; +/// TODO(vjpai): Remove the existence of CallOpSetCollectionInterface +/// and references to it. This code is deprecated-on-arrival and is +/// only added for users that bypassed the code-generator. +class CallOpSetCollectionInterface {}; + /// An abstract collection of call ops, used to generate the /// grpc_call_op structure to pass down to the lower layers, /// and as it is-a CompletionQueueTag, also massages the final @@ -554,6 +559,18 @@ class CallOpSetInterface : public CompletionQueueTag { /// Fills in grpc_op, starting from ops[*nops] and moving /// upwards. virtual void FillOps(grpc_call* call, grpc_op* ops, size_t* nops) = 0; + + /// TODO(vjpai): Remove the SetCollection method and comment. This is only + /// a short-term workaround for users that bypassed the code generator + /// Mark this as belonging to a collection if needed + void SetCollection(std::shared_ptr collection) { + collection_ = collection; + } + + protected: + /// TODO(vjpai): Remove the collection_ field once the idea of bypassing the + /// code generator is forbidden. This is already deprecated + std::shared_ptr collection_; }; /// Primary implementaiton of CallOpSetInterface. @@ -594,6 +611,9 @@ class CallOpSet : public CallOpSetInterface, this->Op6::FinishOp(status); *tag = return_tag_; g_core_codegen_interface->grpc_call_unref(call_); + // TODO(vjpai): Remove the reference to collection_ once the idea of + // bypassing the code generator is forbidden. It is already deprecated + collection_.reset(); return true; } From 7cd1425e29274a32bdbf253a586dbca2318dfb29 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 22 Jun 2017 10:49:43 -0700 Subject: [PATCH 09/69] Fix handling of send_message before send_initial_metadata in compress filter. --- .../message_compress_filter.c | 35 +++++--- test/core/end2end/tests/compressed_payload.c | 89 +++++++++++++------ 2 files changed, 85 insertions(+), 39 deletions(-) diff --git a/src/core/ext/filters/http/message_compress/message_compress_filter.c b/src/core/ext/filters/http/message_compress/message_compress_filter.c index 04cb1d94f80..71a8bc5bec2 100644 --- a/src/core/ext/filters/http/message_compress/message_compress_filter.c +++ b/src/core/ext/filters/http/message_compress/message_compress_filter.c @@ -255,6 +255,23 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx, } } +static void handle_send_message_batch(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + grpc_transport_stream_op_batch *op, + bool has_compression_algorithm) { + call_data *calld = elem->call_data; + if (!skip_compression(elem, op->payload->send_message.send_message->flags, + has_compression_algorithm)) { + calld->send_op = op; + calld->send_length = op->payload->send_message.send_message->length; + calld->send_flags = op->payload->send_message.send_message->flags; + continue_send_message(exec_ctx, elem); + } else { + /* pass control down the stack */ + grpc_call_next_op(exec_ctx, elem, op); + } +} + static void compress_start_transport_stream_op_batch( grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_transport_stream_op_batch *op) { @@ -307,8 +324,9 @@ static void compress_start_transport_stream_op_batch( goto retry_send_im; } if (cur != INITIAL_METADATA_UNSEEN) { - grpc_call_next_op(exec_ctx, elem, - (grpc_transport_stream_op_batch *)cur); + handle_send_message_batch(exec_ctx, elem, + (grpc_transport_stream_op_batch *)cur, + has_compression_algorithm); } } } @@ -325,17 +343,8 @@ static void compress_start_transport_stream_op_batch( break; case HAS_COMPRESSION_ALGORITHM: case NO_COMPRESSION_ALGORITHM: - if (!skip_compression(elem, - op->payload->send_message.send_message->flags, - cur == HAS_COMPRESSION_ALGORITHM)) { - calld->send_op = op; - calld->send_length = op->payload->send_message.send_message->length; - calld->send_flags = op->payload->send_message.send_message->flags; - continue_send_message(exec_ctx, elem); - } else { - /* pass control down the stack */ - grpc_call_next_op(exec_ctx, elem, op); - } + handle_send_message_batch(exec_ctx, elem, op, + cur == HAS_COMPRESSION_ALGORITHM); break; default: if (cur & CANCELLED_BIT) { diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 35e2fd13ddf..e5e0a5ead42 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -274,7 +274,8 @@ static void request_with_payload_template( grpc_compression_algorithm expected_algorithm_from_client, grpc_compression_algorithm expected_algorithm_from_server, grpc_metadata *client_init_metadata, bool set_server_level, - grpc_compression_level server_compression_level) { + grpc_compression_level server_compression_level, + bool send_message_before_initial_metadata) { grpc_call *c; grpc_call *s; grpc_slice request_payload_slice; @@ -330,6 +331,20 @@ static void request_with_payload_template( grpc_metadata_array_init(&request_metadata_recv); grpc_call_details_init(&call_details); + if (send_message_before_initial_metadata) { + request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = request_payload; + op->flags = client_send_flags_bitmask; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(2), true); + } + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; @@ -394,23 +409,21 @@ static void request_with_payload_template( GPR_ASSERT(GRPC_CALL_OK == error); for (int i = 0; i < 2; i++) { - request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); - memset(ops, 0, sizeof(ops)); - op = ops; - op->op = GRPC_OP_SEND_MESSAGE; - op->data.send_message.send_message = request_payload; - op->flags = client_send_flags_bitmask; - op->reserved = NULL; - op++; - op->op = GRPC_OP_RECV_MESSAGE; - op->data.recv_message.recv_message = &response_payload_recv; - op->flags = 0; - op->reserved = NULL; - op++; - error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); - GPR_ASSERT(GRPC_CALL_OK == error); + if (i > 0 || !send_message_before_initial_metadata) { + request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = request_payload; + op->flags = client_send_flags_bitmask; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(2), 1); + } memset(ops, 0, sizeof(ops)); op = ops; @@ -421,6 +434,7 @@ static void request_with_payload_template( op++; error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(102), 1); cq_verify(cqv); @@ -438,8 +452,19 @@ static void request_with_payload_template( op++; error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); GPR_ASSERT(GRPC_CALL_OK == error); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &response_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(103), 1); - CQ_EXPECT_COMPLETION(cqv, tag(2), 1); + CQ_EXPECT_COMPLETION(cqv, tag(3), 1); cq_verify(cqv); GPR_ASSERT(response_payload_recv->type == GRPC_BB_RAW); @@ -469,7 +494,7 @@ static void request_with_payload_template( op->flags = 0; op->reserved = NULL; op++; - error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(3), NULL); + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(4), NULL); GPR_ASSERT(GRPC_CALL_OK == error); memset(ops, 0, sizeof(ops)); @@ -486,7 +511,7 @@ static void request_with_payload_template( GPR_ASSERT(GRPC_CALL_OK == error); CQ_EXPECT_COMPLETION(cqv, tag(1), 1); - CQ_EXPECT_COMPLETION(cqv, tag(3), 1); + CQ_EXPECT_COMPLETION(cqv, tag(4), 1); CQ_EXPECT_COMPLETION(cqv, tag(101), 1); CQ_EXPECT_COMPLETION(cqv, tag(104), 1); cq_verify(cqv); @@ -526,7 +551,7 @@ static void test_invoke_request_with_exceptionally_uncompressed_payload( config, "test_invoke_request_with_exceptionally_uncompressed_payload", GRPC_WRITE_NO_COMPRESS, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, NULL, false, - /* ignored */ GRPC_COMPRESS_LEVEL_NONE); + /* ignored */ GRPC_COMPRESS_LEVEL_NONE, false); } static void test_invoke_request_with_uncompressed_payload( @@ -534,7 +559,8 @@ static void test_invoke_request_with_uncompressed_payload( request_with_payload_template( config, "test_invoke_request_with_uncompressed_payload", 0, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, - GRPC_COMPRESS_NONE, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE); + GRPC_COMPRESS_NONE, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE, + false); } static void test_invoke_request_with_compressed_payload( @@ -542,7 +568,17 @@ static void test_invoke_request_with_compressed_payload( request_with_payload_template( config, "test_invoke_request_with_compressed_payload", 0, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, - GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE); + GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE, + false); +} + +static void test_invoke_request_with_send_message_before_initial_metadata( + grpc_end2end_test_config config) { + request_with_payload_template( + config, "test_invoke_request_with_compressed_payload", 0, + GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_GZIP, + GRPC_COMPRESS_GZIP, NULL, false, /* ignored */ GRPC_COMPRESS_LEVEL_NONE, + true); } static void test_invoke_request_with_server_level( @@ -550,7 +586,7 @@ static void test_invoke_request_with_server_level( request_with_payload_template( config, "test_invoke_request_with_server_level", 0, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE /* ignored */, - NULL, true, GRPC_COMPRESS_LEVEL_HIGH); + NULL, true, GRPC_COMPRESS_LEVEL_HIGH, false); } static void test_invoke_request_with_compressed_payload_md_override( @@ -574,21 +610,21 @@ static void test_invoke_request_with_compressed_payload_md_override( config, "test_invoke_request_with_compressed_payload_md_override_1", 0, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, &gzip_compression_override, false, - /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false); /* Channel default DEFLATE, call override to GZIP */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_2", 0, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_GZIP, GRPC_COMPRESS_NONE, &gzip_compression_override, false, - /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false); /* Channel default DEFLATE, call override to NONE (aka IDENTITY) */ request_with_payload_template( config, "test_invoke_request_with_compressed_payload_md_override_3", 0, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, GRPC_COMPRESS_NONE, &identity_compression_override, false, - /*ignored*/ GRPC_COMPRESS_LEVEL_NONE); + /*ignored*/ GRPC_COMPRESS_LEVEL_NONE, false); } static void test_invoke_request_with_disabled_algorithm( @@ -602,6 +638,7 @@ void compressed_payload(grpc_end2end_test_config config) { test_invoke_request_with_exceptionally_uncompressed_payload(config); test_invoke_request_with_uncompressed_payload(config); test_invoke_request_with_compressed_payload(config); + test_invoke_request_with_send_message_before_initial_metadata(config); test_invoke_request_with_server_level(config); test_invoke_request_with_compressed_payload_md_override(config); test_invoke_request_with_disabled_algorithm(config); From bd3b93b4b55bf0acd50a88f5b062dcb21ba6ba93 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 22 Jun 2017 10:53:01 -0700 Subject: [PATCH 10/69] Add support for Trailers-Only responses. - When receiving a Trailers-Only response, return the metadata as trailing metadata instead of initial metadata. - Send Trailers-Only response when we have no non-default initial metadata, no message to send, and trailing metadata to send. --- .../chttp2/transport/chttp2_transport.c | 2 + .../chttp2/transport/frame_rst_stream.c | 2 +- .../chttp2/transport/hpack_encoder.c | 14 +-- .../chttp2/transport/hpack_encoder.h | 2 + .../ext/transport/chttp2/transport/internal.h | 1 + .../ext/transport/chttp2/transport/parsing.c | 12 ++- .../ext/transport/chttp2/transport/writing.c | 87 ++++++++++++++----- src/core/lib/surface/call.c | 53 +++++------ src/core/lib/transport/transport.h | 4 + .../transport/chttp2/hpack_encoder_test.c | 6 +- test/cpp/microbenchmarks/bm_chttp2_hpack.cc | 2 +- 11 files changed, 121 insertions(+), 64 deletions(-) diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 0ad63d1af2f..a14ddea39d6 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -1403,6 +1403,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, op_payload->recv_initial_metadata.recv_initial_metadata_ready; s->recv_initial_metadata = op_payload->recv_initial_metadata.recv_initial_metadata; + s->trailing_metadata_available = + op_payload->recv_initial_metadata.trailing_metadata_available; grpc_chttp2_maybe_complete_recv_initial_metadata(exec_ctx, t, s); } diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c index ccca0f1871e..689dc8935cf 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c @@ -93,7 +93,7 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx, (((uint32_t)p->reason_bytes[2]) << 8) | (((uint32_t)p->reason_bytes[3])); grpc_error *error = GRPC_ERROR_NONE; - if (reason != GRPC_HTTP2_NO_ERROR || s->header_frames_received < 2) { + if (reason != GRPC_HTTP2_NO_ERROR || s->metadata_buffer[1].size == 0) { char *message; gpr_asprintf(&message, "Received RST_STREAM with error code %d", reason); error = grpc_error_set_int( diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index 28c66326952..a0e748e7b11 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -608,15 +608,14 @@ void grpc_chttp2_hpack_compressor_set_max_table_size( void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c, + grpc_mdelem **extra_headers, + size_t extra_headers_size, grpc_metadata_batch *metadata, const grpc_encode_header_options *options, grpc_slice_buffer *outbuf) { - framer_state st; - grpc_linked_mdelem *l; - gpr_timespec deadline; - GPR_ASSERT(options->stream_id != 0); + framer_state st; st.seen_regular_header = 0; st.stream_id = options->stream_id; st.output = outbuf; @@ -633,11 +632,14 @@ void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx, if (c->advertise_table_size_change != 0) { emit_advertise_table_size_change(c, &st); } + for (size_t i = 0; i < extra_headers_size; ++i) { + hpack_enc(exec_ctx, c, *extra_headers[i], &st); + } grpc_metadata_batch_assert_ok(metadata); - for (l = metadata->list.head; l; l = l->next) { + for (grpc_linked_mdelem *l = metadata->list.head; l; l = l->next) { hpack_enc(exec_ctx, c, l->md, &st); } - deadline = metadata->deadline; + gpr_timespec deadline = metadata->deadline; if (gpr_time_cmp(deadline, gpr_inf_future(deadline.clock_type)) != 0) { deadline_enc(exec_ctx, c, deadline, &st); } diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index 84ab6dde2ce..271192f8947 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -85,6 +85,8 @@ typedef struct { void grpc_chttp2_encode_header(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c, + grpc_mdelem **extra_headers, + size_t extra_headers_size, grpc_metadata_batch *metadata, const grpc_encode_header_options *options, grpc_slice_buffer *outbuf); diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 4041b29fecb..dec0003d55f 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -447,6 +447,7 @@ struct grpc_chttp2_stream { grpc_metadata_batch *recv_initial_metadata; grpc_closure *recv_initial_metadata_ready; + bool *trailing_metadata_available; grpc_byte_stream **recv_message; grpc_closure *recv_message_ready; grpc_metadata_batch *recv_trailing_metadata; diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 941260be9ac..3c8b470b4f9 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -681,9 +681,19 @@ static grpc_error *init_header_frame_parser(grpc_exec_ctx *exec_ctx, t->parser_data = &t->hpack_parser; switch (s->header_frames_received) { case 0: - t->hpack_parser.on_header = on_initial_header; + if (t->is_client && t->header_eof) { + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing Trailers-Only")); + if (s->trailing_metadata_available != NULL) { + *s->trailing_metadata_available = true; + } + t->hpack_parser.on_header = on_trailing_header; + } else { + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing initial_metadata")); + t->hpack_parser.on_header = on_initial_header; + } break; case 1: + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "parsing trailing_metadata")); t->hpack_parser.on_header = on_trailing_header; break; case 2: diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 4db0fbb0980..315f2a67a21 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -162,6 +162,20 @@ static uint32_t target_write_size(grpc_chttp2_transport *t) { return 1024 * 1024; } +// Returns true if initial_metadata contains only default headers. +// +// TODO(roth): The fact that we hard-code these particular headers here +// is fairly ugly. Need some better way to know which headers are +// default, maybe via a bit in the static metadata table? +static bool is_default_initial_metadata(grpc_metadata_batch *initial_metadata) { + int num_default_fields = + (initial_metadata->idx.named.status != NULL) + + (initial_metadata->idx.named.content_type != NULL) + + (initial_metadata->idx.named.grpc_encoding != NULL) + + (initial_metadata->idx.named.grpc_accept_encoding != NULL); + return (size_t)num_default_fields == initial_metadata->list.count; +} + grpc_chttp2_begin_write_result grpc_chttp2_begin_write( grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t) { grpc_chttp2_stream *s; @@ -218,31 +232,59 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( t->is_client ? "CLIENT" : "SERVER", s->id, sent_initial_metadata, s->send_initial_metadata != NULL, s->announce_window)); + grpc_mdelem *extra_headers_for_trailing_metadata[2]; + size_t num_extra_headers_for_trailing_metadata = 0; + /* send initial metadata if it's available */ - if (!sent_initial_metadata && s->send_initial_metadata) { - grpc_encode_header_options hopt = { - .stream_id = s->id, - .is_eof = false, - .use_true_binary_metadata = - t->settings - [GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != 0, - .max_frame_size = t->settings[GRPC_PEER_SETTINGS] - [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], - .stats = &s->stats.outgoing}; - grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, - s->send_initial_metadata, &hopt, &t->outbuf); + if (!sent_initial_metadata && s->send_initial_metadata != NULL) { + // We skip this on the server side if there is no custom initial + // metadata, there are no messages to send, and we are also sending + // trailing metadata. This results in a Trailers-Only response, + // which is required for retries, as per: + // https://github.com/grpc/proposal/blob/master/A6-client-retries.md#when-retries-are-valid + if (t->is_client || s->fetching_send_message != NULL || + s->flow_controlled_buffer.length != 0 || + s->send_trailing_metadata == NULL || + !is_default_initial_metadata(s->send_initial_metadata)) { + grpc_encode_header_options hopt = { + .stream_id = s->id, + .is_eof = false, + .use_true_binary_metadata = + t->settings + [GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_GRPC_ALLOW_TRUE_BINARY_METADATA] != 0, + .max_frame_size = t->settings[GRPC_PEER_SETTINGS] + [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], + .stats = &s->stats.outgoing}; + grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, NULL, 0, + s->send_initial_metadata, &hopt, &t->outbuf); + now_writing = true; + t->ping_state.pings_before_data_required = + t->ping_policy.max_pings_without_data; + if (!t->is_client) { + t->ping_recv_state.last_ping_recv_time = + gpr_inf_past(GPR_CLOCK_MONOTONIC); + t->ping_recv_state.ping_strikes = 0; + } + } else { + GRPC_CHTTP2_IF_TRACING( + gpr_log(GPR_INFO, "not sending initial_metadata (Trailers-Only)")); + // When sending Trailers-Only, we need to move the :status and + // content-type headers to the trailers. + if (s->send_initial_metadata->idx.named.status != NULL) { + extra_headers_for_trailing_metadata + [num_extra_headers_for_trailing_metadata++] = + &s->send_initial_metadata->idx.named.status->md; + } + if (s->send_initial_metadata->idx.named.content_type != NULL) { + extra_headers_for_trailing_metadata + [num_extra_headers_for_trailing_metadata++] = + &s->send_initial_metadata->idx.named.content_type->md; + } + } s->send_initial_metadata = NULL; s->sent_initial_metadata = true; sent_initial_metadata = true; - now_writing = true; - t->ping_state.pings_before_data_required = - t->ping_policy.max_pings_without_data; - if (!t->is_client) { - t->ping_recv_state.last_ping_recv_time = - gpr_inf_past(GPR_CLOCK_MONOTONIC); - t->ping_recv_state.ping_strikes = 0; - } } /* send any window updates */ if (s->announce_window > 0) { @@ -320,6 +362,7 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( if (s->send_trailing_metadata != NULL && s->fetching_send_message == NULL && s->flow_controlled_buffer.length == 0) { + GRPC_CHTTP2_IF_TRACING(gpr_log(GPR_INFO, "sending trailing_metadata")); if (grpc_metadata_batch_is_empty(s->send_trailing_metadata)) { grpc_chttp2_encode_data(s->id, &s->flow_controlled_buffer, 0, true, &s->stats.outgoing, &t->outbuf); @@ -337,6 +380,8 @@ grpc_chttp2_begin_write_result grpc_chttp2_begin_write( [GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE], .stats = &s->stats.outgoing}; grpc_chttp2_encode_header(exec_ctx, &t->hpack_compressor, + extra_headers_for_trailing_metadata, + num_extra_headers_for_trailing_metadata, s->send_trailing_metadata, &hopt, &t->outbuf); } diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index b499219e170..b14f8c46c33 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -929,33 +929,6 @@ static grpc_compression_algorithm decode_compression(grpc_mdelem md) { return algorithm; } -static void recv_common_filter(grpc_exec_ctx *exec_ctx, grpc_call *call, - grpc_metadata_batch *b) { - if (b->idx.named.grpc_status != NULL) { - uint32_t status_code = decode_status(b->idx.named.grpc_status->md); - grpc_error *error = - status_code == GRPC_STATUS_OK - ? GRPC_ERROR_NONE - : grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Error received from peer"), - GRPC_ERROR_INT_GRPC_STATUS, - (intptr_t)status_code); - - if (b->idx.named.grpc_message != NULL) { - error = grpc_error_set_str( - error, GRPC_ERROR_STR_GRPC_MESSAGE, - grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_message->md))); - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_message); - } else if (error != GRPC_ERROR_NONE) { - error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, - grpc_empty_slice()); - } - - set_status_from_error(exec_ctx, call, STATUS_FROM_WIRE, error); - grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_status); - } -} - static void publish_app_metadata(grpc_call *call, grpc_metadata_batch *b, int is_trailing) { if (b->list.count == 0) return; @@ -980,8 +953,6 @@ static void publish_app_metadata(grpc_call *call, grpc_metadata_batch *b, static void recv_initial_filter(grpc_exec_ctx *exec_ctx, grpc_call *call, grpc_metadata_batch *b) { - recv_common_filter(exec_ctx, call, b); - if (b->idx.named.grpc_encoding != NULL) { GPR_TIMER_BEGIN("incoming_compression_algorithm", 0); set_incoming_compression_algorithm( @@ -989,7 +960,6 @@ static void recv_initial_filter(grpc_exec_ctx *exec_ctx, grpc_call *call, GPR_TIMER_END("incoming_compression_algorithm", 0); grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_encoding); } - if (b->idx.named.grpc_accept_encoding != NULL) { GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0); set_encodings_accepted_by_peer(exec_ctx, call, @@ -997,14 +967,33 @@ static void recv_initial_filter(grpc_exec_ctx *exec_ctx, grpc_call *call, grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_accept_encoding); GPR_TIMER_END("encodings_accepted_by_peer", 0); } - publish_app_metadata(call, b, false); } static void recv_trailing_filter(grpc_exec_ctx *exec_ctx, void *args, grpc_metadata_batch *b) { grpc_call *call = args; - recv_common_filter(exec_ctx, call, b); + if (b->idx.named.grpc_status != NULL) { + uint32_t status_code = decode_status(b->idx.named.grpc_status->md); + grpc_error *error = + status_code == GRPC_STATUS_OK + ? GRPC_ERROR_NONE + : grpc_error_set_int(GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Error received from peer"), + GRPC_ERROR_INT_GRPC_STATUS, + (intptr_t)status_code); + if (b->idx.named.grpc_message != NULL) { + error = grpc_error_set_str( + error, GRPC_ERROR_STR_GRPC_MESSAGE, + grpc_slice_ref_internal(GRPC_MDVALUE(b->idx.named.grpc_message->md))); + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_message); + } else if (error != GRPC_ERROR_NONE) { + error = grpc_error_set_str(error, GRPC_ERROR_STR_GRPC_MESSAGE, + grpc_empty_slice()); + } + set_status_from_error(exec_ctx, call, STATUS_FROM_WIRE, error); + grpc_metadata_batch_remove(exec_ctx, b, b->idx.named.grpc_status); + } publish_app_metadata(call, b, true); } diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index d231157c874..978ed0fd0ba 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -165,6 +165,10 @@ struct grpc_transport_stream_op_batch_payload { uint32_t *recv_flags; /** Should be enqueued when initial metadata is ready to be processed. */ grpc_closure *recv_initial_metadata_ready; + // If not NULL, will be set to true if trailing metadata is + // immediately available. This may be a signal that we received a + // Trailers-Only response. + bool *trailing_metadata_available; } recv_initial_metadata; struct { diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c index a12f31a048b..ed51dd18592 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.c +++ b/test/core/transport/chttp2/hpack_encoder_test.c @@ -95,7 +95,8 @@ static void verify(grpc_exec_ctx *exec_ctx, size_t window_available, bool eof, .max_frame_size = 16384, .stats = &stats, }; - grpc_chttp2_encode_header(exec_ctx, &g_compressor, &b, &hopt, &output); + grpc_chttp2_encode_header(exec_ctx, &g_compressor, NULL, 0, &b, &hopt, + &output); merged = grpc_slice_merge(output.slices, output.count); grpc_slice_buffer_destroy_internal(exec_ctx, &output); grpc_metadata_batch_destroy(exec_ctx, &b); @@ -213,7 +214,8 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx, .use_true_binary_metadata = false, .max_frame_size = 16384, .stats = &stats}; - grpc_chttp2_encode_header(exec_ctx, &g_compressor, &b, &hopt, &output); + grpc_chttp2_encode_header(exec_ctx, &g_compressor, NULL, 0, &b, &hopt, + &output); grpc_slice_buffer_destroy_internal(exec_ctx, &output); grpc_metadata_batch_destroy(exec_ctx, &b); diff --git a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc index 3457fd77cfb..adbfa4d7967 100644 --- a/test/cpp/microbenchmarks/bm_chttp2_hpack.cc +++ b/test/cpp/microbenchmarks/bm_chttp2_hpack.cc @@ -82,7 +82,7 @@ static void BM_HpackEncoderEncodeHeader(benchmark::State &state) { (size_t)state.range(1), &stats, }; - grpc_chttp2_encode_header(&exec_ctx, &c, &b, &hopt, &outbuf); + grpc_chttp2_encode_header(&exec_ctx, &c, NULL, 0, &b, &hopt, &outbuf); if (!logged_representative_output && state.iterations() > 3) { logged_representative_output = true; for (size_t i = 0; i < outbuf.count; i++) { From d35730d18564a00a4b9acccaf8387ccb4bb565b8 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 22 Jun 2017 12:06:44 -0700 Subject: [PATCH 11/69] Fix use of terminal underscores in field names. --- .../grpc++/impl/codegen/async_unary_call.h | 52 +++++++++---------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/include/grpc++/impl/codegen/async_unary_call.h b/include/grpc++/impl/codegen/async_unary_call.h index de0ab2372a6..a5a698c6401 100644 --- a/include/grpc++/impl/codegen/async_unary_call.h +++ b/include/grpc++/impl/codegen/async_unary_call.h @@ -100,13 +100,13 @@ class ClientAsyncResponseReader final : context_(context), call_(channel->CreateCall(method, context, cq)), collection_(std::make_shared()) { - collection_->init_buf_.SetCollection(collection_); - collection_->init_buf_.SendInitialMetadata( + collection_->init_buf.SetCollection(collection_); + collection_->init_buf.SendInitialMetadata( context->send_initial_metadata_, context->initial_metadata_flags()); // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(collection_->init_buf_.SendMessage(request).ok()); - collection_->init_buf_.ClientSendClose(); - call_.PerformOps(&collection_->init_buf_); + GPR_CODEGEN_ASSERT(collection_->init_buf.SendMessage(request).ok()); + collection_->init_buf.ClientSendClose(); + call_.PerformOps(&collection_->init_buf); } // always allocated against a call arena, no memory free required @@ -123,18 +123,18 @@ class ClientAsyncResponseReader final void ReadInitialMetadata(void* tag) { GPR_CODEGEN_ASSERT(!context_->initial_metadata_received_); - Ops& o = ops; + Ops& o = ops_; // TODO(vjpai): Remove the collection_ specialization as soon // as the public constructor is deleted if (collection_) { o = *collection_; - collection_->meta_buf_.SetCollection(collection_); + collection_->meta_buf.SetCollection(collection_); } - o.meta_buf_.set_output_tag(tag); - o.meta_buf_.RecvInitialMetadata(context_); - call_.PerformOps(&o.meta_buf_); + o.meta_buf.set_output_tag(tag); + o.meta_buf.RecvInitialMetadata(context_); + call_.PerformOps(&o.meta_buf); } /// See \a ClientAysncResponseReaderInterface::Finish for semantics. @@ -143,23 +143,23 @@ class ClientAsyncResponseReader final /// - the \a ClientContext associated with this call is updated with /// possible initial and trailing metadata sent from the server. void Finish(R* msg, Status* status, void* tag) { - Ops& o = ops; + Ops& o = ops_; // TODO(vjpai): Remove the collection_ specialization as soon // as the public constructor is deleted if (collection_) { o = *collection_; - collection_->finish_buf_.SetCollection(collection_); + collection_->finish_buf.SetCollection(collection_); } - o.finish_buf_.set_output_tag(tag); + o.finish_buf.set_output_tag(tag); if (!context_->initial_metadata_received_) { - o.finish_buf_.RecvInitialMetadata(context_); + o.finish_buf.RecvInitialMetadata(context_); } - o.finish_buf_.RecvMessage(msg); - o.finish_buf_.AllowNoMessage(); - o.finish_buf_.ClientRecvStatus(context_, status); - call_.PerformOps(&o.finish_buf_); + o.finish_buf.RecvMessage(msg); + o.finish_buf.AllowNoMessage(); + o.finish_buf.ClientRecvStatus(context_, status); + call_.PerformOps(&o.finish_buf); } private: @@ -169,12 +169,12 @@ class ClientAsyncResponseReader final template ClientAsyncResponseReader(Call call, ClientContext* context, const W& request) : context_(context), call_(call) { - ops.init_buf_.SendInitialMetadata(context->send_initial_metadata_, + ops_.init_buf.SendInitialMetadata(context->send_initial_metadata_, context->initial_metadata_flags()); // TODO(ctiller): don't assert - GPR_CODEGEN_ASSERT(ops.init_buf_.SendMessage(request).ok()); - ops.init_buf_.ClientSendClose(); - call_.PerformOps(&ops.init_buf_); + GPR_CODEGEN_ASSERT(ops_.init_buf.SendMessage(request).ok()); + ops_.init_buf.ClientSendClose(); + call_.PerformOps(&ops_.init_buf); } // disable operator new @@ -186,12 +186,12 @@ class ClientAsyncResponseReader final struct Ops : public CallOpSetCollectionInterface { SneakyCallOpSet - init_buf_; - CallOpSet meta_buf_; + init_buf; + CallOpSet meta_buf; CallOpSet, CallOpClientRecvStatus> - finish_buf_; - } ops; + finish_buf; + } ops_; // TODO(vjpai): Remove the collection_ as soon as the related workaround // (public constructor) is deleted From 10c040d455289b274fe2c5de00a9ffeb79798681 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Thu, 22 Jun 2017 13:41:41 -0700 Subject: [PATCH 12/69] Move collection reset before unref (since unref could destroy obj) --- include/grpc++/impl/codegen/call.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/grpc++/impl/codegen/call.h b/include/grpc++/impl/codegen/call.h index dba53bc4273..342ea462033 100644 --- a/include/grpc++/impl/codegen/call.h +++ b/include/grpc++/impl/codegen/call.h @@ -610,10 +610,12 @@ class CallOpSet : public CallOpSetInterface, this->Op5::FinishOp(status); this->Op6::FinishOp(status); *tag = return_tag_; - g_core_codegen_interface->grpc_call_unref(call_); + // TODO(vjpai): Remove the reference to collection_ once the idea of // bypassing the code generator is forbidden. It is already deprecated collection_.reset(); + + g_core_codegen_interface->grpc_call_unref(call_); return true; } From 495e9ac023d8ae565d8f7069799e88a79f25b21a Mon Sep 17 00:00:00 2001 From: Michael Bausor Date: Thu, 22 Jun 2017 14:05:24 -0700 Subject: [PATCH 13/69] Run formatter --- src/compiler/php_generator_helpers.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/compiler/php_generator_helpers.h b/src/compiler/php_generator_helpers.h index 8f59b90d049..3a5c08b3e69 100644 --- a/src/compiler/php_generator_helpers.h +++ b/src/compiler/php_generator_helpers.h @@ -56,8 +56,7 @@ template inline grpc::string GetPHPComments(const DescriptorType *desc, grpc::string prefix) { return ReplaceAll(grpc_generator::GetPrefixedComments(desc, true, prefix), - "*/", - "*/"); + "*/", "*/"); } } // namespace grpc_php_generator From 74c74fb04e98fa3641a0eaddddb5526a921f3520 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 19 Jun 2017 16:14:50 +0200 Subject: [PATCH 14/69] workaround zlib cmake issue --- CMakeLists.txt | 3 +++ templates/CMakeLists.txt.template | 3 +++ 2 files changed, 6 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 852eb2bf6c8..e8094b72550 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,9 @@ if("${gRPC_ZLIB_PROVIDER}" STREQUAL "module") endif() set(ZLIB_INCLUDE_DIR "${ZLIB_ROOT_DIR}") if(EXISTS "${ZLIB_ROOT_DIR}/CMakeLists.txt") + # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218 + include_directories(${ZLIB_INCLUDE_DIR}) + add_subdirectory(${ZLIB_ROOT_DIR} third_party/zlib) if(TARGET zlibstatic) set(_gRPC_ZLIB_LIBRARIES zlibstatic) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index ef0faccb2e8..91bed9a6db1 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -143,6 +143,9 @@ endif() set(ZLIB_INCLUDE_DIR "<%text>${ZLIB_ROOT_DIR}") if(EXISTS "<%text>${ZLIB_ROOT_DIR}/CMakeLists.txt") + # TODO(jtattermusch): workaround for https://github.com/madler/zlib/issues/218 + include_directories(<%text>${ZLIB_INCLUDE_DIR}) + add_subdirectory(<%text>${ZLIB_ROOT_DIR} third_party/zlib) if(TARGET zlibstatic) set(_gRPC_ZLIB_LIBRARIES zlibstatic) From b70df57c498a5757693266612bc51e45f2713ab3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Mon, 19 Jun 2017 16:37:15 +0200 Subject: [PATCH 15/69] build protobuf without zlib --- CMakeLists.txt | 5 +++++ templates/CMakeLists.txt.template | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8094b72550..f5e863183b4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,11 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module") if(NOT protobuf_BUILD_TESTS) set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") endif() + # Disable building protobuf with zlib. Building protobuf with zlib breaks + # the build if zlib is not installed on the system. + if(NOT protobuf_WITH_ZLIB) + set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.") + endif() if(NOT PROTOBUF_ROOT_DIR) set(PROTOBUF_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) endif() diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 91bed9a6db1..d279d02553e 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -207,6 +207,11 @@ if(NOT protobuf_BUILD_TESTS) set(protobuf_BUILD_TESTS OFF CACHE BOOL "Build protobuf tests") endif() + # Disable building protobuf with zlib. Building protobuf with zlib breaks + # the build if zlib is not installed on the system. + if(NOT protobuf_WITH_ZLIB) + set(protobuf_WITH_ZLIB OFF CACHE BOOL "Build protobuf with zlib.") + endif() if(NOT PROTOBUF_ROOT_DIR) set(PROTOBUF_ROOT_DIR <%text>${CMAKE_CURRENT_SOURCE_DIR}/third_party/protobuf) endif() From f3219f459d63b66e3ee06b994031608d7107fdd2 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 20 Jun 2017 13:21:53 +0200 Subject: [PATCH 16/69] make some headers public --- templates/CMakeLists.txt.template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index d279d02553e..2a5b12b412e 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -514,8 +514,8 @@ % endfor target_include_directories(${lib.name} + PUBLIC <%text>$ $ PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE <%text>${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE <%text>${BORINGSSL_ROOT_DIR}/include PRIVATE <%text>${PROTOBUF_ROOT_DIR}/src PRIVATE <%text>${ZLIB_INCLUDE_DIR} From 456b713f06b09a2bff42dc7f9ff09fbde973dd58 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 20 Jun 2017 13:21:27 +0200 Subject: [PATCH 17/69] regenerate --- CMakeLists.txt | 66 +++++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f5e863183b4..7e067d5277f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -816,8 +816,8 @@ endif() target_include_directories(gpr + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -908,8 +908,8 @@ endif() target_include_directories(gpr_test_util + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -1195,8 +1195,8 @@ endif() target_include_directories(grpc + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -1494,8 +1494,8 @@ endif() target_include_directories(grpc_cronet + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -1730,8 +1730,8 @@ endif() target_include_directories(grpc_test_util + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -1824,8 +1824,8 @@ endif() target_include_directories(grpc_test_util_unsecure + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2085,8 +2085,8 @@ endif() target_include_directories(grpc_unsecure + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2175,8 +2175,8 @@ endif() target_include_directories(reconnect_server + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2219,8 +2219,8 @@ endif() target_include_directories(test_tcp_server + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2305,8 +2305,8 @@ endif() target_include_directories(grpc++ + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2692,8 +2692,8 @@ endif() target_include_directories(grpc++_cronet + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2865,8 +2865,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(grpc++_error_details + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2932,8 +2932,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(grpc++_proto_reflection_desc_db + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -2995,8 +2995,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(grpc++_reflection + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3055,8 +3055,8 @@ endif() target_include_directories(grpc++_test_config + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3135,8 +3135,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(grpc++_test_util + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3279,8 +3279,8 @@ endif() target_include_directories(grpc++_unsecure + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3433,8 +3433,8 @@ endif() target_include_directories(grpc_benchmark + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3494,8 +3494,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(grpc_cli_libs + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3556,8 +3556,8 @@ endif() target_include_directories(grpc_plugin_support + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3636,8 +3636,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(http2_client_main + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3693,8 +3693,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(interop_client_helper + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3765,8 +3765,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(interop_client_main + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3818,8 +3818,8 @@ endif() target_include_directories(interop_server_helper + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3889,8 +3889,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(interop_server_lib + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -3942,8 +3942,8 @@ endif() target_include_directories(interop_server_main + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -4032,8 +4032,8 @@ protobuf_generate_grpc_cpp( ) target_include_directories(qps + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -4080,8 +4080,8 @@ endif() target_include_directories(grpc_csharp_ext + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -4177,8 +4177,8 @@ endif() target_include_directories(ares + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -4217,8 +4217,8 @@ endif() target_include_directories(bad_client_test + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -4260,8 +4260,8 @@ endif() target_include_directories(bad_ssl_test_server + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -4358,8 +4358,8 @@ endif() target_include_directories(end2end_tests + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} @@ -4456,8 +4456,8 @@ endif() target_include_directories(end2end_nosec_tests + PUBLIC $ $ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include PRIVATE ${BORINGSSL_ROOT_DIR}/include PRIVATE ${PROTOBUF_ROOT_DIR}/src PRIVATE ${ZLIB_INCLUDE_DIR} From f691556db43779f2c33ef29e94392cc7efd0b025 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 23 Jun 2017 14:53:55 +0200 Subject: [PATCH 18/69] dont reuse protobuf cmake install dirs --- templates/CMakeLists.txt.template | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index 2a5b12b412e..1c76136ce3d 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -73,6 +73,11 @@ set(PACKAGE_TARNAME "<%text>${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") project(<%text>${PACKAGE_NAME} C CXX) + + set(gRPC_INSTALL_BINDIR "<%text>${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") + set(gRPC_INSTALL_LIBDIR "<%text>${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") + set(gRPC_INSTALL_INCLUDEDIR "<%text>${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") + set(gRPC_INSTALL_CMAKEDIR "<%text>${CMAKE_INSTALL_PREFIX}/lib/cmake/${PACKAGE_NAME}" CACHE PATH "Installation directory for cmake config files") # Options option(gRPC_BUILD_TESTS "Build tests" OFF) @@ -335,11 +340,6 @@ set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32) endif() - include(GNUInstallDirs) - if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR) - set(CMAKE_INSTALL_CMAKEDIR "<%text>${CMAKE_INSTALL_LIBDIR}/cmake/gRPC") - endif() - # Create directory for generated .proto files set(_gRPC_PROTO_GENS_DIR <%text>${CMAKE_BINARY_DIR}/gens) file(MAKE_DIRECTORY <%text>${_gRPC_PROTO_GENS_DIR}) @@ -500,7 +500,7 @@ ) if (gRPC_INSTALL) install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${lib.name}.pdb - DESTINATION <%text>${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION <%text>${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -554,7 +554,7 @@ string(REPLACE "include/" "" _path <%text>${_hdr}) get_filename_component(_path <%text>${_path} PATH) install(FILES <%text>${_hdr} - DESTINATION "<%text>${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "<%text>${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() % endif @@ -622,16 +622,16 @@ <%def name="cc_install(tgt)"> if (gRPC_INSTALL) install(TARGETS ${tgt.name} EXPORT gRPCTargets - RUNTIME DESTINATION <%text>${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION <%text>${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION <%text>${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION <%text>${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION <%text>${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION <%text>${gRPC_INSTALL_LIBDIR} ) endif() if (gRPC_INSTALL) install(EXPORT gRPCTargets - DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR} + DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR} NAMESPACE gRPC:: ) endif() @@ -640,6 +640,6 @@ configure_file(tools/cmake/<%text>${_config}.cmake.in <%text>${_config}.cmake @ONLY) install(FILES <%text>${CMAKE_CURRENT_BINARY_DIR}/${_config}.cmake - DESTINATION <%text>${CMAKE_INSTALL_CMAKEDIR} + DESTINATION <%text>${gRPC_INSTALL_CMAKEDIR} ) endforeach() From dca8d637c0ccba1ff0c9fdeaf7e57fc432258814 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 23 Jun 2017 15:52:40 +0200 Subject: [PATCH 19/69] regenerate --- CMakeLists.txt | 258 ++++++++++++++++++++++++------------------------- 1 file changed, 129 insertions(+), 129 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e067d5277f..68955ebeea9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,11 @@ set(PACKAGE_TARNAME "${PACKAGE_NAME}-${PACKAGE_VERSION}") set(PACKAGE_BUGREPORT "https://github.com/grpc/grpc/issues/") project(${PACKAGE_NAME} C CXX) +set(gRPC_INSTALL_BINDIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") +set(gRPC_INSTALL_LIBDIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") +set(gRPC_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") +set(gRPC_INSTALL_CMAKEDIR "${CMAKE_INSTALL_PREFIX}/lib/cmake/${PACKAGE_NAME}" CACHE PATH "Installation directory for cmake config files") + # Options option(gRPC_BUILD_TESTS "Build tests" OFF) @@ -290,11 +295,6 @@ if(WIN32 AND MSVC) set(_gRPC_BASELIB_LIBRARIES wsock32 ws2_32) endif() -include(GNUInstallDirs) -if(NOT DEFINED CMAKE_INSTALL_CMAKEDIR) - set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/gRPC") -endif() - # Create directory for generated .proto files set(_gRPC_PROTO_GENS_DIR ${CMAKE_BINARY_DIR}/gens) file(MAKE_DIRECTORY ${_gRPC_PROTO_GENS_DIR}) @@ -809,7 +809,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gpr.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -876,16 +876,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS gpr EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -901,7 +901,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/gpr_test_util.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -1188,7 +1188,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -1255,16 +1255,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -1487,7 +1487,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_cronet.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -1554,16 +1554,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc_cronet EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -1723,7 +1723,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_test_util.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -1786,7 +1786,7 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() @@ -1817,7 +1817,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_test_util_unsecure.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2078,7 +2078,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_unsecure.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2143,16 +2143,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc_unsecure EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -2168,7 +2168,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/reconnect_server.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2212,7 +2212,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/test_tcp_server.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2298,7 +2298,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2428,16 +2428,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc++ EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -2685,7 +2685,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_cronet.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2827,16 +2827,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc++_cronet EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -2855,7 +2855,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_error_details.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2893,16 +2893,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc++_error_details EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -2922,7 +2922,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_proto_reflection_desc_db.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -2964,7 +2964,7 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() @@ -2985,7 +2985,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_reflection.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3023,16 +3023,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc++_reflection EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -3048,7 +3048,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test_config.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3116,7 +3116,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_test_util.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3217,7 +3217,7 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() @@ -3272,7 +3272,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc++_unsecure.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3401,16 +3401,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc++_unsecure EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -3426,7 +3426,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_benchmark.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3484,7 +3484,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_cli_libs.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3527,7 +3527,7 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() @@ -3549,7 +3549,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_plugin_support.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3583,16 +3583,16 @@ foreach(_hdr string(REPLACE "include/" "" _path ${_hdr}) get_filename_component(_path ${_path} PATH) install(FILES ${_hdr} - DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_path}" + DESTINATION "${gRPC_INSTALL_INCLUDEDIR}/${_path}" ) endforeach() if (gRPC_INSTALL) install(TARGETS grpc_plugin_support EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -3620,7 +3620,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/http2_client_main.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3683,7 +3683,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_client_helper.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3749,7 +3749,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_client_main.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3811,7 +3811,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_server_helper.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3873,7 +3873,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_server_lib.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -3935,7 +3935,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/interop_server_main.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4010,7 +4010,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/qps.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4073,7 +4073,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/grpc_csharp_ext.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4104,9 +4104,9 @@ target_link_libraries(grpc_csharp_ext if (gRPC_INSTALL) install(TARGETS grpc_csharp_ext EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -4170,7 +4170,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/ares.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4210,7 +4210,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bad_client_test.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4253,7 +4253,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/bad_ssl_test_server.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4351,7 +4351,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/end2end_tests.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4449,7 +4449,7 @@ if(WIN32 AND MSVC) ) if (gRPC_INSTALL) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/end2end_nosec_tests.pdb - DESTINATION ${CMAKE_INSTALL_LIBDIR} OPTIONAL + DESTINATION ${gRPC_INSTALL_LIBDIR} OPTIONAL ) endif() endif() @@ -4938,9 +4938,9 @@ target_link_libraries(check_epollexclusive if (gRPC_INSTALL) install(TARGETS check_epollexclusive EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -5606,9 +5606,9 @@ target_link_libraries(gen_hpack_tables if (gRPC_INSTALL) install(TARGETS gen_hpack_tables EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -5640,9 +5640,9 @@ target_link_libraries(gen_legal_metadata_characters if (gRPC_INSTALL) install(TARGETS gen_legal_metadata_characters EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -5674,9 +5674,9 @@ target_link_libraries(gen_percent_encoding_tables if (gRPC_INSTALL) install(TARGETS gen_percent_encoding_tables EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -6425,9 +6425,9 @@ target_link_libraries(grpc_create_jwt if (gRPC_INSTALL) install(TARGETS grpc_create_jwt EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -6618,9 +6618,9 @@ target_link_libraries(grpc_print_google_default_creds_token if (gRPC_INSTALL) install(TARGETS grpc_print_google_default_creds_token EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -6685,9 +6685,9 @@ target_link_libraries(grpc_verify_jwt if (gRPC_INSTALL) install(TARGETS grpc_verify_jwt EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -10328,9 +10328,9 @@ target_link_libraries(grpc_cpp_plugin if (gRPC_INSTALL) install(TARGETS grpc_cpp_plugin EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -10366,9 +10366,9 @@ target_link_libraries(grpc_csharp_plugin if (gRPC_INSTALL) install(TARGETS grpc_csharp_plugin EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -10404,9 +10404,9 @@ target_link_libraries(grpc_node_plugin if (gRPC_INSTALL) install(TARGETS grpc_node_plugin EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -10442,9 +10442,9 @@ target_link_libraries(grpc_objective_c_plugin if (gRPC_INSTALL) install(TARGETS grpc_objective_c_plugin EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -10480,9 +10480,9 @@ target_link_libraries(grpc_php_plugin if (gRPC_INSTALL) install(TARGETS grpc_php_plugin EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -10518,9 +10518,9 @@ target_link_libraries(grpc_python_plugin if (gRPC_INSTALL) install(TARGETS grpc_python_plugin EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -10556,9 +10556,9 @@ target_link_libraries(grpc_ruby_plugin if (gRPC_INSTALL) install(TARGETS grpc_ruby_plugin EXPORT gRPCTargets - RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} - ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + RUNTIME DESTINATION ${gRPC_INSTALL_BINDIR} + LIBRARY DESTINATION ${gRPC_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${gRPC_INSTALL_LIBDIR} ) endif() @@ -14190,7 +14190,7 @@ endif (gRPC_BUILD_TESTS) if (gRPC_INSTALL) install(EXPORT gRPCTargets - DESTINATION ${CMAKE_INSTALL_CMAKEDIR} + DESTINATION ${gRPC_INSTALL_CMAKEDIR} NAMESPACE gRPC:: ) endif() @@ -14199,6 +14199,6 @@ foreach(_config gRPCConfig gRPCConfigVersion) configure_file(tools/cmake/${_config}.cmake.in ${_config}.cmake @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_config}.cmake - DESTINATION ${CMAKE_INSTALL_CMAKEDIR} + DESTINATION ${gRPC_INSTALL_CMAKEDIR} ) endforeach() From 5dc774199b18b94642eae61c865d7f64d7d6ad8f Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 23 Jun 2017 09:13:16 -0700 Subject: [PATCH 20/69] Fix Windows compiler problem. --- test/core/end2end/tests/compressed_payload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index e5e0a5ead42..429717a7be0 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -279,7 +279,7 @@ static void request_with_payload_template( grpc_call *c; grpc_call *s; grpc_slice request_payload_slice; - grpc_byte_buffer *request_payload; + grpc_byte_buffer *request_payload = NULL; grpc_channel_args *client_args; grpc_channel_args *server_args; grpc_end2end_test_fixture f; From a1fe5e5ae3b2021045d18281e3424312cfbe3679 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 30 May 2017 08:31:36 -0700 Subject: [PATCH 21/69] Remove remaining thrift content from main repo --- tools/grift/Dockerfile | 52 - tools/grift/README.md | 24 - tools/grift/grpc_plugins_generator.patch | 2505 ---------------------- 3 files changed, 2581 deletions(-) delete mode 100644 tools/grift/Dockerfile delete mode 100644 tools/grift/README.md delete mode 100644 tools/grift/grpc_plugins_generator.patch diff --git a/tools/grift/Dockerfile b/tools/grift/Dockerfile deleted file mode 100644 index 4d2fc3146b4..00000000000 --- a/tools/grift/Dockerfile +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright 2016 gRPC authors. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -FROM ubuntu:14.04 - -RUN apt-get update && \ - apt-get install -y \ - git build-essential \ - pkg-config flex \ - bison \ - libkrb5-dev \ - libsasl2-dev \ - libnuma-dev \ - pkg-config \ - libssl-dev \ - autoconf libtool \ - cmake \ - libiberty-dev \ - g++ unzip \ - curl make automake libtool libboost-dev - -# Configure git -RUN git config --global user.name "Jenkins" && \ - git config --global user.email "jenkins@grpc" - -# Clone gRPC -RUN git clone https://github.com/grpc/grpc - -# Update Submodules -RUN cd grpc && git submodule update --init - -# Install protobuf -RUN cd grpc/third_party/protobuf && ./autogen.sh && ./configure && \ - make -j && make check -j && make install && ldconfig - -# Install gRPC -RUN cd grpc && make -j && make install - -# Install thrift -RUN cd grpc/third_party/thrift && git am --signoff < ../../tools/grift/grpc_plugins_generator.patch && \ - ./bootstrap.sh && ./configure && make -j && make install \ No newline at end of file diff --git a/tools/grift/README.md b/tools/grift/README.md deleted file mode 100644 index 2b5fa5ae14b..00000000000 --- a/tools/grift/README.md +++ /dev/null @@ -1,24 +0,0 @@ -# Documentation - -grift is integration of [Apache Thrift](https://github.com/apache/thrift.git) Serializer with gRPC. - -This integration allows you to use grpc to send thrift messages in C++ and java. - -grift uses Compact Protocol to serialize thrift messages. - -## generating grpc plugins for thrift services - -### C++ -```sh - $ thrift --gen cpp -``` - -### Java -```sh - $ thrift --gen java -``` - -# Installation - -Before Installing thrift make sure to apply this [patch](grpc_plugins_generator.patch) to third_party/thrift. -Go to third_party/thrift and follow the [INSTALLATION](https://github.com/apache/thrift.git) instructions to install thrift with commit id bcad91771b7f0bff28a1cac1981d7ef2b9bcef3c. \ No newline at end of file diff --git a/tools/grift/grpc_plugins_generator.patch b/tools/grift/grpc_plugins_generator.patch deleted file mode 100644 index de82a01f625..00000000000 --- a/tools/grift/grpc_plugins_generator.patch +++ /dev/null @@ -1,2505 +0,0 @@ -From 0894590b5020c38106d4ebb2291994668c64f9dd Mon Sep 17 00:00:00 2001 -From: chedeti -Date: Sun, 31 Jul 2016 15:47:47 -0700 -Subject: [PATCH 1/3] don't build tests - ---- - Makefile.am | 7 ++----- - lib/cpp/Makefile.am | 7 ++----- - 2 files changed, 4 insertions(+), 10 deletions(-) - -diff --git a/Makefile.am b/Makefile.am -index 10fe49a..d49caac 100755 ---- a/Makefile.am -+++ b/Makefile.am -@@ -21,10 +21,6 @@ ACLOCAL_AMFLAGS = -I ./aclocal - - SUBDIRS = compiler/cpp lib - --if WITH_TESTS --SUBDIRS += test --endif -- - if WITH_TUTORIAL - SUBDIRS += tutorial - endif -@@ -117,4 +113,5 @@ EXTRA_DIST = \ - CHANGES \ - NOTICE \ - README.md \ -- Thrift.podspec -+ Thrift.podspec \ -+ test -diff --git a/lib/cpp/Makefile.am b/lib/cpp/Makefile.am -index 6fd15d2..7de1fad 100755 ---- a/lib/cpp/Makefile.am -+++ b/lib/cpp/Makefile.am -@@ -27,10 +27,6 @@ moc__%.cpp: %.h - - SUBDIRS = . - --if WITH_TESTS --SUBDIRS += test --endif -- - pkgconfigdir = $(libdir)/pkgconfig - - lib_LTLIBRARIES = libthrift.la -@@ -277,7 +273,8 @@ EXTRA_DIST = \ - thrift-qt.pc.in \ - thrift-qt5.pc.in \ - src/thrift/qt/CMakeLists.txt \ -- $(WINDOWS_DIST) -+ $(WINDOWS_DIST) \ -+ test - - style-local: - $(CPPSTYLE_CMD) --- -2.8.0.rc3.226.g39d4020 - - -From 387e4300bc9d98176a92a7c010621443a538e7f2 Mon Sep 17 00:00:00 2001 -From: chedeti -Date: Sun, 31 Jul 2016 16:16:40 -0700 -Subject: [PATCH 2/3] grpc cpp plugins generator with example - ---- - compiler/cpp/src/generate/t_cpp_generator.cc | 489 +++++++++++++++++++++++---- - tutorial/cpp/CMakeLists.txt | 53 --- - tutorial/cpp/CppClient.cpp | 80 ----- - tutorial/cpp/CppServer.cpp | 181 ---------- - tutorial/cpp/GriftClient.cpp | 93 +++++ - tutorial/cpp/GriftServer.cpp | 93 +++++ - tutorial/cpp/Makefile.am | 66 ++-- - tutorial/cpp/test.thrift | 13 + - 8 files changed, 652 insertions(+), 416 deletions(-) - delete mode 100644 tutorial/cpp/CMakeLists.txt - delete mode 100644 tutorial/cpp/CppClient.cpp - delete mode 100644 tutorial/cpp/CppServer.cpp - create mode 100644 tutorial/cpp/GriftClient.cpp - create mode 100644 tutorial/cpp/GriftServer.cpp - create mode 100644 tutorial/cpp/test.thrift - -diff --git a/compiler/cpp/src/generate/t_cpp_generator.cc b/compiler/cpp/src/generate/t_cpp_generator.cc -index 6c04899..1557241 100644 ---- a/compiler/cpp/src/generate/t_cpp_generator.cc -+++ b/compiler/cpp/src/generate/t_cpp_generator.cc -@@ -162,6 +162,8 @@ public: - bool specialized = false); - void generate_function_helpers(t_service* tservice, t_function* tfunction); - void generate_service_async_skeleton(t_service* tservice); -+ void generate_service_stub_interface(t_service* tservice); -+ void generate_service_stub(t_service* tservice); - - /** - * Serialization constructs -@@ -883,10 +885,10 @@ void t_cpp_generator::generate_struct_declaration(ofstream& out, - bool is_user_struct) { - string extends = ""; - if (is_exception) { -- extends = " : public ::apache::thrift::TException"; -+ extends = " : public apache::thrift::TException"; - } else { -- if (is_user_struct && !gen_templates_) { -- extends = " : public virtual ::apache::thrift::TBase"; -+ if (!gen_templates_) { -+ extends = " : public virtual apache::thrift::TBase"; - } - } - -@@ -1130,9 +1132,15 @@ void t_cpp_generator::generate_struct_definition(ofstream& out, - vector::const_iterator m_iter; - const vector& members = tstruct->get_members(); - -+ string method_prefix = ""; -+ if (service_name_ != "") { -+ method_prefix = service_name_ + "::"; -+ } -+ - // Destructor - if (tstruct->annotations_.find("final") == tstruct->annotations_.end()) { -- force_cpp_out << endl << indent() << tstruct->get_name() << "::~" << tstruct->get_name() -+ force_cpp_out << endl << indent() << method_prefix << -+ tstruct->get_name() << "::~" << tstruct->get_name() - << "() throw() {" << endl; - indent_up(); - -@@ -1145,12 +1153,14 @@ void t_cpp_generator::generate_struct_definition(ofstream& out, - for (m_iter = members.begin(); m_iter != members.end(); ++m_iter) { - if (is_reference((*m_iter))) { - std::string type = type_name((*m_iter)->get_type()); -- out << endl << indent() << "void " << tstruct->get_name() << "::__set_" -+ out << endl << indent() << "void " << method_prefix -+ << tstruct->get_name() << "::__set_" - << (*m_iter)->get_name() << "(boost::shared_ptr<" - << type_name((*m_iter)->get_type(), false, false) << ">"; - out << " val) {" << endl; - } else { -- out << endl << indent() << "void " << tstruct->get_name() << "::__set_" -+ out << endl << indent() << "void " << method_prefix -+ << tstruct->get_name() << "::__set_" - << (*m_iter)->get_name() << "(" << type_name((*m_iter)->get_type(), false, true); - out << " val) {" << endl; - } -@@ -1177,11 +1187,16 @@ void t_cpp_generator::generate_struct_definition(ofstream& out, - * @param tstruct The struct - */ - void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, bool pointers) { -+ string method_prefix = ""; -+ if (service_name_ != "") { -+ method_prefix = service_name_ + "::"; -+ } -+ - if (gen_templates_) { - out << indent() << "template " << endl << indent() << "uint32_t " -- << tstruct->get_name() << "::read(Protocol_* iprot) {" << endl; -+ << method_prefix << tstruct->get_name() << "::read(Protocol_* iprot) {" << endl; - } else { -- indent(out) << "uint32_t " << tstruct->get_name() -+ indent(out) << "uint32_t " << method_prefix << tstruct->get_name() - << "::read(::apache::thrift::protocol::TProtocol* iprot) {" << endl; - } - indent_up(); -@@ -1301,14 +1316,18 @@ void t_cpp_generator::generate_struct_reader(ofstream& out, t_struct* tstruct, b - */ - void t_cpp_generator::generate_struct_writer(ofstream& out, t_struct* tstruct, bool pointers) { - string name = tstruct->get_name(); -+ string method_prefix = ""; -+ if (service_name_ != "") { -+ method_prefix = service_name_ + "::"; -+ } - const vector& fields = tstruct->get_sorted_members(); - vector::const_iterator f_iter; - - if (gen_templates_) { - out << indent() << "template " << endl << indent() << "uint32_t " -- << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl; -+ << method_prefix << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl; - } else { -- indent(out) << "uint32_t " << tstruct->get_name() -+ indent(out) << "uint32_t " << method_prefix << tstruct->get_name() - << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl; - } - indent_up(); -@@ -1369,14 +1388,18 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out, - t_struct* tstruct, - bool pointers) { - string name = tstruct->get_name(); -+ string method_prefix = ""; -+ if (service_name_ != "") { -+ method_prefix = service_name_ + "::"; -+ } - const vector& fields = tstruct->get_sorted_members(); - vector::const_iterator f_iter; - - if (gen_templates_) { - out << indent() << "template " << endl << indent() << "uint32_t " -- << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl; -+ << method_prefix << tstruct->get_name() << "::write(Protocol_* oprot) const {" << endl; - } else { -- indent(out) << "uint32_t " << tstruct->get_name() -+ indent(out) << "uint32_t " << method_prefix << tstruct->get_name() - << "::write(::apache::thrift::protocol::TProtocol* oprot) const {" << endl; - } - indent_up(); -@@ -1385,18 +1408,7 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out, - - indent(out) << "xfer += oprot->writeStructBegin(\"" << name << "\");" << endl; - -- bool first = true; - for (f_iter = fields.begin(); f_iter != fields.end(); ++f_iter) { -- if (first) { -- first = false; -- out << endl << indent() << "if "; -- } else { -- out << " else if "; -- } -- -- out << "(this->__isset." << (*f_iter)->get_name() << ") {" << endl; -- -- indent_up(); - - // Write field header - out << indent() << "xfer += oprot->writeFieldBegin(" -@@ -1410,9 +1422,6 @@ void t_cpp_generator::generate_struct_result_writer(ofstream& out, - } - // Write field closer - indent(out) << "xfer += oprot->writeFieldEnd();" << endl; -- -- indent_down(); -- indent(out) << "}"; - } - - // Write the struct map -@@ -1478,9 +1487,13 @@ void t_cpp_generator::generate_struct_ostream_operator(std::ofstream& out, t_str - } - - void t_cpp_generator::generate_struct_print_method_decl(std::ofstream& out, t_struct* tstruct) { -+ string method_prefix = ""; -+ if (service_name_ != "") { -+ method_prefix = service_name_ + "::"; -+ } - out << "void "; - if (tstruct) { -- out << tstruct->get_name() << "::"; -+ out << method_prefix << tstruct->get_name() << "::"; - } - out << "printTo(std::ostream& out) const"; - } -@@ -1601,11 +1614,13 @@ void t_cpp_generator::generate_exception_what_method(std::ofstream& out, t_struc - */ - void t_cpp_generator::generate_service(t_service* tservice) { - string svcname = tservice->get_name(); -+ string ns = tservice->get_program()->get_namespace("cpp"); - - // Make output files -- string f_header_name = get_out_dir() + svcname + ".h"; -+ string f_header_name = get_out_dir() + svcname + ".grpc.thrift.h"; - f_header_.open(f_header_name.c_str()); - -+ - // Print header file includes - f_header_ << autogen_comment(); - f_header_ << "#ifndef " << svcname << "_H" << endl << "#define " << svcname << "_H" << endl -@@ -1621,15 +1636,38 @@ void t_cpp_generator::generate_service(t_service* tservice) { - f_header_ << "#include " << endl; - } - f_header_ << "#include " << endl; -+ - f_header_ << "#include \"" << get_include_prefix(*get_program()) << program_name_ << "_types.h\"" - << endl; - - t_service* extends_service = tservice->get_extends(); -- if (extends_service != NULL) { -+ if (extends_service) { - f_header_ << "#include \"" << get_include_prefix(*(extends_service->get_program())) -- << extends_service->get_name() << ".h\"" << endl; -+ << extends_service->get_name() << ".grpc.thrift.h\"" << endl; - } - -+ -+ f_header_ << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl; -+ -+ -+ f_header_ << -+ endl << -+ "namespace grpc {" << endl << -+ "class CompletionQueue;" << endl << -+ "class Channel;" << endl << -+ "class RpcService;" << endl << -+ "class ServerCompletionQueue;" << endl << -+ "class ServerContext;" << endl << -+ "}" << endl; -+ - f_header_ << endl << ns_open_ << endl << endl; - - f_header_ << "#ifdef _WIN32\n" -@@ -1638,10 +1676,13 @@ void t_cpp_generator::generate_service(t_service* tservice) { - "#endif\n\n"; - - // Service implementation file includes -- string f_service_name = get_out_dir() + svcname + ".cpp"; -+ string f_service_name = get_out_dir() + svcname + ".grpc.thrift.cpp"; - f_service_.open(f_service_name.c_str()); - f_service_ << autogen_comment(); -- f_service_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" << endl; -+ -+ f_service_ << "#include \"" << -+ get_include_prefix(*get_program()) << svcname << ".grpc.thrift.h\"" << endl; -+ - if (gen_cob_style_) { - f_service_ << "#include \"thrift/async/TAsyncChannel.h\"" << endl; - } -@@ -1652,7 +1693,7 @@ void t_cpp_generator::generate_service(t_service* tservice) { - string f_service_tcc_name = get_out_dir() + svcname + ".tcc"; - f_service_tcc_.open(f_service_tcc_name.c_str()); - f_service_tcc_ << autogen_comment(); -- f_service_tcc_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".h\"" -+ f_service_tcc_ << "#include \"" << get_include_prefix(*get_program()) << svcname << ".grpc.thrift.h\"" - << endl; - - f_service_tcc_ << "#ifndef " << svcname << "_TCC" << endl << "#define " << svcname << "_TCC" -@@ -1663,19 +1704,69 @@ void t_cpp_generator::generate_service(t_service* tservice) { - } - } - -+ f_service_ << -+ endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ "#include " << endl << -+ endl; -+ - f_service_ << endl << ns_open_ << endl << endl; - f_service_tcc_ << endl << ns_open_ << endl << endl; - -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ -+ f_service_ << -+ "static const char* " << service_name_ << "_method_names[] = {" << endl; -+ -+ -+ indent_up(); -+ -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "\"/" << ns << "." << service_name_ << "/" << (*f_iter)->get_name() << "\"," << endl; -+ } -+ -+ -+ t_service* service_iter = extends_service; -+ while (service_iter) { -+ vector functions = service_iter->get_functions(); -+ vector::iterator f_iter; -+ -+ for ( f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "\"/" << service_iter->get_program()->get_namespace("cpp") << -+ "." << service_iter->get_name() << "/" << (*f_iter)->get_name() << "\"," << endl; -+ } -+ service_iter = service_iter->get_extends(); -+ } -+ -+ indent_down(); -+ f_service_ << -+ "};" << endl; -+ -+ // Generate service class -+ if ( extends_service) { -+ f_header_ << "class " << service_name_ << " : public " << -+ type_name(extends_service) << " {" << endl << -+ "public:" << endl; -+ } -+ else { -+ f_header_ << "class " << service_name_ << "{" << endl << -+ "public:" << endl; -+ } -+ - // Generate all the components -- generate_service_interface(tservice, ""); -- generate_service_interface_factory(tservice, ""); -- generate_service_null(tservice, ""); - generate_service_helpers(tservice); -- generate_service_client(tservice, ""); -- generate_service_processor(tservice, ""); -- generate_service_multiface(tservice); -- generate_service_skeleton(tservice); -- generate_service_client(tservice, "Concurrent"); -+ generate_service_interface(tservice, ""); -+ generate_service_stub_interface(tservice); -+ generate_service_stub(tservice); - - // Generate all the cob components - if (gen_cob_style_) { -@@ -1688,10 +1779,14 @@ void t_cpp_generator::generate_service(t_service* tservice) { - generate_service_async_skeleton(tservice); - } - -+ // Close service class -+ f_header_ << "};" << endl; -+ - f_header_ << "#ifdef _WIN32\n" - " #pragma warning( pop )\n" - "#endif\n\n"; - -+ - // Close the namespace - f_service_ << ns_close_ << endl << endl; - f_service_tcc_ << ns_close_ << endl << endl; -@@ -1729,15 +1824,11 @@ void t_cpp_generator::generate_service_helpers(t_service* tservice) { - string name_orig = ts->get_name(); - - // TODO(dreiss): Why is this stuff not in generate_function_helpers? -- ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_args"); -+ ts->set_name((*f_iter)->get_name() + "Req"); - generate_struct_declaration(f_header_, ts, false); -- generate_struct_definition(out, f_service_, ts, false); -+ generate_struct_definition(out, f_service_, ts, true); - generate_struct_reader(out, ts); - generate_struct_writer(out, ts); -- ts->set_name(tservice->get_name() + "_" + (*f_iter)->get_name() + "_pargs"); -- generate_struct_declaration(f_header_, ts, false, true, false, true); -- generate_struct_definition(out, f_service_, ts, false); -- generate_struct_writer(out, ts, true); - ts->set_name(name_orig); - - generate_function_helpers(tservice, *f_iter); -@@ -1745,13 +1836,218 @@ void t_cpp_generator::generate_service_helpers(t_service* tservice) { - } - - /** -+ * Generates a service Stub Interface -+ * -+ * @param tservice The service to generate a stub for. -+ * -+ */ -+void t_cpp_generator::generate_service_stub_interface(t_service* tservice) { -+ -+ string extends = ""; -+ if (tservice->get_extends()) { -+ extends = " : virtual public " + type_name(tservice->get_extends()) + "::StubInterface"; -+ } -+ -+ f_header_ << -+ endl << -+ "class StubInterface " << extends << " {" << endl; -+ indent_up(); -+ f_header_ << -+ " public:" << endl << -+ indent() << "virtual ~StubInterface() {}" << endl; -+ -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ string function_name = (*f_iter)->get_name(); -+ f_header_ << -+ indent() << "virtual ::grpc::Status " << function_name << -+ "(::grpc::ClientContext* context, const " << function_name << -+ "Req& request, " << function_name << "Resp* response) = 0;" << endl; -+ } -+ indent_down(); -+ f_header_ << -+ "};" << endl << endl; -+ -+} -+void t_cpp_generator::generate_service_stub(t_service* tservice) { -+ f_header_ << -+ endl << -+ "class Stub : public StubInterface {" << -+ endl; -+ -+ indent_up(); -+ f_header_ << -+ " public:" << endl << -+ indent() << "Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel);" << -+ endl; -+ -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ string function_name = (*f_iter)->get_name(); -+ f_header_ << -+ indent() << "::grpc::Status " << function_name << -+ "(::grpc::ClientContext* context, const " << function_name << -+ "Req& request, " << function_name << "Resp* response) override;" << endl; -+ } -+ -+ t_service* extends_service = tservice->get_extends(); -+ t_service* service_iter = extends_service; -+ while (service_iter) { -+ // generate inherited methods -+ vector functions = service_iter->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ string function_name = (*f_iter)->get_name(); -+ f_header_ << -+ indent() << "::grpc::Status " << function_name << -+ "(::grpc::ClientContext* context, const " << function_name << -+ "Req& request, " << function_name << "Resp* response) override;" << endl; -+ } -+ service_iter = service_iter->get_extends(); -+ } -+ -+ f_header_ << -+ endl << -+ " private:" << endl << -+ indent() << "std::shared_ptr< ::grpc::ChannelInterface> channel_;" << -+ endl; -+ -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_header_ << -+ indent() << "const ::grpc::RpcMethod rpcmethod_" << (*f_iter)->get_name() << "_;" << endl; -+ } -+ -+ service_iter = extends_service; -+ while (service_iter) { -+ // generate inherited methods -+ vector functions = service_iter->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_header_ << -+ indent() << "const ::grpc::RpcMethod rpcmethod_" << (*f_iter)->get_name() << "_;" << endl; -+ } -+ service_iter = service_iter->get_extends(); -+ } -+ -+ indent_down(); -+ f_header_ << -+ "};" << endl << endl; -+ -+ // generate the implementaion of Stub -+ f_service_ << -+ endl << -+ service_name_ << "::Stub::Stub(const std::shared_ptr< ::grpc::ChannelInterface>& channel)" << endl; -+ -+ indent_up(); -+ f_service_ << -+ indent() << ": channel_(channel)" << endl; -+ int i=0; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter , ++i) { -+ f_service_ << -+ indent() << -+ ", rpcmethod_" << (*f_iter)->get_name() << "_(" << -+ service_name_ << "_method_names[" << i << "], ::grpc::RpcMethod::NORMAL_RPC, channel)" << endl; -+ } -+ -+ service_iter = extends_service; -+ while (service_iter) { -+ // generate inherited methods -+ vector functions = service_iter->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter, ++i) { -+ f_service_ << -+ indent() << -+ ", rpcmethod_" << (*f_iter)->get_name() << "_(" << -+ service_name_ << "_method_names[" << i << "], ::grpc::RpcMethod::NORMAL_RPC, channel)" << endl; -+ } -+ service_iter = service_iter->get_extends(); -+ } -+ f_service_ << -+ indent() << "{}" << endl; -+ indent_down(); -+ -+ // generate NewStub -+ f_header_ << -+ endl << -+ "static std::unique_ptr NewStub(const std::shared_ptr\ -+ < ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options = ::grpc::StubOptions());" << -+ endl; -+ -+ // generate NewStub Implementation -+ f_service_ << -+ endl << -+ "std::unique_ptr< " << service_name_ << "::Stub> " << service_name_ << "::NewStub(const std::shared_ptr\ -+ < ::grpc::ChannelInterface>& channel, const ::grpc::StubOptions& options) {" << endl; -+ -+ indent_up(); -+ f_service_ << -+ indent() << "std::unique_ptr< " << service_name_ << "::Stub> stub(new " << service_name_ << -+ "::Stub(channel));" << endl << -+ indent() << "return stub;" << endl; -+ indent_down(); -+ f_service_ << -+ "}" << endl; -+ -+ // generate stub methods -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ string function_name = (*f_iter)->get_name(); -+ f_service_ << -+ endl << -+ "::grpc::Status " << service_name_ << "::Stub::" << function_name << -+ "(::grpc::ClientContext* context, const " << service_name_ << "::" << -+ function_name << "Req& request, " << service_name_ << "::" << -+ function_name << "Resp* response) {" << endl; -+ -+ indent_up(); -+ f_service_ << -+ indent() << "return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_" << -+ function_name << "_, context, request, response);" << endl; -+ indent_down(); -+ -+ f_service_ << -+ "}" << endl; -+ -+ } -+ -+ service_iter = extends_service; -+ while (service_iter) { -+ vector functions = service_iter->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ string function_name = (*f_iter)->get_name(); -+ f_service_ << -+ endl << -+ "::grpc::Status " << service_name_ << "::Stub::" << function_name << -+ "(::grpc::ClientContext* context, const " << service_name_ << "::" << -+ function_name << "Req& request, " << service_name_ << "::" << -+ function_name << "Resp* response) {" << endl; -+ -+ indent_up(); -+ f_service_ << -+ indent() << "return ::grpc::BlockingUnaryCall(channel_.get(), rpcmethod_" << -+ function_name << "_, context, request, response);" << endl; -+ indent_down(); -+ -+ f_service_ << -+ "}" << endl; -+ -+ } -+ service_iter = service_iter->get_extends(); -+ } -+ -+} -+ -+ -+/** - * Generates a service interface definition. - * - * @param tservice The service to generate a header definition for - */ - void t_cpp_generator::generate_service_interface(t_service* tservice, string style) { - -- string service_if_name = service_name_ + style + "If"; -+ string service_if_name = "Service"; - if (style == "CobCl") { - // Forward declare the client. - string client_name = service_name_ + "CobClient"; -@@ -1764,13 +2060,15 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty - } - - string extends = ""; -- if (tservice->get_extends() != NULL) { -- extends = " : virtual public " + type_name(tservice->get_extends()) + style + "If"; -+ if (tservice->get_extends()) { -+ extends = " : virtual public " + type_name(tservice->get_extends()) + style + "::Service"; - if (style == "CobCl" && gen_templates_) { - // TODO(simpkins): If gen_templates_ is enabled, we currently assume all - // parent services were also generated with templates enabled. - extends += "T"; - } -+ } else { -+ extends = " : public ::grpc::Service"; - } - - if (style == "CobCl" && gen_templates_) { -@@ -1778,7 +2076,9 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty - } - f_header_ << "class " << service_if_name << extends << " {" << endl << " public:" << endl; - indent_up(); -- f_header_ << indent() << "virtual ~" << service_if_name << "() {}" << endl; -+ -+ f_header_ << indent() << "Service();" << endl; -+ f_header_ << indent() << "virtual ~Service();" << endl; - - vector functions = tservice->get_functions(); - vector::iterator f_iter; -@@ -1786,7 +2086,12 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty - if ((*f_iter)->has_doc()) - f_header_ << endl; - generate_java_doc(f_header_, *f_iter); -- f_header_ << indent() << "virtual " << function_signature(*f_iter, style) << " = 0;" << endl; -+ -+ string function_name = (*f_iter)->get_name(); -+ f_header_ << -+ indent() << "virtual ::grpc::Status " << function_name << -+ "(::grpc::ServerContext* context, const "<< function_name << -+ "Req* request, "<< function_name << "Resp* response);" << endl; - } - indent_down(); - f_header_ << "};" << endl << endl; -@@ -1797,6 +2102,66 @@ void t_cpp_generator::generate_service_interface(t_service* tservice, string sty - f_header_ << "typedef " << service_if_name << "< ::apache::thrift::protocol::TProtocol> " - << service_name_ << style << "If;" << endl << endl; - } -+ -+ // generate the service interface implementations -+ -+ f_service_ << -+ endl << -+ service_name_ << "::Service::Service() {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "(void)" << service_name_ << "_method_names;" << endl; -+ uint32_t i=0; -+ for(i=0;iget_name(); -+ f_service_ << -+ endl << -+ indent() << "AddMethod(new ::grpc::RpcServiceMethod(" << endl; -+ indent_up(); -+ -+ f_service_ << -+ indent() << service_name_ << "_method_names[" << i << "]," << endl << -+ indent() << "::grpc::RpcMethod::NORMAL_RPC," << endl << -+ indent() << "new ::grpc::RpcMethodHandler< " << service_name_ << "::Service, " << -+ service_name_ << "::" << function_name << "Req, " << service_name_ << "::" << -+ function_name << "Resp>(" << endl; -+ -+ indent_up(); -+ f_service_ << -+ indent() << "std::mem_fn(&" << service_name_ << "::Service::" << function_name << "), this)));" << endl; -+ -+ indent_down(); -+ indent_down(); -+ } -+ -+ indent_down(); -+ f_service_ << -+ "}" << endl; -+ -+ f_service_ << -+ endl << -+ service_name_ << "::Service::~Service() {" << endl << -+ "}" << endl; -+ -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ string function_name = (*f_iter)->get_name(); -+ f_service_ << -+ endl << -+ "::grpc::Status " << service_name_ << "::Service::" << function_name << -+ "(::grpc::ServerContext* context, const " << service_name_ << "::" << function_name << -+ "Req* request, " << service_name_ << "::" << function_name << "Resp* response) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "(void) context;" << endl << -+ indent() << "(void) request;" << endl << -+ indent() << "(void) response;" << endl << -+ indent() << "return ::grpc::Status(::grpc::StatusCode::UNIMPLEMENTED,\"\");" << endl; -+ indent_down(); -+ -+ f_service_ << -+ "}" << endl; -+ } -+ - } - - /** -@@ -3095,7 +3460,7 @@ void t_cpp_generator::generate_function_helpers(t_service* tservice, t_function* - - std::ofstream& out = (gen_templates_ ? f_service_tcc_ : f_service_); - -- t_struct result(program_, tservice->get_name() + "_" + tfunction->get_name() + "_result"); -+ t_struct result(program_, tfunction->get_name() + "Resp"); - t_field success(tfunction->get_returntype(), "success", 0); - if (!tfunction->get_returntype()->is_void()) { - result.append(&success); -@@ -3109,17 +3474,9 @@ void t_cpp_generator::generate_function_helpers(t_service* tservice, t_function* - } - - generate_struct_declaration(f_header_, &result, false); -- generate_struct_definition(out, f_service_, &result, false); -+ generate_struct_definition(out, f_service_, &result, true); - generate_struct_reader(out, &result); - generate_struct_result_writer(out, &result); -- -- result.set_name(tservice->get_name() + "_" + tfunction->get_name() + "_presult"); -- generate_struct_declaration(f_header_, &result, false, true, true, gen_cob_style_); -- generate_struct_definition(out, f_service_, &result, false); -- generate_struct_reader(out, &result, true); -- if (gen_cob_style_) { -- generate_struct_writer(out, &result, true); -- } - } - - /** -@@ -3162,8 +3519,8 @@ void t_cpp_generator::generate_process_function(t_service* tservice, - << endl; - scope_up(out); - -- string argsname = tservice->get_name() + "_" + tfunction->get_name() + "_args"; -- string resultname = tservice->get_name() + "_" + tfunction->get_name() + "_result"; -+ string argsname = tfunction->get_name() + "Req"; -+ string resultname = tfunction->get_name() + "Resp"; - - if (tfunction->is_oneway() && !unnamed_oprot_seqid) { - out << indent() << "(void) seqid;" << endl << indent() << "(void) oprot;" << endl; -@@ -3320,7 +3677,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice, - out << indent() << "(void) seqid;" << endl << indent() << "(void) oprot;" << endl; - } - -- out << indent() << tservice->get_name() + "_" + tfunction->get_name() << "_args args;" << endl -+ out << indent() << tfunction->get_name() << "Req args;" << endl - << indent() << "void* ctx = NULL;" << endl << indent() - << "if (this->eventHandler_.get() != NULL) {" << endl << indent() - << " ctx = this->eventHandler_->getContext(" << service_func_name << ", NULL);" << endl -@@ -3487,7 +3844,7 @@ void t_cpp_generator::generate_process_function(t_service* tservice, - << "this->eventHandler_.get(), ctx, " << service_func_name << ");" << endl << endl; - - // Throw the TDelayedException, and catch the result -- out << indent() << tservice->get_name() << "_" << tfunction->get_name() << "_result result;" -+ out << indent() << tfunction->get_name() << "Resp result;" - << endl << endl << indent() << "try {" << endl; - indent_up(); - out << indent() << "_throw->throw_it();" << endl << indent() << "return cob(false);" -diff --git a/tutorial/cpp/CMakeLists.txt b/tutorial/cpp/CMakeLists.txt -deleted file mode 100644 -index 8a3d085..0000000 ---- a/tutorial/cpp/CMakeLists.txt -+++ /dev/null -@@ -1,53 +0,0 @@ --# --# Licensed to the Apache Software Foundation (ASF) under one --# or more contributor license agreements. See the NOTICE file --# distributed with this work for additional information --# regarding copyright ownership. The ASF licenses this file --# to you under the Apache License, Version 2.0 (the --# "License"); you may not use this file except in compliance --# with the License. You may obtain a copy of the License at --# --# http://www.apache.org/licenses/LICENSE-2.0 --# --# Unless required by applicable law or agreed to in writing, --# software distributed under the License is distributed on an --# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY --# KIND, either express or implied. See the License for the --# specific language governing permissions and limitations --# under the License. --# -- --find_package(Boost 1.53.0 REQUIRED) --include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") -- --#Make sure gen-cpp files can be included --include_directories("${CMAKE_CURRENT_BINARY_DIR}") --include_directories("${CMAKE_CURRENT_BINARY_DIR}/gen-cpp") --include_directories("${PROJECT_SOURCE_DIR}/lib/cpp/src") -- --include(ThriftMacros) -- --set(tutorialgencpp_SOURCES -- gen-cpp/Calculator.cpp -- gen-cpp/SharedService.cpp -- gen-cpp/shared_constants.cpp -- gen-cpp/shared_types.cpp -- gen-cpp/tutorial_constants.cpp -- gen-cpp/tutorial_types.cpp --) --add_library(tutorialgencpp STATIC ${tutorialgencpp_SOURCES}) --LINK_AGAINST_THRIFT_LIBRARY(tutorialgencpp thrift) -- --add_custom_command(OUTPUT gen-cpp/Calculator.cpp gen-cpp/SharedService.cpp gen-cpp/shared_constants.cpp gen-cpp/shared_types.cpp gen-cpp/tutorial_constants.cpp gen-cpp/tutorial_types.cpp -- COMMAND ${THRIFT_COMPILER} --gen cpp -r ${PROJECT_SOURCE_DIR}/tutorial/tutorial.thrift --) -- --add_executable(TutorialServer CppServer.cpp) --target_link_libraries(TutorialServer tutorialgencpp) --LINK_AGAINST_THRIFT_LIBRARY(TutorialServer thrift) --target_link_libraries(TutorialServer ${ZLIB_LIBRARIES}) -- --add_executable(TutorialClient CppClient.cpp) --target_link_libraries(TutorialClient tutorialgencpp) --LINK_AGAINST_THRIFT_LIBRARY(TutorialClient thrift) --target_link_libraries(TutorialClient ${ZLIB_LIBRARIES}) -diff --git a/tutorial/cpp/CppClient.cpp b/tutorial/cpp/CppClient.cpp -deleted file mode 100644 -index 2763fee..0000000 ---- a/tutorial/cpp/CppClient.cpp -+++ /dev/null -@@ -1,80 +0,0 @@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, -- * software distributed under the License is distributed on an -- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -- * KIND, either express or implied. See the License for the -- * specific language governing permissions and limitations -- * under the License. -- */ -- --#include -- --#include --#include --#include -- --#include "../gen-cpp/Calculator.h" -- --using namespace std; --using namespace apache::thrift; --using namespace apache::thrift::protocol; --using namespace apache::thrift::transport; -- --using namespace tutorial; --using namespace shared; -- --int main() { -- boost::shared_ptr socket(new TSocket("localhost", 9090)); -- boost::shared_ptr transport(new TBufferedTransport(socket)); -- boost::shared_ptr protocol(new TBinaryProtocol(transport)); -- CalculatorClient client(protocol); -- -- try { -- transport->open(); -- -- client.ping(); -- cout << "ping()" << endl; -- -- cout << "1 + 1 = " << client.add(1, 1) << endl; -- -- Work work; -- work.op = Operation::DIVIDE; -- work.num1 = 1; -- work.num2 = 0; -- -- try { -- client.calculate(1, work); -- cout << "Whoa? We can divide by zero!" << endl; -- } catch (InvalidOperation& io) { -- cout << "InvalidOperation: " << io.why << endl; -- // or using generated operator<<: cout << io << endl; -- // or by using std::exception native method what(): cout << io.what() << endl; -- } -- -- work.op = Operation::SUBTRACT; -- work.num1 = 15; -- work.num2 = 10; -- int32_t diff = client.calculate(1, work); -- cout << "15 - 10 = " << diff << endl; -- -- // Note that C++ uses return by reference for complex types to avoid -- // costly copy construction -- SharedStruct ss; -- client.getStruct(ss, 1); -- cout << "Received log: " << ss << endl; -- -- transport->close(); -- } catch (TException& tx) { -- cout << "ERROR: " << tx.what() << endl; -- } --} -diff --git a/tutorial/cpp/CppServer.cpp b/tutorial/cpp/CppServer.cpp -deleted file mode 100644 -index eafffa9..0000000 ---- a/tutorial/cpp/CppServer.cpp -+++ /dev/null -@@ -1,181 +0,0 @@ --/* -- * Licensed to the Apache Software Foundation (ASF) under one -- * or more contributor license agreements. See the NOTICE file -- * distributed with this work for additional information -- * regarding copyright ownership. The ASF licenses this file -- * to you under the Apache License, Version 2.0 (the -- * "License"); you may not use this file except in compliance -- * with the License. You may obtain a copy of the License at -- * -- * http://www.apache.org/licenses/LICENSE-2.0 -- * -- * Unless required by applicable law or agreed to in writing, -- * software distributed under the License is distributed on an -- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -- * KIND, either express or implied. See the License for the -- * specific language governing permissions and limitations -- * under the License. -- */ -- --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include -- --#include -- --#include --#include --#include -- --#include "../gen-cpp/Calculator.h" -- --using namespace std; --using namespace apache::thrift; --using namespace apache::thrift::concurrency; --using namespace apache::thrift::protocol; --using namespace apache::thrift::transport; --using namespace apache::thrift::server; -- --using namespace tutorial; --using namespace shared; -- --class CalculatorHandler : public CalculatorIf { --public: -- CalculatorHandler() {} -- -- void ping() { cout << "ping()" << endl; } -- -- int32_t add(const int32_t n1, const int32_t n2) { -- cout << "add(" << n1 << ", " << n2 << ")" << endl; -- return n1 + n2; -- } -- -- int32_t calculate(const int32_t logid, const Work& work) { -- cout << "calculate(" << logid << ", " << work << ")" << endl; -- int32_t val; -- -- switch (work.op) { -- case Operation::ADD: -- val = work.num1 + work.num2; -- break; -- case Operation::SUBTRACT: -- val = work.num1 - work.num2; -- break; -- case Operation::MULTIPLY: -- val = work.num1 * work.num2; -- break; -- case Operation::DIVIDE: -- if (work.num2 == 0) { -- InvalidOperation io; -- io.whatOp = work.op; -- io.why = "Cannot divide by 0"; -- throw io; -- } -- val = work.num1 / work.num2; -- break; -- default: -- InvalidOperation io; -- io.whatOp = work.op; -- io.why = "Invalid Operation"; -- throw io; -- } -- -- SharedStruct ss; -- ss.key = logid; -- ss.value = to_string(val); -- -- log[logid] = ss; -- -- return val; -- } -- -- void getStruct(SharedStruct& ret, const int32_t logid) { -- cout << "getStruct(" << logid << ")" << endl; -- ret = log[logid]; -- } -- -- void zip() { cout << "zip()" << endl; } -- --protected: -- map log; --}; -- --/* -- CalculatorIfFactory is code generated. -- CalculatorCloneFactory is useful for getting access to the server side of the -- transport. It is also useful for making per-connection state. Without this -- CloneFactory, all connections will end up sharing the same handler instance. --*/ --class CalculatorCloneFactory : virtual public CalculatorIfFactory { -- public: -- virtual ~CalculatorCloneFactory() {} -- virtual CalculatorIf* getHandler(const ::apache::thrift::TConnectionInfo& connInfo) -- { -- boost::shared_ptr sock = boost::dynamic_pointer_cast(connInfo.transport); -- cout << "Incoming connection\n"; -- cout << "\tSocketInfo: " << sock->getSocketInfo() << "\n"; -- cout << "\tPeerHost: " << sock->getPeerHost() << "\n"; -- cout << "\tPeerAddress: " << sock->getPeerAddress() << "\n"; -- cout << "\tPeerPort: " << sock->getPeerPort() << "\n"; -- return new CalculatorHandler; -- } -- virtual void releaseHandler( ::shared::SharedServiceIf* handler) { -- delete handler; -- } --}; -- --int main() { -- TThreadedServer server( -- boost::make_shared(boost::make_shared()), -- boost::make_shared(9090), //port -- boost::make_shared(), -- boost::make_shared()); -- -- /* -- // if you don't need per-connection state, do the following instead -- TThreadedServer server( -- boost::make_shared(boost::make_shared()), -- boost::make_shared(9090), //port -- boost::make_shared(), -- boost::make_shared()); -- */ -- -- /** -- * Here are some alternate server types... -- -- // This server only allows one connection at a time, but spawns no threads -- TSimpleServer server( -- boost::make_shared(boost::make_shared()), -- boost::make_shared(9090), -- boost::make_shared(), -- boost::make_shared()); -- -- const int workerCount = 4; -- -- boost::shared_ptr threadManager = -- ThreadManager::newSimpleThreadManager(workerCount); -- threadManager->threadFactory( -- boost::make_shared()); -- threadManager->start(); -- -- // This server allows "workerCount" connection at a time, and reuses threads -- TThreadPoolServer server( -- boost::make_shared(boost::make_shared()), -- boost::make_shared(9090), -- boost::make_shared(), -- boost::make_shared(), -- threadManager); -- */ -- -- cout << "Starting the server..." << endl; -- server.serve(); -- cout << "Done." << endl; -- return 0; --} -diff --git a/tutorial/cpp/GriftClient.cpp b/tutorial/cpp/GriftClient.cpp -new file mode 100644 -index 0000000..647a683 ---- /dev/null -+++ b/tutorial/cpp/GriftClient.cpp -@@ -0,0 +1,93 @@ -+/* -+ * -+ * Copyright 2016, Google Inc. -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions are -+ * met: -+ * -+ * * Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * * Redistributions in binary form must reproduce the above -+ * copyright notice, this list of conditions and the following disclaimer -+ * in the documentation and/or other materials provided with the -+ * distribution. -+ * * Neither the name of Google Inc. nor the names of its -+ * contributors may be used to endorse or promote products derived from -+ * this software without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ */ -+ -+#include -+#include -+#include -+ -+#include -+ -+#include "gen-cpp/Greeter.grpc.thrift.h" -+ -+using grpc::Channel; -+using grpc::ClientContext; -+using grpc::Status; -+using test::Greeter; -+ -+class GreeterClient { -+ public: -+ GreeterClient(std::shared_ptr channel) -+ : stub_(Greeter::NewStub(channel)) {} -+ -+ // Assembles the client's payload, sends it and presents the response back -+ // from the server. -+ std::string SayHello(const std::string& user) { -+ // Data we are sending to the server. -+ Greeter::SayHelloReq req; -+ req.request.name = user; -+ -+ // Container for the data we expect from the server. -+ Greeter::SayHelloResp reply; -+ -+ // Context for the client. It could be used to convey extra information to -+ // the server and/or tweak certain RPC behaviors. -+ ClientContext context; -+ -+ // The actual RPC. -+ Status status = stub_->SayHello(&context, req, &reply); -+ -+ // Act upon its status. -+ if (status.ok()) { -+ return reply.success.message; -+ } else { -+ return "RPC failed"; -+ } -+ } -+ -+ private: -+ std::unique_ptr stub_; -+}; -+ -+int main() { -+ // Instantiate the client. It requires a channel, out of which the actual RPCs -+ // are created. This channel models a connection to an endpoint (in this case, -+ // localhost at port 50051). We indicate that the channel isn't authenticated -+ // (use of InsecureChannelCredentials()). -+ GreeterClient greeter(grpc::CreateChannel( -+ "localhost:50051", grpc::InsecureChannelCredentials())); -+ std::string user("world"); -+ std::string reply = greeter.SayHello(user); -+ std::cout << "Greeter received: " << reply << std::endl; -+ -+ return 0; -+} -diff --git a/tutorial/cpp/GriftServer.cpp b/tutorial/cpp/GriftServer.cpp -new file mode 100644 -index 0000000..7c01606 ---- /dev/null -+++ b/tutorial/cpp/GriftServer.cpp -@@ -0,0 +1,93 @@ -+/* -+ * -+ * Copyright 2016, Google Inc. -+ * All rights reserved. -+ * -+ * Redistribution and use in source and binary forms, with or without -+ * modification, are permitted provided that the following conditions are -+ * met: -+ * -+ * * Redistributions of source code must retain the above copyright -+ * notice, this list of conditions and the following disclaimer. -+ * * Redistributions in binary form must reproduce the above -+ * copyright notice, this list of conditions and the following disclaimer -+ * in the documentation and/or other materials provided with the -+ * distribution. -+ * * Neither the name of Google Inc. nor the names of its -+ * contributors may be used to endorse or promote products derived from -+ * this software without specific prior written permission. -+ * -+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -+ * -+ */ -+ -+#include -+#include -+#include -+ -+#include -+ -+#include "gen-cpp/Greeter.grpc.thrift.h" -+#include -+ -+using grpc::Server; -+using grpc::ServerBuilder; -+using grpc::ServerContext; -+using grpc::Status; -+using test::Greeter; -+ -+// Logic and data behind the server's behavior. -+class GreeterServiceImpl final : public Greeter::Service { -+ public: -+ ~GreeterServiceImpl() { -+ // shutdown server -+ server->Shutdown(); -+ } -+ -+ Status SayHello(ServerContext* context,const Greeter::SayHelloReq* request, -+ Greeter::SayHelloResp* reply) override { -+ std::string prefix("Hello "); -+ -+ reply->success.message = prefix + request->request.name; -+ -+ return Status::OK; -+ } -+ -+ void RunServer() { -+ std::string server_address("0.0.0.0:50051"); -+ -+ ServerBuilder builder; -+ // Listen on the given address without any authentication mechanism. -+ builder.AddListeningPort(server_address, grpc::InsecureServerCredentials()); -+ // Register "service" as the instance through which we'll communicate with -+ // clients. In this case it corresponds to an *synchronous* service. -+ builder.RegisterService(this); -+ // Finally assemble the server. -+ server = builder.BuildAndStart(); -+ std::cout << "Server listening on " << server_address << std::endl; -+ -+ // Wait for the server to shutdown. Note that some other thread must be -+ // responsible for shutting down the server for this call to ever return. -+ server->Wait(); -+ } -+ -+ private: -+ std::unique_ptr server; -+}; -+ -+int main() { -+ GreeterServiceImpl service; -+ service.RunServer(); -+ -+ return 0; -+} -diff --git a/tutorial/cpp/Makefile.am b/tutorial/cpp/Makefile.am -index 184a69d..6f91e28 100755 ---- a/tutorial/cpp/Makefile.am -+++ b/tutorial/cpp/Makefile.am -@@ -18,44 +18,38 @@ - # - AUTOMAKE_OPTIONS = subdir-objects serial-tests - --BUILT_SOURCES = gen-cpp/shared_types.cpp \ -- gen-cpp/tutorial_types.cpp -+BUILT_SOURCES = gen-cpp/test_types.cpp - --noinst_LTLIBRARIES = libtutorialgencpp.la --nodist_libtutorialgencpp_la_SOURCES = \ -- gen-cpp/Calculator.cpp \ -- gen-cpp/Calculator.h \ -- gen-cpp/SharedService.cpp \ -- gen-cpp/SharedService.h \ -- gen-cpp/shared_constants.cpp \ -- gen-cpp/shared_constants.h \ -- gen-cpp/shared_types.cpp \ -- gen-cpp/shared_types.h \ -- gen-cpp/tutorial_constants.cpp \ -- gen-cpp/tutorial_constants.h \ -- gen-cpp/tutorial_types.cpp \ -- gen-cpp/tutorial_types.h -+#noinst_LTLIBRARIES = libtutorialgencpp.la -+noinst_LTLIBRARIES = libtestgencpp.la -+nodist_libtestgencpp_la_SOURCES = \ -+ gen-cpp/Greeter.grpc.thrift.cpp \ -+ gen-cpp/Greeter.grpc.thrift.h \ -+ gen-cpp/test_constants.cpp \ -+ gen-cpp/test_constants.h \ -+ gen-cpp/test_types.cpp \ -+ gen-cpp/test_types.h - - - --libtutorialgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la -+libtestgencpp_la_LIBADD = $(top_builddir)/lib/cpp/libthrift.la - - noinst_PROGRAMS = \ -- TutorialServer \ -- TutorialClient -+ TestServer \ -+ TestClient - --TutorialServer_SOURCES = \ -- CppServer.cpp -+TestServer_SOURCES = \ -+ GriftServer.cpp - --TutorialServer_LDADD = \ -- libtutorialgencpp.la \ -+TestServer_LDADD = \ -+ libtestgencpp.la \ - $(top_builddir)/lib/cpp/libthrift.la - --TutorialClient_SOURCES = \ -- CppClient.cpp -+TestClient_SOURCES = \ -+ GriftClient.cpp - --TutorialClient_LDADD = \ -- libtutorialgencpp.la \ -+TestClient_LDADD = \ -+ libtestgencpp.la \ - $(top_builddir)/lib/cpp/libthrift.la - - # -@@ -63,26 +57,26 @@ TutorialClient_LDADD = \ - # - THRIFT = $(top_builddir)/compiler/cpp/thrift - --gen-cpp/Calculator.cpp gen-cpp/SharedService.cpp gen-cpp/shared_constants.cpp gen-cpp/shared_types.cpp gen-cpp/tutorial_constants.cpp gen-cpp/tutorial_types.cpp: $(top_srcdir)/tutorial/tutorial.thrift -+gen-cpp/Greeter.grpc.thrift.cpp gen-cpp/test_constants.cpp gen-cpp/test_types.cpp: $(top_srcdir)/tutorial/cpp/test.thrift - $(THRIFT) --gen cpp -r $< - - AM_CPPFLAGS = $(BOOST_CPPFLAGS) $(LIBEVENT_CPPFLAGS) -I$(top_srcdir)/lib/cpp/src -Igen-cpp - AM_CXXFLAGS = -Wall -Wextra -pedantic --AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS) -+AM_LDFLAGS = $(BOOST_LDFLAGS) $(LIBEVENT_LDFLAGS) `pkg-config --libs grpc++ grpc` -lpthread -ldl -lgrpc - - clean-local: -- $(RM) gen-cpp/* -+ $(RM) -r gen-cpp - --tutorialserver: all -- ./TutorialServer -+testserver: all -+ ./TestServer - --tutorialclient: all -- ./TutorialClient -+testclient: all -+ ./TestClient - - style-local: - $(CPPSTYLE_CMD) - - EXTRA_DIST = \ - CMakeLists.txt \ -- CppClient.cpp \ -- CppServer.cpp -+ GriftClient.cpp \ -+ GriftServer.cpp -diff --git a/tutorial/cpp/test.thrift b/tutorial/cpp/test.thrift -new file mode 100644 -index 0000000..de3c9a4 ---- /dev/null -+++ b/tutorial/cpp/test.thrift -@@ -0,0 +1,13 @@ -+namespace cpp test -+ -+struct HelloRequest { -+ 1:string name -+} -+ -+struct HelloResponse { -+ 1:string message -+} -+ -+service Greeter { -+ HelloResponse SayHello(1:HelloRequest request); -+} -\ No newline at end of file --- -2.8.0.rc3.226.g39d4020 - - -From 3e4d75a2e2c474ee7700e7c9acaf89fdb768bedc Mon Sep 17 00:00:00 2001 -From: chedeti -Date: Sun, 31 Jul 2016 16:23:53 -0700 -Subject: [PATCH 3/3] grpc java plugins generator - -for examples refer to https://github.com/grpc/grpc-java/tree/master/examples/thrift ---- - compiler/cpp/src/generate/t_java_generator.cc | 906 +++++++++++++++++++++++++- - tutorial/Makefile.am | 8 +- - 2 files changed, 887 insertions(+), 27 deletions(-) - -diff --git a/compiler/cpp/src/generate/t_java_generator.cc b/compiler/cpp/src/generate/t_java_generator.cc -index 2db8cb8..8b28fe2 100644 ---- a/compiler/cpp/src/generate/t_java_generator.cc -+++ b/compiler/cpp/src/generate/t_java_generator.cc -@@ -97,10 +97,10 @@ public: - } else if(iter->second.compare("suppress") == 0) { - suppress_generated_annotations_ = true; - } else { -- throw "unknown option java:" + iter->first + "=" + iter->second; -+ throw "unknown option java:" + iter->first + "=" + iter->second; - } - } else { -- throw "unknown option java:" + iter->first; -+ throw "unknown option java:" + iter->first; - } - } - -@@ -195,6 +195,17 @@ public: - void generate_service_async_server(t_service* tservice); - void generate_process_function(t_service* tservice, t_function* tfunction); - void generate_process_async_function(t_service* tservice, t_function* tfunction); -+ void generate_service_impl_base(t_service* tservice); -+ void generate_method_descriptors(t_service* tservice); -+ void generate_stub(t_service* tservice); -+ void generate_blocking_stub(t_service* tservice); -+ void generate_future_stub(t_service* tservice); -+ void generate_method_ids(t_service* tservice); -+ void generate_method_handlers(t_service* tservice); -+ void generate_service_descriptors(t_service* tservice); -+ void generate_service_builder(t_service* tservice); -+ void generate_arg_ids(t_service* tservice); -+ void generate_message_factory(t_service* tservice); - - void generate_java_union(t_struct* tstruct); - void generate_union_constructor(ofstream& out, t_struct* tstruct); -@@ -307,6 +318,8 @@ public: - std::string java_package(); - std::string java_type_imports(); - std::string java_suppressions(); -+ std::string grpc_imports(); -+ std::string import_extended_service(t_service* tservice); - std::string type_name(t_type* ttype, - bool in_container = false, - bool in_init = false, -@@ -368,7 +381,7 @@ private: - bool use_option_type_; - bool undated_generated_annotations_; - bool suppress_generated_annotations_; -- -+ - }; - - /** -@@ -456,6 +469,35 @@ string t_java_generator::java_suppressions() { - return "@SuppressWarnings({\"cast\", \"rawtypes\", \"serial\", \"unchecked\", \"unused\"})\n"; - } - -+string t_java_generator::grpc_imports() { -+ return -+ string() + -+ "import static io.grpc.stub.ClientCalls.asyncUnaryCall;\n" + -+ "import static io.grpc.stub.ClientCalls.asyncServerStreamingCall;\n" + -+ "import static io.grpc.stub.ClientCalls.asyncClientStreamingCall;\n" + -+ "import static io.grpc.stub.ClientCalls.asyncBidiStreamingCall;\n" + -+ "import static io.grpc.stub.ClientCalls.blockingUnaryCall;\n" + -+ "import static io.grpc.stub.ClientCalls.blockingServerStreamingCall;\n" + -+ "import static io.grpc.stub.ClientCalls.futureUnaryCall;\n" + -+ "import static io.grpc.MethodDescriptor.generateFullMethodName;\n" + -+ "import static io.grpc.stub.ServerCalls.asyncUnaryCall;\n" + -+ "import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;\n" + -+ "import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;\n" + -+ "import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;\n" + -+ "import static io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall;\n" + -+ "import static io.grpc.stub.ServerCalls.asyncUnimplementedStreamingCall;\n" + -+ "import io.grpc.thrift.ThriftUtils;\n\n"; -+} -+ -+string t_java_generator::import_extended_service(t_service* tservice) { -+ if (!tservice) { -+ return string() + "\n"; -+ } -+ string ns = tservice->get_program()->get_namespace("java"); -+ string extend_service_name = tservice->get_name() + "Grpc"; -+ return string() + "import " + ns + "." + extend_service_name + ";\n\n"; -+} -+ - /** - * Nothing in Java - */ -@@ -2772,25 +2814,51 @@ void t_java_generator::generate_field_value_meta_data(std::ofstream& out, t_type - */ - void t_java_generator::generate_service(t_service* tservice) { - // Make output file -- string f_service_name = package_dir_ + "/" + make_valid_java_filename(service_name_) + ".java"; -+ string f_service_name = package_dir_ + "/" + make_valid_java_filename(service_name_) + "Grpc.java"; - f_service_.open(f_service_name.c_str()); - -- f_service_ << autogen_comment() << java_package() << java_type_imports() << java_suppressions(); -+ f_service_ << -+ autogen_comment() << -+ java_package() << -+ java_type_imports() << -+ grpc_imports() << -+ import_extended_service(tservice->get_extends()); -+ java_suppressions(); -+ -+ f_service_ << -+ "public class " << service_name_ << "Grpc {" << endl << -+ endl; - -- if (!suppress_generated_annotations_) { -- generate_javax_generated_annotation(f_service_); -- } -- f_service_ << "public class " << service_name_ << " {" << endl << endl; - indent_up(); - -+ // generate constructor -+ f_service_ << -+ indent() << "private " << service_name_ << -+ "Grpc() {}" << endl << endl; -+ -+ f_service_ << -+ indent() << "public static final String SERVICE_NAME = " << -+ "\"" << package_name_ << "." << service_name_ << "\";" << endl << endl; -+ - // Generate the three main parts of the service - generate_service_interface(tservice); -- generate_service_async_interface(tservice); -- generate_service_client(tservice); -- generate_service_async_client(tservice); -- generate_service_server(tservice); -- generate_service_async_server(tservice); -+ generate_arg_ids(tservice); -+ generate_message_factory(tservice); -+ generate_service_impl_base(tservice); -+ //generate_service_async_interface(tservice); -+ //generate_service_client(tservice); -+ //generate_service_async_client(tservice); -+ //generate_service_server(tservice); -+ //generate_service_async_server(tservice); - generate_service_helpers(tservice); -+ generate_method_descriptors(tservice); -+ generate_stub(tservice); -+ generate_blocking_stub(tservice); -+ generate_future_stub(tservice); -+ generate_method_ids(tservice); -+ generate_method_handlers(tservice); -+ generate_service_descriptors(tservice); -+ generate_service_builder(tservice); - - indent_down(); - f_service_ << "}" << endl; -@@ -2805,24 +2873,820 @@ void t_java_generator::generate_service(t_service* tservice) { - void t_java_generator::generate_service_interface(t_service* tservice) { - string extends = ""; - string extends_iface = ""; -- if (tservice->get_extends() != NULL) { -- extends = type_name(tservice->get_extends()); -- extends_iface = " extends " + extends + ".Iface"; -- } - - generate_java_doc(f_service_, tservice); -- f_service_ << indent() << "public interface Iface" << extends_iface << " {" << endl << endl; -+ f_service_ << indent() << -+ "@java.lang.Deprecated public static interface " << service_name_; -+ -+ if (tservice->get_extends()) { -+ f_service_ << " extends " << tservice->get_extends()->get_name() + "Grpc." << -+ tservice->get_extends()->get_name() << endl; -+ } -+ f_service_ << " {" << endl; -+ -+ indent_up(); -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ //generate_java_doc(f_service_, *f_iter); -+ f_service_ << -+ indent() << "public void " << (*f_iter)->get_name() << "(" << (*f_iter)->get_name() << -+ "_args request," << endl << -+ indent() << " io.grpc.stub.StreamObserver<" << (*f_iter)->get_name() << -+ "_result> responseObserver);" << endl << endl; -+ } -+ indent_down(); -+ f_service_ << indent() << "}" << endl << endl; -+} -+ -+void t_java_generator::generate_arg_ids(t_service* tservice) { -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ int i=0; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << indent() << -+ "private static final int ARG_IN_METHOD_" << -+ (*f_iter)->get_name() << " = " << ++i << ";" << endl; -+ f_service_ << indent() << -+ "private static final int ARG_OUT_METHOD_" << -+ (*f_iter)->get_name() << " = " << ++i << ";" << endl; -+ } -+ f_service_ << endl; -+ -+ if (tservice->get_extends()) { -+ f_service_ << indent() << "// ARG IDs for extended service" << endl; -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << indent() << -+ "private static final int ARG_IN_METHOD_" << -+ (*f_iter)->get_name() << " = " << ++i << ";" << endl; -+ f_service_ << indent() << -+ "private static final int ARG_OUT_METHOD_" << -+ (*f_iter)->get_name() << " = " << ++i << ";" << endl; -+ } -+ f_service_ << endl; -+ } -+} -+ -+void t_java_generator::generate_message_factory(t_service* tservice) { -+ f_service_ << indent() << -+ "private static final class ThriftMessageFactory>" << endl << indent() << -+ " implements io.grpc.thrift.MessageFactory {" << endl; -+ indent_up(); -+ f_service_ << indent() << -+ "private final int id;" << endl << endl; -+ f_service_ << endl; -+ -+ f_service_ << indent() << -+ "ThriftMessageFactory(int id) {" << endl << -+ indent() << " this.id = id;" << endl << -+ indent() << "}" << endl; -+ -+ f_service_ << indent() << -+ "@java.lang.Override" << endl << -+ indent() << "public T newInstance() {" << endl; -+ indent_up(); -+ -+ f_service_ << indent() << -+ "Object o;" << endl << -+ indent() << "switch (id) {" << endl; -+ -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << indent() << -+ "case ARG_IN_METHOD_" << (*f_iter)->get_name() << ":" << endl << -+ indent() << " o = new " << (*f_iter)->get_name() << "_args();" << -+ endl << indent() << " break;" << endl; -+ f_service_ << indent() << -+ "case ARG_OUT_METHOD_" << (*f_iter)->get_name() << ":" << endl << -+ indent() << " o = new " << (*f_iter)->get_name() << "_result();" << -+ endl << indent() << " break;" << endl; -+ } -+ -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for (f_iter = functions.begin(); f_iter!= functions.end(); ++f_iter) { -+ f_service_ << indent() << -+ "case ARG_IN_METHOD_" << (*f_iter)->get_name() << ":" << endl << -+ indent() << " o = new " << extend_service_name << "." << (*f_iter)->get_name() << "_args();" << -+ endl << indent() << " break;" << endl; -+ f_service_ << indent() << -+ "case ARG_OUT_METHOD_" << (*f_iter)->get_name() << ":" << endl << -+ indent() << " o = new " << extend_service_name << "." << (*f_iter)->get_name() << "_result();" << -+ endl << indent() << " break;" << endl; -+ } -+ } -+ -+ f_service_ << indent() << -+ "default:" << endl << indent() << -+ " throw new AssertionError();" << endl << indent() << -+ "}" << endl; -+ -+ f_service_ << indent() << -+ "@java.lang.SuppressWarnings(\"unchecked\")" << endl << -+ indent() << "T t = (T) o;" << endl << indent() << -+ "return t;" << endl; -+ -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl; -+ -+ indent_down(); -+ f_service_ << indent() << "}" << endl; -+} -+ -+void t_java_generator::generate_service_impl_base(t_service* tservice) { -+ f_service_ << -+ indent() << "public static abstract class " << service_name_ << -+ "ImplBase implements " << service_name_ << ", io.grpc.BindableService {" << endl; -+ indent_up(); -+ -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public void " << (*f_iter)->get_name() << "(" << (*f_iter)->get_name() << -+ "_args request, " << endl << -+ indent() << " io.grpc.stub.StreamObserver<" << (*f_iter)->get_name() << -+ "_result> responseObserver) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "asyncUnimplementedUnaryCall(METHOD_" << (*f_iter)->get_name() << -+ ", responseObserver);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc" ; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public void " << (*f_iter)->get_name() << "(" << -+ extend_service_name << "." << (*f_iter)->get_name() << -+ "_args request, " << endl << -+ indent() << " io.grpc.stub.StreamObserver<" << extend_service_name -+ << "." << (*f_iter)->get_name() << "_result> responseObserver) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "asyncUnimplementedUnaryCall(METHOD_" << (*f_iter)->get_name() << -+ ", responseObserver);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ } -+ -+ f_service_ << -+ indent() << "@java.lang.Override" << -+ " public io.grpc.ServerServiceDefinition bindService() {" << endl; - indent_up(); -+ f_service_ << -+ indent() << "return " << service_name_ << "Grpc.bindService(this);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // generate Abstract Service -+ f_service_ << -+ indent() << "@java.lang.Deprecated public static abstract class Abstract" << service_name_ << -+ " extends " << service_name_ << "ImplBase {}" << endl << endl; -+} -+ -+void t_java_generator::generate_method_descriptors(t_service* tservice) { -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for( f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "public static final io.grpc.MethodDescriptor<" << -+ (*f_iter)->get_name() << "_args," << endl << -+ indent() << " " << (*f_iter)->get_name() << "_result> METHOD_" << (*f_iter)->get_name() << -+ " = " << endl << indent() << " io.grpc.MethodDescriptor.create(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " io.grpc.MethodDescriptor.MethodType.UNARY," << endl << -+ indent() << " generateFullMethodName(" << "\"" << package_name_ << "." << -+ service_name_ << "\" , \"" << (*f_iter)->get_name() << "\")," << endl << -+ indent() << " io.grpc.thrift.ThriftUtils.marshaller(" << endl << -+ indent() << " new ThriftMessageFactory<" << (*f_iter)->get_name() << -+ "_args>( ARG_IN_METHOD_" << (*f_iter)->get_name() << "))," << endl << -+ indent() << " io.grpc.thrift.ThriftUtils.marshaller(" << endl << -+ indent() << " new ThriftMessageFactory<" << (*f_iter)->get_name() << -+ "_result>( ARG_OUT_METHOD_" << (*f_iter)->get_name() << ")));" << endl << endl; -+ indent_down(); -+ } -+ -+ if(tservice->get_extends()) { -+ t_service* extends_service = tservice->get_extends(); -+ functions = extends_service->get_functions(); -+ string extend_service_name = extends_service->get_name() + "Grpc"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "public static final io.grpc.MethodDescriptor<" << extend_service_name << "." << -+ (*f_iter)->get_name() << "_args," << endl << -+ indent() << " " << extend_service_name << "." << (*f_iter)->get_name() << "_result> METHOD_" -+ << (*f_iter)->get_name() << " = " << endl << indent() << -+ " io.grpc.MethodDescriptor.create(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " io.grpc.MethodDescriptor.MethodType.UNARY," << endl << -+ indent() << " generateFullMethodName(" << "\"" << package_name_ << "." << -+ service_name_ << "\" , \"" << (*f_iter)->get_name() << "\")," << endl << -+ indent() << " io.grpc.thrift.ThriftUtils.marshaller(" << endl << -+ indent() << " new ThriftMessageFactory<" << extend_service_name << "." << -+ (*f_iter)->get_name() << "_args>( ARG_IN_METHOD_" << (*f_iter)->get_name() << "))," << endl << -+ indent() << " io.grpc.thrift.ThriftUtils.marshaller(" << endl << -+ indent() << " new ThriftMessageFactory<" << extend_service_name << "." << (*f_iter)->get_name() << -+ "_result>( ARG_OUT_METHOD_" << (*f_iter)->get_name() << ")));" << endl << endl; -+ indent_down(); -+ } -+ } -+} -+ -+void t_java_generator::generate_stub(t_service* tservice) { -+ f_service_ << -+ indent() << -+ "public static " << service_name_ << -+ "Stub newStub(io.grpc.Channel channel) {" << -+ endl; -+ -+ indent_up(); -+ f_service_ << -+ indent() << -+ "return new " << service_name_ << "Stub(channel);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // generate Stub impl -+ -+ f_service_ << -+ indent() << "public static class " << -+ service_name_ << "Stub extends io.grpc.stub.AbstractStub<" << -+ service_name_ << "Stub>" << endl << -+ indent() << " implements " << service_name_ << "{" << endl; -+ indent_up(); -+ -+ f_service_ << -+ indent() << "private " << service_name_ << "Stub(io.grpc.Channel channel) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "super(channel);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ f_service_ << -+ indent() << "private " << service_name_ << "Stub(io.grpc.Channel channel, " << endl << -+ indent() << " io.grpc.CallOptions callOptions) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "super(channel, callOptions);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "protected " << service_name_ << "Stub build(io.grpc.Channel channel, " << -+ endl << indent() << " io.grpc.CallOptions callOptions) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return new " << service_name_ << "Stub(channel, callOptions);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public void " << (*f_iter)->get_name() << "(" << -+ (*f_iter)->get_name() << "_args request," << endl << indent() << -+ " io.grpc.stub.StreamObserver<" << (*f_iter)->get_name() << -+ "_result> responseObserver) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "asyncUnaryCall(" << endl << -+ indent() << " getChannel().newCall(METHOD_" << (*f_iter)->get_name() << -+ ", getCallOptions()), request, responseObserver);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public void " << (*f_iter)->get_name() << "(" << -+ extend_service_name << "." << (*f_iter)->get_name() << "_args request," -+ << endl << indent() << " io.grpc.stub.StreamObserver<" << -+ extend_service_name << "." << (*f_iter)->get_name() << -+ "_result> responseObserver) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "asyncUnaryCall(" << endl << -+ indent() << " getChannel().newCall(METHOD_" << (*f_iter)->get_name() << -+ ", getCallOptions()), request, responseObserver);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ } -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+} -+ -+void t_java_generator::generate_blocking_stub(t_service* tservice) { -+ f_service_ << -+ indent() << "public static " << service_name_ << -+ "BlockingStub newBlockingStub(" << endl << -+ indent() << " io.grpc.Channel channel) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return new " << service_name_ << "BlockingStub(channel);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // generate Blocking Client -+ f_service_ << -+ indent() << "@java.lang.Deprecated public static interface " << service_name_ << -+ "BlockingClient " ; -+ -+ if (tservice->get_extends()) { -+ string extend_service_name = tservice->get_extends()->get_name(); -+ f_service_ << endl << indent() << " extends " << extend_service_name << "Grpc." << -+ extend_service_name << "BlockingClient " ; -+ } -+ -+ f_service_ << "{" << endl; -+ -+ indent_up(); -+ - vector functions = tservice->get_functions(); - vector::iterator f_iter; - for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -- generate_java_doc(f_service_, *f_iter); -- indent(f_service_) << "public " << function_signature(*f_iter) << ";" << endl << endl; -+ f_service_ << -+ indent() << "public " << (*f_iter)->get_name() << "_result " << -+ (*f_iter)->get_name() << "(" << (*f_iter)->get_name() << "_args request);" << endl << endl; -+ } -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // generate Blocking Stub impl -+ -+ f_service_ << -+ indent() << "public static class " << -+ service_name_ << "BlockingStub extends io.grpc.stub.AbstractStub<" << -+ service_name_ << "BlockingStub>" << endl << -+ indent() << " implements " << service_name_ << "BlockingClient {"; -+ -+ indent_up(); -+ -+ f_service_ << -+ indent() << "private " << service_name_ << "BlockingStub(io.grpc.Channel channel) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "super(channel);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ f_service_ << -+ indent() << "private " << service_name_ << "BlockingStub(io.grpc.Channel channel, " << endl << -+ indent() << " io.grpc.CallOptions callOptions) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "super(channel, callOptions);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "protected " << service_name_ << "BlockingStub build(io.grpc.Channel channel, " << -+ endl << indent() << " io.grpc.CallOptions callOptions) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return new " << service_name_ << "BlockingStub(channel, callOptions);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public " << (*f_iter)->get_name() << "_result " << (*f_iter)->get_name() << "(" << -+ (*f_iter)->get_name() << "_args request) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return blockingUnaryCall(" << endl << -+ indent() << " getChannel(), METHOD_" << (*f_iter)->get_name() << -+ ", getCallOptions(), request);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public " << extend_service_name << "." << (*f_iter)->get_name() << -+ "_result " << (*f_iter)->get_name() << "(" << extend_service_name << "." << -+ (*f_iter)->get_name() << "_args request) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return blockingUnaryCall(" << endl << -+ indent() << " getChannel(), METHOD_" << (*f_iter)->get_name() << -+ ", getCallOptions(), request);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ } -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+} -+ -+void t_java_generator::generate_future_stub(t_service* tservice) { -+ f_service_ << -+ indent() << "public static " << service_name_ << -+ "FutureStub newFutureStub(" << endl << -+ indent() << " io.grpc.Channel channel) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return new " << service_name_ << "FutureStub(channel);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // generate Future Client -+ f_service_ << -+ indent() << "@java.lang.Deprecated public static interface " << service_name_ << -+ "FutureClient " ; -+ -+ if (tservice->get_extends()) { -+ string extend_service_name = tservice->get_extends()->get_name(); -+ f_service_ << endl << indent() << " extends " << extend_service_name << "Grpc." << -+ extend_service_name << "FutureClient " ; -+ } -+ f_service_ << "{" << endl; -+ -+ indent_up(); -+ -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "public com.google.common.util.concurrent.ListenableFuture<" << -+ (*f_iter)->get_name() << "_result> " << (*f_iter)->get_name() << "(" << endl << -+ indent() << " " << (*f_iter)->get_name() << "_args request);" << endl << endl; -+ } -+ -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "public com.google.common.util.concurrent.ListenableFuture<" << -+ extend_service_name << "." << (*f_iter)->get_name() << "_result> " << -+ (*f_iter)->get_name() << "(" << endl << -+ indent() << " " << extend_service_name << "." << (*f_iter)->get_name() << -+ "_args request);" << endl << endl; -+ } -+ } -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // generate Stub impl -+ -+ f_service_ << -+ indent() << "public static class " << -+ service_name_ << "FutureStub extends io.grpc.stub.AbstractStub<" << -+ service_name_ << "FutureStub>" << endl << -+ indent() << " implements " << service_name_ << "FutureClient {" << endl; -+ indent_up(); -+ -+ f_service_ << -+ indent() << "private " << service_name_ << "FutureStub(io.grpc.Channel channel) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "super(channel);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ f_service_ << -+ indent() << "private " << service_name_ << "FutureStub(io.grpc.Channel channel, " << endl << -+ indent() << " io.grpc.CallOptions callOptions) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "super(channel, callOptions);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "protected " << service_name_ << "FutureStub build(io.grpc.Channel channel, " << -+ endl << indent() << " io.grpc.CallOptions callOptions) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return new " << service_name_ << "FutureStub(channel, callOptions);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ functions = tservice->get_functions(); -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public com.google.common.util.concurrent.ListenableFuture<" << -+ (*f_iter)->get_name() << "_result> " << (*f_iter)->get_name() << "(" << -+ endl << indent() << " " << (*f_iter)->get_name() << "_args request) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return futureUnaryCall(" << endl << -+ indent() << " getChannel().newCall(METHOD_" << (*f_iter)->get_name() << -+ ", getCallOptions()), request);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "public com.google.common.util.concurrent.ListenableFuture<" << -+ extend_service_name << "." << (*f_iter)->get_name() << "_result> " << -+ (*f_iter)->get_name() << "(" << endl << indent() << " " << -+ extend_service_name << "." << (*f_iter)->get_name() << "_args request) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return futureUnaryCall(" << endl << -+ indent() << " getChannel().newCall(METHOD_" << (*f_iter)->get_name() << -+ ", getCallOptions()), request);" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ } -+ } -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+} -+ -+void t_java_generator::generate_method_ids(t_service* tservice) { -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ int i=0; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter, ++i) { -+ f_service_ << -+ indent() << "private static final int METHODID_" << -+ (*f_iter)->get_name() << " = " << i << ";" << endl; -+ } -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter, ++i) { -+ f_service_ << -+ indent() << "private static final int METHODID_" << -+ (*f_iter)->get_name() << " = " << i << ";" << endl; -+ } -+ } -+ f_service_ << endl; -+} -+ -+void t_java_generator::generate_method_handlers(t_service* tservice) { -+ f_service_ << -+ indent() << "private static class MethodHandlers implements" << -+ endl << indent() << " io.grpc.stub.ServerCalls.UnaryMethod," << -+ endl << indent() << " io.grpc.stub.ServerCalls.ServerStreamingMethod," << -+ endl << indent() << " io.grpc.stub.ServerCalls.ClientStreamingMethod," << -+ endl << indent() << " io.grpc.stub.ServerCalls.BidiStreamingMethod {" << -+ endl; -+ indent_up(); -+ f_service_ << -+ indent() << "private final " << service_name_ << " serviceImpl;" << endl << -+ indent() << "private final int methodId;" << endl << endl; -+ -+ f_service_ << -+ indent() << "public MethodHandlers(" << service_name_ << " serviceImpl, int " << -+ "methodId) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "this.serviceImpl = serviceImpl;" << endl << -+ indent() << "this.methodId = methodId;" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // invoke -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "@java.lang.SuppressWarnings(\"unchecked\")" << endl << -+ indent() << "public void invoke(Req request, io.grpc.stub.StreamObserver responseObserver) {" << -+ endl; -+ indent_up(); -+ f_service_ << -+ indent() << "switch (methodId) {" << endl; -+ indent_up(); -+ -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "case METHODID_" << (*f_iter)->get_name() << ":" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "serviceImpl." << (*f_iter)->get_name() << "((" << (*f_iter)->get_name() << -+ "_args) request," << endl << -+ indent() << " (io.grpc.stub.StreamObserver<" << (*f_iter)->get_name() << "_result>)" << -+ " responseObserver);" << endl << -+ indent() << "break;" << endl << endl; -+ indent_down(); -+ } -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "case METHODID_" << (*f_iter)->get_name() << ":" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "serviceImpl." << (*f_iter)->get_name() << "((" << extend_service_name << -+ "." << (*f_iter)->get_name() << "_args) request," << endl << -+ indent() << " (io.grpc.stub.StreamObserver<" << extend_service_name << "." << -+ (*f_iter)->get_name() << "_result>)" << " responseObserver);" << endl << -+ indent() << "break;" << endl << endl; -+ indent_down(); -+ } - } -+ f_service_ << -+ indent() << "default:" << endl << -+ indent() << " throw new AssertionError();" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl; -+ indent_down(); -+ f_service_ << -+ indent() << "}" << endl << endl; -+ -+ // invoke -+ f_service_ << -+ indent() << "@java.lang.Override" << endl << -+ indent() << "@java.lang.SuppressWarnings(\"unchecked\")" << endl << -+ indent() << "public io.grpc.stub.StreamObserver invoke(" << endl << -+ indent() << " io.grpc.stub.StreamObserver responseObserver) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "switch (methodId) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "default:" << endl; -+ f_service_ << -+ indent() << " throw new AssertionError();" << endl; -+ indent_down(); -+ f_service_ << indent() << "}" << endl; - indent_down(); - f_service_ << indent() << "}" << endl << endl; -+ indent_down(); -+ f_service_ << indent() << "}" << endl << endl; -+ - } - -+void t_java_generator::generate_service_descriptors(t_service* tservice) { -+ // generate service descriptor -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ f_service_ << -+ indent() << "public static io.grpc.ServiceDescriptor getServiceDescriptor() {" << -+ endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return new io.grpc.ServiceDescriptor(SERVICE_NAME"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "," << endl << -+ indent() << " METHOD_" << (*f_iter)->get_name(); -+ } -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << "," << endl << -+ indent() << " METHOD_" << (*f_iter)->get_name(); -+ } -+ } -+ f_service_ << ");" << endl; -+ indent_down(); -+ f_service_ << indent() << "}" << endl << endl; -+} -+ -+void t_java_generator::generate_service_builder(t_service* tservice) { -+ // bind Service -+ vector functions = tservice->get_functions(); -+ vector::iterator f_iter; -+ f_service_ << -+ indent() << "@java.lang.Deprecated public static io.grpc.ServerServiceDefinition" << -+ " bindService(" << endl << -+ indent() << " final " << service_name_ << " serviceImpl) {" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << "return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())" << -+ endl; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << " .addMethod(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " METHOD_" << (*f_iter)->get_name() << "," << endl << -+ indent() << " asyncUnaryCall(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " new MethodHandlers<" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " " << (*f_iter)->get_name() << "_args," << endl << -+ indent() << " " << (*f_iter)->get_name() << "_result>(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " serviceImpl, METHODID_" << (*f_iter)->get_name() << ")))" << endl; -+ indent_down(); -+ indent_down(); -+ indent_down(); -+ indent_down(); -+ } -+ -+ if (tservice->get_extends()) { -+ t_service* extend_service = tservice->get_extends(); -+ functions = extend_service->get_functions(); -+ string extend_service_name = extend_service->get_name() + "Grpc"; -+ for(f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) { -+ f_service_ << -+ indent() << " .addMethod(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " METHOD_" << (*f_iter)->get_name() << "," << endl << -+ indent() << " asyncUnaryCall(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " new MethodHandlers<" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " " << extend_service_name << "." << (*f_iter)->get_name() << "_args," << endl << -+ indent() << " " << extend_service_name << "." << (*f_iter)->get_name() << "_result>(" << endl; -+ indent_up(); -+ f_service_ << -+ indent() << " serviceImpl, METHODID_" << (*f_iter)->get_name() << ")))" << endl; -+ indent_down(); -+ indent_down(); -+ indent_down(); -+ indent_down(); -+ } -+ } -+ f_service_ << -+ indent() << " .build();" << endl; -+ indent_down(); -+ f_service_ << indent() << "}" << endl << endl; -+} -+ -+ - void t_java_generator::generate_service_async_interface(t_service* tservice) { - string extends = ""; - string extends_iface = ""; -diff --git a/tutorial/Makefile.am b/tutorial/Makefile.am -index 5865c54..1cffbe6 100755 ---- a/tutorial/Makefile.am -+++ b/tutorial/Makefile.am -@@ -35,11 +35,6 @@ if WITH_D - SUBDIRS += d - endif - --if WITH_JAVA --SUBDIRS += java --SUBDIRS += js --endif -- - if WITH_PYTHON - SUBDIRS += py - SUBDIRS += py.twisted -@@ -95,4 +90,5 @@ EXTRA_DIST = \ - php \ - shared.thrift \ - tutorial.thrift \ -- README.md -+ README.md \ -+ java --- -2.8.0.rc3.226.g39d4020 - From a1d79d9763ea5500ad4f50e02b2f72659f3fb0ba Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 22 Jun 2017 18:24:12 -0700 Subject: [PATCH 22/69] Handle cancel correctly --- .../cronet/transport/cronet_transport.c | 47 +++++++++++++++---- 1 file changed, 38 insertions(+), 9 deletions(-) diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index ce72fc3d08a..c178c71e7b6 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -766,20 +766,47 @@ static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op, bool is_canceled_or_failed = stream_state->state_op_done[OP_CANCEL_ERROR] || stream_state->state_callback_received[OP_FAILED]; if (is_canceled_or_failed) { - if (op_id == OP_SEND_INITIAL_METADATA) result = false; - if (op_id == OP_SEND_MESSAGE) result = false; - if (op_id == OP_SEND_TRAILING_METADATA) result = false; - if (op_id == OP_CANCEL_ERROR) result = false; + if (op_id == OP_SEND_INITIAL_METADATA) { + CRONET_LOG(GPR_DEBUG, "Because"); + result = false; + } + if (op_id == OP_SEND_MESSAGE) { + CRONET_LOG(GPR_DEBUG, "Because"); + result = false; + } + if (op_id == OP_SEND_TRAILING_METADATA) { + CRONET_LOG(GPR_DEBUG, "Because"); + result = false; + } + if (op_id == OP_CANCEL_ERROR) { + CRONET_LOG(GPR_DEBUG, "Because"); + result = false; + } /* already executed */ if (op_id == OP_RECV_INITIAL_METADATA && - stream_state->state_op_done[OP_RECV_INITIAL_METADATA]) + stream_state->state_op_done[OP_RECV_INITIAL_METADATA]) { + CRONET_LOG(GPR_DEBUG, "Because"); result = false; + } if (op_id == OP_RECV_MESSAGE && - stream_state->state_op_done[OP_RECV_MESSAGE]) + stream_state->state_op_done[OP_RECV_MESSAGE]) { + CRONET_LOG(GPR_DEBUG, "Because"); result = false; + } if (op_id == OP_RECV_TRAILING_METADATA && - stream_state->state_op_done[OP_RECV_TRAILING_METADATA]) + stream_state->state_op_done[OP_RECV_TRAILING_METADATA]) { + CRONET_LOG(GPR_DEBUG, "Because"); result = false; + } + /* If cancelled, we need to wait for the cancel callback (if call is already + * started) */ + if (op_id == OP_ON_COMPLETE && + !(stream_state->state_callback_received[OP_FAILED] || + stream_state->state_callback_received[OP_CANCELED] || + !stream_state->state_op_done[OP_SEND_INITIAL_METADATA])) { + CRONET_LOG(GPR_DEBUG, "Because"); + result = false; + } } else if (op_id == OP_SEND_INITIAL_METADATA) { /* already executed */ if (stream_state->state_op_done[OP_SEND_INITIAL_METADATA]) result = false; @@ -868,7 +895,7 @@ static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op, CRONET_LOG(GPR_DEBUG, "Because"); result = false; } else if (curr_op->recv_message && - !stream_state->state_op_done[OP_RECV_MESSAGE]) { + !op_state->state_op_done[OP_RECV_MESSAGE]) { CRONET_LOG(GPR_DEBUG, "Because"); result = false; } else if (curr_op->cancel_stream && @@ -1067,6 +1094,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, stream_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); stream_state->state_op_done[OP_RECV_MESSAGE] = true; + oas->state.state_op_done[OP_RECV_MESSAGE] = true; result = ACTION_TAKEN_NO_CALLBACK; } else if (stream_state->state_callback_received[OP_FAILED]) { CRONET_LOG(GPR_DEBUG, "Stream failed."); @@ -1074,6 +1102,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, stream_op->payload->recv_message.recv_message_ready, GRPC_ERROR_NONE); stream_state->state_op_done[OP_RECV_MESSAGE] = true; + oas->state.state_op_done[OP_RECV_MESSAGE] = true; result = ACTION_TAKEN_NO_CALLBACK; } else if (stream_state->rs.read_stream_closed == true) { /* No more data will be received */ @@ -1214,8 +1243,8 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, } else if (stream_op->cancel_stream && op_can_be_run(stream_op, s, &oas->state, OP_CANCEL_ERROR)) { CRONET_LOG(GPR_DEBUG, "running: %p OP_CANCEL_ERROR", oas); - CRONET_LOG(GPR_DEBUG, "W: bidirectional_stream_cancel(%p)", s->cbs); if (s->cbs) { + CRONET_LOG(GPR_DEBUG, "W: bidirectional_stream_cancel(%p)", s->cbs); bidirectional_stream_cancel(s->cbs); result = ACTION_TAKEN_WITH_CALLBACK; } else { From 275e392449ad4c366e65911a4d3b803f5bd840e5 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 23 Jun 2017 16:26:33 -0700 Subject: [PATCH 23/69] Another bug fix in the same series --- src/core/ext/transport/cronet/transport/cronet_transport.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index c178c71e7b6..380146fece8 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -47,7 +47,7 @@ } while (0) /* TODO (makdharma): Hook up into the wider tracing mechanism */ -int grpc_cronet_trace = 0; +int grpc_cronet_trace = 1; enum e_op_result { ACTION_TAKEN_WITH_CALLBACK, @@ -788,8 +788,7 @@ static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op, CRONET_LOG(GPR_DEBUG, "Because"); result = false; } - if (op_id == OP_RECV_MESSAGE && - stream_state->state_op_done[OP_RECV_MESSAGE]) { + if (op_id == OP_RECV_MESSAGE && op_state->state_op_done[OP_RECV_MESSAGE]) { CRONET_LOG(GPR_DEBUG, "Because"); result = false; } From 32e41b452abf0842080530d7f01a748767197e10 Mon Sep 17 00:00:00 2001 From: Yuchen Zeng Date: Fri, 23 Jun 2017 16:34:34 -0700 Subject: [PATCH 24/69] Fix bad_ping --- test/core/end2end/tests/bad_ping.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/core/end2end/tests/bad_ping.c b/test/core/end2end/tests/bad_ping.c index 78032a6b5fd..12aceda6881 100644 --- a/test/core/end2end/tests/bad_ping.c +++ b/test/core/end2end/tests/bad_ping.c @@ -81,7 +81,10 @@ static void test_bad_ping(grpc_end2end_test_config config) { .value.integer = 300000 /* 5 minutes */}, {.type = GRPC_ARG_INTEGER, .key = GRPC_ARG_HTTP2_MAX_PING_STRIKES, - .value.integer = MAX_PING_STRIKES}}; + .value.integer = MAX_PING_STRIKES}, + {.type = GRPC_ARG_INTEGER, + .key = GRPC_ARG_HTTP2_BDP_PROBE, + .value.integer = 0}}; grpc_channel_args client_args = {.num_args = GPR_ARRAY_SIZE(client_a), .args = client_a}; grpc_channel_args server_args = {.num_args = GPR_ARRAY_SIZE(server_a), From c7208282aeb2140655f8d4b80335f6945a256a42 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 23 Jun 2017 17:05:54 -0700 Subject: [PATCH 25/69] Add comment to explain the added lines and disable debugging log --- .../ext/transport/cronet/transport/cronet_transport.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 380146fece8..498b4440015 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -47,7 +47,7 @@ } while (0) /* TODO (makdharma): Hook up into the wider tracing mechanism */ -int grpc_cronet_trace = 1; +int grpc_cronet_trace = 0; enum e_op_result { ACTION_TAKEN_WITH_CALLBACK, @@ -797,8 +797,10 @@ static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op, CRONET_LOG(GPR_DEBUG, "Because"); result = false; } - /* If cancelled, we need to wait for the cancel callback (if call is already - * started) */ + /* ON_COMPLETE can be processed if one of the following conditions is met: + * 1. the stream failed + * 2. the stream is cancelled, and the callback is received, or + * 3. the stream is cancelled, and the stream is never started */ if (op_id == OP_ON_COMPLETE && !(stream_state->state_callback_received[OP_FAILED] || stream_state->state_callback_received[OP_CANCELED] || From 2b8b7482abf5e98e091f910da979d552a3312fd2 Mon Sep 17 00:00:00 2001 From: yang-g Date: Fri, 23 Jun 2017 17:07:54 -0700 Subject: [PATCH 26/69] Destroy byte buffer to avoid leak in zombied calls --- src/core/lib/surface/server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 8a2616b027c..84ddf74ab9c 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -475,6 +475,7 @@ static void publish_call(grpc_exec_ctx *exec_ctx, grpc_server *server, *rc->data.registered.deadline = calld->deadline; if (rc->data.registered.optional_payload) { *rc->data.registered.optional_payload = calld->payload; + calld->payload = NULL; } break; default: @@ -878,6 +879,7 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_slice_unref_internal(exec_ctx, calld->path); } grpc_metadata_array_destroy(&calld->initial_metadata); + grpc_byte_buffer_destroy(calld->payload); gpr_mu_destroy(&calld->mu_state); From d19c112db066c35b461ad3e5c992d9b7727545d6 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 23 Jun 2017 17:00:20 -0700 Subject: [PATCH 27/69] Add test --- CMakeLists.txt | 2 + Makefile | 2 + .../CoreCronetEnd2EndTests.m | 4 + test/core/end2end/end2end_nosec_tests.c | 8 + test/core/end2end/end2end_tests.c | 8 + test/core/end2end/gen_build_yaml.py | 1 + test/core/end2end/generate_tests.bzl | 1 + .../end2end/tests/cancel_after_round_trip.c | 293 ++++++ .../generated/sources_and_headers.json | 2 + tools/run_tests/generated/tests.json | 950 ++++++++++++++++-- .../end2end_nosec_tests.vcxproj | 2 + .../end2end_nosec_tests.vcxproj.filters | 3 + .../tests/end2end_tests/end2end_tests.vcxproj | 2 + .../end2end_tests.vcxproj.filters | 3 + 14 files changed, 1189 insertions(+), 92 deletions(-) create mode 100644 test/core/end2end/tests/cancel_after_round_trip.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 852eb2bf6c8..6c7584d136b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4289,6 +4289,7 @@ add_library(end2end_tests test/core/end2end/tests/cancel_after_accept.c test/core/end2end/tests/cancel_after_client_done.c test/core/end2end/tests/cancel_after_invoke.c + test/core/end2end/tests/cancel_after_round_trip.c test/core/end2end/tests/cancel_before_invoke.c test/core/end2end/tests/cancel_in_a_vacuum.c test/core/end2end/tests/cancel_with_status.c @@ -4387,6 +4388,7 @@ add_library(end2end_nosec_tests test/core/end2end/tests/cancel_after_accept.c test/core/end2end/tests/cancel_after_client_done.c test/core/end2end/tests/cancel_after_invoke.c + test/core/end2end/tests/cancel_after_round_trip.c test/core/end2end/tests/cancel_before_invoke.c test/core/end2end/tests/cancel_in_a_vacuum.c test/core/end2end/tests/cancel_with_status.c diff --git a/Makefile b/Makefile index 0ca788592c4..b0b29c8d793 100644 --- a/Makefile +++ b/Makefile @@ -7892,6 +7892,7 @@ LIBEND2END_TESTS_SRC = \ test/core/end2end/tests/cancel_after_accept.c \ test/core/end2end/tests/cancel_after_client_done.c \ test/core/end2end/tests/cancel_after_invoke.c \ + test/core/end2end/tests/cancel_after_round_trip.c \ test/core/end2end/tests/cancel_before_invoke.c \ test/core/end2end/tests/cancel_in_a_vacuum.c \ test/core/end2end/tests/cancel_with_status.c \ @@ -7985,6 +7986,7 @@ LIBEND2END_NOSEC_TESTS_SRC = \ test/core/end2end/tests/cancel_after_accept.c \ test/core/end2end/tests/cancel_after_client_done.c \ test/core/end2end/tests/cancel_after_invoke.c \ + test/core/end2end/tests/cancel_after_round_trip.c \ test/core/end2end/tests/cancel_before_invoke.c \ test/core/end2end/tests/cancel_in_a_vacuum.c \ test/core/end2end/tests/cancel_with_status.c \ diff --git a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m index aa52239f8ff..453b0752c31 100644 --- a/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m +++ b/src/objective-c/tests/CoreCronetEnd2EndTests/CoreCronetEnd2EndTests.m @@ -246,6 +246,10 @@ static char *roots_filename; [self testIndividualCase:"cancel_after_invoke"]; } +- (void)testCancelAfterRoundTrip { + [self testIndividualCase:"cancel_after_round_trip"]; +} + - (void)testCancelBeforeInvoke { [self testIndividualCase:"cancel_before_invoke"]; } diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index 9e753975028..ae1db54f1a8 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -44,6 +44,8 @@ extern void cancel_after_client_done(grpc_end2end_test_config config); extern void cancel_after_client_done_pre_init(void); extern void cancel_after_invoke(grpc_end2end_test_config config); extern void cancel_after_invoke_pre_init(void); +extern void cancel_after_round_trip(grpc_end2end_test_config config); +extern void cancel_after_round_trip_pre_init(void); extern void cancel_before_invoke(grpc_end2end_test_config config); extern void cancel_before_invoke_pre_init(void); extern void cancel_in_a_vacuum(grpc_end2end_test_config config); @@ -148,6 +150,7 @@ void grpc_end2end_tests_pre_init(void) { cancel_after_accept_pre_init(); cancel_after_client_done_pre_init(); cancel_after_invoke_pre_init(); + cancel_after_round_trip_pre_init(); cancel_before_invoke_pre_init(); cancel_in_a_vacuum_pre_init(); cancel_with_status_pre_init(); @@ -210,6 +213,7 @@ void grpc_end2end_tests(int argc, char **argv, cancel_after_accept(config); cancel_after_client_done(config); cancel_after_invoke(config); + cancel_after_round_trip(config); cancel_before_invoke(config); cancel_in_a_vacuum(config); cancel_with_status(config); @@ -288,6 +292,10 @@ void grpc_end2end_tests(int argc, char **argv, cancel_after_invoke(config); continue; } + if (0 == strcmp("cancel_after_round_trip", argv[i])) { + cancel_after_round_trip(config); + continue; + } if (0 == strcmp("cancel_before_invoke", argv[i])) { cancel_before_invoke(config); continue; diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index a0e6ac7f93a..d18dd9c7b6b 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -46,6 +46,8 @@ extern void cancel_after_client_done(grpc_end2end_test_config config); extern void cancel_after_client_done_pre_init(void); extern void cancel_after_invoke(grpc_end2end_test_config config); extern void cancel_after_invoke_pre_init(void); +extern void cancel_after_round_trip(grpc_end2end_test_config config); +extern void cancel_after_round_trip_pre_init(void); extern void cancel_before_invoke(grpc_end2end_test_config config); extern void cancel_before_invoke_pre_init(void); extern void cancel_in_a_vacuum(grpc_end2end_test_config config); @@ -151,6 +153,7 @@ void grpc_end2end_tests_pre_init(void) { cancel_after_accept_pre_init(); cancel_after_client_done_pre_init(); cancel_after_invoke_pre_init(); + cancel_after_round_trip_pre_init(); cancel_before_invoke_pre_init(); cancel_in_a_vacuum_pre_init(); cancel_with_status_pre_init(); @@ -214,6 +217,7 @@ void grpc_end2end_tests(int argc, char **argv, cancel_after_accept(config); cancel_after_client_done(config); cancel_after_invoke(config); + cancel_after_round_trip(config); cancel_before_invoke(config); cancel_in_a_vacuum(config); cancel_with_status(config); @@ -296,6 +300,10 @@ void grpc_end2end_tests(int argc, char **argv, cancel_after_invoke(config); continue; } + if (0 == strcmp("cancel_after_round_trip", argv[i])) { + cancel_after_round_trip(config); + continue; + } if (0 == strcmp("cancel_before_invoke", argv[i])) { cancel_before_invoke(config); continue; diff --git a/test/core/end2end/gen_build_yaml.py b/test/core/end2end/gen_build_yaml.py index de1eccec15d..6dffacf9d71 100755 --- a/test/core/end2end/gen_build_yaml.py +++ b/test/core/end2end/gen_build_yaml.py @@ -87,6 +87,7 @@ END2END_TESTS = { 'cancel_after_accept': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_after_client_done': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_after_invoke': default_test_options._replace(cpu_cost=LOWCPU), + 'cancel_after_round_trip': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_before_invoke': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_in_a_vacuum': default_test_options._replace(cpu_cost=LOWCPU), 'cancel_with_status': default_test_options._replace(cpu_cost=LOWCPU), diff --git a/test/core/end2end/generate_tests.bzl b/test/core/end2end/generate_tests.bzl index 185ca606b8d..3312f4e596c 100755 --- a/test/core/end2end/generate_tests.bzl +++ b/test/core/end2end/generate_tests.bzl @@ -79,6 +79,7 @@ END2END_TESTS = { 'cancel_after_accept': test_options(), 'cancel_after_client_done': test_options(), 'cancel_after_invoke': test_options(), + 'cancel_after_round_trip': test_options(), 'cancel_before_invoke': test_options(), 'cancel_in_a_vacuum': test_options(), 'cancel_with_status': test_options(), diff --git a/test/core/end2end/tests/cancel_after_round_trip.c b/test/core/end2end/tests/cancel_after_round_trip.c new file mode 100644 index 00000000000..032f74aa917 --- /dev/null +++ b/test/core/end2end/tests/cancel_after_round_trip.c @@ -0,0 +1,293 @@ +/* + * + * Copyright 2015 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "test/core/end2end/end2end_tests.h" + +#include +#include + +#include +#include +#include +#include +#include + +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/transport/metadata.h" +#include "src/core/lib/transport/service_config.h" + +#include "test/core/end2end/cq_verifier.h" +#include "test/core/end2end/tests/cancel_test_helpers.h" + +static void *tag(intptr_t t) { return (void *)t; } + +static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, + const char *test_name, + grpc_channel_args *client_args, + grpc_channel_args *server_args) { + grpc_end2end_test_fixture f; + gpr_log(GPR_INFO, "Running test: %s/%s", test_name, config.name); + f = config.create_fixture(client_args, server_args); + config.init_server(&f, server_args); + config.init_client(&f, client_args); + return f; +} + +static gpr_timespec n_seconds_from_now(int n) { + return grpc_timeout_seconds_to_deadline(n); +} + +static gpr_timespec five_seconds_from_now(void) { + return n_seconds_from_now(5); +} + +static void drain_cq(grpc_completion_queue *cq) { + grpc_event ev; + do { + ev = grpc_completion_queue_next(cq, five_seconds_from_now(), NULL); + } while (ev.type != GRPC_QUEUE_SHUTDOWN); +} + +static void shutdown_server(grpc_end2end_test_fixture *f) { + if (!f->server) return; + grpc_server_shutdown_and_notify(f->server, f->shutdown_cq, tag(1000)); + GPR_ASSERT(grpc_completion_queue_pluck(f->shutdown_cq, tag(1000), + grpc_timeout_seconds_to_deadline(5), + NULL) + .type == GRPC_OP_COMPLETE); + grpc_server_destroy(f->server); + f->server = NULL; +} + +static void shutdown_client(grpc_end2end_test_fixture *f) { + if (!f->client) return; + grpc_channel_destroy(f->client); + f->client = NULL; +} + +static void end_test(grpc_end2end_test_fixture *f) { + shutdown_server(f); + shutdown_client(f); + + grpc_completion_queue_shutdown(f->cq); + drain_cq(f->cq); + grpc_completion_queue_destroy(f->cq); + grpc_completion_queue_destroy(f->shutdown_cq); +} + +/* Cancel after accept, no payload */ +static void test_cancel_after_round_trip(grpc_end2end_test_config config, + cancellation_mode mode, + bool use_service_config) { + grpc_op ops[6]; + grpc_op *op; + grpc_call *c; + grpc_call *s; + grpc_metadata_array initial_metadata_recv; + grpc_metadata_array trailing_metadata_recv; + grpc_metadata_array request_metadata_recv; + grpc_call_details call_details; + grpc_status_code status; + grpc_call_error error; + grpc_slice details; + grpc_byte_buffer *request_payload_recv = NULL; + grpc_byte_buffer *response_payload_recv = NULL; + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); + grpc_byte_buffer *request_payload = + grpc_raw_byte_buffer_create(&request_payload_slice, 1); + grpc_byte_buffer *response_payload = + grpc_raw_byte_buffer_create(&response_payload_slice, 1); + int was_cancelled = 2; + + grpc_channel_args *args = NULL; + if (use_service_config) { + grpc_arg arg; + arg.type = GRPC_ARG_STRING; + arg.key = GRPC_ARG_SERVICE_CONFIG; + arg.value.string = + "{\n" + " \"methodConfig\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"timeout\": \"5s\"\n" + " } ]\n" + "}"; + args = grpc_channel_args_copy_and_add(args, &arg, 1); + } + + grpc_end2end_test_fixture f = + begin_test(config, "cancel_after_round_trip", args, NULL); + cq_verifier *cqv = cq_verifier_create(f.cq); + + gpr_timespec deadline = use_service_config + ? gpr_inf_future(GPR_CLOCK_MONOTONIC) + : five_seconds_from_now(); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, + grpc_slice_from_static_string("/service/method"), + get_host_override_slice("foo.test.google.fr:1234", config), deadline, + NULL); + GPR_ASSERT(c); + + grpc_metadata_array_init(&initial_metadata_recv); + grpc_metadata_array_init(&trailing_metadata_recv); + grpc_metadata_array_init(&request_metadata_recv); + grpc_call_details_init(&call_details); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = request_payload; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_INITIAL_METADATA; + op->data.recv_initial_metadata.recv_initial_metadata = &initial_metadata_recv; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &response_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + error = + grpc_server_request_call(f.server, &s, &call_details, + &request_metadata_recv, f.cq, f.cq, tag(101)); + GPR_ASSERT(GRPC_CALL_OK == error); + CQ_EXPECT_COMPLETION(cqv, tag(101), 1); + cq_verify(cqv); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &request_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_INITIAL_METADATA; + op->data.send_initial_metadata.count = 0; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = response_payload; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(102), 1); + CQ_EXPECT_COMPLETION(cqv, tag(1), 1); + cq_verify(cqv); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; + op->data.recv_status_on_client.trailing_metadata = &trailing_metadata_recv; + op->data.recv_status_on_client.status = &status; + op->data.recv_status_on_client.status_details = &details; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_RECV_MESSAGE; + op->data.recv_message.recv_message = &response_payload_recv; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(2), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); + + memset(ops, 0, sizeof(ops)); + op = ops; + op->op = GRPC_OP_RECV_CLOSE_ON_SERVER; + op->data.recv_close_on_server.cancelled = &was_cancelled; + op->flags = 0; + op->reserved = NULL; + op++; + op->op = GRPC_OP_SEND_MESSAGE; + op->data.send_message.send_message = response_payload; + op->flags = 0; + op->reserved = NULL; + op++; + error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(103), NULL); + GPR_ASSERT(GRPC_CALL_OK == error); + + CQ_EXPECT_COMPLETION(cqv, tag(2), 1); + CQ_EXPECT_COMPLETION(cqv, tag(103), 1); + cq_verify(cqv); + + GPR_ASSERT(status == mode.expect_status || status == GRPC_STATUS_INTERNAL); + GPR_ASSERT(was_cancelled == 1); + + grpc_metadata_array_destroy(&initial_metadata_recv); + grpc_metadata_array_destroy(&trailing_metadata_recv); + grpc_metadata_array_destroy(&request_metadata_recv); + grpc_call_details_destroy(&call_details); + + grpc_byte_buffer_destroy(request_payload); + grpc_byte_buffer_destroy(response_payload); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + grpc_slice_unref(details); + + grpc_call_unref(c); + grpc_call_unref(s); + + if (args != NULL) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_channel_args_destroy(&exec_ctx, args); + grpc_exec_ctx_finish(&exec_ctx); + } + + cq_verifier_destroy(cqv); + end_test(&f); + config.tear_down_data(&f); +} + +void cancel_after_round_trip(grpc_end2end_test_config config) { + unsigned i; + + for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { + test_cancel_after_round_trip(config, cancellation_modes[i], + false /* use_service_config */); + if (config.feature_mask & FEATURE_MASK_SUPPORTS_CLIENT_CHANNEL && + cancellation_modes[i].expect_status == GRPC_STATUS_DEADLINE_EXCEEDED) { + test_cancel_after_round_trip(config, cancellation_modes[i], + true /* use_service_config */); + } + } +} + +void cancel_after_round_trip_pre_init(void) {} diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 0c4e1fae1d8..65a99bf7d61 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -7209,6 +7209,7 @@ "test/core/end2end/tests/cancel_after_accept.c", "test/core/end2end/tests/cancel_after_client_done.c", "test/core/end2end/tests/cancel_after_invoke.c", + "test/core/end2end/tests/cancel_after_round_trip.c", "test/core/end2end/tests/cancel_before_invoke.c", "test/core/end2end/tests/cancel_in_a_vacuum.c", "test/core/end2end/tests/cancel_test_helpers.h", @@ -7285,6 +7286,7 @@ "test/core/end2end/tests/cancel_after_accept.c", "test/core/end2end/tests/cancel_after_client_done.c", "test/core/end2end/tests/cancel_after_invoke.c", + "test/core/end2end/tests/cancel_after_round_trip.c", "test/core/end2end/tests/cancel_before_invoke.c", "test/core/end2end/tests/cancel_in_a_vacuum.c", "test/core/end2end/tests/cancel_test_helpers.h", diff --git a/tools/run_tests/generated/tests.json b/tools/run_tests/generated/tests.json index 8cca6d3dafb..b66a84285ac 100644 --- a/tools/run_tests/generated/tests.json +++ b/tools/run_tests/generated/tests.json @@ -5892,6 +5892,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_census_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -7138,6 +7161,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_compress_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -8353,6 +8399,28 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_fakesec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -9530,6 +9598,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_fd_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -10634,6 +10725,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -11848,6 +11962,25 @@ "linux" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_full+pipe_test", + "platforms": [ + "linux" + ] + }, { "args": [ "cancel_before_invoke" @@ -12906,6 +13039,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+trace_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -14106,6 +14262,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+workarounds_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -15360,6 +15539,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_http_proxy_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -16648,6 +16851,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_load_reporting_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -17904,7 +18130,7 @@ }, { "args": [ - "cancel_before_invoke" + "cancel_after_round_trip" ], "ci_platforms": [ "windows", @@ -17928,7 +18154,7 @@ }, { "args": [ - "cancel_in_a_vacuum" + "cancel_before_invoke" ], "ci_platforms": [ "windows", @@ -17952,7 +18178,7 @@ }, { "args": [ - "cancel_with_status" + "cancel_in_a_vacuum" ], "ci_platforms": [ "windows", @@ -17976,14 +18202,14 @@ }, { "args": [ - "compressed_payload" + "cancel_with_status" ], "ci_platforms": [ "windows", "linux", "posix" ], - "cpu_cost": 1.0, + "cpu_cost": 0.1, "exclude_configs": [], "exclude_iomgrs": [ "uv" @@ -18000,14 +18226,14 @@ }, { "args": [ - "connectivity" + "compressed_payload" ], "ci_platforms": [ "windows", "linux", "posix" ], - "cpu_cost": 0.1, + "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [ "uv" @@ -18024,14 +18250,14 @@ }, { "args": [ - "default_host" + "connectivity" ], "ci_platforms": [ "windows", "linux", "posix" ], - "cpu_cost": 1.0, + "cpu_cost": 0.1, "exclude_configs": [], "exclude_iomgrs": [ "uv" @@ -18048,7 +18274,7 @@ }, { "args": [ - "disappearing_server" + "default_host" ], "ci_platforms": [ "windows", @@ -18060,7 +18286,7 @@ "exclude_iomgrs": [ "uv" ], - "flaky": true, + "flaky": false, "language": "c", "name": "h2_oauth2_test", "platforms": [ @@ -18072,19 +18298,19 @@ }, { "args": [ - "empty_batch" + "disappearing_server" ], "ci_platforms": [ "windows", "linux", "posix" ], - "cpu_cost": 0.1, + "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [ "uv" ], - "flaky": false, + "flaky": true, "language": "c", "name": "h2_oauth2_test", "platforms": [ @@ -18096,14 +18322,14 @@ }, { "args": [ - "filter_call_init_fails" + "empty_batch" ], "ci_platforms": [ "windows", "linux", "posix" ], - "cpu_cost": 1.0, + "cpu_cost": 0.1, "exclude_configs": [], "exclude_iomgrs": [ "uv" @@ -18120,14 +18346,14 @@ }, { "args": [ - "filter_causes_close" + "filter_call_init_fails" ], "ci_platforms": [ "windows", "linux", "posix" ], - "cpu_cost": 0.1, + "cpu_cost": 1.0, "exclude_configs": [], "exclude_iomgrs": [ "uv" @@ -18144,7 +18370,7 @@ }, { "args": [ - "filter_latency" + "filter_causes_close" ], "ci_platforms": [ "windows", @@ -18168,7 +18394,7 @@ }, { "args": [ - "graceful_server_shutdown" + "filter_latency" ], "ci_platforms": [ "windows", @@ -18192,7 +18418,31 @@ }, { "args": [ - "high_initial_seqno" + "graceful_server_shutdown" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_oauth2_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, + { + "args": [ + "high_initial_seqno" ], "ci_platforms": [ "windows", @@ -19174,6 +19424,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_proxy_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -20230,6 +20504,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -21358,6 +21656,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair+trace_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -22428,6 +22750,32 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "msan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_1byte_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -23626,6 +23974,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_ssl_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -24872,6 +25243,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_ssl_cert_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -26102,6 +26496,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_ssl_proxy_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -27176,53 +27594,7 @@ }, { "args": [ - "cancel_before_invoke" - ], - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [ - "uv" - ], - "flaky": false, - "language": "c", - "name": "h2_uds_test", - "platforms": [ - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_in_a_vacuum" - ], - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 0.1, - "exclude_configs": [], - "exclude_iomgrs": [ - "uv" - ], - "flaky": false, - "language": "c", - "name": "h2_uds_test", - "platforms": [ - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "cancel_with_status" + "cancel_after_round_trip" ], "ci_platforms": [ "linux", @@ -27245,30 +27617,99 @@ }, { "args": [ - "compressed_payload" - ], - "ci_platforms": [ - "linux", - "mac", - "posix" - ], - "cpu_cost": 1.0, - "exclude_configs": [], - "exclude_iomgrs": [ - "uv" - ], - "flaky": false, - "language": "c", - "name": "h2_uds_test", - "platforms": [ - "linux", - "mac", - "posix" - ] - }, - { - "args": [ - "connectivity" + "cancel_before_invoke" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_uds_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ + "cancel_in_a_vacuum" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_uds_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ + "cancel_with_status" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_uds_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ + "compressed_payload" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_uds_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, + { + "args": [ + "connectivity" ], "ci_platforms": [ "linux", @@ -28370,6 +28811,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_census_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -29593,6 +30057,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_compress_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -30770,6 +31257,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_fd_nosec_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -31851,6 +32361,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -33046,6 +33579,25 @@ "linux" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "linux" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_full+pipe_nosec_test", + "platforms": [ + "linux" + ] + }, { "args": [ "cancel_before_invoke" @@ -34081,6 +34633,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+trace_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -35258,6 +35833,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_full+workarounds_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -36488,6 +37086,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_http_proxy_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -37753,6 +38375,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [], + "flaky": false, + "language": "c", + "name": "h2_load_reporting_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -38959,6 +39604,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_proxy_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -39991,6 +40660,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -41095,6 +41788,30 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair+trace_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -42139,6 +42856,32 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "windows", + "linux", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [ + "msan" + ], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_sockpair_1byte_nosec_test", + "platforms": [ + "windows", + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" @@ -43314,6 +44057,29 @@ "posix" ] }, + { + "args": [ + "cancel_after_round_trip" + ], + "ci_platforms": [ + "linux", + "mac", + "posix" + ], + "cpu_cost": 0.1, + "exclude_configs": [], + "exclude_iomgrs": [ + "uv" + ], + "flaky": false, + "language": "c", + "name": "h2_uds_nosec_test", + "platforms": [ + "linux", + "mac", + "posix" + ] + }, { "args": [ "cancel_before_invoke" diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj index 8581f0cb374..4d02c880825 100644 --- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj +++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj @@ -169,6 +169,8 @@ + + diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters index ae2937b1b9e..89316bc535f 100644 --- a/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters +++ b/vsprojects/vcxproj/test/end2end/tests/end2end_nosec_tests/end2end_nosec_tests.vcxproj.filters @@ -28,6 +28,9 @@ test\core\end2end\tests + + test\core\end2end\tests + test\core\end2end\tests diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj index 1bd09989e89..95731114523 100644 --- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj +++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj @@ -171,6 +171,8 @@ + + diff --git a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters index 217c60ee052..7d02fc3fa07 100644 --- a/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters +++ b/vsprojects/vcxproj/test/end2end/tests/end2end_tests/end2end_tests.vcxproj.filters @@ -31,6 +31,9 @@ test\core\end2end\tests + + test\core\end2end\tests + test\core\end2end\tests From 366270eee58df0c59dd3c7453e5ffd0d3d9eebc5 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Fri, 23 Jun 2017 18:08:27 -0700 Subject: [PATCH 28/69] Fix test --- src/core/ext/transport/cronet/transport/cronet_transport.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 498b4440015..29dfa885de4 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -799,11 +799,13 @@ static bool op_can_be_run(grpc_transport_stream_op_batch *curr_op, } /* ON_COMPLETE can be processed if one of the following conditions is met: * 1. the stream failed - * 2. the stream is cancelled, and the callback is received, or - * 3. the stream is cancelled, and the stream is never started */ + * 2. the stream is cancelled, and the callback is received + * 3. the stream succeeded before cancel is effective + * 4. the stream is cancelled, and the stream is never started */ if (op_id == OP_ON_COMPLETE && !(stream_state->state_callback_received[OP_FAILED] || stream_state->state_callback_received[OP_CANCELED] || + stream_state->state_callback_received[OP_SUCCEEDED] || !stream_state->state_op_done[OP_SEND_INITIAL_METADATA])) { CRONET_LOG(GPR_DEBUG, "Because"); result = false; From 38ba4661cec913c72b81beb15f34e263c694858b Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Fri, 23 Jun 2017 18:24:01 -0700 Subject: [PATCH 29/69] Fix segfault in rr trace --- .../client_channel/lb_policy/round_robin/round_robin.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c index 3c8520cc1c3..e7d38f751d2 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c @@ -571,11 +571,13 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, GPR_ASSERT(sd->subchannel_list == p->latest_pending_subchannel_list); GPR_ASSERT(!sd->subchannel_list->shutting_down); if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { + const unsigned long num_subchannels = + p->subchannel_list != NULL ? p->subchannel_list->num_subchannels + : 0; gpr_log(GPR_DEBUG, "[RR %p] phasing out subchannel list %p (size %lu) in favor " "of %p (size %lu)", - (void *)p, (void *)p->subchannel_list, - (unsigned long)p->subchannel_list->num_subchannels, + (void *)p, (void *)p->subchannel_list, num_subchannels, (void *)sd->subchannel_list, (unsigned long)sd->subchannel_list->num_subchannels); } From 936f8d5eaaf63a72792226eda0209becb60b0ec8 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Wed, 8 Mar 2017 21:34:41 +0000 Subject: [PATCH 30/69] Enable next-method-called lint --- .pylintrc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.pylintrc b/.pylintrc index 41027479061..e7b4eb01097 100644 --- a/.pylintrc +++ b/.pylintrc @@ -32,9 +32,8 @@ notes=FIXME,XXX #TODO: Enable too-many-instance-attributes #TODO: Enable too-many-lines #TODO: Enable redefined-variable-type -#TODO: Enable next-method-called #TODO: Enable import-error #TODO: Enable useless-else-on-loop #TODO: Enable too-many-nested-blocks -disable=missing-docstring,too-few-public-methods,no-init,duplicate-code,invalid-name,locally-disabled,protected-access,no-name-in-module,wrong-import-order,cyclic-import,too-many-instance-attributes,too-many-lines,redefined-variable-type,next-method-called,import-error,useless-else-on-loop,too-many-nested-blocks +disable=missing-docstring,too-few-public-methods,no-init,duplicate-code,invalid-name,locally-disabled,protected-access,no-name-in-module,wrong-import-order,cyclic-import,too-many-instance-attributes,too-many-lines,redefined-variable-type,import-error,useless-else-on-loop,too-many-nested-blocks From a7182f7f5a7253bbcd33eabff1b3ec4fb686edb0 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Sat, 24 Jun 2017 20:57:00 +0000 Subject: [PATCH 31/69] Always use an upgraded pip when running pylint --- tools/distrib/pylint_code.sh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/distrib/pylint_code.sh b/tools/distrib/pylint_code.sh index f5c958473f1..3a1825535d5 100755 --- a/tools/distrib/pylint_code.sh +++ b/tools/distrib/pylint_code.sh @@ -19,15 +19,16 @@ set -ex cd "$(dirname "$0")/../.." DIRS=( - 'src/python/grpcio/grpc' - 'src/python/grpcio_reflection/grpc_reflection' - 'src/python/grpcio_health_checking/grpc_health' + 'src/python/grpcio/grpc' + 'src/python/grpcio_health_checking/grpc_health' + 'src/python/grpcio_reflection/grpc_reflection' ) VIRTUALENV=python_pylint_venv virtualenv $VIRTUALENV PYTHON=$(realpath $VIRTUALENV/bin/python) +$PYTHON -m pip install --upgrade pip $PYTHON -m pip install pylint==1.6.5 for dir in "${DIRS[@]}"; do From 37c83ffbed4e01f02d4fdee3e8e9156e877d4608 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Sat, 24 Jun 2017 21:03:21 +0000 Subject: [PATCH 32/69] Enable redefined-variable-type lint --- .pylintrc | 3 +-- src/python/grpcio/grpc/_channel.py | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index e7b4eb01097..15062dca9c6 100644 --- a/.pylintrc +++ b/.pylintrc @@ -31,9 +31,8 @@ notes=FIXME,XXX # disable=cyclic-import suppressions. #TODO: Enable too-many-instance-attributes #TODO: Enable too-many-lines -#TODO: Enable redefined-variable-type #TODO: Enable import-error #TODO: Enable useless-else-on-loop #TODO: Enable too-many-nested-blocks -disable=missing-docstring,too-few-public-methods,no-init,duplicate-code,invalid-name,locally-disabled,protected-access,no-name-in-module,wrong-import-order,cyclic-import,too-many-instance-attributes,too-many-lines,redefined-variable-type,import-error,useless-else-on-loop,too-many-nested-blocks +disable=missing-docstring,too-few-public-methods,no-init,duplicate-code,invalid-name,locally-disabled,protected-access,no-name-in-module,wrong-import-order,cyclic-import,too-many-instance-attributes,too-many-lines,import-error,useless-else-on-loop,too-many-nested-blocks diff --git a/src/python/grpcio/grpc/_channel.py b/src/python/grpcio/grpc/_channel.py index 1562c3e24dc..cf4ce0941ba 100644 --- a/src/python/grpcio/grpc/_channel.py +++ b/src/python/grpcio/grpc/_channel.py @@ -849,7 +849,10 @@ def _poll_connectivity(state, channel, initial_try_to_connect): _common.CYGRPC_CONNECTIVITY_STATE_TO_CHANNEL_CONNECTIVITY[ connectivity]) if not state.delivering: - callbacks = _deliveries(state) + # NOTE(nathaniel): The field is only ever used as a + # sequence so it's fine that both lists and tuples are + # assigned to it. + callbacks = _deliveries(state) # pylint: disable=redefined-variable-type if callbacks: _spawn_delivery(state, callbacks) From 6613f601660e7cf58db2a5dd1e11556378955910 Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Sat, 24 Jun 2017 21:13:24 +0000 Subject: [PATCH 33/69] Enable wrong-import-order lint --- .pylintrc | 3 +-- src/python/grpcio/grpc/_server.py | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.pylintrc b/.pylintrc index 15062dca9c6..188b7d7058e 100644 --- a/.pylintrc +++ b/.pylintrc @@ -25,7 +25,6 @@ notes=FIXME,XXX #TODO: Enable locally-disabled #TODO: Enable protected-access #TODO: Enable no-name-in-module -#TODO: Enable wrong-import-order # TODO(https://github.com/PyCQA/pylint/issues/59#issuecomment-283774279): # enable cyclic-import after a 1.7-or-later pylint release that recognizes our # disable=cyclic-import suppressions. @@ -35,4 +34,4 @@ notes=FIXME,XXX #TODO: Enable useless-else-on-loop #TODO: Enable too-many-nested-blocks -disable=missing-docstring,too-few-public-methods,no-init,duplicate-code,invalid-name,locally-disabled,protected-access,no-name-in-module,wrong-import-order,cyclic-import,too-many-instance-attributes,too-many-lines,import-error,useless-else-on-loop,too-many-nested-blocks +disable=missing-docstring,too-few-public-methods,no-init,duplicate-code,invalid-name,locally-disabled,protected-access,no-name-in-module,cyclic-import,too-many-instance-attributes,too-many-lines,import-error,useless-else-on-loop,too-many-nested-blocks diff --git a/src/python/grpcio/grpc/_server.py b/src/python/grpcio/grpc/_server.py index 9e2d40b67d1..cd59b07c04c 100644 --- a/src/python/grpcio/grpc/_server.py +++ b/src/python/grpcio/grpc/_server.py @@ -16,10 +16,11 @@ import collections import enum import logging -import six import threading import time +import six + import grpc from grpc import _common from grpc._cython import cygrpc From 9104884a1903606831b15476b01ef9f87a89b29b Mon Sep 17 00:00:00 2001 From: Nathaniel Manista Date: Sat, 24 Jun 2017 21:16:53 +0000 Subject: [PATCH 34/69] Clean up and opinionate .pylintrc --- .pylintrc | 68 ++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 50 insertions(+), 18 deletions(-) diff --git a/.pylintrc b/.pylintrc index 188b7d7058e..8447821b4e5 100644 --- a/.pylintrc +++ b/.pylintrc @@ -1,15 +1,18 @@ [VARIABLES] + # TODO(https://github.com/PyCQA/pylint/issues/1345): How does the inspection # not include "unused_" and "ignored_" by default? dummy-variables-rgx=^ignored_|^unused_ [DESIGN] + # NOTE(nathaniel): Not particularly attached to this value; it just seems to # be what works for us at the moment (excepting the dead-code-walking Beta # API). max-args=6 [MISCELLANEOUS] + # NOTE(nathaniel): We are big fans of "TODO(): " and # "NOTE(): ". We do not allow "TODO:", # "TODO():", "FIXME:", or anything else. @@ -17,21 +20,50 @@ notes=FIXME,XXX [MESSAGES CONTROL] -#TODO: Enable missing-docstring -#TODO: Enable too-few-public-methods -#TODO: Enable no-init -#TODO: Enable duplicate-code -#TODO: Enable invalid-name -#TODO: Enable locally-disabled -#TODO: Enable protected-access -#TODO: Enable no-name-in-module -# TODO(https://github.com/PyCQA/pylint/issues/59#issuecomment-283774279): -# enable cyclic-import after a 1.7-or-later pylint release that recognizes our -# disable=cyclic-import suppressions. -#TODO: Enable too-many-instance-attributes -#TODO: Enable too-many-lines -#TODO: Enable import-error -#TODO: Enable useless-else-on-loop -#TODO: Enable too-many-nested-blocks - -disable=missing-docstring,too-few-public-methods,no-init,duplicate-code,invalid-name,locally-disabled,protected-access,no-name-in-module,cyclic-import,too-many-instance-attributes,too-many-lines,import-error,useless-else-on-loop,too-many-nested-blocks +disable= + # TODO(https://github.com/PyCQA/pylint/issues/59#issuecomment-283774279): + # Enable cyclic-import after a 1.7-or-later pylint release that + # recognizes our disable=cyclic-import suppressions. + cyclic-import, + # TODO(https://github.com/grpc/grpc/issues/8622): Enable this after the + # Beta API is removed. + duplicate-code, + # TODO(https://github.com/grpc/grpc/issues/261): Doesn't seem to + # understand enum and concurrent.futures; look into this later with the + # latest pylint version. + import-error, + # TODO(https://github.com/grpc/grpc/issues/261): Enable this one. + # Should take a little configuration but not much. + invalid-name, + # TODO(https://github.com/grpc/grpc/issues/261): This doesn't seem to + # work for now? Try with a later pylint? + locally-disabled, + # NOTE(nathaniel): We don't write doc strings for most private code + # elements. + missing-docstring, + # NOTE(nathaniel): Our completely abstract interface classes don't have + # constructors. + no-init, + # TODO(https://github.com/grpc/grpc/issues/261): Doesn't yet play + # nicely with some of our code being implemented in Cython. Maybe in a + # later version? + no-name-in-module, + # TODO(https://github.com/grpc/grpc/issues/261): Suppress these where + # the odd shape of the authentication portion of the API forces them on + # us and enable everywhere else. + protected-access, + # NOTE(nathaniel): Pylint and I will probably never agree on this. + too-few-public-methods, + # NOTE(nathaniel): Pylint and I wil probably never agree on this for + # private classes. For public classes maybe? + too-many-instance-attributes, + # NOTE(nathaniel): Some of our modules have a lot of lines... of + # specification and documentation. Maybe if this were + # lines-of-code-based we would use it. + too-many-lines, + # TODO(https://github.com/grpc/grpc/issues/261): Maybe we could have + # this one if we extracted just a few more helper functions... + too-many-nested-blocks, + # NOTE(nathaniel): I have disputed the premise of this inspection from + # the beginning and will continue to do so until it goes away for good. + useless-else-on-loop, From 1f0fc53e9719755302d5f160959728b4c30077c3 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 26 Jun 2017 11:05:33 -0700 Subject: [PATCH 35/69] Have the fake resolver "re-resolve" upon seeing error --- .../client_channel/resolver/fake/fake_resolver.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c index a311334d131..56ed4371a91 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c @@ -56,6 +56,10 @@ typedef struct { // grpc_resolver_next_locked()'s closure. grpc_channel_args* next_results; + // Results to use for the pretended re-resolution in + // fake_resolver_channel_saw_error_locked(). + grpc_channel_args* results_upon_error; + // pending next completion, or NULL grpc_closure* next_completion; // target result address for next completion @@ -65,6 +69,7 @@ typedef struct { static void fake_resolver_destroy(grpc_exec_ctx* exec_ctx, grpc_resolver* gr) { fake_resolver* r = (fake_resolver*)gr; grpc_channel_args_destroy(exec_ctx, r->next_results); + grpc_channel_args_destroy(exec_ctx, r->results_upon_error); grpc_channel_args_destroy(exec_ctx, r->channel_args); gpr_free(r); } @@ -87,15 +92,19 @@ static void fake_resolver_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx, *r->target_result = grpc_channel_args_union(r->next_results, r->channel_args); grpc_channel_args_destroy(exec_ctx, r->next_results); + r->next_results = NULL; GRPC_CLOSURE_SCHED(exec_ctx, r->next_completion, GRPC_ERROR_NONE); r->next_completion = NULL; - r->next_results = NULL; } } static void fake_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver) { fake_resolver* r = (fake_resolver*)resolver; + if (r->next_results == NULL && r->results_upon_error != NULL) { + // Pretend we re-resolved. + r->next_results = grpc_channel_args_copy(r->results_upon_error); + } fake_resolver_maybe_finish_next_locked(exec_ctx, r); } @@ -151,6 +160,10 @@ static void set_response_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_channel_args_destroy(exec_ctx, r->next_results); } r->next_results = generator->next_response; + if (r->results_upon_error != NULL) { + grpc_channel_args_destroy(exec_ctx, r->results_upon_error); + } + r->results_upon_error = grpc_channel_args_copy(generator->next_response); fake_resolver_maybe_finish_next_locked(exec_ctx, r); } From 9d1a5de94e438c89dc0e359ce0038fc138cdaf9f Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 26 Jun 2017 11:06:00 -0700 Subject: [PATCH 36/69] Fix RR policy connectivity state upon subchannels shutdown --- .../lb_policy/round_robin/round_robin.c | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c index e7d38f751d2..c41f22ea9ab 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c @@ -126,6 +126,8 @@ struct rr_subchannel_list { size_t num_ready; /** how many subchannels are in state TRANSIENT_FAILURE */ size_t num_transient_failures; + /** how many subchannels are in state SHUTDOWN */ + size_t num_shutdown; /** how many subchannels are in state IDLE */ size_t num_idle; @@ -425,14 +427,20 @@ static void update_state_counters_locked(subchannel_data *sd) { } else if (sd->prev_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { GPR_ASSERT(subchannel_list->num_transient_failures > 0); --subchannel_list->num_transient_failures; + } else if (sd->prev_connectivity_state == GRPC_CHANNEL_SHUTDOWN) { + GPR_ASSERT(subchannel_list->num_shutdown > 0); + --subchannel_list->num_shutdown; } else if (sd->prev_connectivity_state == GRPC_CHANNEL_IDLE) { GPR_ASSERT(subchannel_list->num_idle > 0); --subchannel_list->num_idle; } + if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) { ++subchannel_list->num_ready; } else if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { ++subchannel_list->num_transient_failures; + } else if (sd->curr_connectivity_state == GRPC_CHANNEL_SHUTDOWN) { + ++subchannel_list->num_shutdown; } else if (sd->curr_connectivity_state == GRPC_CHANNEL_IDLE) { ++subchannel_list->num_idle; } @@ -455,7 +463,8 @@ static grpc_connectivity_state update_lb_connectivity_status_locked( * CHECK: sd->curr_connectivity_state == CONNECTING. * * 3) RULE: ALL subchannels are SHUTDOWN => policy is SHUTDOWN. - * CHECK: p->subchannel_list->num_subchannels = 0. + * CHECK: p->subchannel_list->num_shutdown == + * p->subchannel_list->num_subchannels. * * 4) RULE: ALL subchannels are TRANSIENT_FAILURE => policy is * TRANSIENT_FAILURE. @@ -464,37 +473,38 @@ static grpc_connectivity_state update_lb_connectivity_status_locked( * 5) RULE: ALL subchannels are IDLE => policy is IDLE. * CHECK: p->num_idle == p->subchannel_list->num_subchannels. */ + grpc_connectivity_state new_state = sd->curr_connectivity_state; rr_subchannel_list *subchannel_list = sd->subchannel_list; round_robin_lb_policy *p = subchannel_list->policy; if (subchannel_list->num_ready > 0) { /* 1) READY */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_READY, GRPC_ERROR_NONE, "rr_ready"); - return GRPC_CHANNEL_READY; + new_state = GRPC_CHANNEL_READY; } else if (sd->curr_connectivity_state == GRPC_CHANNEL_CONNECTING) { /* 2) CONNECTING */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE, "rr_connecting"); - return GRPC_CHANNEL_CONNECTING; - } else if (p->subchannel_list->num_subchannels == 0) { /* 3) SHUTDOWN */ + new_state = GRPC_CHANNEL_CONNECTING; + } else if (p->subchannel_list->num_shutdown == + p->subchannel_list->num_subchannels) { /* 3) SHUTDOWN */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, - GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), - "rr_shutdown"); - return GRPC_CHANNEL_SHUTDOWN; + GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), "rr_shutdown"); + new_state = GRPC_CHANNEL_SHUTDOWN; } else if (subchannel_list->num_transient_failures == p->subchannel_list->num_subchannels) { /* 4) TRANSIENT_FAILURE */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, - GRPC_CHANNEL_TRANSIENT_FAILURE, - GRPC_ERROR_REF(error), "rr_transient_failure"); - return GRPC_CHANNEL_TRANSIENT_FAILURE; + GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), + "rr_transient_failure"); + new_state = GRPC_CHANNEL_TRANSIENT_FAILURE; } else if (subchannel_list->num_idle == p->subchannel_list->num_subchannels) { /* 5) IDLE */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_IDLE, GRPC_ERROR_NONE, "rr_idle"); - return GRPC_CHANNEL_IDLE; + new_state = GRPC_CHANNEL_IDLE; } - /* no change */ - return sd->curr_connectivity_state; + GRPC_ERROR_UNREF(error); + return new_state; } static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, @@ -657,8 +667,9 @@ static void rr_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_connected_subchannel_ping(exec_ctx, target, closure); GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, target, "rr_picked"); } else { - GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING( - "Round Robin not connected")); + GRPC_CLOSURE_SCHED( + exec_ctx, closure, + GRPC_ERROR_CREATE_FROM_STATIC_STRING("Round Robin not connected")); } } From 05e15745d3a562c4fc43180ab4153766ac2a9851 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 26 Jun 2017 11:06:17 -0700 Subject: [PATCH 37/69] added test for RR connectivity state upon subchannels shutdown --- test/cpp/end2end/client_lb_end2end_test.cc | 60 ++++++++++++++++++---- 1 file changed, 50 insertions(+), 10 deletions(-) diff --git a/test/cpp/end2end/client_lb_end2end_test.cc b/test/cpp/end2end/client_lb_end2end_test.cc index 776d94d3b61..f71e557450d 100644 --- a/test/cpp/end2end/client_lb_end2end_test.cc +++ b/test/cpp/end2end/client_lb_end2end_test.cc @@ -97,9 +97,12 @@ class ClientLbEnd2endTest : public ::testing::Test { } } - void StartServers(int num_servers) { - for (int i = 0; i < num_servers; ++i) { - servers_.emplace_back(new ServerData(server_host_)); + void StartServers(size_t num_servers, + std::vector ports = std::vector()) { + for (size_t i = 0; i < num_servers; ++i) { + int port = 0; + if (ports.size() == num_servers) port = ports[i]; + servers_.emplace_back(new ServerData(server_host_, port)); } } @@ -146,14 +149,18 @@ class ClientLbEnd2endTest : public ::testing::Test { stub_ = grpc::testing::EchoTestService::NewStub(channel_); } - void SendRpc() { + void SendRpc(bool expect_ok = true) { EchoRequest request; EchoResponse response; request.set_message("Live long and prosper."); ClientContext context; Status status = stub_->Echo(&context, request, &response); - EXPECT_TRUE(status.ok()); - EXPECT_EQ(response.message(), request.message()); + if (expect_ok) { + EXPECT_TRUE(status.ok()); + EXPECT_EQ(response.message(), request.message()); + } else { + EXPECT_FALSE(status.ok()); + } } struct ServerData { @@ -162,8 +169,8 @@ class ClientLbEnd2endTest : public ::testing::Test { MyTestServiceImpl service_; std::unique_ptr thread_; - explicit ServerData(const grpc::string& server_host) { - port_ = grpc_pick_unused_port_or_die(); + explicit ServerData(const grpc::string& server_host, int port = 0) { + port_ = port > 0 ? port : grpc_pick_unused_port_or_die(); gpr_log(GPR_INFO, "starting server on port %d", port_); std::mutex mu; std::condition_variable cond; @@ -187,9 +194,9 @@ class ClientLbEnd2endTest : public ::testing::Test { cond->notify_one(); } - void Shutdown() { + void Shutdown(bool join = true) { server_->Shutdown(); - thread_->join(); + if (join) thread_->join(); } }; @@ -456,6 +463,39 @@ TEST_F(ClientLbEnd2endTest, RoundRobinManyUpdates) { EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName()); } +TEST_F(ClientLbEnd2endTest, RoundRobinReconnect) { + // Start servers and send one RPC per server. + const int kNumServers = 1; + std::vector ports; + ports.push_back(grpc_pick_unused_port_or_die()); + StartServers(kNumServers, ports); + ResetStub("round_robin"); + SetNextResolution(ports); + // Send one RPC per backend and make sure they are used in order. + // Note: This relies on the fact that the subchannels are reported in + // state READY in the order in which the addresses are specified, + // which is only true because the backends are all local. + for (size_t i = 0; i < servers_.size(); ++i) { + SendRpc(); + EXPECT_EQ(1, servers_[i]->service_.request_count()) << "for backend #" << i; + } + // Check LB policy name for the channel. + EXPECT_EQ("round_robin", channel_->GetLoadBalancingPolicyName()); + + // Kill all servers + for (size_t i = 0; i < servers_.size(); ++i) { + servers_[i]->Shutdown(false); + } + // Client request should fail. + SendRpc(false); + + // Bring servers back up on the same port (we aren't recreating the channel). + StartServers(kNumServers, ports); + + // Client request should succeed. + SendRpc(); +} + } // namespace } // namespace testing } // namespace grpc From a139bfdc4c8c785e05dc6e8ac8ccbd50a92b2f89 Mon Sep 17 00:00:00 2001 From: thassss Date: Mon, 26 Jun 2017 13:34:40 -0700 Subject: [PATCH 38/69] Expose :authority pseudo-header to Obj-C API. --- src/objective-c/GRPCClient/GRPCCall.h | 5 +++++ src/objective-c/GRPCClient/GRPCCall.m | 2 +- src/objective-c/GRPCClient/private/GRPCChannel.h | 1 + src/objective-c/GRPCClient/private/GRPCChannel.m | 5 ++++- src/objective-c/GRPCClient/private/GRPCHost.h | 1 + src/objective-c/GRPCClient/private/GRPCHost.m | 4 +++- src/objective-c/GRPCClient/private/GRPCWrappedCall.h | 1 + src/objective-c/GRPCClient/private/GRPCWrappedCall.m | 5 +++-- 8 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 8c5bcf1c8b1..2495aface69 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -163,6 +163,11 @@ extern id const kGRPCTrailersKey; /** Represents a single gRPC remote call. */ @interface GRPCCall : GRXWriter +/** + * The server name for the RPC. If nil, the host name of the service object will be used instead. + */ +@property (atomic, readwrite) NSString *serverName; + /** * The container of the request headers of an RPC conforms to this protocol, which is a subset of * NSMutableDictionary's interface. It will become a NSMutableDictionary later on. diff --git a/src/objective-c/GRPCClient/GRPCCall.m b/src/objective-c/GRPCClient/GRPCCall.m index 6ba401def44..872362419eb 100644 --- a/src/objective-c/GRPCClient/GRPCCall.m +++ b/src/objective-c/GRPCClient/GRPCCall.m @@ -425,7 +425,7 @@ static NSMutableDictionary *callFlags; _responseWriteable = [[GRXConcurrentWriteable alloc] initWithWriteable:writeable dispatchQueue:_responseQueue]; - _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host path:_path]; + _wrappedCall = [[GRPCWrappedCall alloc] initWithHost:_host serverName:_serverName path:_path]; NSAssert(_wrappedCall, @"Error allocating RPC objects. Low memory?"); [self sendHeaders:_requestHeaders]; diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.h b/src/objective-c/GRPCClient/private/GRPCChannel.h index e4dfbca38dc..e2aa5bd036f 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.h +++ b/src/objective-c/GRPCClient/private/GRPCChannel.h @@ -62,5 +62,6 @@ struct grpc_channel_credentials; channelArgs:(nullable NSDictionary *)channelArgs; - (nullable grpc_call *)unmanagedCallWithPath:(nonnull NSString *)path + serverName:(nonnull NSString *)serverName completionQueue:(nonnull GRPCCompletionQueue *)queue; @end diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index ca494d5ff29..690fad25965 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -181,14 +181,17 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) { } - (grpc_call *)unmanagedCallWithPath:(NSString *)path + serverName:(NSString *)serverName completionQueue:(GRPCCompletionQueue *)queue { + grpc_slice host_slice = grpc_slice_from_copied_string(serverName.UTF8String); grpc_slice path_slice = grpc_slice_from_copied_string(path.UTF8String); grpc_call *call = grpc_channel_create_call(_unmanagedChannel, NULL, GRPC_PROPAGATE_DEFAULTS, queue.unmanagedQueue, path_slice, - NULL, // Passing NULL for host + &host_slice, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + grpc_slice_unref(host_slice); grpc_slice_unref(path_slice); return call; } diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h index 4b1f780dd21..bb68fa3ec4a 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.h +++ b/src/objective-c/GRPCClient/private/GRPCHost.h @@ -54,6 +54,7 @@ struct grpc_channel_credentials; /** Create a grpc_call object to the provided path on this host. */ - (nullable struct grpc_call *)unmanagedCallWithPath:(NSString *)path + serverName:(nullable NSString *)serverName completionQueue:(GRPCCompletionQueue *)queue; // TODO: There's a race when a new RPC is coming through just as an existing one is getting diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 5b4d647a1a2..5658150b339 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -120,6 +120,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; } - (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path + serverName:(nullable NSString *)serverName completionQueue:(GRPCCompletionQueue *)queue { GRPCChannel *channel; // This is racing -[GRPCHost disconnect]. @@ -129,7 +130,8 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; } channel = _channel; } - return [channel unmanagedCallWithPath:path completionQueue:queue]; + NSString *name = serverName ? serverName : _address; + return [channel unmanagedCallWithPath:path serverName:name completionQueue:queue]; } - (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h index ed245ff7ed2..e24d2469122 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h @@ -75,6 +75,7 @@ @interface GRPCWrappedCall : NSObject - (instancetype)initWithHost:(NSString *)host + serverName:(nullable NSString *)serverName path:(NSString *)path NS_DESIGNATED_INITIALIZER; - (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)())errorHandler; diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 8c8b0b2570e..2d98f708990 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -232,10 +232,11 @@ } - (instancetype)init { - return [self initWithHost:nil path:nil]; + return [self initWithHost:nil serverName:nil path:nil]; } - (instancetype)initWithHost:(NSString *)host + serverName:(nullable NSString *)serverName path:(NSString *)path { if (!path || !host) { [NSException raise:NSInvalidArgumentException @@ -248,7 +249,7 @@ // queue. Currently we use a singleton queue. _queue = [GRPCCompletionQueue completionQueue]; - _call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path completionQueue:_queue]; + _call = [[GRPCHost hostWithAddress:host] unmanagedCallWithPath:path serverName:serverName completionQueue:_queue]; if (_call == NULL) { return nil; } From b8be14309df478973990d1908430763b399b7027 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Mon, 26 Jun 2017 13:38:42 -0700 Subject: [PATCH 39/69] formatting changes --- .../filters/client_channel/lb_policy/round_robin/round_robin.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c index c41f22ea9ab..b648bba3fb3 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c @@ -434,7 +434,6 @@ static void update_state_counters_locked(subchannel_data *sd) { GPR_ASSERT(subchannel_list->num_idle > 0); --subchannel_list->num_idle; } - if (sd->curr_connectivity_state == GRPC_CHANNEL_READY) { ++subchannel_list->num_ready; } else if (sd->curr_connectivity_state == GRPC_CHANNEL_TRANSIENT_FAILURE) { From 3598ac81b0ad9666f98c13414c492243366fc635 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 27 Jun 2017 12:49:40 +0200 Subject: [PATCH 40/69] update scenario result schema --- .../performance/scenario_result_schema.json | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/run_tests/performance/scenario_result_schema.json b/tools/run_tests/performance/scenario_result_schema.json index 8ec41c377c5..245861f8c27 100644 --- a/tools/run_tests/performance/scenario_result_schema.json +++ b/tools/run_tests/performance/scenario_result_schema.json @@ -107,6 +107,11 @@ "name": "timeSystem", "type": "FLOAT", "mode": "NULLABLE" + }, + { + "name": "cqPollCount", + "type": "INTEGER", + "mode": "NULLABLE" } ] }, @@ -129,6 +134,11 @@ "name": "timeSystem", "type": "FLOAT", "mode": "NULLABLE" + }, + { + "name": "cqPollCount", + "type": "INTEGER", + "mode": "NULLABLE" } ] }, @@ -196,6 +206,16 @@ "name": "latency999", "type": "FLOAT", "mode": "NULLABLE" + }, + { + "name": "clientPollsPerRequest", + "type": "FLOAT", + "mode": "NULLABLE" + }, + { + "name": "serverPollsPerRequest", + "type": "FLOAT", + "mode": "NULLABLE" } ] }, From 58ca8beb165b1a741072ed6ff826c2b87066bc00 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 27 Jun 2017 13:45:46 +0200 Subject: [PATCH 41/69] add script for patching perf benchmark schema --- tools/gcp/utils/big_query_utils.py | 27 +++++++++ .../patch_scenario_results_schema.py | 55 +++++++++++++++++++ 2 files changed, 82 insertions(+) create mode 100755 tools/run_tests/performance/patch_scenario_results_schema.py diff --git a/tools/gcp/utils/big_query_utils.py b/tools/gcp/utils/big_query_utils.py index 76c86645b76..77a5f5691e9 100755 --- a/tools/gcp/utils/big_query_utils.py +++ b/tools/gcp/utils/big_query_utils.py @@ -116,6 +116,33 @@ def create_table2(big_query, project_id, dataset_id, table_id, fields_schema, return is_success +def patch_table(big_query, project_id, dataset_id, table_id, fields_schema): + is_success = True + + body = { + 'schema': { + 'fields': fields_schema + }, + 'tableReference': { + 'datasetId': dataset_id, + 'projectId': project_id, + 'tableId': table_id + } + } + + try: + table_req = big_query.tables().patch(projectId=project_id, + datasetId=dataset_id, + tableId=table_id, + body=body) + res = table_req.execute(num_retries=NUM_RETRIES) + print 'Successfully patched %s "%s"' % (res['kind'], res['id']) + except HttpError as http_error: + print 'Error in creating table: %s. Err: %s' % (table_id, http_error) + is_success = False + return is_success + + def insert_rows(big_query, project_id, dataset_id, table_id, rows_list): is_success = True body = {'rows': rows_list} diff --git a/tools/run_tests/performance/patch_scenario_results_schema.py b/tools/run_tests/performance/patch_scenario_results_schema.py new file mode 100755 index 00000000000..81ba5381b3e --- /dev/null +++ b/tools/run_tests/performance/patch_scenario_results_schema.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python +# Copyright 2016 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Use to patch schema of existing scenario results tables (after adding fields). + +from __future__ import print_function + +import argparse +import calendar +import json +import os +import sys +import time +import uuid + + +gcp_utils_dir = os.path.abspath(os.path.join( + os.path.dirname(__file__), '../../gcp/utils')) +sys.path.append(gcp_utils_dir) +import big_query_utils + + +_PROJECT_ID='grpc-testing' + +def _patch_results_table(dataset_id, table_id): + bq = big_query_utils.create_big_query() + with open(os.path.dirname(__file__) + '/scenario_result_schema.json', 'r') as f: + table_schema = json.loads(f.read()) + desc = 'Results of performance benchmarks.' + return big_query_utils.patch_table(bq, _PROJECT_ID, dataset_id, + table_id, table_schema) + + +argp = argparse.ArgumentParser(description='Patch schema of scenario results table.') +argp.add_argument('--bq_result_table', required=True, default=None, type=str, + help='Bigquery "dataset.table" to patch.') + +args = argp.parse_args() + +dataset_id, table_id = args.bq_result_table.split('.', 2) + +_patch_results_table(dataset_id, table_id) +print('Successfully patched schema of %s.\n' % args.bq_result_table) From be3c7e2a4266979f3ba355aaaa00a1fb4185cc71 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 27 Jun 2017 11:52:52 -0700 Subject: [PATCH 42/69] Fix the memory leak in metadata --- src/objective-c/GRPCClient/private/GRPCWrappedCall.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 8c8b0b2570e..bebfc39af16 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -75,6 +75,10 @@ } - (void)dealloc { + for (int i = 0; i < _op.data.send_initial_metadata.count; i++) { + grpc_slice_unref(_op.data.send_initial_metadata.metadata[i].key); + grpc_slice_unref(_op.data.send_initial_metadata.metadata[i].value); + } gpr_free(_op.data.send_initial_metadata.metadata); } From 7ad758cd846bb6f15d3e655ce148ccc099a041e4 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 27 Jun 2017 13:53:19 -0700 Subject: [PATCH 43/69] Make various scripts use the same version of Node --- templates/tools/dockerfile/node_deps.include | 5 +++-- tools/dockerfile/interoptest/grpc_interop_node/Dockerfile | 5 +++-- tools/dockerfile/test/multilang_jessie_x64/Dockerfile | 5 +++-- tools/dockerfile/test/node_jessie_x64/Dockerfile | 5 +++-- tools/run_tests/artifacts/build_artifact_node.sh | 2 +- tools/run_tests/artifacts/build_package_node.sh | 2 +- tools/run_tests/helper_scripts/build_node_electron.sh | 2 +- tools/run_tests/helper_scripts/pre_build_node_electron.sh | 2 +- tools/run_tests/helper_scripts/run_node_electron.sh | 2 +- tools/run_tests/performance/run_worker_node.sh | 2 +- 10 files changed, 18 insertions(+), 14 deletions(-) diff --git a/templates/tools/dockerfile/node_deps.include b/templates/tools/dockerfile/node_deps.include index 7855fbfee36..d0d1b6b49a2 100644 --- a/templates/tools/dockerfile/node_deps.include +++ b/templates/tools/dockerfile/node_deps.include @@ -5,7 +5,8 @@ RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 0.12 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm alias default 4" \ No newline at end of file +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm alias default 8" \ No newline at end of file diff --git a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile index b8e584af7a7..8d8bac6e8e0 100644 --- a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile @@ -70,10 +70,11 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 0.12 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm alias default 4" +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm alias default 8" # Prepare ccache RUN ln -s /usr/bin/ccache /usr/local/bin/gcc RUN ln -s /usr/bin/ccache /usr/local/bin/g++ diff --git a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile index 2d22bb567bf..07fc906aacc 100644 --- a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile @@ -81,10 +81,11 @@ RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev c RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 0.12 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm alias default 4" +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm alias default 8" #================= # PHP dependencies diff --git a/tools/dockerfile/test/node_jessie_x64/Dockerfile b/tools/dockerfile/test/node_jessie_x64/Dockerfile index f6ea639f6cd..868f1f796c0 100644 --- a/tools/dockerfile/test/node_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/node_jessie_x64/Dockerfile @@ -85,10 +85,11 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 0.12 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm alias default 4" +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm alias default 8" # Prepare ccache RUN ln -s /usr/bin/ccache /usr/local/bin/gcc RUN ln -s /usr/bin/ccache /usr/local/bin/g++ diff --git a/tools/run_tests/artifacts/build_artifact_node.sh b/tools/run_tests/artifacts/build_artifact_node.sh index 9d390831b85..581df721aed 100755 --- a/tools/run_tests/artifacts/build_artifact_node.sh +++ b/tools/run_tests/artifacts/build_artifact_node.sh @@ -16,7 +16,7 @@ NODE_TARGET_ARCH=$1 source ~/.nvm/nvm.sh -nvm use 4 +nvm use 8 set -ex cd $(dirname $0)/../../.. diff --git a/tools/run_tests/artifacts/build_package_node.sh b/tools/run_tests/artifacts/build_package_node.sh index 69cea3d1373..2860f68bc44 100755 --- a/tools/run_tests/artifacts/build_package_node.sh +++ b/tools/run_tests/artifacts/build_package_node.sh @@ -15,7 +15,7 @@ source ~/.nvm/nvm.sh -nvm use 4 +nvm use 8 set -ex cd $(dirname $0)/../../.. diff --git a/tools/run_tests/helper_scripts/build_node_electron.sh b/tools/run_tests/helper_scripts/build_node_electron.sh index 5835235970d..ebcdceb0bf9 100755 --- a/tools/run_tests/helper_scripts/build_node_electron.sh +++ b/tools/run_tests/helper_scripts/build_node_electron.sh @@ -17,7 +17,7 @@ ELECTRON_VERSION=$1 source ~/.nvm/nvm.sh -nvm use 6 +nvm use 8 set -ex # change to grpc repo root diff --git a/tools/run_tests/helper_scripts/pre_build_node_electron.sh b/tools/run_tests/helper_scripts/pre_build_node_electron.sh index d42d70d2140..29394d294f6 100755 --- a/tools/run_tests/helper_scripts/pre_build_node_electron.sh +++ b/tools/run_tests/helper_scripts/pre_build_node_electron.sh @@ -16,7 +16,7 @@ ELECTRON_VERSION=$1 -nvm install 6 +nvm install 8 set -ex npm install xvfb-maybe diff --git a/tools/run_tests/helper_scripts/run_node_electron.sh b/tools/run_tests/helper_scripts/run_node_electron.sh index 37d3fa04591..7d436b02cb5 100755 --- a/tools/run_tests/helper_scripts/run_node_electron.sh +++ b/tools/run_tests/helper_scripts/run_node_electron.sh @@ -15,7 +15,7 @@ source ~/.nvm/nvm.sh -nvm use 6 +nvm use 8 set -ex # change to grpc repo root diff --git a/tools/run_tests/performance/run_worker_node.sh b/tools/run_tests/performance/run_worker_node.sh index 16c473ffda0..1286c831fb0 100755 --- a/tools/run_tests/performance/run_worker_node.sh +++ b/tools/run_tests/performance/run_worker_node.sh @@ -14,7 +14,7 @@ # limitations under the License. source ~/.nvm/nvm.sh -nvm use 7 +nvm use 8 set -ex From 0c8cb1d6524fa2f072d45df359f7b8c8b8ec7265 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 27 Jun 2017 14:00:53 -0700 Subject: [PATCH 44/69] Resolve asan failure --- test/core/end2end/tests/cancel_after_round_trip.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/test/core/end2end/tests/cancel_after_round_trip.c b/test/core/end2end/tests/cancel_after_round_trip.c index 032f74aa917..ce98075ae6a 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.c +++ b/test/core/end2end/tests/cancel_after_round_trip.c @@ -210,6 +210,9 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config, CQ_EXPECT_COMPLETION(cqv, tag(1), 1); cq_verify(cqv); + grpc_byte_buffer_destroy(request_payload_recv); + grpc_byte_buffer_destroy(response_payload_recv); + memset(ops, 0, sizeof(ops)); op = ops; op->op = GRPC_OP_RECV_STATUS_ON_CLIENT; From d46239a8c2fc44ca17be3747b57387d358bcacb9 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Tue, 27 Jun 2017 16:30:46 -0700 Subject: [PATCH 45/69] Correct copyright year --- test/core/end2end/tests/cancel_after_round_trip.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/core/end2end/tests/cancel_after_round_trip.c b/test/core/end2end/tests/cancel_after_round_trip.c index ce98075ae6a..eb7bd36228a 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.c +++ b/test/core/end2end/tests/cancel_after_round_trip.c @@ -1,6 +1,6 @@ /* * - * Copyright 2015 gRPC authors. + * Copyright 2017 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From a6ce1ff1d6b451b0e747293a6d39bea4262492a8 Mon Sep 17 00:00:00 2001 From: murgatroid99 Date: Tue, 27 Jun 2017 18:15:38 -0700 Subject: [PATCH 46/69] Fix how npm is upgraded, add npm update line for electron --- templates/tools/dockerfile/node_deps.include | 8 ++++---- tools/dockerfile/interoptest/grpc_interop_node/Dockerfile | 8 ++++---- tools/dockerfile/test/multilang_jessie_x64/Dockerfile | 8 ++++---- tools/dockerfile/test/node_jessie_x64/Dockerfile | 8 ++++---- tools/run_tests/helper_scripts/build_node_electron.sh | 1 + tools/run_tests/helper_scripts/pre_build_node.sh | 3 --- 6 files changed, 17 insertions(+), 19 deletions(-) diff --git a/templates/tools/dockerfile/node_deps.include b/templates/tools/dockerfile/node_deps.include index d0d1b6b49a2..2f7d0d3abbc 100644 --- a/templates/tools/dockerfile/node_deps.include +++ b/templates/tools/dockerfile/node_deps.include @@ -5,8 +5,8 @@ RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache && npm install -g npm" RUN /bin/bash -l -c "nvm alias default 8" \ No newline at end of file diff --git a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile index 8d8bac6e8e0..c59b12d1556 100644 --- a/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile +++ b/tools/dockerfile/interoptest/grpc_interop_node/Dockerfile @@ -70,10 +70,10 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache && npm install -g npm" RUN /bin/bash -l -c "nvm alias default 8" # Prepare ccache RUN ln -s /usr/bin/ccache /usr/local/bin/gcc diff --git a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile index 07fc906aacc..b7373b5d9c3 100644 --- a/tools/dockerfile/test/multilang_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/multilang_jessie_x64/Dockerfile @@ -81,10 +81,10 @@ RUN apt-get update && apt-get -y install libgflags-dev libgtest-dev libc++-dev c RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache && npm install -g npm" RUN /bin/bash -l -c "nvm alias default 8" #================= # PHP dependencies diff --git a/tools/dockerfile/test/node_jessie_x64/Dockerfile b/tools/dockerfile/test/node_jessie_x64/Dockerfile index 868f1f796c0..31602e594ec 100644 --- a/tools/dockerfile/test/node_jessie_x64/Dockerfile +++ b/tools/dockerfile/test/node_jessie_x64/Dockerfile @@ -85,10 +85,10 @@ RUN pip install futures==2.2.0 enum34==1.0.4 protobuf==3.2.0 six==1.10.0 RUN touch .profile RUN curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash # Install all versions of node that we want to test -RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache" -RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache" +RUN /bin/bash -l -c "nvm install 4 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 5 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 6 && npm config set cache /tmp/npm-cache && npm install -g npm" +RUN /bin/bash -l -c "nvm install 8 && npm config set cache /tmp/npm-cache && npm install -g npm" RUN /bin/bash -l -c "nvm alias default 8" # Prepare ccache RUN ln -s /usr/bin/ccache /usr/local/bin/gcc diff --git a/tools/run_tests/helper_scripts/build_node_electron.sh b/tools/run_tests/helper_scripts/build_node_electron.sh index ebcdceb0bf9..424da2c6e3e 100755 --- a/tools/run_tests/helper_scripts/build_node_electron.sh +++ b/tools/run_tests/helper_scripts/build_node_electron.sh @@ -28,4 +28,5 @@ export npm_config_disturl=https://atom.io/download/atom-shell export npm_config_runtime=electron export npm_config_build_from_source=true mkdir -p ~/.electron-gyp +HOME=~/.electron-gyp npm update --prefer-online HOME=~/.electron-gyp npm install --unsafe-perm diff --git a/tools/run_tests/helper_scripts/pre_build_node.sh b/tools/run_tests/helper_scripts/pre_build_node.sh index f41da71d221..d4702b8705e 100755 --- a/tools/run_tests/helper_scripts/pre_build_node.sh +++ b/tools/run_tests/helper_scripts/pre_build_node.sh @@ -20,9 +20,6 @@ source ~/.nvm/nvm.sh nvm install $NODE_VERSION set -ex -# Update npm to at least version 5 -npm update -g npm - export GRPC_CONFIG=${CONFIG:-opt} npm update --prefer-online From ff17b050e6ab499eeaf292e316d6a481b2095b3f Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Tue, 27 Jun 2017 11:05:29 -0700 Subject: [PATCH 47/69] Document error unref contract for iomgr cb's and transport/stream errors --- src/core/lib/iomgr/closure.h | 4 +++- src/core/lib/transport/transport.c | 5 +++++ src/core/lib/transport/transport.h | 10 ++++++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index 2ec6f77e761..2560bf4527e 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -42,7 +42,9 @@ typedef struct grpc_closure_list { * * \param arg Arbitrary input. * \param error GRPC_ERROR_NONE if no error occurred, otherwise some grpc_error - * describing what went wrong */ + * describing what went wrong. + * Error contract: it is not the cb's job to unref this error; + * the closure scheduler will do that after the cb returns */ typedef void (*grpc_iomgr_cb_func)(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error); diff --git a/src/core/lib/transport/transport.c b/src/core/lib/transport/transport.c index 52725846e66..6a9eba110d1 100644 --- a/src/core/lib/transport/transport.c +++ b/src/core/lib/transport/transport.c @@ -206,6 +206,11 @@ grpc_endpoint *grpc_transport_get_endpoint(grpc_exec_ctx *exec_ctx, return transport->vtable->get_endpoint(exec_ctx, transport); } +// grpc_transport_stream_op_batch_finish_with_failure +// is a function that must always unref cancel_error +// though it lives in lib, it handles transport stream ops sure +// it's grpc_transport_stream_op_batch_finish_with_failure + void grpc_transport_stream_op_batch_finish_with_failure( grpc_exec_ctx *exec_ctx, grpc_transport_stream_op_batch *op, grpc_error *error) { diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 2a1a24db203..84e53e683ac 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -198,6 +198,8 @@ struct grpc_transport_stream_op_batch_payload { grpc_chttp2_grpc_status_to_http2_error. Send a RST_STREAM with this error. */ struct { + // Error contract: the transport that gets this op must cause cancel_error + // to be unref'ed after processing it grpc_error *cancel_error; } cancel_stream; @@ -212,9 +214,13 @@ typedef struct grpc_transport_op { /** connectivity monitoring - set connectivity_state to NULL to unsubscribe */ grpc_closure *on_connectivity_state_change; grpc_connectivity_state *connectivity_state; - /** should the transport be disconnected */ + /** should the transport be disconnected + * Error contract: the transport that gets this op must cause + * disconnect_with_error to be unref'ed after processing it */ grpc_error *disconnect_with_error; - /** what should the goaway contain? */ + /** what should the goaway contain? + * Error contract: the transport that gets this op must cause + * goaway_error to be unref'ed after processing it */ grpc_error *goaway_error; /** set the callback for accepting new streams; this is a permanent callback, unlike the other one-shot closures. From e282dfe9e9af3a28f3d80225214388cbc2ceb7c3 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Wed, 28 Jun 2017 19:40:35 +0200 Subject: [PATCH 48/69] update macos kokoro rc script --- .../helper_scripts/prepare_build_macos_rc | 52 +++++-------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index 3851e565a4d..1dabeeb3de9 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -15,53 +15,29 @@ # Source this rc script to prepare the environment for macos builds -# TODO(jtattermusch): remove all deps once installed on MacOS workers +# required to build protobuf +brew install gflags -# brew and C++ deps -yes | ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -brew install autoconf automake libtool ccache cmake gflags gpg wget - -# TODO(jtattermusch): hkp://keys.gnupg.net fails with "No route to host" -gpg --keyserver hkp://193.164.133.100 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 -curl -sSL https://get.rvm.io | sudo bash -s stable - -# add ourselves to rvm group to prevent later "access denied" errors. -sudo dseditgroup -o edit -a `whoami` -t user rvm - -set +ex -source /etc/profile.d/rvm.sh +set +ex # rvm script is very verbose and exits with errorcode +source $HOME/.rvm/scripts/rvm +set -e # rvm commands are very verbose rvm install ruby-2.3 -gem install bundler - rvm osx-ssl-certs status all rvm osx-ssl-certs update all set -ex +gem install bundler + # cocoapods -gem install cocoapods --version 1.0.0 +export LANG=en_US.UTF-8 +gem install cocoapods +pod repo update # needed by python # python -wget -q https://bootstrap.pypa.io/get-pip.py -sudo python get-pip.py +brew install coreutils # we need grealpath +#wget -q https://bootstrap.pypa.io/get-pip.py +#sudo python get-pip.py sudo pip install virtualenv - -# TODO(jtattermusch): install python3 - -# mono -wget -q https://download.mono-project.com/archive/5.0.1/macos-10-universal/MonoFramework-MDK-5.0.1.1.macos10.xamarin.universal.pkg -sudo installer -pkg MonoFramework-MDK-5.0.1.1.macos10.xamarin.universal.pkg -target / -ln -s /Library/Frameworks/Mono.framework/Versions/Current/bin/mono /usr/local/bin/mono - -# dotnet SDK -brew install openssl -wget -q https://go.microsoft.com/fwlink/?linkid=843444 -O dotnet-dev-osx-x64.1.0.1.pkg -sudo installer -pkg dotnet-dev-osx-x64.1.0.1.pkg -target / -ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/dotnet -dotnet --version # bootstrap dotnet SDK - -# nvm -wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.30.2/install.sh | bash - -# TODO(jtattermusch): install node if needed +sudo pip install -U six tox setuptools git submodule update --init From 6ba7d53b63532c3a1ed41cac54460a912c930539 Mon Sep 17 00:00:00 2001 From: Kamil Skalski Date: Wed, 28 Jun 2017 19:42:26 +0100 Subject: [PATCH 49/69] Make CMake find_package work for preinstalled libprotobuf on Raspbian. --- CMakeLists.txt | 21 +++++++++++++++------ templates/CMakeLists.txt.template | 21 +++++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 852eb2bf6c8..384e275d53f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,9 @@ set_property(CACHE gRPC_SSL_PROVIDER PROPERTY STRINGS "module" "package") set(gRPC_PROTOBUF_PROVIDER "module" CACHE STRING "Provider of protobuf library") set_property(CACHE gRPC_PROTOBUF_PROVIDER PROPERTY STRINGS "module" "package") +set(gRPC_PROTOBUF_PACKAGE_TYPE "" CACHE STRING "Algorithm for searching protobuf package") +set_property(CACHE gRPC_PROTOBUF_PACKAGE_TYPE PROPERTY STRINGS "CONFIG" "MODULE") + set(gRPC_GFLAGS_PROVIDER "module" CACHE STRING "Provider of gflags library") set_property(CACHE gRPC_GFLAGS_PROVIDER PROPERTY STRINGS "module" "package") @@ -183,21 +186,27 @@ if("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "module") set(gRPC_INSTALL FALSE) endif() elseif("${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package") - find_package(protobuf CONFIG) - if(protobuf_FOUND) + find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE}) + if(Protobuf_FOUND OR PROTOBUF_FOUND) if(TARGET protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME}) set(_gRPC_PROTOBUF_LIBRARIES protobuf::${_gRPC_PROTOBUF_LIBRARY_NAME}) + else() + set(_gRPC_PROTOBUF_LIBRARIES ${PROTOBUF_LIBRARIES}) endif() if(TARGET protobuf::libprotoc) set(_gRPC_PROTOBUF_PROTOC_LIBRARIES protobuf::libprotoc) + else() + set(_gRPC_PROTOBUF_PROTOC_LIBRARIES ${PROTOBUF_PROTOC_LIBRARIES}) endif() if(TARGET protobuf::protoc) set(_gRPC_PROTOBUF_PROTOC protobuf::protoc) + else() + set(_gRPC_PROTOBUF_PROTOC ${PROTOBUF_PROTOC_EXECUTABLE}) endif() - set(_gRPC_FIND_PROTOBUF "if(NOT protobuf_FOUND)\n find_package(protobuf CONFIG)\nendif()") - else() - find_package(Protobuf MODULE) - set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND)\n find_package(Protobuf)\nendif()") + set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf ${gRPC_PROTOBUF_PACKAGE_TYPE})\nendif()") + endif() + if(PROTOBUF_FOUND) + include_directories(${PROTOBUF_INCLUDE_DIRS}) endif() set(PROTOBUF_WELLKNOWN_IMPORT_DIR /usr/local/include) endif() diff --git a/templates/CMakeLists.txt.template b/templates/CMakeLists.txt.template index ef0faccb2e8..8c38954c911 100644 --- a/templates/CMakeLists.txt.template +++ b/templates/CMakeLists.txt.template @@ -97,6 +97,9 @@ set(gRPC_PROTOBUF_PROVIDER "module" CACHE STRING "Provider of protobuf library") set_property(CACHE gRPC_PROTOBUF_PROVIDER PROPERTY STRINGS "module" "package") + set(gRPC_PROTOBUF_PACKAGE_TYPE "" CACHE STRING "Algorithm for searching protobuf package") + set_property(CACHE gRPC_PROTOBUF_PACKAGE_TYPE PROPERTY STRINGS "CONFIG" "MODULE") + set(gRPC_GFLAGS_PROVIDER "module" CACHE STRING "Provider of gflags library") set_property(CACHE gRPC_GFLAGS_PROVIDER PROPERTY STRINGS "module" "package") @@ -228,21 +231,27 @@ set(gRPC_INSTALL FALSE) endif() elseif("<%text>${gRPC_PROTOBUF_PROVIDER}" STREQUAL "package") - find_package(protobuf CONFIG) - if(protobuf_FOUND) + find_package(Protobuf <%text>${gRPC_PROTOBUF_PACKAGE_TYPE}) + if(Protobuf_FOUND OR PROTOBUF_FOUND) if(TARGET protobuf::<%text>${_gRPC_PROTOBUF_LIBRARY_NAME}) set(_gRPC_PROTOBUF_LIBRARIES protobuf::<%text>${_gRPC_PROTOBUF_LIBRARY_NAME}) + else() + set(_gRPC_PROTOBUF_LIBRARIES <%text>${PROTOBUF_LIBRARIES}) endif() if(TARGET protobuf::libprotoc) set(_gRPC_PROTOBUF_PROTOC_LIBRARIES protobuf::libprotoc) + else() + set(_gRPC_PROTOBUF_PROTOC_LIBRARIES <%text>${PROTOBUF_PROTOC_LIBRARIES}) endif() if(TARGET protobuf::protoc) set(_gRPC_PROTOBUF_PROTOC protobuf::protoc) + else() + set(_gRPC_PROTOBUF_PROTOC <%text>${PROTOBUF_PROTOC_EXECUTABLE}) endif() - set(_gRPC_FIND_PROTOBUF "if(NOT protobuf_FOUND)\n find_package(protobuf CONFIG)\nendif()") - else() - find_package(Protobuf MODULE) - set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND)\n find_package(Protobuf)\nendif()") + set(_gRPC_FIND_PROTOBUF "if(NOT Protobuf_FOUND AND NOT PROTOBUF_FOUND)\n find_package(Protobuf <%text>${gRPC_PROTOBUF_PACKAGE_TYPE})\nendif()") + endif() + if(PROTOBUF_FOUND) + include_directories(<%text>${PROTOBUF_INCLUDE_DIRS}) endif() set(PROTOBUF_WELLKNOWN_IMPORT_DIR /usr/local/include) endif() From b9078c8ee86664fd204b7b0f205e6bb0897a9e42 Mon Sep 17 00:00:00 2001 From: Vijay Pai Date: Wed, 28 Jun 2017 12:37:23 -0700 Subject: [PATCH 50/69] Properly use uint64_t not unsigned int64_t --- src/core/lib/support/time_precise.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/lib/support/time_precise.c b/src/core/lib/support/time_precise.c index 22971ef6c3e..6ce19e53ccb 100644 --- a/src/core/lib/support/time_precise.c +++ b/src/core/lib/support/time_precise.c @@ -31,7 +31,7 @@ static void gpr_get_cycle_counter(int64_t int *clk) { // ---------------------------------------------------------------- #elif defined(__x86_64__) || defined(__amd64__) static void gpr_get_cycle_counter(int64_t *clk) { - unsigned int64_t low, high; + uint64_t low, high; __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); *clk = (int64_t)(high << 32) | (int64_t)low; } From ab1ff6b0415a3582b7aee26e19e738928c75e0d3 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 28 Jun 2017 14:14:24 -0700 Subject: [PATCH 51/69] Split move test --- test/cpp/common/alarm_cpp_test.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/test/cpp/common/alarm_cpp_test.cc b/test/cpp/common/alarm_cpp_test.cc index 760dd7b956a..ce4168843cd 100644 --- a/test/cpp/common/alarm_cpp_test.cc +++ b/test/cpp/common/alarm_cpp_test.cc @@ -40,13 +40,25 @@ TEST(AlarmTest, RegularExpiry) { EXPECT_EQ(junk, output_tag); } -TEST(AlarmTest, Move) { +TEST(AlarmTest, MoveConstructor) { + CompletionQueue cq; + void* junk = reinterpret_cast(1618033); + Alarm first(&cq, grpc_timeout_seconds_to_deadline(1), junk); + Alarm second(std::move(first)); + void* output_tag; + bool ok; + const CompletionQueue::NextStatus status = cq.AsyncNext( + (void**)&output_tag, &ok, grpc_timeout_seconds_to_deadline(2)); + EXPECT_EQ(status, CompletionQueue::GOT_EVENT); + EXPECT_TRUE(ok); + EXPECT_EQ(junk, output_tag); +} + +TEST(AlarmTest, MoveAssignment) { CompletionQueue cq; void* junk = reinterpret_cast(1618033); Alarm first(&cq, grpc_timeout_seconds_to_deadline(1), junk); - // Move constructor. Alarm second(std::move(first)); - // Moving assignment. first = std::move(second); void* output_tag; From b8e6e2f2999c71f50c8442d76c73870b841dafc3 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Wed, 28 Jun 2017 17:59:52 -0700 Subject: [PATCH 52/69] Fix test failures --- test/core/end2end/tests/cancel_after_round_trip.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/core/end2end/tests/cancel_after_round_trip.c b/test/core/end2end/tests/cancel_after_round_trip.c index eb7bd36228a..0fc8b95ef72 100644 --- a/test/core/end2end/tests/cancel_after_round_trip.c +++ b/test/core/end2end/tests/cancel_after_round_trip.c @@ -212,6 +212,8 @@ static void test_cancel_after_round_trip(grpc_end2end_test_config config, grpc_byte_buffer_destroy(request_payload_recv); grpc_byte_buffer_destroy(response_payload_recv); + request_payload_recv = NULL; + response_payload_recv = NULL; memset(ops, 0, sizeof(ops)); op = ops; From af084dc37c2d31f199cfa0516473fbe308ed9ba4 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Tue, 27 Jun 2017 13:42:54 -0700 Subject: [PATCH 53/69] Fixes to pick first --- .../lb_policy/pick_first/pick_first.c | 45 ++++++++++++++++--- .../lb_policy/round_robin/round_robin.c | 30 ++++++------- .../resolver/fake/fake_resolver.c | 3 ++ 3 files changed, 57 insertions(+), 21 deletions(-) diff --git a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c index 307e3bad674..d0acd7a9019 100644 --- a/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c +++ b/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.c @@ -95,6 +95,9 @@ static void pf_destroy(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { gpr_free(p->subchannels); gpr_free(p->new_subchannels); gpr_free(p); + if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { + gpr_log(GPR_DEBUG, "Pick First %p destroyed.", (void *)p); + } } static void pf_shutdown_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol) { @@ -268,11 +271,20 @@ static void stop_connectivity_watchers(grpc_exec_ctx *exec_ctx, pick_first_lb_policy *p) { if (p->num_subchannels > 0) { GPR_ASSERT(p->selected == NULL); + if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { + gpr_log(GPR_DEBUG, "Pick First %p unsubscribing from subchannel %p", + (void *)p, (void *)p->subchannels[p->checking_subchannel]); + } grpc_subchannel_notify_on_state_change( exec_ctx, p->subchannels[p->checking_subchannel], NULL, NULL, &p->connectivity_changed); p->updating_subchannels = true; } else if (p->selected != NULL) { + if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { + gpr_log(GPR_DEBUG, + "Pick First %p unsubscribing from selected subchannel %p", + (void *)p, (void *)p->selected); + } grpc_connected_subchannel_notify_on_state_change( exec_ctx, p->selected, NULL, NULL, &p->connectivity_changed); p->updating_selected = true; @@ -451,12 +463,25 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, grpc_subchannel *selected_subchannel; pending_pick *pp; + if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { + gpr_log( + GPR_DEBUG, + "Pick First %p connectivity changed. Updating selected: %d; Updating " + "subchannels: %d; Checking %lu index (%lu total); State: %d; ", + (void *)p, p->updating_selected, p->updating_subchannels, + (unsigned long)p->checking_subchannel, + (unsigned long)p->num_subchannels, p->checking_connectivity); + } bool restart = false; - if (p->updating_selected && error == GRPC_ERROR_CANCELLED) { + if (p->updating_selected && error != GRPC_ERROR_NONE) { /* Captured the unsubscription for p->selected */ GPR_ASSERT(p->selected != NULL); GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, p->selected, "pf_update_connectivity"); + if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { + gpr_log(GPR_DEBUG, "Pick First %p unreffing selected subchannel %p", + (void *)p, (void *)p->selected); + } p->updating_selected = false; if (p->num_new_subchannels == 0) { p->selected = NULL; @@ -464,12 +489,16 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, } restart = true; } - if (p->updating_subchannels && error == GRPC_ERROR_CANCELLED) { + if (p->updating_subchannels && error != GRPC_ERROR_NONE) { /* Captured the unsubscription for the checking subchannel */ GPR_ASSERT(p->selected == NULL); for (size_t i = 0; i < p->num_subchannels; i++) { GRPC_SUBCHANNEL_UNREF(exec_ctx, p->subchannels[i], "pf_update_connectivity"); + if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { + gpr_log(GPR_DEBUG, "Pick First %p unreffing subchannel %p", (void *)p, + (void *)p->subchannels[i]); + } } gpr_free(p->subchannels); p->subchannels = NULL; @@ -481,14 +510,12 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, if (restart) { p->selected = NULL; p->selected_key = NULL; - GPR_ASSERT(p->new_subchannels != NULL); GPR_ASSERT(p->num_new_subchannels > 0); p->num_subchannels = p->num_new_subchannels; p->subchannels = p->new_subchannels; p->num_new_subchannels = 0; p->new_subchannels = NULL; - if (p->started_picking) { /* If we were picking, continue to do so over the new subchannels, * starting from the 0th index. */ @@ -542,7 +569,9 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, "picked_first"); if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { - gpr_log(GPR_INFO, "Selected subchannel %p", (void *)p->selected); + gpr_log(GPR_INFO, + "Pick First %p selected subchannel %p (connected %p)", + (void *)p, (void *)selected_subchannel, (void *)p->selected); } p->selected_key = grpc_subchannel_get_key(selected_subchannel); /* drop the pick list: we are connected now */ @@ -568,7 +597,8 @@ static void pf_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, p->checking_subchannel = (p->checking_subchannel + 1) % p->num_subchannels; if (p->checking_subchannel == 0) { - /* only trigger transient failure when we've tried all alternatives */ + /* only trigger transient failure when we've tried all alternatives + */ grpc_connectivity_state_set( exec_ctx, &p->state_tracker, GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), "connecting_transient_failure"); @@ -652,6 +682,9 @@ static grpc_lb_policy *create_pick_first(grpc_exec_ctx *exec_ctx, grpc_lb_policy_args *args) { GPR_ASSERT(args->client_channel_factory != NULL); pick_first_lb_policy *p = gpr_zalloc(sizeof(*p)); + if (GRPC_TRACER_ON(grpc_lb_pick_first_trace)) { + gpr_log(GPR_DEBUG, "Pick First %p created.", (void *)p); + } pf_update_locked(exec_ctx, &p->base, args); grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable, args->combiner); GRPC_CLOSURE_INIT(&p->connectivity_changed, pf_connectivity_changed_locked, p, diff --git a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c index b648bba3fb3..8e9d6b0f47b 100644 --- a/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c +++ b/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.c @@ -478,29 +478,30 @@ static grpc_connectivity_state update_lb_connectivity_status_locked( if (subchannel_list->num_ready > 0) { /* 1) READY */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_READY, GRPC_ERROR_NONE, "rr_ready"); - new_state = GRPC_CHANNEL_READY; + new_state = GRPC_CHANNEL_READY; } else if (sd->curr_connectivity_state == GRPC_CHANNEL_CONNECTING) { /* 2) CONNECTING */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_CONNECTING, GRPC_ERROR_NONE, "rr_connecting"); - new_state = GRPC_CHANNEL_CONNECTING; + new_state = GRPC_CHANNEL_CONNECTING; } else if (p->subchannel_list->num_shutdown == p->subchannel_list->num_subchannels) { /* 3) SHUTDOWN */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, - GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), "rr_shutdown"); - new_state = GRPC_CHANNEL_SHUTDOWN; + GRPC_CHANNEL_SHUTDOWN, GRPC_ERROR_REF(error), + "rr_shutdown"); + new_state = GRPC_CHANNEL_SHUTDOWN; } else if (subchannel_list->num_transient_failures == p->subchannel_list->num_subchannels) { /* 4) TRANSIENT_FAILURE */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, - GRPC_CHANNEL_TRANSIENT_FAILURE, GRPC_ERROR_REF(error), - "rr_transient_failure"); - new_state = GRPC_CHANNEL_TRANSIENT_FAILURE; + GRPC_CHANNEL_TRANSIENT_FAILURE, + GRPC_ERROR_REF(error), "rr_transient_failure"); + new_state = GRPC_CHANNEL_TRANSIENT_FAILURE; } else if (subchannel_list->num_idle == p->subchannel_list->num_subchannels) { /* 5) IDLE */ grpc_connectivity_state_set(exec_ctx, &p->state_tracker, GRPC_CHANNEL_IDLE, GRPC_ERROR_NONE, "rr_idle"); - new_state = GRPC_CHANNEL_IDLE; + new_state = GRPC_CHANNEL_IDLE; } GRPC_ERROR_UNREF(error); return new_state; @@ -581,14 +582,14 @@ static void rr_connectivity_changed_locked(grpc_exec_ctx *exec_ctx, void *arg, GPR_ASSERT(!sd->subchannel_list->shutting_down); if (GRPC_TRACER_ON(grpc_lb_round_robin_trace)) { const unsigned long num_subchannels = - p->subchannel_list != NULL ? p->subchannel_list->num_subchannels - : 0; + p->subchannel_list != NULL + ? (unsigned long)p->subchannel_list->num_subchannels + : 0; gpr_log(GPR_DEBUG, "[RR %p] phasing out subchannel list %p (size %lu) in favor " "of %p (size %lu)", (void *)p, (void *)p->subchannel_list, num_subchannels, - (void *)sd->subchannel_list, - (unsigned long)sd->subchannel_list->num_subchannels); + (void *)sd->subchannel_list, num_subchannels); } if (p->subchannel_list != NULL) { // dispose of the current subchannel_list @@ -666,9 +667,8 @@ static void rr_ping_one_locked(grpc_exec_ctx *exec_ctx, grpc_lb_policy *pol, grpc_connected_subchannel_ping(exec_ctx, target, closure); GRPC_CONNECTED_SUBCHANNEL_UNREF(exec_ctx, target, "rr_picked"); } else { - GRPC_CLOSURE_SCHED( - exec_ctx, closure, - GRPC_ERROR_CREATE_FROM_STATIC_STRING("Round Robin not connected")); + GRPC_CLOSURE_SCHED(exec_ctx, closure, GRPC_ERROR_CREATE_FROM_STATIC_STRING( + "Round Robin not connected")); } } diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c index 56ed4371a91..479ba393a26 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c @@ -101,6 +101,9 @@ static void fake_resolver_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx, static void fake_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver) { fake_resolver* r = (fake_resolver*)resolver; + gpr_log( + GPR_INFO, + "FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"); if (r->next_results == NULL && r->results_upon_error != NULL) { // Pretend we re-resolved. r->next_results = grpc_channel_args_copy(r->results_upon_error); From 1e0aae6304b93f0fbd2ca10d683adf92b5c5d330 Mon Sep 17 00:00:00 2001 From: Noah Eisen Date: Thu, 29 Jun 2017 03:00:18 -0700 Subject: [PATCH 54/69] Fix musl --- src/core/lib/iomgr/ev_epollsig_linux.c | 5 ----- src/core/lib/iomgr/ev_poll_posix.c | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/core/lib/iomgr/ev_epollsig_linux.c b/src/core/lib/iomgr/ev_epollsig_linux.c index 17fef01e6ea..255e07010ba 100644 --- a/src/core/lib/iomgr/ev_epollsig_linux.c +++ b/src/core/lib/iomgr/ev_epollsig_linux.c @@ -840,11 +840,6 @@ static grpc_fd *fd_create(int fd, const char *name) { char *fd_name; gpr_asprintf(&fd_name, "%s fd=%d", name, fd); grpc_iomgr_register_object(&new_fd->iomgr_object, fd_name); -#ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) { - gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, new_fd, fd_name); - } -#endif gpr_free(fd_name); return new_fd; } diff --git a/src/core/lib/iomgr/ev_poll_posix.c b/src/core/lib/iomgr/ev_poll_posix.c index 1f66159c4a1..1f8d7eef26d 100644 --- a/src/core/lib/iomgr/ev_poll_posix.c +++ b/src/core/lib/iomgr/ev_poll_posix.c @@ -323,11 +323,6 @@ static grpc_fd *fd_create(int fd, const char *name) { gpr_asprintf(&name2, "%s fd=%d", name, fd); grpc_iomgr_register_object(&r->iomgr_object, name2); gpr_free(name2); -#ifndef NDEBUG - if (GRPC_TRACER_ON(grpc_trace_fd_refcount)) { - gpr_log(GPR_DEBUG, "FD %d %p create %s", fd, r, name); - } -#endif return r; } From f53eb370560b797463ff571b384c66ef787d67dc Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Jun 2017 14:18:38 +0200 Subject: [PATCH 55/69] improvements to kokoro macos build --- .../helper_scripts/prepare_build_macos_rc | 12 ++++++++++-- tools/internal_ci/macos/grpc_master.sh | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index 1dabeeb3de9..6d9db5db47e 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -15,6 +15,12 @@ # Source this rc script to prepare the environment for macos builds +ulimit -n 1000 + +# show current limits +ulimit -a + + # required to build protobuf brew install gflags @@ -35,9 +41,11 @@ pod repo update # needed by python # python brew install coreutils # we need grealpath -#wget -q https://bootstrap.pypa.io/get-pip.py -#sudo python get-pip.py sudo pip install virtualenv sudo pip install -U six tox setuptools +# python 3.4 +wget https://www.python.org/ftp/python/3.4.4/python-3.4.4-macosx10.6.pkg +sudo installer -pkg python-3.4.4-macosx10.6.pkg -target / + git submodule update --init diff --git a/tools/internal_ci/macos/grpc_master.sh b/tools/internal_ci/macos/grpc_master.sh index 786859be3fe..c64666b2dec 100755 --- a/tools/internal_ci/macos/grpc_master.sh +++ b/tools/internal_ci/macos/grpc_master.sh @@ -20,7 +20,7 @@ cd $(dirname $0)/../../.. source tools/internal_ci/helper_scripts/prepare_build_macos_rc -tools/run_tests/run_tests_matrix.py -f basictests macos --internal_ci || FAILED="true" +tools/run_tests/run_tests_matrix.py -f basictests macos --internal_ci -j 2 --inner_jobs 4 || FAILED="true" # kill port_server.py to prevent the build from hanging ps aux | grep port_server\\.py | awk '{print $2}' | xargs kill -9 From cc4ef5919f81dc0c1be14172785da0f4d24d1e21 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 29 Jun 2017 08:11:57 -0700 Subject: [PATCH 56/69] Improvements to C++ filter API: - Make sure all C-core parameters are passed into C++ methods. - Add Destroy() methods for ChannelData and CallData. - Use C++-style casts. - Add 'extern "C"' to iomgr/closure.h, which is used in C++ filters. --- src/core/lib/iomgr/closure.h | 8 ++++ src/cpp/common/channel_filter.h | 54 +++++++++++++++----------- test/cpp/common/channel_filter_test.cc | 4 +- 3 files changed, 42 insertions(+), 24 deletions(-) diff --git a/src/core/lib/iomgr/closure.h b/src/core/lib/iomgr/closure.h index 2560bf4527e..cd32a4ba381 100644 --- a/src/core/lib/iomgr/closure.h +++ b/src/core/lib/iomgr/closure.h @@ -26,6 +26,10 @@ #include "src/core/lib/iomgr/error.h" #include "src/core/lib/support/mpscq.h" +#ifdef __cplusplus +extern "C" { +#endif + struct grpc_closure; typedef struct grpc_closure grpc_closure; @@ -197,4 +201,8 @@ void grpc_closure_list_sched(grpc_exec_ctx *exec_ctx, grpc_closure_list_sched(exec_ctx, closure_list) #endif +#ifdef __cplusplus +} +#endif + #endif /* GRPC_CORE_LIB_IOMGR_CLOSURE_H */ diff --git a/src/cpp/common/channel_filter.h b/src/cpp/common/channel_filter.h index 1b6ace6b130..5d629f7c14b 100644 --- a/src/cpp/common/channel_filter.h +++ b/src/cpp/common/channel_filter.h @@ -208,38 +208,45 @@ class TransportStreamOpBatch { /// Represents channel data. class ChannelData { public: + ChannelData() {} virtual ~ChannelData() {} - /// Initializes the call data. - virtual grpc_error *Init(grpc_exec_ctx *exec_ctx, + // TODO(roth): Come up with a more C++-like API for the channel element. + + /// Initializes the channel data. + virtual grpc_error *Init(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_channel_element_args *args) { return GRPC_ERROR_NONE; } - // TODO(roth): Find a way to avoid passing elem into these methods. + // Called before destruction. + virtual void Destroy(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) {} virtual void StartTransportOp(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, TransportOp *op); virtual void GetInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, const grpc_channel_info *channel_info); - - protected: - ChannelData() {} }; /// Represents call data. class CallData { public: + CallData() {} virtual ~CallData() {} + // TODO(roth): Come up with a more C++-like API for the call element. + /// Initializes the call data. - virtual grpc_error *Init(grpc_exec_ctx *exec_ctx, ChannelData *channel_data, + virtual grpc_error *Init(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, const grpc_call_element_args *args) { return GRPC_ERROR_NONE; } - // TODO(roth): Find a way to avoid passing elem into these methods. + // Called before destruction. + virtual void Destroy(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + const grpc_call_final_info *final_info, + grpc_closure *then_call_closure) {} /// Starts a new stream operation. virtual void StartTransportStreamOpBatch(grpc_exec_ctx *exec_ctx, @@ -253,9 +260,6 @@ class CallData { /// Gets the peer name. virtual char *GetPeer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem); - - protected: - CallData() {} }; namespace internal { @@ -271,19 +275,24 @@ class ChannelFilter final { static grpc_error *InitChannelElement(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_channel_element_args *args) { + // Construct the object in the already-allocated memory. ChannelDataType *channel_data = new (elem->channel_data) ChannelDataType(); - return channel_data->Init(exec_ctx, args); + return channel_data->Init(exec_ctx, elem, args); } static void DestroyChannelElement(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem) { - reinterpret_cast(elem->channel_data)->~ChannelDataType(); + ChannelDataType *channel_data = + reinterpret_cast(elem->channel_data); + channel_data->Destroy(exec_ctx, elem); + channel_data->~ChannelDataType(); } static void StartTransportOp(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_transport_op *op) { - ChannelDataType *channel_data = (ChannelDataType *)elem->channel_data; + ChannelDataType *channel_data = + reinterpret_cast(elem->channel_data); TransportOp op_wrapper(op); channel_data->StartTransportOp(exec_ctx, elem, &op_wrapper); } @@ -291,7 +300,8 @@ class ChannelFilter final { static void GetChannelInfo(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, const grpc_channel_info *channel_info) { - ChannelDataType *channel_data = (ChannelDataType *)elem->channel_data; + ChannelDataType *channel_data = + reinterpret_cast(elem->channel_data); channel_data->GetInfo(exec_ctx, elem, channel_info); } @@ -300,24 +310,24 @@ class ChannelFilter final { static grpc_error *InitCallElement(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, const grpc_call_element_args *args) { - ChannelDataType *channel_data = (ChannelDataType *)elem->channel_data; // Construct the object in the already-allocated memory. CallDataType *call_data = new (elem->call_data) CallDataType(); - return call_data->Init(exec_ctx, channel_data, args); + return call_data->Init(exec_ctx, elem, args); } static void DestroyCallElement(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, const grpc_call_final_info *final_info, grpc_closure *then_call_closure) { - GPR_ASSERT(then_call_closure == NULL); - reinterpret_cast(elem->call_data)->~CallDataType(); + CallDataType *call_data = reinterpret_cast(elem->call_data); + call_data->Destroy(exec_ctx, elem, final_info, then_call_closure); + call_data->~CallDataType(); } static void StartTransportStreamOpBatch(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_transport_stream_op_batch *op) { - CallDataType *call_data = (CallDataType *)elem->call_data; + CallDataType *call_data = reinterpret_cast(elem->call_data); TransportStreamOpBatch op_wrapper(op); call_data->StartTransportStreamOpBatch(exec_ctx, elem, &op_wrapper); } @@ -325,12 +335,12 @@ class ChannelFilter final { static void SetPollsetOrPollsetSet(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_polling_entity *pollent) { - CallDataType *call_data = (CallDataType *)elem->call_data; + CallDataType *call_data = reinterpret_cast(elem->call_data); call_data->SetPollsetOrPollsetSet(exec_ctx, elem, pollent); } static char *GetPeer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { - CallDataType *call_data = (CallDataType *)elem->call_data; + CallDataType *call_data = reinterpret_cast(elem->call_data); return call_data->GetPeer(exec_ctx, elem); } }; diff --git a/test/cpp/common/channel_filter_test.cc b/test/cpp/common/channel_filter_test.cc index e747e633a02..638518107bb 100644 --- a/test/cpp/common/channel_filter_test.cc +++ b/test/cpp/common/channel_filter_test.cc @@ -28,7 +28,7 @@ class MyChannelData : public ChannelData { public: MyChannelData() {} - grpc_error* Init(grpc_exec_ctx* exec_ctx, + grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, grpc_channel_element_args* args) override { (void)args->channel_args; // Make sure field is available. return GRPC_ERROR_NONE; @@ -39,7 +39,7 @@ class MyCallData : public CallData { public: MyCallData() {} - grpc_error* Init(grpc_exec_ctx* exec_ctx, ChannelData* channel_data, + grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_call_element* elem, const grpc_call_element_args* args) override { (void)args->path; // Make sure field is available. return GRPC_ERROR_NONE; From c250b048a0abde515bad066f14dcaf5c33e4e730 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Thu, 29 Jun 2017 15:06:09 +0200 Subject: [PATCH 57/69] add mac deps to build artifacts on kokoro --- .../helper_scripts/prepare_build_macos_rc | 2 +- .../internal_ci/macos/grpc_build_artifacts.sh | 20 ++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index 6d9db5db47e..6b942d22b8c 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -45,7 +45,7 @@ sudo pip install virtualenv sudo pip install -U six tox setuptools # python 3.4 -wget https://www.python.org/ftp/python/3.4.4/python-3.4.4-macosx10.6.pkg +wget -q https://www.python.org/ftp/python/3.4.4/python-3.4.4-macosx10.6.pkg sudo installer -pkg python-3.4.4-macosx10.6.pkg -target / git submodule update --init diff --git a/tools/internal_ci/macos/grpc_build_artifacts.sh b/tools/internal_ci/macos/grpc_build_artifacts.sh index aad99b068d7..3884a4f2e50 100755 --- a/tools/internal_ci/macos/grpc_build_artifacts.sh +++ b/tools/internal_ci/macos/grpc_build_artifacts.sh @@ -18,6 +18,24 @@ set -ex # change to grpc repo root cd $(dirname $0)/../../.. -git submodule update --init +source tools/internal_ci/helper_scripts/prepare_build_macos_rc + +# python 3.5 +wget -q https://www.python.org/ftp/python/3.5.2/python-3.5.2-macosx10.6.pkg +sudo installer -pkg python-3.5.2-macosx10.6.pkg -target / + +# install cython for all python versions +python2.7 -m pip install cython setuptools wheel +python3.4 -m pip install cython setuptools wheel +python3.5 -m pip install cython setuptools wheel +python3.6 -m pip install cython setuptools wheel + +# node-gyp (needed for node artifacts) +npm install -g node-gyp + +# php dependencies: pecl +curl -O http://pear.php.net/go-pear.phar +sudo php -d detect_unicode=0 go-pear.phar + tools/run_tests/task_runner.py -f artifact macos From b2b54fe60fd0f9353ba536f8217fa8119a5bbb77 Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 27 Jun 2017 14:37:01 +0200 Subject: [PATCH 58/69] add C# test demoing custom error details --- .../CustomErrorDetailsTest.cs | 112 ++++++++++++++++++ src/csharp/generate_proto_csharp.sh | 2 +- src/csharp/tests.json | 1 + 3 files changed, 114 insertions(+), 1 deletion(-) create mode 100644 src/csharp/Grpc.IntegrationTesting/CustomErrorDetailsTest.cs diff --git a/src/csharp/Grpc.IntegrationTesting/CustomErrorDetailsTest.cs b/src/csharp/Grpc.IntegrationTesting/CustomErrorDetailsTest.cs new file mode 100644 index 00000000000..be996f91e03 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/CustomErrorDetailsTest.cs @@ -0,0 +1,112 @@ +#region Copyright notice and license + +// Copyright 2015-2016 gRPC authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#endregion + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Google.Protobuf; +using Grpc.Core; +using Grpc.Core.Utils; +using Grpc.Testing; +using NUnit.Framework; + +namespace Grpc.IntegrationTesting +{ + /// + /// Shows how to attach custom error details as a binary trailer. + /// + public class CustomErrorDetailsTest + { + const string DebugInfoTrailerName = "debug-info-bin"; + const string ExceptionDetail = "Exception thrown on purpose."; + const string Host = "localhost"; + Server server; + Channel channel; + TestService.TestServiceClient client; + + [TestFixtureSetUp] + public void Init() + { + // Disable SO_REUSEPORT to prevent https://github.com/grpc/grpc/issues/10755 + server = new Server(new[] { new ChannelOption(ChannelOptions.SoReuseport, 0) }) + { + Services = { TestService.BindService(new CustomErrorDetailsTestServiceImpl()) }, + Ports = { { Host, ServerPort.PickUnused, ServerCredentials.Insecure } } + }; + server.Start(); + + channel = new Channel(Host, server.Ports.Single().BoundPort, ChannelCredentials.Insecure); + client = new TestService.TestServiceClient(channel); + } + + [TestFixtureTearDown] + public void Cleanup() + { + channel.ShutdownAsync().Wait(); + server.ShutdownAsync().Wait(); + } + + [Test] + public async Task UnaryCall() + { + var call = client.UnaryCallAsync(new SimpleRequest { ResponseSize = 10 }); + + try + { + await call.ResponseAsync; + Assert.Fail(); + } + catch (RpcException e) + { + Assert.AreEqual(StatusCode.Unknown, e.Status.StatusCode); + var debugInfo = GetDebugInfo(call.GetTrailers()); + Assert.AreEqual(debugInfo.Detail, ExceptionDetail); + Assert.IsNotEmpty(debugInfo.StackEntries); + } + } + + private DebugInfo GetDebugInfo(Metadata trailers) + { + var entry = trailers.First((e) => e.Key == DebugInfoTrailerName); + return DebugInfo.Parser.ParseFrom(entry.ValueBytes); + } + + private class CustomErrorDetailsTestServiceImpl : TestService.TestServiceBase + { + public override async Task UnaryCall(SimpleRequest request, ServerCallContext context) + { + try + { + throw new ArgumentException(ExceptionDetail); + } + catch (Exception e) + { + // Fill debug info with some structured details about the failure. + var debugInfo = new DebugInfo(); + debugInfo.Detail = e.Message; + debugInfo.StackEntries.AddRange(e.StackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)); + context.ResponseTrailers.Add(DebugInfoTrailerName, debugInfo.ToByteArray()); + throw new RpcException(new Status(StatusCode.Unknown, "The handler threw exception.")); + } + } + } + } +} diff --git a/src/csharp/generate_proto_csharp.sh b/src/csharp/generate_proto_csharp.sh index 8caaaabe0f5..1a1adbbae56 100755 --- a/src/csharp/generate_proto_csharp.sh +++ b/src/csharp/generate_proto_csharp.sh @@ -37,4 +37,4 @@ $PROTOC --plugin=$PLUGIN --csharp_out=$REFLECTION_DIR --grpc_out=$REFLECTION_DIR # don't match the package names. Setting -I to the correct value src/proto # breaks the code generation. $PROTOC --plugin=$PLUGIN --csharp_out=$TESTING_DIR --grpc_out=$TESTING_DIR \ - -I . src/proto/grpc/testing/{control,empty,messages,metrics,payloads,services,stats,test}.proto + -I . src/proto/grpc/testing/{control,echo_messages,empty,messages,metrics,payloads,services,stats,test}.proto diff --git a/src/csharp/tests.json b/src/csharp/tests.json index 707d140f62c..bc6adbbfe8b 100644 --- a/src/csharp/tests.json +++ b/src/csharp/tests.json @@ -42,6 +42,7 @@ "Grpc.HealthCheck.Tests.HealthServiceImplTest" ], "Grpc.IntegrationTesting": [ + "Grpc.IntegrationTesting.CustomErrorDetailsTest", "Grpc.IntegrationTesting.GeneratedClientTest", "Grpc.IntegrationTesting.GeneratedServiceBaseTest", "Grpc.IntegrationTesting.HistogramTest", From eb0219ba76c1f3beaa598457c85cf73b2d09342c Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Tue, 27 Jun 2017 17:04:04 +0200 Subject: [PATCH 59/69] regenerate C# protos --- src/csharp/Grpc.IntegrationTesting/Control.cs | 260 +++- .../Grpc.IntegrationTesting/EchoMessages.cs | 1354 +++++++++++++++++ .../Grpc.IntegrationTesting/Services.cs | 34 +- .../Grpc.IntegrationTesting/ServicesGrpc.cs | 266 +++- src/csharp/Grpc.IntegrationTesting/Stats.cs | 93 +- 5 files changed, 1922 insertions(+), 85 deletions(-) create mode 100644 src/csharp/Grpc.IntegrationTesting/EchoMessages.cs diff --git a/src/csharp/Grpc.IntegrationTesting/Control.cs b/src/csharp/Grpc.IntegrationTesting/Control.cs index 6c0176fb43f..d62b5a1c5b4 100644 --- a/src/csharp/Grpc.IntegrationTesting/Control.cs +++ b/src/csharp/Grpc.IntegrationTesting/Control.cs @@ -32,7 +32,7 @@ namespace Grpc.Testing { "U2VjdXJpdHlQYXJhbXMSEwoLdXNlX3Rlc3RfY2EYASABKAgSHAoUc2VydmVy", "X2hvc3Rfb3ZlcnJpZGUYAiABKAkiTQoKQ2hhbm5lbEFyZxIMCgRuYW1lGAEg", "ASgJEhMKCXN0cl92YWx1ZRgCIAEoCUgAEhMKCWludF92YWx1ZRgDIAEoBUgA", - "QgcKBXZhbHVlIqAECgxDbGllbnRDb25maWcSFgoOc2VydmVyX3RhcmdldHMY", + "QgcKBXZhbHVlItUECgxDbGllbnRDb25maWcSFgoOc2VydmVyX3RhcmdldHMY", "ASADKAkSLQoLY2xpZW50X3R5cGUYAiABKA4yGC5ncnBjLnRlc3RpbmcuQ2xp", "ZW50VHlwZRI1Cg9zZWN1cml0eV9wYXJhbXMYAyABKAsyHC5ncnBjLnRlc3Rp", "bmcuU2VjdXJpdHlQYXJhbXMSJAocb3V0c3RhbmRpbmdfcnBjc19wZXJfY2hh", @@ -44,52 +44,57 @@ namespace Grpc.Testing { "cxgMIAEoCzIdLmdycGMudGVzdGluZy5IaXN0b2dyYW1QYXJhbXMSEQoJY29y", "ZV9saXN0GA0gAygFEhIKCmNvcmVfbGltaXQYDiABKAUSGAoQb3RoZXJfY2xp", "ZW50X2FwaRgPIAEoCRIuCgxjaGFubmVsX2FyZ3MYECADKAsyGC5ncnBjLnRl", - "c3RpbmcuQ2hhbm5lbEFyZyI4CgxDbGllbnRTdGF0dXMSKAoFc3RhdHMYASAB", - "KAsyGS5ncnBjLnRlc3RpbmcuQ2xpZW50U3RhdHMiFQoETWFyaxINCgVyZXNl", - "dBgBIAEoCCJoCgpDbGllbnRBcmdzEisKBXNldHVwGAEgASgLMhouZ3JwYy50", - "ZXN0aW5nLkNsaWVudENvbmZpZ0gAEiIKBG1hcmsYAiABKAsyEi5ncnBjLnRl", - "c3RpbmcuTWFya0gAQgkKB2FyZ3R5cGUitAIKDFNlcnZlckNvbmZpZxItCgtz", - "ZXJ2ZXJfdHlwZRgBIAEoDjIYLmdycGMudGVzdGluZy5TZXJ2ZXJUeXBlEjUK", - "D3NlY3VyaXR5X3BhcmFtcxgCIAEoCzIcLmdycGMudGVzdGluZy5TZWN1cml0", - "eVBhcmFtcxIMCgRwb3J0GAQgASgFEhwKFGFzeW5jX3NlcnZlcl90aHJlYWRz", - "GAcgASgFEhIKCmNvcmVfbGltaXQYCCABKAUSMwoOcGF5bG9hZF9jb25maWcY", - "CSABKAsyGy5ncnBjLnRlc3RpbmcuUGF5bG9hZENvbmZpZxIRCgljb3JlX2xp", - "c3QYCiADKAUSGAoQb3RoZXJfc2VydmVyX2FwaRgLIAEoCRIcChNyZXNvdXJj", - "ZV9xdW90YV9zaXplGOkHIAEoBSJoCgpTZXJ2ZXJBcmdzEisKBXNldHVwGAEg", - "ASgLMhouZ3JwYy50ZXN0aW5nLlNlcnZlckNvbmZpZ0gAEiIKBG1hcmsYAiAB", - "KAsyEi5ncnBjLnRlc3RpbmcuTWFya0gAQgkKB2FyZ3R5cGUiVQoMU2VydmVy", - "U3RhdHVzEigKBXN0YXRzGAEgASgLMhkuZ3JwYy50ZXN0aW5nLlNlcnZlclN0", - "YXRzEgwKBHBvcnQYAiABKAUSDQoFY29yZXMYAyABKAUiDQoLQ29yZVJlcXVl", - "c3QiHQoMQ29yZVJlc3BvbnNlEg0KBWNvcmVzGAEgASgFIgYKBFZvaWQi/QEK", - "CFNjZW5hcmlvEgwKBG5hbWUYASABKAkSMQoNY2xpZW50X2NvbmZpZxgCIAEo", - "CzIaLmdycGMudGVzdGluZy5DbGllbnRDb25maWcSEwoLbnVtX2NsaWVudHMY", - "AyABKAUSMQoNc2VydmVyX2NvbmZpZxgEIAEoCzIaLmdycGMudGVzdGluZy5T", - "ZXJ2ZXJDb25maWcSEwoLbnVtX3NlcnZlcnMYBSABKAUSFgoOd2FybXVwX3Nl", - "Y29uZHMYBiABKAUSGQoRYmVuY2htYXJrX3NlY29uZHMYByABKAUSIAoYc3Bh", - "d25fbG9jYWxfd29ya2VyX2NvdW50GAggASgFIjYKCVNjZW5hcmlvcxIpCglz", - "Y2VuYXJpb3MYASADKAsyFi5ncnBjLnRlc3RpbmcuU2NlbmFyaW8i+AIKFVNj", - "ZW5hcmlvUmVzdWx0U3VtbWFyeRILCgNxcHMYASABKAESGwoTcXBzX3Blcl9z", - "ZXJ2ZXJfY29yZRgCIAEoARIaChJzZXJ2ZXJfc3lzdGVtX3RpbWUYAyABKAES", - "GAoQc2VydmVyX3VzZXJfdGltZRgEIAEoARIaChJjbGllbnRfc3lzdGVtX3Rp", - "bWUYBSABKAESGAoQY2xpZW50X3VzZXJfdGltZRgGIAEoARISCgpsYXRlbmN5", - "XzUwGAcgASgBEhIKCmxhdGVuY3lfOTAYCCABKAESEgoKbGF0ZW5jeV85NRgJ", - "IAEoARISCgpsYXRlbmN5Xzk5GAogASgBEhMKC2xhdGVuY3lfOTk5GAsgASgB", - "EhgKEHNlcnZlcl9jcHVfdXNhZ2UYDCABKAESJgoec3VjY2Vzc2Z1bF9yZXF1", - "ZXN0c19wZXJfc2Vjb25kGA0gASgBEiIKGmZhaWxlZF9yZXF1ZXN0c19wZXJf", - "c2Vjb25kGA4gASgBIoMDCg5TY2VuYXJpb1Jlc3VsdBIoCghzY2VuYXJpbxgB", - "IAEoCzIWLmdycGMudGVzdGluZy5TY2VuYXJpbxIuCglsYXRlbmNpZXMYAiAB", - "KAsyGy5ncnBjLnRlc3RpbmcuSGlzdG9ncmFtRGF0YRIvCgxjbGllbnRfc3Rh", - "dHMYAyADKAsyGS5ncnBjLnRlc3RpbmcuQ2xpZW50U3RhdHMSLwoMc2VydmVy", - "X3N0YXRzGAQgAygLMhkuZ3JwYy50ZXN0aW5nLlNlcnZlclN0YXRzEhQKDHNl", - "cnZlcl9jb3JlcxgFIAMoBRI0CgdzdW1tYXJ5GAYgASgLMiMuZ3JwYy50ZXN0", - "aW5nLlNjZW5hcmlvUmVzdWx0U3VtbWFyeRIWCg5jbGllbnRfc3VjY2VzcxgH", - "IAMoCBIWCg5zZXJ2ZXJfc3VjY2VzcxgIIAMoCBI5Cg9yZXF1ZXN0X3Jlc3Vs", - "dHMYCSADKAsyIC5ncnBjLnRlc3RpbmcuUmVxdWVzdFJlc3VsdENvdW50KkEK", - "CkNsaWVudFR5cGUSDwoLU1lOQ19DTElFTlQQABIQCgxBU1lOQ19DTElFTlQQ", - "ARIQCgxPVEhFUl9DTElFTlQQAipbCgpTZXJ2ZXJUeXBlEg8KC1NZTkNfU0VS", - "VkVSEAASEAoMQVNZTkNfU0VSVkVSEAESGAoUQVNZTkNfR0VORVJJQ19TRVJW", - "RVIQAhIQCgxPVEhFUl9TRVJWRVIQAyojCgdScGNUeXBlEgkKBVVOQVJZEAAS", - "DQoJU1RSRUFNSU5HEAFiBnByb3RvMw==")); + "c3RpbmcuQ2hhbm5lbEFyZxIWCg50aHJlYWRzX3Blcl9jcRgRIAEoBRIbChNt", + "ZXNzYWdlc19wZXJfc3RyZWFtGBIgASgFIjgKDENsaWVudFN0YXR1cxIoCgVz", + "dGF0cxgBIAEoCzIZLmdycGMudGVzdGluZy5DbGllbnRTdGF0cyIVCgRNYXJr", + "Eg0KBXJlc2V0GAEgASgIImgKCkNsaWVudEFyZ3MSKwoFc2V0dXAYASABKAsy", + "Gi5ncnBjLnRlc3RpbmcuQ2xpZW50Q29uZmlnSAASIgoEbWFyaxgCIAEoCzIS", + "LmdycGMudGVzdGluZy5NYXJrSABCCQoHYXJndHlwZSLMAgoMU2VydmVyQ29u", + "ZmlnEi0KC3NlcnZlcl90eXBlGAEgASgOMhguZ3JwYy50ZXN0aW5nLlNlcnZl", + "clR5cGUSNQoPc2VjdXJpdHlfcGFyYW1zGAIgASgLMhwuZ3JwYy50ZXN0aW5n", + "LlNlY3VyaXR5UGFyYW1zEgwKBHBvcnQYBCABKAUSHAoUYXN5bmNfc2VydmVy", + "X3RocmVhZHMYByABKAUSEgoKY29yZV9saW1pdBgIIAEoBRIzCg5wYXlsb2Fk", + "X2NvbmZpZxgJIAEoCzIbLmdycGMudGVzdGluZy5QYXlsb2FkQ29uZmlnEhEK", + "CWNvcmVfbGlzdBgKIAMoBRIYChBvdGhlcl9zZXJ2ZXJfYXBpGAsgASgJEhYK", + "DnRocmVhZHNfcGVyX2NxGAwgASgFEhwKE3Jlc291cmNlX3F1b3RhX3NpemUY", + "6QcgASgFImgKClNlcnZlckFyZ3MSKwoFc2V0dXAYASABKAsyGi5ncnBjLnRl", + "c3RpbmcuU2VydmVyQ29uZmlnSAASIgoEbWFyaxgCIAEoCzISLmdycGMudGVz", + "dGluZy5NYXJrSABCCQoHYXJndHlwZSJVCgxTZXJ2ZXJTdGF0dXMSKAoFc3Rh", + "dHMYASABKAsyGS5ncnBjLnRlc3RpbmcuU2VydmVyU3RhdHMSDAoEcG9ydBgC", + "IAEoBRINCgVjb3JlcxgDIAEoBSINCgtDb3JlUmVxdWVzdCIdCgxDb3JlUmVz", + "cG9uc2USDQoFY29yZXMYASABKAUiBgoEVm9pZCL9AQoIU2NlbmFyaW8SDAoE", + "bmFtZRgBIAEoCRIxCg1jbGllbnRfY29uZmlnGAIgASgLMhouZ3JwYy50ZXN0", + "aW5nLkNsaWVudENvbmZpZxITCgtudW1fY2xpZW50cxgDIAEoBRIxCg1zZXJ2", + "ZXJfY29uZmlnGAQgASgLMhouZ3JwYy50ZXN0aW5nLlNlcnZlckNvbmZpZxIT", + "CgtudW1fc2VydmVycxgFIAEoBRIWCg53YXJtdXBfc2Vjb25kcxgGIAEoBRIZ", + "ChFiZW5jaG1hcmtfc2Vjb25kcxgHIAEoBRIgChhzcGF3bl9sb2NhbF93b3Jr", + "ZXJfY291bnQYCCABKAUiNgoJU2NlbmFyaW9zEikKCXNjZW5hcmlvcxgBIAMo", + "CzIWLmdycGMudGVzdGluZy5TY2VuYXJpbyK8AwoVU2NlbmFyaW9SZXN1bHRT", + "dW1tYXJ5EgsKA3FwcxgBIAEoARIbChNxcHNfcGVyX3NlcnZlcl9jb3JlGAIg", + "ASgBEhoKEnNlcnZlcl9zeXN0ZW1fdGltZRgDIAEoARIYChBzZXJ2ZXJfdXNl", + "cl90aW1lGAQgASgBEhoKEmNsaWVudF9zeXN0ZW1fdGltZRgFIAEoARIYChBj", + "bGllbnRfdXNlcl90aW1lGAYgASgBEhIKCmxhdGVuY3lfNTAYByABKAESEgoK", + "bGF0ZW5jeV85MBgIIAEoARISCgpsYXRlbmN5Xzk1GAkgASgBEhIKCmxhdGVu", + "Y3lfOTkYCiABKAESEwoLbGF0ZW5jeV85OTkYCyABKAESGAoQc2VydmVyX2Nw", + "dV91c2FnZRgMIAEoARImCh5zdWNjZXNzZnVsX3JlcXVlc3RzX3Blcl9zZWNv", + "bmQYDSABKAESIgoaZmFpbGVkX3JlcXVlc3RzX3Blcl9zZWNvbmQYDiABKAES", + "IAoYY2xpZW50X3BvbGxzX3Blcl9yZXF1ZXN0GA8gASgBEiAKGHNlcnZlcl9w", + "b2xsc19wZXJfcmVxdWVzdBgQIAEoASKDAwoOU2NlbmFyaW9SZXN1bHQSKAoI", + "c2NlbmFyaW8YASABKAsyFi5ncnBjLnRlc3RpbmcuU2NlbmFyaW8SLgoJbGF0", + "ZW5jaWVzGAIgASgLMhsuZ3JwYy50ZXN0aW5nLkhpc3RvZ3JhbURhdGESLwoM", + "Y2xpZW50X3N0YXRzGAMgAygLMhkuZ3JwYy50ZXN0aW5nLkNsaWVudFN0YXRz", + "Ei8KDHNlcnZlcl9zdGF0cxgEIAMoCzIZLmdycGMudGVzdGluZy5TZXJ2ZXJT", + "dGF0cxIUCgxzZXJ2ZXJfY29yZXMYBSADKAUSNAoHc3VtbWFyeRgGIAEoCzIj", + "LmdycGMudGVzdGluZy5TY2VuYXJpb1Jlc3VsdFN1bW1hcnkSFgoOY2xpZW50", + "X3N1Y2Nlc3MYByADKAgSFgoOc2VydmVyX3N1Y2Nlc3MYCCADKAgSOQoPcmVx", + "dWVzdF9yZXN1bHRzGAkgAygLMiAuZ3JwYy50ZXN0aW5nLlJlcXVlc3RSZXN1", + "bHRDb3VudCpBCgpDbGllbnRUeXBlEg8KC1NZTkNfQ0xJRU5UEAASEAoMQVNZ", + "TkNfQ0xJRU5UEAESEAoMT1RIRVJfQ0xJRU5UEAIqWwoKU2VydmVyVHlwZRIP", + "CgtTWU5DX1NFUlZFUhAAEhAKDEFTWU5DX1NFUlZFUhABEhgKFEFTWU5DX0dF", + "TkVSSUNfU0VSVkVSEAISEAoMT1RIRVJfU0VSVkVSEAMqcgoHUnBjVHlwZRIJ", + "CgVVTkFSWRAAEg0KCVNUUkVBTUlORxABEhkKFVNUUkVBTUlOR19GUk9NX0NM", + "SUVOVBACEhkKFVNUUkVBTUlOR19GUk9NX1NFUlZFUhADEhcKE1NUUkVBTUlO", + "R19CT1RIX1dBWVMQBGIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { global::Grpc.Testing.PayloadsReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Grpc.Testing.ClientType), typeof(global::Grpc.Testing.ServerType), typeof(global::Grpc.Testing.RpcType), }, new pbr::GeneratedClrTypeInfo[] { @@ -98,11 +103,11 @@ namespace Grpc.Testing { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.LoadParams), global::Grpc.Testing.LoadParams.Parser, new[]{ "ClosedLoop", "Poisson" }, new[]{ "Load" }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.SecurityParams), global::Grpc.Testing.SecurityParams.Parser, new[]{ "UseTestCa", "ServerHostOverride" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ChannelArg), global::Grpc.Testing.ChannelArg.Parser, new[]{ "Name", "StrValue", "IntValue" }, new[]{ "Value" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientConfig), global::Grpc.Testing.ClientConfig.Parser, new[]{ "ServerTargets", "ClientType", "SecurityParams", "OutstandingRpcsPerChannel", "ClientChannels", "AsyncClientThreads", "RpcType", "LoadParams", "PayloadConfig", "HistogramParams", "CoreList", "CoreLimit", "OtherClientApi", "ChannelArgs" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientConfig), global::Grpc.Testing.ClientConfig.Parser, new[]{ "ServerTargets", "ClientType", "SecurityParams", "OutstandingRpcsPerChannel", "ClientChannels", "AsyncClientThreads", "RpcType", "LoadParams", "PayloadConfig", "HistogramParams", "CoreList", "CoreLimit", "OtherClientApi", "ChannelArgs", "ThreadsPerCq", "MessagesPerStream" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStatus), global::Grpc.Testing.ClientStatus.Parser, new[]{ "Stats" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Mark), global::Grpc.Testing.Mark.Parser, new[]{ "Reset" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientArgs), global::Grpc.Testing.ClientArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig", "CoreList", "OtherServerApi", "ResourceQuotaSize" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerConfig), global::Grpc.Testing.ServerConfig.Parser, new[]{ "ServerType", "SecurityParams", "Port", "AsyncServerThreads", "CoreLimit", "PayloadConfig", "CoreList", "OtherServerApi", "ThreadsPerCq", "ResourceQuotaSize" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerArgs), global::Grpc.Testing.ServerArgs.Parser, new[]{ "Setup", "Mark" }, new[]{ "Argtype" }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStatus), global::Grpc.Testing.ServerStatus.Parser, new[]{ "Stats", "Port", "Cores" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.CoreRequest), global::Grpc.Testing.CoreRequest.Parser, null, null, null, null), @@ -110,7 +115,7 @@ namespace Grpc.Testing { new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Void), global::Grpc.Testing.Void.Parser, null, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Scenario), global::Grpc.Testing.Scenario.Parser, new[]{ "Name", "ClientConfig", "NumClients", "ServerConfig", "NumServers", "WarmupSeconds", "BenchmarkSeconds", "SpawnLocalWorkerCount" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.Scenarios), global::Grpc.Testing.Scenarios.Parser, new[]{ "Scenarios_" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ScenarioResultSummary), global::Grpc.Testing.ScenarioResultSummary.Parser, new[]{ "Qps", "QpsPerServerCore", "ServerSystemTime", "ServerUserTime", "ClientSystemTime", "ClientUserTime", "Latency50", "Latency90", "Latency95", "Latency99", "Latency999", "ServerCpuUsage", "SuccessfulRequestsPerSecond", "FailedRequestsPerSecond" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ScenarioResultSummary), global::Grpc.Testing.ScenarioResultSummary.Parser, new[]{ "Qps", "QpsPerServerCore", "ServerSystemTime", "ServerUserTime", "ClientSystemTime", "ClientUserTime", "Latency50", "Latency90", "Latency95", "Latency99", "Latency999", "ServerCpuUsage", "SuccessfulRequestsPerSecond", "FailedRequestsPerSecond", "ClientPollsPerRequest", "ServerPollsPerRequest" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ScenarioResult), global::Grpc.Testing.ScenarioResult.Parser, new[]{ "Scenario", "Latencies", "ClientStats", "ServerStats", "ServerCores", "Summary", "ClientSuccess", "ServerSuccess", "RequestResults" }, null, null, null) })); } @@ -144,6 +149,9 @@ namespace Grpc.Testing { public enum RpcType { [pbr::OriginalName("UNARY")] Unary = 0, [pbr::OriginalName("STREAMING")] Streaming = 1, + [pbr::OriginalName("STREAMING_FROM_CLIENT")] StreamingFromClient = 2, + [pbr::OriginalName("STREAMING_FROM_SERVER")] StreamingFromServer = 3, + [pbr::OriginalName("STREAMING_BOTH_WAYS")] StreamingBothWays = 4, } #endregion @@ -942,6 +950,8 @@ namespace Grpc.Testing { coreLimit_ = other.coreLimit_; otherClientApi_ = other.otherClientApi_; channelArgs_ = other.channelArgs_.Clone(); + threadsPerCq_ = other.threadsPerCq_; + messagesPerStream_ = other.messagesPerStream_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1123,6 +1133,34 @@ namespace Grpc.Testing { get { return channelArgs_; } } + /// Field number for the "threads_per_cq" field. + public const int ThreadsPerCqFieldNumber = 17; + private int threadsPerCq_; + /// + /// Number of threads that share each completion queue + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ThreadsPerCq { + get { return threadsPerCq_; } + set { + threadsPerCq_ = value; + } + } + + /// Field number for the "messages_per_stream" field. + public const int MessagesPerStreamFieldNumber = 18; + private int messagesPerStream_; + /// + /// Number of messages on a stream before it gets finished/restarted + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int MessagesPerStream { + get { return messagesPerStream_; } + set { + messagesPerStream_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ClientConfig); @@ -1150,6 +1188,8 @@ namespace Grpc.Testing { if (CoreLimit != other.CoreLimit) return false; if (OtherClientApi != other.OtherClientApi) return false; if(!channelArgs_.Equals(other.channelArgs_)) return false; + if (ThreadsPerCq != other.ThreadsPerCq) return false; + if (MessagesPerStream != other.MessagesPerStream) return false; return true; } @@ -1170,6 +1210,8 @@ namespace Grpc.Testing { if (CoreLimit != 0) hash ^= CoreLimit.GetHashCode(); if (OtherClientApi.Length != 0) hash ^= OtherClientApi.GetHashCode(); hash ^= channelArgs_.GetHashCode(); + if (ThreadsPerCq != 0) hash ^= ThreadsPerCq.GetHashCode(); + if (MessagesPerStream != 0) hash ^= MessagesPerStream.GetHashCode(); return hash; } @@ -1227,6 +1269,14 @@ namespace Grpc.Testing { output.WriteString(OtherClientApi); } channelArgs_.WriteTo(output, _repeated_channelArgs_codec); + if (ThreadsPerCq != 0) { + output.WriteRawTag(136, 1); + output.WriteInt32(ThreadsPerCq); + } + if (MessagesPerStream != 0) { + output.WriteRawTag(144, 1); + output.WriteInt32(MessagesPerStream); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1268,6 +1318,12 @@ namespace Grpc.Testing { size += 1 + pb::CodedOutputStream.ComputeStringSize(OtherClientApi); } size += channelArgs_.CalculateSize(_repeated_channelArgs_codec); + if (ThreadsPerCq != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(ThreadsPerCq); + } + if (MessagesPerStream != 0) { + size += 2 + pb::CodedOutputStream.ComputeInt32Size(MessagesPerStream); + } return size; } @@ -1324,6 +1380,12 @@ namespace Grpc.Testing { OtherClientApi = other.OtherClientApi; } channelArgs_.Add(other.channelArgs_); + if (other.ThreadsPerCq != 0) { + ThreadsPerCq = other.ThreadsPerCq; + } + if (other.MessagesPerStream != 0) { + MessagesPerStream = other.MessagesPerStream; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1403,6 +1465,14 @@ namespace Grpc.Testing { channelArgs_.AddEntriesFrom(input, _repeated_channelArgs_codec); break; } + case 136: { + ThreadsPerCq = input.ReadInt32(); + break; + } + case 144: { + MessagesPerStream = input.ReadInt32(); + break; + } } } } @@ -1873,6 +1943,7 @@ namespace Grpc.Testing { PayloadConfig = other.payloadConfig_ != null ? other.PayloadConfig.Clone() : null; coreList_ = other.coreList_.Clone(); otherServerApi_ = other.otherServerApi_; + threadsPerCq_ = other.threadsPerCq_; resourceQuotaSize_ = other.resourceQuotaSize_; } @@ -1989,6 +2060,20 @@ namespace Grpc.Testing { } } + /// Field number for the "threads_per_cq" field. + public const int ThreadsPerCqFieldNumber = 12; + private int threadsPerCq_; + /// + /// Number of threads that share each completion queue + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ThreadsPerCq { + get { return threadsPerCq_; } + set { + threadsPerCq_ = value; + } + } + /// Field number for the "resource_quota_size" field. public const int ResourceQuotaSizeFieldNumber = 1001; private int resourceQuotaSize_; @@ -2024,6 +2109,7 @@ namespace Grpc.Testing { if (!object.Equals(PayloadConfig, other.PayloadConfig)) return false; if(!coreList_.Equals(other.coreList_)) return false; if (OtherServerApi != other.OtherServerApi) return false; + if (ThreadsPerCq != other.ThreadsPerCq) return false; if (ResourceQuotaSize != other.ResourceQuotaSize) return false; return true; } @@ -2039,6 +2125,7 @@ namespace Grpc.Testing { if (payloadConfig_ != null) hash ^= PayloadConfig.GetHashCode(); hash ^= coreList_.GetHashCode(); if (OtherServerApi.Length != 0) hash ^= OtherServerApi.GetHashCode(); + if (ThreadsPerCq != 0) hash ^= ThreadsPerCq.GetHashCode(); if (ResourceQuotaSize != 0) hash ^= ResourceQuotaSize.GetHashCode(); return hash; } @@ -2079,6 +2166,10 @@ namespace Grpc.Testing { output.WriteRawTag(90); output.WriteString(OtherServerApi); } + if (ThreadsPerCq != 0) { + output.WriteRawTag(96); + output.WriteInt32(ThreadsPerCq); + } if (ResourceQuotaSize != 0) { output.WriteRawTag(200, 62); output.WriteInt32(ResourceQuotaSize); @@ -2110,6 +2201,9 @@ namespace Grpc.Testing { if (OtherServerApi.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(OtherServerApi); } + if (ThreadsPerCq != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ThreadsPerCq); + } if (ResourceQuotaSize != 0) { size += 2 + pb::CodedOutputStream.ComputeInt32Size(ResourceQuotaSize); } @@ -2149,6 +2243,9 @@ namespace Grpc.Testing { if (other.OtherServerApi.Length != 0) { OtherServerApi = other.OtherServerApi; } + if (other.ThreadsPerCq != 0) { + ThreadsPerCq = other.ThreadsPerCq; + } if (other.ResourceQuotaSize != 0) { ResourceQuotaSize = other.ResourceQuotaSize; } @@ -2201,6 +2298,10 @@ namespace Grpc.Testing { OtherServerApi = input.ReadString(); break; } + case 96: { + ThreadsPerCq = input.ReadInt32(); + break; + } case 8008: { ResourceQuotaSize = input.ReadInt32(); break; @@ -3386,6 +3487,8 @@ namespace Grpc.Testing { serverCpuUsage_ = other.serverCpuUsage_; successfulRequestsPerSecond_ = other.successfulRequestsPerSecond_; failedRequestsPerSecond_ = other.failedRequestsPerSecond_; + clientPollsPerRequest_ = other.clientPollsPerRequest_; + serverPollsPerRequest_ = other.serverPollsPerRequest_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3574,6 +3677,31 @@ namespace Grpc.Testing { } } + /// Field number for the "client_polls_per_request" field. + public const int ClientPollsPerRequestFieldNumber = 15; + private double clientPollsPerRequest_; + /// + /// Number of polls called inside completion queue per request + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double ClientPollsPerRequest { + get { return clientPollsPerRequest_; } + set { + clientPollsPerRequest_ = value; + } + } + + /// Field number for the "server_polls_per_request" field. + public const int ServerPollsPerRequestFieldNumber = 16; + private double serverPollsPerRequest_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public double ServerPollsPerRequest { + get { return serverPollsPerRequest_; } + set { + serverPollsPerRequest_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ScenarioResultSummary); @@ -3601,6 +3729,8 @@ namespace Grpc.Testing { if (ServerCpuUsage != other.ServerCpuUsage) return false; if (SuccessfulRequestsPerSecond != other.SuccessfulRequestsPerSecond) return false; if (FailedRequestsPerSecond != other.FailedRequestsPerSecond) return false; + if (ClientPollsPerRequest != other.ClientPollsPerRequest) return false; + if (ServerPollsPerRequest != other.ServerPollsPerRequest) return false; return true; } @@ -3621,6 +3751,8 @@ namespace Grpc.Testing { if (ServerCpuUsage != 0D) hash ^= ServerCpuUsage.GetHashCode(); if (SuccessfulRequestsPerSecond != 0D) hash ^= SuccessfulRequestsPerSecond.GetHashCode(); if (FailedRequestsPerSecond != 0D) hash ^= FailedRequestsPerSecond.GetHashCode(); + if (ClientPollsPerRequest != 0D) hash ^= ClientPollsPerRequest.GetHashCode(); + if (ServerPollsPerRequest != 0D) hash ^= ServerPollsPerRequest.GetHashCode(); return hash; } @@ -3687,6 +3819,14 @@ namespace Grpc.Testing { output.WriteRawTag(113); output.WriteDouble(FailedRequestsPerSecond); } + if (ClientPollsPerRequest != 0D) { + output.WriteRawTag(121); + output.WriteDouble(ClientPollsPerRequest); + } + if (ServerPollsPerRequest != 0D) { + output.WriteRawTag(129, 1); + output.WriteDouble(ServerPollsPerRequest); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3734,6 +3874,12 @@ namespace Grpc.Testing { if (FailedRequestsPerSecond != 0D) { size += 1 + 8; } + if (ClientPollsPerRequest != 0D) { + size += 1 + 8; + } + if (ServerPollsPerRequest != 0D) { + size += 2 + 8; + } return size; } @@ -3784,6 +3930,12 @@ namespace Grpc.Testing { if (other.FailedRequestsPerSecond != 0D) { FailedRequestsPerSecond = other.FailedRequestsPerSecond; } + if (other.ClientPollsPerRequest != 0D) { + ClientPollsPerRequest = other.ClientPollsPerRequest; + } + if (other.ServerPollsPerRequest != 0D) { + ServerPollsPerRequest = other.ServerPollsPerRequest; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -3850,6 +4002,14 @@ namespace Grpc.Testing { FailedRequestsPerSecond = input.ReadDouble(); break; } + case 121: { + ClientPollsPerRequest = input.ReadDouble(); + break; + } + case 129: { + ServerPollsPerRequest = input.ReadDouble(); + break; + } } } } diff --git a/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs new file mode 100644 index 00000000000..b2fe73acdf4 --- /dev/null +++ b/src/csharp/Grpc.IntegrationTesting/EchoMessages.cs @@ -0,0 +1,1354 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: src/proto/grpc/testing/echo_messages.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Grpc.Testing { + + /// Holder for reflection information generated from src/proto/grpc/testing/echo_messages.proto + public static partial class EchoMessagesReflection { + + #region Descriptor + /// File descriptor for src/proto/grpc/testing/echo_messages.proto + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static EchoMessagesReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "CipzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL2VjaG9fbWVzc2FnZXMucHJvdG8S", + "DGdycGMudGVzdGluZyIyCglEZWJ1Z0luZm8SFQoNc3RhY2tfZW50cmllcxgB", + "IAMoCRIOCgZkZXRhaWwYAiABKAkiUAoLRXJyb3JTdGF0dXMSDAoEY29kZRgB", + "IAEoBRIVCg1lcnJvcl9tZXNzYWdlGAIgASgJEhwKFGJpbmFyeV9lcnJvcl9k", + "ZXRhaWxzGAMgASgJIskDCg1SZXF1ZXN0UGFyYW1zEhUKDWVjaG9fZGVhZGxp", + "bmUYASABKAgSHgoWY2xpZW50X2NhbmNlbF9hZnRlcl91cxgCIAEoBRIeChZz", + "ZXJ2ZXJfY2FuY2VsX2FmdGVyX3VzGAMgASgFEhUKDWVjaG9fbWV0YWRhdGEY", + "BCABKAgSGgoSY2hlY2tfYXV0aF9jb250ZXh0GAUgASgIEh8KF3Jlc3BvbnNl", + "X21lc3NhZ2VfbGVuZ3RoGAYgASgFEhEKCWVjaG9fcGVlchgHIAEoCBIgChhl", + "eHBlY3RlZF9jbGllbnRfaWRlbnRpdHkYCCABKAkSHAoUc2tpcF9jYW5jZWxs", + "ZWRfY2hlY2sYCSABKAgSKAogZXhwZWN0ZWRfdHJhbnNwb3J0X3NlY3VyaXR5", + "X3R5cGUYCiABKAkSKwoKZGVidWdfaW5mbxgLIAEoCzIXLmdycGMudGVzdGlu", + "Zy5EZWJ1Z0luZm8SEgoKc2VydmVyX2RpZRgMIAEoCBIcChRiaW5hcnlfZXJy", + "b3JfZGV0YWlscxgNIAEoCRIxCg5leHBlY3RlZF9lcnJvchgOIAEoCzIZLmdy", + "cGMudGVzdGluZy5FcnJvclN0YXR1cyJKCgtFY2hvUmVxdWVzdBIPCgdtZXNz", + "YWdlGAEgASgJEioKBXBhcmFtGAIgASgLMhsuZ3JwYy50ZXN0aW5nLlJlcXVl", + "c3RQYXJhbXMiRgoOUmVzcG9uc2VQYXJhbXMSGAoQcmVxdWVzdF9kZWFkbGlu", + "ZRgBIAEoAxIMCgRob3N0GAIgASgJEgwKBHBlZXIYAyABKAkiTAoMRWNob1Jl", + "c3BvbnNlEg8KB21lc3NhZ2UYASABKAkSKwoFcGFyYW0YAiABKAsyHC5ncnBj", + "LnRlc3RpbmcuUmVzcG9uc2VQYXJhbXNiBnByb3RvMw==")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.DebugInfo), global::Grpc.Testing.DebugInfo.Parser, new[]{ "StackEntries", "Detail" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ErrorStatus), global::Grpc.Testing.ErrorStatus.Parser, new[]{ "Code", "ErrorMessage", "BinaryErrorDetails" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestParams), global::Grpc.Testing.RequestParams.Parser, new[]{ "EchoDeadline", "ClientCancelAfterUs", "ServerCancelAfterUs", "EchoMetadata", "CheckAuthContext", "ResponseMessageLength", "EchoPeer", "ExpectedClientIdentity", "SkipCancelledCheck", "ExpectedTransportSecurityType", "DebugInfo", "ServerDie", "BinaryErrorDetails", "ExpectedError" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoRequest), global::Grpc.Testing.EchoRequest.Parser, new[]{ "Message", "Param" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ResponseParams), global::Grpc.Testing.ResponseParams.Parser, new[]{ "RequestDeadline", "Host", "Peer" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.EchoResponse), global::Grpc.Testing.EchoResponse.Parser, new[]{ "Message", "Param" }, null, null, null) + })); + } + #endregion + + } + #region Messages + /// + /// Message to be echoed back serialized in trailer. + /// + public sealed partial class DebugInfo : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new DebugInfo()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.EchoMessagesReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugInfo() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugInfo(DebugInfo other) : this() { + stackEntries_ = other.stackEntries_.Clone(); + detail_ = other.detail_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public DebugInfo Clone() { + return new DebugInfo(this); + } + + /// Field number for the "stack_entries" field. + public const int StackEntriesFieldNumber = 1; + private static readonly pb::FieldCodec _repeated_stackEntries_codec + = pb::FieldCodec.ForString(10); + private readonly pbc::RepeatedField stackEntries_ = new pbc::RepeatedField(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public pbc::RepeatedField StackEntries { + get { return stackEntries_; } + } + + /// Field number for the "detail" field. + public const int DetailFieldNumber = 2; + private string detail_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Detail { + get { return detail_; } + set { + detail_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as DebugInfo); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(DebugInfo other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if(!stackEntries_.Equals(other.stackEntries_)) return false; + if (Detail != other.Detail) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + hash ^= stackEntries_.GetHashCode(); + if (Detail.Length != 0) hash ^= Detail.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + stackEntries_.WriteTo(output, _repeated_stackEntries_codec); + if (Detail.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Detail); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + size += stackEntries_.CalculateSize(_repeated_stackEntries_codec); + if (Detail.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Detail); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(DebugInfo other) { + if (other == null) { + return; + } + stackEntries_.Add(other.stackEntries_); + if (other.Detail.Length != 0) { + Detail = other.Detail; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + stackEntries_.AddEntriesFrom(input, _repeated_stackEntries_codec); + break; + } + case 18: { + Detail = input.ReadString(); + break; + } + } + } + } + + } + + /// + /// Error status client expects to see. + /// + public sealed partial class ErrorStatus : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ErrorStatus()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.EchoMessagesReflection.Descriptor.MessageTypes[1]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorStatus() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorStatus(ErrorStatus other) : this() { + code_ = other.code_; + errorMessage_ = other.errorMessage_; + binaryErrorDetails_ = other.binaryErrorDetails_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ErrorStatus Clone() { + return new ErrorStatus(this); + } + + /// Field number for the "code" field. + public const int CodeFieldNumber = 1; + private int code_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int Code { + get { return code_; } + set { + code_ = value; + } + } + + /// Field number for the "error_message" field. + public const int ErrorMessageFieldNumber = 2; + private string errorMessage_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ErrorMessage { + get { return errorMessage_; } + set { + errorMessage_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "binary_error_details" field. + public const int BinaryErrorDetailsFieldNumber = 3; + private string binaryErrorDetails_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string BinaryErrorDetails { + get { return binaryErrorDetails_; } + set { + binaryErrorDetails_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ErrorStatus); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ErrorStatus other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Code != other.Code) return false; + if (ErrorMessage != other.ErrorMessage) return false; + if (BinaryErrorDetails != other.BinaryErrorDetails) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Code != 0) hash ^= Code.GetHashCode(); + if (ErrorMessage.Length != 0) hash ^= ErrorMessage.GetHashCode(); + if (BinaryErrorDetails.Length != 0) hash ^= BinaryErrorDetails.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Code != 0) { + output.WriteRawTag(8); + output.WriteInt32(Code); + } + if (ErrorMessage.Length != 0) { + output.WriteRawTag(18); + output.WriteString(ErrorMessage); + } + if (BinaryErrorDetails.Length != 0) { + output.WriteRawTag(26); + output.WriteString(BinaryErrorDetails); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Code != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(Code); + } + if (ErrorMessage.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ErrorMessage); + } + if (BinaryErrorDetails.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(BinaryErrorDetails); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ErrorStatus other) { + if (other == null) { + return; + } + if (other.Code != 0) { + Code = other.Code; + } + if (other.ErrorMessage.Length != 0) { + ErrorMessage = other.ErrorMessage; + } + if (other.BinaryErrorDetails.Length != 0) { + BinaryErrorDetails = other.BinaryErrorDetails; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Code = input.ReadInt32(); + break; + } + case 18: { + ErrorMessage = input.ReadString(); + break; + } + case 26: { + BinaryErrorDetails = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class RequestParams : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RequestParams()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.EchoMessagesReflection.Descriptor.MessageTypes[2]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RequestParams() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RequestParams(RequestParams other) : this() { + echoDeadline_ = other.echoDeadline_; + clientCancelAfterUs_ = other.clientCancelAfterUs_; + serverCancelAfterUs_ = other.serverCancelAfterUs_; + echoMetadata_ = other.echoMetadata_; + checkAuthContext_ = other.checkAuthContext_; + responseMessageLength_ = other.responseMessageLength_; + echoPeer_ = other.echoPeer_; + expectedClientIdentity_ = other.expectedClientIdentity_; + skipCancelledCheck_ = other.skipCancelledCheck_; + expectedTransportSecurityType_ = other.expectedTransportSecurityType_; + DebugInfo = other.debugInfo_ != null ? other.DebugInfo.Clone() : null; + serverDie_ = other.serverDie_; + binaryErrorDetails_ = other.binaryErrorDetails_; + ExpectedError = other.expectedError_ != null ? other.ExpectedError.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public RequestParams Clone() { + return new RequestParams(this); + } + + /// Field number for the "echo_deadline" field. + public const int EchoDeadlineFieldNumber = 1; + private bool echoDeadline_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool EchoDeadline { + get { return echoDeadline_; } + set { + echoDeadline_ = value; + } + } + + /// Field number for the "client_cancel_after_us" field. + public const int ClientCancelAfterUsFieldNumber = 2; + private int clientCancelAfterUs_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ClientCancelAfterUs { + get { return clientCancelAfterUs_; } + set { + clientCancelAfterUs_ = value; + } + } + + /// Field number for the "server_cancel_after_us" field. + public const int ServerCancelAfterUsFieldNumber = 3; + private int serverCancelAfterUs_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ServerCancelAfterUs { + get { return serverCancelAfterUs_; } + set { + serverCancelAfterUs_ = value; + } + } + + /// Field number for the "echo_metadata" field. + public const int EchoMetadataFieldNumber = 4; + private bool echoMetadata_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool EchoMetadata { + get { return echoMetadata_; } + set { + echoMetadata_ = value; + } + } + + /// Field number for the "check_auth_context" field. + public const int CheckAuthContextFieldNumber = 5; + private bool checkAuthContext_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool CheckAuthContext { + get { return checkAuthContext_; } + set { + checkAuthContext_ = value; + } + } + + /// Field number for the "response_message_length" field. + public const int ResponseMessageLengthFieldNumber = 6; + private int responseMessageLength_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int ResponseMessageLength { + get { return responseMessageLength_; } + set { + responseMessageLength_ = value; + } + } + + /// Field number for the "echo_peer" field. + public const int EchoPeerFieldNumber = 7; + private bool echoPeer_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool EchoPeer { + get { return echoPeer_; } + set { + echoPeer_ = value; + } + } + + /// Field number for the "expected_client_identity" field. + public const int ExpectedClientIdentityFieldNumber = 8; + private string expectedClientIdentity_ = ""; + /// + /// will force check_auth_context. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ExpectedClientIdentity { + get { return expectedClientIdentity_; } + set { + expectedClientIdentity_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "skip_cancelled_check" field. + public const int SkipCancelledCheckFieldNumber = 9; + private bool skipCancelledCheck_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool SkipCancelledCheck { + get { return skipCancelledCheck_; } + set { + skipCancelledCheck_ = value; + } + } + + /// Field number for the "expected_transport_security_type" field. + public const int ExpectedTransportSecurityTypeFieldNumber = 10; + private string expectedTransportSecurityType_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string ExpectedTransportSecurityType { + get { return expectedTransportSecurityType_; } + set { + expectedTransportSecurityType_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "debug_info" field. + public const int DebugInfoFieldNumber = 11; + private global::Grpc.Testing.DebugInfo debugInfo_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Testing.DebugInfo DebugInfo { + get { return debugInfo_; } + set { + debugInfo_ = value; + } + } + + /// Field number for the "server_die" field. + public const int ServerDieFieldNumber = 12; + private bool serverDie_; + /// + /// Server should not see a request with this set. + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool ServerDie { + get { return serverDie_; } + set { + serverDie_ = value; + } + } + + /// Field number for the "binary_error_details" field. + public const int BinaryErrorDetailsFieldNumber = 13; + private string binaryErrorDetails_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string BinaryErrorDetails { + get { return binaryErrorDetails_; } + set { + binaryErrorDetails_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "expected_error" field. + public const int ExpectedErrorFieldNumber = 14; + private global::Grpc.Testing.ErrorStatus expectedError_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Testing.ErrorStatus ExpectedError { + get { return expectedError_; } + set { + expectedError_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as RequestParams); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(RequestParams other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (EchoDeadline != other.EchoDeadline) return false; + if (ClientCancelAfterUs != other.ClientCancelAfterUs) return false; + if (ServerCancelAfterUs != other.ServerCancelAfterUs) return false; + if (EchoMetadata != other.EchoMetadata) return false; + if (CheckAuthContext != other.CheckAuthContext) return false; + if (ResponseMessageLength != other.ResponseMessageLength) return false; + if (EchoPeer != other.EchoPeer) return false; + if (ExpectedClientIdentity != other.ExpectedClientIdentity) return false; + if (SkipCancelledCheck != other.SkipCancelledCheck) return false; + if (ExpectedTransportSecurityType != other.ExpectedTransportSecurityType) return false; + if (!object.Equals(DebugInfo, other.DebugInfo)) return false; + if (ServerDie != other.ServerDie) return false; + if (BinaryErrorDetails != other.BinaryErrorDetails) return false; + if (!object.Equals(ExpectedError, other.ExpectedError)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (EchoDeadline != false) hash ^= EchoDeadline.GetHashCode(); + if (ClientCancelAfterUs != 0) hash ^= ClientCancelAfterUs.GetHashCode(); + if (ServerCancelAfterUs != 0) hash ^= ServerCancelAfterUs.GetHashCode(); + if (EchoMetadata != false) hash ^= EchoMetadata.GetHashCode(); + if (CheckAuthContext != false) hash ^= CheckAuthContext.GetHashCode(); + if (ResponseMessageLength != 0) hash ^= ResponseMessageLength.GetHashCode(); + if (EchoPeer != false) hash ^= EchoPeer.GetHashCode(); + if (ExpectedClientIdentity.Length != 0) hash ^= ExpectedClientIdentity.GetHashCode(); + if (SkipCancelledCheck != false) hash ^= SkipCancelledCheck.GetHashCode(); + if (ExpectedTransportSecurityType.Length != 0) hash ^= ExpectedTransportSecurityType.GetHashCode(); + if (debugInfo_ != null) hash ^= DebugInfo.GetHashCode(); + if (ServerDie != false) hash ^= ServerDie.GetHashCode(); + if (BinaryErrorDetails.Length != 0) hash ^= BinaryErrorDetails.GetHashCode(); + if (expectedError_ != null) hash ^= ExpectedError.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (EchoDeadline != false) { + output.WriteRawTag(8); + output.WriteBool(EchoDeadline); + } + if (ClientCancelAfterUs != 0) { + output.WriteRawTag(16); + output.WriteInt32(ClientCancelAfterUs); + } + if (ServerCancelAfterUs != 0) { + output.WriteRawTag(24); + output.WriteInt32(ServerCancelAfterUs); + } + if (EchoMetadata != false) { + output.WriteRawTag(32); + output.WriteBool(EchoMetadata); + } + if (CheckAuthContext != false) { + output.WriteRawTag(40); + output.WriteBool(CheckAuthContext); + } + if (ResponseMessageLength != 0) { + output.WriteRawTag(48); + output.WriteInt32(ResponseMessageLength); + } + if (EchoPeer != false) { + output.WriteRawTag(56); + output.WriteBool(EchoPeer); + } + if (ExpectedClientIdentity.Length != 0) { + output.WriteRawTag(66); + output.WriteString(ExpectedClientIdentity); + } + if (SkipCancelledCheck != false) { + output.WriteRawTag(72); + output.WriteBool(SkipCancelledCheck); + } + if (ExpectedTransportSecurityType.Length != 0) { + output.WriteRawTag(82); + output.WriteString(ExpectedTransportSecurityType); + } + if (debugInfo_ != null) { + output.WriteRawTag(90); + output.WriteMessage(DebugInfo); + } + if (ServerDie != false) { + output.WriteRawTag(96); + output.WriteBool(ServerDie); + } + if (BinaryErrorDetails.Length != 0) { + output.WriteRawTag(106); + output.WriteString(BinaryErrorDetails); + } + if (expectedError_ != null) { + output.WriteRawTag(114); + output.WriteMessage(ExpectedError); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (EchoDeadline != false) { + size += 1 + 1; + } + if (ClientCancelAfterUs != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ClientCancelAfterUs); + } + if (ServerCancelAfterUs != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ServerCancelAfterUs); + } + if (EchoMetadata != false) { + size += 1 + 1; + } + if (CheckAuthContext != false) { + size += 1 + 1; + } + if (ResponseMessageLength != 0) { + size += 1 + pb::CodedOutputStream.ComputeInt32Size(ResponseMessageLength); + } + if (EchoPeer != false) { + size += 1 + 1; + } + if (ExpectedClientIdentity.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ExpectedClientIdentity); + } + if (SkipCancelledCheck != false) { + size += 1 + 1; + } + if (ExpectedTransportSecurityType.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(ExpectedTransportSecurityType); + } + if (debugInfo_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(DebugInfo); + } + if (ServerDie != false) { + size += 1 + 1; + } + if (BinaryErrorDetails.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(BinaryErrorDetails); + } + if (expectedError_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(ExpectedError); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(RequestParams other) { + if (other == null) { + return; + } + if (other.EchoDeadline != false) { + EchoDeadline = other.EchoDeadline; + } + if (other.ClientCancelAfterUs != 0) { + ClientCancelAfterUs = other.ClientCancelAfterUs; + } + if (other.ServerCancelAfterUs != 0) { + ServerCancelAfterUs = other.ServerCancelAfterUs; + } + if (other.EchoMetadata != false) { + EchoMetadata = other.EchoMetadata; + } + if (other.CheckAuthContext != false) { + CheckAuthContext = other.CheckAuthContext; + } + if (other.ResponseMessageLength != 0) { + ResponseMessageLength = other.ResponseMessageLength; + } + if (other.EchoPeer != false) { + EchoPeer = other.EchoPeer; + } + if (other.ExpectedClientIdentity.Length != 0) { + ExpectedClientIdentity = other.ExpectedClientIdentity; + } + if (other.SkipCancelledCheck != false) { + SkipCancelledCheck = other.SkipCancelledCheck; + } + if (other.ExpectedTransportSecurityType.Length != 0) { + ExpectedTransportSecurityType = other.ExpectedTransportSecurityType; + } + if (other.debugInfo_ != null) { + if (debugInfo_ == null) { + debugInfo_ = new global::Grpc.Testing.DebugInfo(); + } + DebugInfo.MergeFrom(other.DebugInfo); + } + if (other.ServerDie != false) { + ServerDie = other.ServerDie; + } + if (other.BinaryErrorDetails.Length != 0) { + BinaryErrorDetails = other.BinaryErrorDetails; + } + if (other.expectedError_ != null) { + if (expectedError_ == null) { + expectedError_ = new global::Grpc.Testing.ErrorStatus(); + } + ExpectedError.MergeFrom(other.ExpectedError); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + EchoDeadline = input.ReadBool(); + break; + } + case 16: { + ClientCancelAfterUs = input.ReadInt32(); + break; + } + case 24: { + ServerCancelAfterUs = input.ReadInt32(); + break; + } + case 32: { + EchoMetadata = input.ReadBool(); + break; + } + case 40: { + CheckAuthContext = input.ReadBool(); + break; + } + case 48: { + ResponseMessageLength = input.ReadInt32(); + break; + } + case 56: { + EchoPeer = input.ReadBool(); + break; + } + case 66: { + ExpectedClientIdentity = input.ReadString(); + break; + } + case 72: { + SkipCancelledCheck = input.ReadBool(); + break; + } + case 82: { + ExpectedTransportSecurityType = input.ReadString(); + break; + } + case 90: { + if (debugInfo_ == null) { + debugInfo_ = new global::Grpc.Testing.DebugInfo(); + } + input.ReadMessage(debugInfo_); + break; + } + case 96: { + ServerDie = input.ReadBool(); + break; + } + case 106: { + BinaryErrorDetails = input.ReadString(); + break; + } + case 114: { + if (expectedError_ == null) { + expectedError_ = new global::Grpc.Testing.ErrorStatus(); + } + input.ReadMessage(expectedError_); + break; + } + } + } + } + + } + + public sealed partial class EchoRequest : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EchoRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.EchoMessagesReflection.Descriptor.MessageTypes[3]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EchoRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EchoRequest(EchoRequest other) : this() { + message_ = other.message_; + Param = other.param_ != null ? other.Param.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EchoRequest Clone() { + return new EchoRequest(this); + } + + /// Field number for the "message" field. + public const int MessageFieldNumber = 1; + private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Message { + get { return message_; } + set { + message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "param" field. + public const int ParamFieldNumber = 2; + private global::Grpc.Testing.RequestParams param_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Testing.RequestParams Param { + get { return param_; } + set { + param_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as EchoRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(EchoRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Message != other.Message) return false; + if (!object.Equals(Param, other.Param)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Message.Length != 0) hash ^= Message.GetHashCode(); + if (param_ != null) hash ^= Param.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Message.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Message); + } + if (param_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Param); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Message.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); + } + if (param_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Param); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(EchoRequest other) { + if (other == null) { + return; + } + if (other.Message.Length != 0) { + Message = other.Message; + } + if (other.param_ != null) { + if (param_ == null) { + param_ = new global::Grpc.Testing.RequestParams(); + } + Param.MergeFrom(other.Param); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Message = input.ReadString(); + break; + } + case 18: { + if (param_ == null) { + param_ = new global::Grpc.Testing.RequestParams(); + } + input.ReadMessage(param_); + break; + } + } + } + } + + } + + public sealed partial class ResponseParams : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new ResponseParams()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.EchoMessagesReflection.Descriptor.MessageTypes[4]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ResponseParams() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ResponseParams(ResponseParams other) : this() { + requestDeadline_ = other.requestDeadline_; + host_ = other.host_; + peer_ = other.peer_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ResponseParams Clone() { + return new ResponseParams(this); + } + + /// Field number for the "request_deadline" field. + public const int RequestDeadlineFieldNumber = 1; + private long requestDeadline_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public long RequestDeadline { + get { return requestDeadline_; } + set { + requestDeadline_ = value; + } + } + + /// Field number for the "host" field. + public const int HostFieldNumber = 2; + private string host_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Host { + get { return host_; } + set { + host_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "peer" field. + public const int PeerFieldNumber = 3; + private string peer_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Peer { + get { return peer_; } + set { + peer_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ResponseParams); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ResponseParams other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (RequestDeadline != other.RequestDeadline) return false; + if (Host != other.Host) return false; + if (Peer != other.Peer) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (RequestDeadline != 0L) hash ^= RequestDeadline.GetHashCode(); + if (Host.Length != 0) hash ^= Host.GetHashCode(); + if (Peer.Length != 0) hash ^= Peer.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (RequestDeadline != 0L) { + output.WriteRawTag(8); + output.WriteInt64(RequestDeadline); + } + if (Host.Length != 0) { + output.WriteRawTag(18); + output.WriteString(Host); + } + if (Peer.Length != 0) { + output.WriteRawTag(26); + output.WriteString(Peer); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (RequestDeadline != 0L) { + size += 1 + pb::CodedOutputStream.ComputeInt64Size(RequestDeadline); + } + if (Host.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Host); + } + if (Peer.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Peer); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ResponseParams other) { + if (other == null) { + return; + } + if (other.RequestDeadline != 0L) { + RequestDeadline = other.RequestDeadline; + } + if (other.Host.Length != 0) { + Host = other.Host; + } + if (other.Peer.Length != 0) { + Peer = other.Peer; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + RequestDeadline = input.ReadInt64(); + break; + } + case 18: { + Host = input.ReadString(); + break; + } + case 26: { + Peer = input.ReadString(); + break; + } + } + } + } + + } + + public sealed partial class EchoResponse : pb::IMessage { + private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new EchoResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Grpc.Testing.EchoMessagesReflection.Descriptor.MessageTypes[5]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EchoResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EchoResponse(EchoResponse other) : this() { + message_ = other.message_; + Param = other.param_ != null ? other.Param.Clone() : null; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public EchoResponse Clone() { + return new EchoResponse(this); + } + + /// Field number for the "message" field. + public const int MessageFieldNumber = 1; + private string message_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public string Message { + get { return message_; } + set { + message_ = pb::ProtoPreconditions.CheckNotNull(value, "value"); + } + } + + /// Field number for the "param" field. + public const int ParamFieldNumber = 2; + private global::Grpc.Testing.ResponseParams param_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Grpc.Testing.ResponseParams Param { + get { return param_; } + set { + param_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as EchoResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(EchoResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Message != other.Message) return false; + if (!object.Equals(Param, other.Param)) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Message.Length != 0) hash ^= Message.GetHashCode(); + if (param_ != null) hash ^= Param.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Message.Length != 0) { + output.WriteRawTag(10); + output.WriteString(Message); + } + if (param_ != null) { + output.WriteRawTag(18); + output.WriteMessage(Param); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Message.Length != 0) { + size += 1 + pb::CodedOutputStream.ComputeStringSize(Message); + } + if (param_ != null) { + size += 1 + pb::CodedOutputStream.ComputeMessageSize(Param); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(EchoResponse other) { + if (other == null) { + return; + } + if (other.Message.Length != 0) { + Message = other.Message; + } + if (other.param_ != null) { + if (param_ == null) { + param_ = new global::Grpc.Testing.ResponseParams(); + } + Param.MergeFrom(other.Param); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 10: { + Message = input.ReadString(); + break; + } + case 18: { + if (param_ == null) { + param_ = new global::Grpc.Testing.ResponseParams(); + } + input.ReadMessage(param_); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/src/csharp/Grpc.IntegrationTesting/Services.cs b/src/csharp/Grpc.IntegrationTesting/Services.cs index bf36a0253b5..7a0845dffb0 100644 --- a/src/csharp/Grpc.IntegrationTesting/Services.cs +++ b/src/csharp/Grpc.IntegrationTesting/Services.cs @@ -24,20 +24,28 @@ namespace Grpc.Testing { string.Concat( "CiVzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL3NlcnZpY2VzLnByb3RvEgxncnBj", "LnRlc3RpbmcaJXNyYy9wcm90by9ncnBjL3Rlc3RpbmcvbWVzc2FnZXMucHJv", - "dG8aJHNyYy9wcm90by9ncnBjL3Rlc3RpbmcvY29udHJvbC5wcm90bzKqAQoQ", - "QmVuY2htYXJrU2VydmljZRJGCglVbmFyeUNhbGwSGy5ncnBjLnRlc3Rpbmcu", - "U2ltcGxlUmVxdWVzdBocLmdycGMudGVzdGluZy5TaW1wbGVSZXNwb25zZRJO", - "Cg1TdHJlYW1pbmdDYWxsEhsuZ3JwYy50ZXN0aW5nLlNpbXBsZVJlcXVlc3Qa", - "HC5ncnBjLnRlc3RpbmcuU2ltcGxlUmVzcG9uc2UoATABMpcCCg1Xb3JrZXJT", - "ZXJ2aWNlEkUKCVJ1blNlcnZlchIYLmdycGMudGVzdGluZy5TZXJ2ZXJBcmdz", - "GhouZ3JwYy50ZXN0aW5nLlNlcnZlclN0YXR1cygBMAESRQoJUnVuQ2xpZW50", - "EhguZ3JwYy50ZXN0aW5nLkNsaWVudEFyZ3MaGi5ncnBjLnRlc3RpbmcuQ2xp", - "ZW50U3RhdHVzKAEwARJCCglDb3JlQ291bnQSGS5ncnBjLnRlc3RpbmcuQ29y", - "ZVJlcXVlc3QaGi5ncnBjLnRlc3RpbmcuQ29yZVJlc3BvbnNlEjQKClF1aXRX", - "b3JrZXISEi5ncnBjLnRlc3RpbmcuVm9pZBoSLmdycGMudGVzdGluZy5Wb2lk", - "YgZwcm90bzM=")); + "dG8aJHNyYy9wcm90by9ncnBjL3Rlc3RpbmcvY29udHJvbC5wcm90bxoic3Jj", + "L3Byb3RvL2dycGMvdGVzdGluZy9zdGF0cy5wcm90bzKmAwoQQmVuY2htYXJr", + "U2VydmljZRJGCglVbmFyeUNhbGwSGy5ncnBjLnRlc3RpbmcuU2ltcGxlUmVx", + "dWVzdBocLmdycGMudGVzdGluZy5TaW1wbGVSZXNwb25zZRJOCg1TdHJlYW1p", + "bmdDYWxsEhsuZ3JwYy50ZXN0aW5nLlNpbXBsZVJlcXVlc3QaHC5ncnBjLnRl", + "c3RpbmcuU2ltcGxlUmVzcG9uc2UoATABElIKE1N0cmVhbWluZ0Zyb21DbGll", + "bnQSGy5ncnBjLnRlc3RpbmcuU2ltcGxlUmVxdWVzdBocLmdycGMudGVzdGlu", + "Zy5TaW1wbGVSZXNwb25zZSgBElIKE1N0cmVhbWluZ0Zyb21TZXJ2ZXISGy5n", + "cnBjLnRlc3RpbmcuU2ltcGxlUmVxdWVzdBocLmdycGMudGVzdGluZy5TaW1w", + "bGVSZXNwb25zZTABElIKEVN0cmVhbWluZ0JvdGhXYXlzEhsuZ3JwYy50ZXN0", + "aW5nLlNpbXBsZVJlcXVlc3QaHC5ncnBjLnRlc3RpbmcuU2ltcGxlUmVzcG9u", + "c2UoATABMpcCCg1Xb3JrZXJTZXJ2aWNlEkUKCVJ1blNlcnZlchIYLmdycGMu", + "dGVzdGluZy5TZXJ2ZXJBcmdzGhouZ3JwYy50ZXN0aW5nLlNlcnZlclN0YXR1", + "cygBMAESRQoJUnVuQ2xpZW50EhguZ3JwYy50ZXN0aW5nLkNsaWVudEFyZ3Ma", + "Gi5ncnBjLnRlc3RpbmcuQ2xpZW50U3RhdHVzKAEwARJCCglDb3JlQ291bnQS", + "GS5ncnBjLnRlc3RpbmcuQ29yZVJlcXVlc3QaGi5ncnBjLnRlc3RpbmcuQ29y", + "ZVJlc3BvbnNlEjQKClF1aXRXb3JrZXISEi5ncnBjLnRlc3RpbmcuVm9pZBoS", + "LmdycGMudGVzdGluZy5Wb2lkMl4KGFJlcG9ydFFwc1NjZW5hcmlvU2Vydmlj", + "ZRJCCg5SZXBvcnRTY2VuYXJpbxIcLmdycGMudGVzdGluZy5TY2VuYXJpb1Jl", + "c3VsdBoSLmdycGMudGVzdGluZy5Wb2lkYgZwcm90bzM=")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, - new pbr::FileDescriptor[] { global::Grpc.Testing.MessagesReflection.Descriptor, global::Grpc.Testing.ControlReflection.Descriptor, }, + new pbr::FileDescriptor[] { global::Grpc.Testing.MessagesReflection.Descriptor, global::Grpc.Testing.ControlReflection.Descriptor, global::Grpc.Testing.StatsReflection.Descriptor, }, new pbr::GeneratedClrTypeInfo(null, null)); } #endregion diff --git a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs index 143c9ac9fcc..bd5971e296f 100644 --- a/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs +++ b/src/csharp/Grpc.IntegrationTesting/ServicesGrpc.cs @@ -46,6 +46,27 @@ namespace Grpc.Testing { __Marshaller_SimpleRequest, __Marshaller_SimpleResponse); + static readonly grpc::Method __Method_StreamingFromClient = new grpc::Method( + grpc::MethodType.ClientStreaming, + __ServiceName, + "StreamingFromClient", + __Marshaller_SimpleRequest, + __Marshaller_SimpleResponse); + + static readonly grpc::Method __Method_StreamingFromServer = new grpc::Method( + grpc::MethodType.ServerStreaming, + __ServiceName, + "StreamingFromServer", + __Marshaller_SimpleRequest, + __Marshaller_SimpleResponse); + + static readonly grpc::Method __Method_StreamingBothWays = new grpc::Method( + grpc::MethodType.DuplexStreaming, + __ServiceName, + "StreamingBothWays", + __Marshaller_SimpleRequest, + __Marshaller_SimpleResponse); + /// Service descriptor public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor { @@ -68,8 +89,9 @@ namespace Grpc.Testing { } /// - /// One request followed by one response. - /// The server returns the client payload as-is. + /// Repeated sequence of one request followed by one response. + /// Should be called streaming ping-pong + /// The server returns the client payload as-is on each response /// /// Used for reading requests from the client. /// Used for sending responses back to the client. @@ -80,6 +102,44 @@ namespace Grpc.Testing { throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); } + /// + /// Single-sided unbounded streaming from client to server + /// The server returns the client payload as-is once the client does WritesDone + /// + /// Used for reading requests from the client. + /// The context of the server-side call handler being invoked. + /// The response to send back to the client (wrapped by a task). + public virtual global::System.Threading.Tasks.Task StreamingFromClient(grpc::IAsyncStreamReader requestStream, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + /// + /// Single-sided unbounded streaming from server to client + /// The server repeatedly returns the client payload as-is + /// + /// The request received from the client. + /// Used for sending responses back to the client. + /// The context of the server-side call handler being invoked. + /// A task indicating completion of the handler. + public virtual global::System.Threading.Tasks.Task StreamingFromServer(global::Grpc.Testing.SimpleRequest request, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + /// + /// Two-sided unbounded streaming between server to client + /// Both sides send the content of their own choice to the other + /// + /// Used for reading requests from the client. + /// Used for sending responses back to the client. + /// The context of the server-side call handler being invoked. + /// A task indicating completion of the handler. + public virtual global::System.Threading.Tasks.Task StreamingBothWays(grpc::IAsyncStreamReader requestStream, grpc::IServerStreamWriter responseStream, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + } /// Client for BenchmarkService @@ -154,8 +214,9 @@ namespace Grpc.Testing { return CallInvoker.AsyncUnaryCall(__Method_UnaryCall, null, options, request); } /// - /// One request followed by one response. - /// The server returns the client payload as-is. + /// Repeated sequence of one request followed by one response. + /// Should be called streaming ping-pong + /// The server returns the client payload as-is on each response /// /// The initial metadata to send with the call. This parameter is optional. /// An optional deadline for the call. The call will be cancelled if deadline is hit. @@ -166,8 +227,9 @@ namespace Grpc.Testing { return StreamingCall(new grpc::CallOptions(headers, deadline, cancellationToken)); } /// - /// One request followed by one response. - /// The server returns the client payload as-is. + /// Repeated sequence of one request followed by one response. + /// Should be called streaming ping-pong + /// The server returns the client payload as-is on each response /// /// The options for the call. /// The call object. @@ -175,6 +237,74 @@ namespace Grpc.Testing { { return CallInvoker.AsyncDuplexStreamingCall(__Method_StreamingCall, null, options); } + /// + /// Single-sided unbounded streaming from client to server + /// The server returns the client payload as-is once the client does WritesDone + /// + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncClientStreamingCall StreamingFromClient(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return StreamingFromClient(new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Single-sided unbounded streaming from client to server + /// The server returns the client payload as-is once the client does WritesDone + /// + /// The options for the call. + /// The call object. + public virtual grpc::AsyncClientStreamingCall StreamingFromClient(grpc::CallOptions options) + { + return CallInvoker.AsyncClientStreamingCall(__Method_StreamingFromClient, null, options); + } + /// + /// Single-sided unbounded streaming from server to client + /// The server repeatedly returns the client payload as-is + /// + /// The request to send to the server. + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncServerStreamingCall StreamingFromServer(global::Grpc.Testing.SimpleRequest request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return StreamingFromServer(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Single-sided unbounded streaming from server to client + /// The server repeatedly returns the client payload as-is + /// + /// The request to send to the server. + /// The options for the call. + /// The call object. + public virtual grpc::AsyncServerStreamingCall StreamingFromServer(global::Grpc.Testing.SimpleRequest request, grpc::CallOptions options) + { + return CallInvoker.AsyncServerStreamingCall(__Method_StreamingFromServer, null, options, request); + } + /// + /// Two-sided unbounded streaming between server to client + /// Both sides send the content of their own choice to the other + /// + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncDuplexStreamingCall StreamingBothWays(grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return StreamingBothWays(new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Two-sided unbounded streaming between server to client + /// Both sides send the content of their own choice to the other + /// + /// The options for the call. + /// The call object. + public virtual grpc::AsyncDuplexStreamingCall StreamingBothWays(grpc::CallOptions options) + { + return CallInvoker.AsyncDuplexStreamingCall(__Method_StreamingBothWays, null, options); + } /// Creates a new instance of client from given ClientBaseConfiguration. protected override BenchmarkServiceClient NewInstance(ClientBaseConfiguration configuration) { @@ -188,7 +318,10 @@ namespace Grpc.Testing { { return grpc::ServerServiceDefinition.CreateBuilder() .AddMethod(__Method_UnaryCall, serviceImpl.UnaryCall) - .AddMethod(__Method_StreamingCall, serviceImpl.StreamingCall).Build(); + .AddMethod(__Method_StreamingCall, serviceImpl.StreamingCall) + .AddMethod(__Method_StreamingFromClient, serviceImpl.StreamingFromClient) + .AddMethod(__Method_StreamingFromServer, serviceImpl.StreamingFromServer) + .AddMethod(__Method_StreamingBothWays, serviceImpl.StreamingBothWays).Build(); } } @@ -489,5 +622,124 @@ namespace Grpc.Testing { } } + public static partial class ReportQpsScenarioService + { + static readonly string __ServiceName = "grpc.testing.ReportQpsScenarioService"; + + static readonly grpc::Marshaller __Marshaller_ScenarioResult = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.ScenarioResult.Parser.ParseFrom); + static readonly grpc::Marshaller __Marshaller_Void = grpc::Marshallers.Create((arg) => global::Google.Protobuf.MessageExtensions.ToByteArray(arg), global::Grpc.Testing.Void.Parser.ParseFrom); + + static readonly grpc::Method __Method_ReportScenario = new grpc::Method( + grpc::MethodType.Unary, + __ServiceName, + "ReportScenario", + __Marshaller_ScenarioResult, + __Marshaller_Void); + + /// Service descriptor + public static global::Google.Protobuf.Reflection.ServiceDescriptor Descriptor + { + get { return global::Grpc.Testing.ServicesReflection.Descriptor.Services[2]; } + } + + /// Base class for server-side implementations of ReportQpsScenarioService + public abstract partial class ReportQpsScenarioServiceBase + { + /// + /// Report results of a QPS test benchmark scenario. + /// + /// The request received from the client. + /// The context of the server-side call handler being invoked. + /// The response to send back to the client (wrapped by a task). + public virtual global::System.Threading.Tasks.Task ReportScenario(global::Grpc.Testing.ScenarioResult request, grpc::ServerCallContext context) + { + throw new grpc::RpcException(new grpc::Status(grpc::StatusCode.Unimplemented, "")); + } + + } + + /// Client for ReportQpsScenarioService + public partial class ReportQpsScenarioServiceClient : grpc::ClientBase + { + /// Creates a new client for ReportQpsScenarioService + /// The channel to use to make remote calls. + public ReportQpsScenarioServiceClient(grpc::Channel channel) : base(channel) + { + } + /// Creates a new client for ReportQpsScenarioService that uses a custom CallInvoker. + /// The callInvoker to use to make remote calls. + public ReportQpsScenarioServiceClient(grpc::CallInvoker callInvoker) : base(callInvoker) + { + } + /// Protected parameterless constructor to allow creation of test doubles. + protected ReportQpsScenarioServiceClient() : base() + { + } + /// Protected constructor to allow creation of configured clients. + /// The client configuration. + protected ReportQpsScenarioServiceClient(ClientBaseConfiguration configuration) : base(configuration) + { + } + + /// + /// Report results of a QPS test benchmark scenario. + /// + /// The request to send to the server. + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The response received from the server. + public virtual global::Grpc.Testing.Void ReportScenario(global::Grpc.Testing.ScenarioResult request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return ReportScenario(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Report results of a QPS test benchmark scenario. + /// + /// The request to send to the server. + /// The options for the call. + /// The response received from the server. + public virtual global::Grpc.Testing.Void ReportScenario(global::Grpc.Testing.ScenarioResult request, grpc::CallOptions options) + { + return CallInvoker.BlockingUnaryCall(__Method_ReportScenario, null, options, request); + } + /// + /// Report results of a QPS test benchmark scenario. + /// + /// The request to send to the server. + /// The initial metadata to send with the call. This parameter is optional. + /// An optional deadline for the call. The call will be cancelled if deadline is hit. + /// An optional token for canceling the call. + /// The call object. + public virtual grpc::AsyncUnaryCall ReportScenarioAsync(global::Grpc.Testing.ScenarioResult request, grpc::Metadata headers = null, DateTime? deadline = null, CancellationToken cancellationToken = default(CancellationToken)) + { + return ReportScenarioAsync(request, new grpc::CallOptions(headers, deadline, cancellationToken)); + } + /// + /// Report results of a QPS test benchmark scenario. + /// + /// The request to send to the server. + /// The options for the call. + /// The call object. + public virtual grpc::AsyncUnaryCall ReportScenarioAsync(global::Grpc.Testing.ScenarioResult request, grpc::CallOptions options) + { + return CallInvoker.AsyncUnaryCall(__Method_ReportScenario, null, options, request); + } + /// Creates a new instance of client from given ClientBaseConfiguration. + protected override ReportQpsScenarioServiceClient NewInstance(ClientBaseConfiguration configuration) + { + return new ReportQpsScenarioServiceClient(configuration); + } + } + + /// Creates service definition that can be registered with a server + /// An object implementing the server-side handling logic. + public static grpc::ServerServiceDefinition BindService(ReportQpsScenarioServiceBase serviceImpl) + { + return grpc::ServerServiceDefinition.CreateBuilder() + .AddMethod(__Method_ReportScenario, serviceImpl.ReportScenario).Build(); + } + + } } #endregion diff --git a/src/csharp/Grpc.IntegrationTesting/Stats.cs b/src/csharp/Grpc.IntegrationTesting/Stats.cs index 79ff220436a..23b56df6bdb 100644 --- a/src/csharp/Grpc.IntegrationTesting/Stats.cs +++ b/src/csharp/Grpc.IntegrationTesting/Stats.cs @@ -23,27 +23,28 @@ namespace Grpc.Testing { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CiJzcmMvcHJvdG8vZ3JwYy90ZXN0aW5nL3N0YXRzLnByb3RvEgxncnBjLnRl", - "c3RpbmciegoLU2VydmVyU3RhdHMSFAoMdGltZV9lbGFwc2VkGAEgASgBEhEK", - "CXRpbWVfdXNlchgCIAEoARITCgt0aW1lX3N5c3RlbRgDIAEoARIWCg50b3Rh", - "bF9jcHVfdGltZRgEIAEoBBIVCg1pZGxlX2NwdV90aW1lGAUgASgEIjsKD0hp", - "c3RvZ3JhbVBhcmFtcxISCgpyZXNvbHV0aW9uGAEgASgBEhQKDG1heF9wb3Nz", - "aWJsZRgCIAEoASJ3Cg1IaXN0b2dyYW1EYXRhEg4KBmJ1Y2tldBgBIAMoDRIQ", - "CghtaW5fc2VlbhgCIAEoARIQCghtYXhfc2VlbhgDIAEoARILCgNzdW0YBCAB", - "KAESFgoOc3VtX29mX3NxdWFyZXMYBSABKAESDQoFY291bnQYBiABKAEiOAoS", - "UmVxdWVzdFJlc3VsdENvdW50EhMKC3N0YXR1c19jb2RlGAEgASgFEg0KBWNv", - "dW50GAIgASgDIrYBCgtDbGllbnRTdGF0cxIuCglsYXRlbmNpZXMYASABKAsy", - "Gy5ncnBjLnRlc3RpbmcuSGlzdG9ncmFtRGF0YRIUCgx0aW1lX2VsYXBzZWQY", - "AiABKAESEQoJdGltZV91c2VyGAMgASgBEhMKC3RpbWVfc3lzdGVtGAQgASgB", - "EjkKD3JlcXVlc3RfcmVzdWx0cxgFIAMoCzIgLmdycGMudGVzdGluZy5SZXF1", - "ZXN0UmVzdWx0Q291bnRiBnByb3RvMw==")); + "c3RpbmcikQEKC1NlcnZlclN0YXRzEhQKDHRpbWVfZWxhcHNlZBgBIAEoARIR", + "Cgl0aW1lX3VzZXIYAiABKAESEwoLdGltZV9zeXN0ZW0YAyABKAESFgoOdG90", + "YWxfY3B1X3RpbWUYBCABKAQSFQoNaWRsZV9jcHVfdGltZRgFIAEoBBIVCg1j", + "cV9wb2xsX2NvdW50GAYgASgEIjsKD0hpc3RvZ3JhbVBhcmFtcxISCgpyZXNv", + "bHV0aW9uGAEgASgBEhQKDG1heF9wb3NzaWJsZRgCIAEoASJ3Cg1IaXN0b2dy", + "YW1EYXRhEg4KBmJ1Y2tldBgBIAMoDRIQCghtaW5fc2VlbhgCIAEoARIQCght", + "YXhfc2VlbhgDIAEoARILCgNzdW0YBCABKAESFgoOc3VtX29mX3NxdWFyZXMY", + "BSABKAESDQoFY291bnQYBiABKAEiOAoSUmVxdWVzdFJlc3VsdENvdW50EhMK", + "C3N0YXR1c19jb2RlGAEgASgFEg0KBWNvdW50GAIgASgDIs0BCgtDbGllbnRT", + "dGF0cxIuCglsYXRlbmNpZXMYASABKAsyGy5ncnBjLnRlc3RpbmcuSGlzdG9n", + "cmFtRGF0YRIUCgx0aW1lX2VsYXBzZWQYAiABKAESEQoJdGltZV91c2VyGAMg", + "ASgBEhMKC3RpbWVfc3lzdGVtGAQgASgBEjkKD3JlcXVlc3RfcmVzdWx0cxgF", + "IAMoCzIgLmdycGMudGVzdGluZy5SZXF1ZXN0UmVzdWx0Q291bnQSFQoNY3Ff", + "cG9sbF9jb3VudBgGIAEoBGIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStats), global::Grpc.Testing.ServerStats.Parser, new[]{ "TimeElapsed", "TimeUser", "TimeSystem", "TotalCpuTime", "IdleCpuTime" }, null, null, null), + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ServerStats), global::Grpc.Testing.ServerStats.Parser, new[]{ "TimeElapsed", "TimeUser", "TimeSystem", "TotalCpuTime", "IdleCpuTime", "CqPollCount" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.HistogramParams), global::Grpc.Testing.HistogramParams.Parser, new[]{ "Resolution", "MaxPossible" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.HistogramData), global::Grpc.Testing.HistogramData.Parser, new[]{ "Bucket", "MinSeen", "MaxSeen", "Sum", "SumOfSquares", "Count" }, null, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.RequestResultCount), global::Grpc.Testing.RequestResultCount.Parser, new[]{ "StatusCode", "Count" }, null, null, null), - new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStats), global::Grpc.Testing.ClientStats.Parser, new[]{ "Latencies", "TimeElapsed", "TimeUser", "TimeSystem", "RequestResults" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Grpc.Testing.ClientStats), global::Grpc.Testing.ClientStats.Parser, new[]{ "Latencies", "TimeElapsed", "TimeUser", "TimeSystem", "RequestResults", "CqPollCount" }, null, null, null) })); } #endregion @@ -79,6 +80,7 @@ namespace Grpc.Testing { timeSystem_ = other.timeSystem_; totalCpuTime_ = other.totalCpuTime_; idleCpuTime_ = other.idleCpuTime_; + cqPollCount_ = other.cqPollCount_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -157,6 +159,20 @@ namespace Grpc.Testing { } } + /// Field number for the "cq_poll_count" field. + public const int CqPollCountFieldNumber = 6; + private ulong cqPollCount_; + /// + /// Number of polls called inside completion queue + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong CqPollCount { + get { return cqPollCount_; } + set { + cqPollCount_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ServerStats); @@ -175,6 +191,7 @@ namespace Grpc.Testing { if (TimeSystem != other.TimeSystem) return false; if (TotalCpuTime != other.TotalCpuTime) return false; if (IdleCpuTime != other.IdleCpuTime) return false; + if (CqPollCount != other.CqPollCount) return false; return true; } @@ -186,6 +203,7 @@ namespace Grpc.Testing { if (TimeSystem != 0D) hash ^= TimeSystem.GetHashCode(); if (TotalCpuTime != 0UL) hash ^= TotalCpuTime.GetHashCode(); if (IdleCpuTime != 0UL) hash ^= IdleCpuTime.GetHashCode(); + if (CqPollCount != 0UL) hash ^= CqPollCount.GetHashCode(); return hash; } @@ -216,6 +234,10 @@ namespace Grpc.Testing { output.WriteRawTag(40); output.WriteUInt64(IdleCpuTime); } + if (CqPollCount != 0UL) { + output.WriteRawTag(48); + output.WriteUInt64(CqPollCount); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -236,6 +258,9 @@ namespace Grpc.Testing { if (IdleCpuTime != 0UL) { size += 1 + pb::CodedOutputStream.ComputeUInt64Size(IdleCpuTime); } + if (CqPollCount != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(CqPollCount); + } return size; } @@ -259,6 +284,9 @@ namespace Grpc.Testing { if (other.IdleCpuTime != 0UL) { IdleCpuTime = other.IdleCpuTime; } + if (other.CqPollCount != 0UL) { + CqPollCount = other.CqPollCount; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -289,6 +317,10 @@ namespace Grpc.Testing { IdleCpuTime = input.ReadUInt64(); break; } + case 48: { + CqPollCount = input.ReadUInt64(); + break; + } } } } @@ -876,6 +908,7 @@ namespace Grpc.Testing { timeUser_ = other.timeUser_; timeSystem_ = other.timeSystem_; requestResults_ = other.requestResults_.Clone(); + cqPollCount_ = other.cqPollCount_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -946,6 +979,20 @@ namespace Grpc.Testing { get { return requestResults_; } } + /// Field number for the "cq_poll_count" field. + public const int CqPollCountFieldNumber = 6; + private ulong cqPollCount_; + /// + /// Number of polls called inside completion queue + /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ulong CqPollCount { + get { return cqPollCount_; } + set { + cqPollCount_ = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ClientStats); @@ -964,6 +1011,7 @@ namespace Grpc.Testing { if (TimeUser != other.TimeUser) return false; if (TimeSystem != other.TimeSystem) return false; if(!requestResults_.Equals(other.requestResults_)) return false; + if (CqPollCount != other.CqPollCount) return false; return true; } @@ -975,6 +1023,7 @@ namespace Grpc.Testing { if (TimeUser != 0D) hash ^= TimeUser.GetHashCode(); if (TimeSystem != 0D) hash ^= TimeSystem.GetHashCode(); hash ^= requestResults_.GetHashCode(); + if (CqPollCount != 0UL) hash ^= CqPollCount.GetHashCode(); return hash; } @@ -1002,6 +1051,10 @@ namespace Grpc.Testing { output.WriteDouble(TimeSystem); } requestResults_.WriteTo(output, _repeated_requestResults_codec); + if (CqPollCount != 0UL) { + output.WriteRawTag(48); + output.WriteUInt64(CqPollCount); + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1020,6 +1073,9 @@ namespace Grpc.Testing { size += 1 + 8; } size += requestResults_.CalculateSize(_repeated_requestResults_codec); + if (CqPollCount != 0UL) { + size += 1 + pb::CodedOutputStream.ComputeUInt64Size(CqPollCount); + } return size; } @@ -1044,6 +1100,9 @@ namespace Grpc.Testing { TimeSystem = other.TimeSystem; } requestResults_.Add(other.requestResults_); + if (other.CqPollCount != 0UL) { + CqPollCount = other.CqPollCount; + } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -1077,6 +1136,10 @@ namespace Grpc.Testing { requestResults_.AddEntriesFrom(input, _repeated_requestResults_codec); break; } + case 48: { + CqPollCount = input.ReadUInt64(); + break; + } } } } From e78a0b79fa5b8c7d0154ba91b2fcca4d55bb2e08 Mon Sep 17 00:00:00 2001 From: thassss Date: Thu, 29 Jun 2017 09:23:23 -0700 Subject: [PATCH 60/69] Warn against using serverName property with Cronet --- src/objective-c/GRPCClient/GRPCCall.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 2495aface69..496242a1b6f 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -165,6 +165,7 @@ extern id const kGRPCTrailersKey; /** * The server name for the RPC. If nil, the host name of the service object will be used instead. + * This property must be nil when Cronet transport is enabled. */ @property (atomic, readwrite) NSString *serverName; From 260ddd175977c4c19d2b06287c1db416b2a4fbf4 Mon Sep 17 00:00:00 2001 From: thassss Date: Thu, 29 Jun 2017 09:24:16 -0700 Subject: [PATCH 61/69] Remove nullability specifiers --- src/objective-c/GRPCClient/private/GRPCHost.h | 2 +- src/objective-c/GRPCClient/private/GRPCHost.m | 2 +- src/objective-c/GRPCClient/private/GRPCWrappedCall.h | 2 +- src/objective-c/GRPCClient/private/GRPCWrappedCall.m | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCHost.h b/src/objective-c/GRPCClient/private/GRPCHost.h index bb68fa3ec4a..0c1d7152405 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.h +++ b/src/objective-c/GRPCClient/private/GRPCHost.h @@ -54,7 +54,7 @@ struct grpc_channel_credentials; /** Create a grpc_call object to the provided path on this host. */ - (nullable struct grpc_call *)unmanagedCallWithPath:(NSString *)path - serverName:(nullable NSString *)serverName + serverName:(NSString *)serverName completionQueue:(GRPCCompletionQueue *)queue; // TODO: There's a race when a new RPC is coming through just as an existing one is getting diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 5658150b339..800c5480774 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -120,7 +120,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; } - (nullable grpc_call *)unmanagedCallWithPath:(NSString *)path - serverName:(nullable NSString *)serverName + serverName:(NSString *)serverName completionQueue:(GRPCCompletionQueue *)queue { GRPCChannel *channel; // This is racing -[GRPCHost disconnect]. diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h index e24d2469122..64075591a37 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.h +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.h @@ -75,7 +75,7 @@ @interface GRPCWrappedCall : NSObject - (instancetype)initWithHost:(NSString *)host - serverName:(nullable NSString *)serverName + serverName:(NSString *)serverName path:(NSString *)path NS_DESIGNATED_INITIALIZER; - (void)startBatchWithOperations:(NSArray *)ops errorHandler:(void(^)())errorHandler; diff --git a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m index 2d98f708990..7593a8ab0d1 100644 --- a/src/objective-c/GRPCClient/private/GRPCWrappedCall.m +++ b/src/objective-c/GRPCClient/private/GRPCWrappedCall.m @@ -236,7 +236,7 @@ } - (instancetype)initWithHost:(NSString *)host - serverName:(nullable NSString *)serverName + serverName:(NSString *)serverName path:(NSString *)path { if (!path || !host) { [NSException raise:NSInvalidArgumentException From a5082db9dabb3aae114fa773d1f6edf1f8d54363 Mon Sep 17 00:00:00 2001 From: thassss Date: Thu, 29 Jun 2017 09:26:20 -0700 Subject: [PATCH 62/69] Pass NULL to grpc_channel_create_call for nil serverName --- src/objective-c/GRPCClient/private/GRPCChannel.m | 11 ++++++++--- src/objective-c/GRPCClient/private/GRPCHost.m | 3 +-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/objective-c/GRPCClient/private/GRPCChannel.m b/src/objective-c/GRPCClient/private/GRPCChannel.m index 690fad25965..52dbc70b997 100644 --- a/src/objective-c/GRPCClient/private/GRPCChannel.m +++ b/src/objective-c/GRPCClient/private/GRPCChannel.m @@ -183,15 +183,20 @@ static grpc_channel_args *BuildChannelArgs(NSDictionary *dictionary) { - (grpc_call *)unmanagedCallWithPath:(NSString *)path serverName:(NSString *)serverName completionQueue:(GRPCCompletionQueue *)queue { - grpc_slice host_slice = grpc_slice_from_copied_string(serverName.UTF8String); + grpc_slice host_slice; + if (serverName) { + host_slice = grpc_slice_from_copied_string(serverName.UTF8String); + } grpc_slice path_slice = grpc_slice_from_copied_string(path.UTF8String); grpc_call *call = grpc_channel_create_call(_unmanagedChannel, NULL, GRPC_PROPAGATE_DEFAULTS, queue.unmanagedQueue, path_slice, - &host_slice, + serverName ? &host_slice : NULL, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); - grpc_slice_unref(host_slice); + if (serverName) { + grpc_slice_unref(host_slice); + } grpc_slice_unref(path_slice); return call; } diff --git a/src/objective-c/GRPCClient/private/GRPCHost.m b/src/objective-c/GRPCClient/private/GRPCHost.m index 800c5480774..23794c1fed2 100644 --- a/src/objective-c/GRPCClient/private/GRPCHost.m +++ b/src/objective-c/GRPCClient/private/GRPCHost.m @@ -130,8 +130,7 @@ static GRPCConnectivityMonitor *connectivityMonitor = nil; } channel = _channel; } - NSString *name = serverName ? serverName : _address; - return [channel unmanagedCallWithPath:path serverName:name completionQueue:queue]; + return [channel unmanagedCallWithPath:path serverName:serverName completionQueue:queue]; } - (BOOL)setTLSPEMRootCerts:(nullable NSString *)pemRootCerts From be928be48acf7cafdf82b99a5bc5ba7e620a1f06 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 29 Jun 2017 10:43:00 -0700 Subject: [PATCH 63/69] Allow HTTP CONNECT handshaker to be used in http1 client. --- src/core/lib/http/httpcli_security_connector.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/lib/http/httpcli_security_connector.c b/src/core/lib/http/httpcli_security_connector.c index 34a77c3bf41..97c28865258 100644 --- a/src/core/lib/http/httpcli_security_connector.c +++ b/src/core/lib/http/httpcli_security_connector.c @@ -25,6 +25,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/channel/handshaker_registry.h" #include "src/core/lib/security/transport/security_handshaker.h" #include "src/core/lib/slice/slice_internal.h" #include "src/core/lib/support/string.h" @@ -157,7 +158,6 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg, gpr_timespec deadline, void (*on_done)(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *endpoint)) { - grpc_channel_security_connector *sc = NULL; on_done_closure *c = gpr_malloc(sizeof(*c)); const char *pem_root_certs = grpc_get_default_ssl_roots(); if (pem_root_certs == NULL) { @@ -168,11 +168,13 @@ static void ssl_handshake(grpc_exec_ctx *exec_ctx, void *arg, } c->func = on_done; c->arg = arg; - c->handshake_mgr = grpc_handshake_manager_create(); + grpc_channel_security_connector *sc = NULL; GPR_ASSERT(httpcli_ssl_channel_security_connector_create( exec_ctx, pem_root_certs, host, &sc) == GRPC_SECURITY_OK); - grpc_channel_security_connector_add_handshakers(exec_ctx, sc, - c->handshake_mgr); + grpc_arg channel_arg = grpc_security_connector_to_arg(&sc->base); + grpc_channel_args args = {1, &channel_arg}; + c->handshake_mgr = grpc_handshake_manager_create(); + grpc_handshakers_add(exec_ctx, HANDSHAKER_CLIENT, &args, c->handshake_mgr); grpc_handshake_manager_do_handshake( exec_ctx, c->handshake_mgr, tcp, NULL /* channel_args */, deadline, NULL /* acceptor */, on_handshake_done, c /* user_data */); From 5c8f27bf1833dcfc0ae49b0d05546586db4d404f Mon Sep 17 00:00:00 2001 From: thassss Date: Thu, 29 Jun 2017 16:23:08 -0700 Subject: [PATCH 64/69] Update serverName comment to be more accurate --- src/objective-c/GRPCClient/GRPCCall.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/objective-c/GRPCClient/GRPCCall.h b/src/objective-c/GRPCClient/GRPCCall.h index 496242a1b6f..178a446c8b4 100644 --- a/src/objective-c/GRPCClient/GRPCCall.h +++ b/src/objective-c/GRPCClient/GRPCCall.h @@ -164,8 +164,8 @@ extern id const kGRPCTrailersKey; @interface GRPCCall : GRXWriter /** - * The server name for the RPC. If nil, the host name of the service object will be used instead. - * This property must be nil when Cronet transport is enabled. + * The authority for the RPC. If nil, the default authority will be used. This property must be nil + * when Cronet transport is enabled. */ @property (atomic, readwrite) NSString *serverName; From 36a481e647dd671d3c9975cf55d99bd272831915 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 29 Jun 2017 17:07:33 -0700 Subject: [PATCH 65/69] Removed leftover debugging msg --- .../ext/filters/client_channel/resolver/fake/fake_resolver.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c index 479ba393a26..56ed4371a91 100644 --- a/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c +++ b/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c @@ -101,9 +101,6 @@ static void fake_resolver_maybe_finish_next_locked(grpc_exec_ctx* exec_ctx, static void fake_resolver_channel_saw_error_locked(grpc_exec_ctx* exec_ctx, grpc_resolver* resolver) { fake_resolver* r = (fake_resolver*)resolver; - gpr_log( - GPR_INFO, - "FOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO"); if (r->next_results == NULL && r->results_upon_error != NULL) { // Pretend we re-resolved. r->next_results = grpc_channel_args_copy(r->results_upon_error); From 2faddbd639c594fd7c6acc64660042a3b6a7e4ae Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Fri, 30 Jun 2017 07:10:10 -0700 Subject: [PATCH 66/69] Fix filter_end2end_test. --- test/cpp/end2end/filter_end2end_test.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/cpp/end2end/filter_end2end_test.cc b/test/cpp/end2end/filter_end2end_test.cc index bf5a9c227aa..f260ea0016d 100644 --- a/test/cpp/end2end/filter_end2end_test.cc +++ b/test/cpp/end2end/filter_end2end_test.cc @@ -100,7 +100,8 @@ int GetCallCounterValue() { class ChannelDataImpl : public ChannelData { public: - grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element_args* args) { + grpc_error* Init(grpc_exec_ctx* exec_ctx, grpc_channel_element* elem, + grpc_channel_element_args* args) { IncrementConnectionCounter(); return GRPC_ERROR_NONE; } From 0c435fe6cbb0113f108f10805dbc6cb49bf8335f Mon Sep 17 00:00:00 2001 From: Jan Tattermusch Date: Fri, 30 Jun 2017 12:42:30 +0200 Subject: [PATCH 67/69] add more ruby artifact deps --- tools/internal_ci/helper_scripts/prepare_build_macos_rc | 2 +- tools/internal_ci/macos/grpc_build_artifacts.sh | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/internal_ci/helper_scripts/prepare_build_macos_rc b/tools/internal_ci/helper_scripts/prepare_build_macos_rc index 6b942d22b8c..22e80d2afa1 100644 --- a/tools/internal_ci/helper_scripts/prepare_build_macos_rc +++ b/tools/internal_ci/helper_scripts/prepare_build_macos_rc @@ -27,7 +27,7 @@ brew install gflags set +ex # rvm script is very verbose and exits with errorcode source $HOME/.rvm/scripts/rvm set -e # rvm commands are very verbose -rvm install ruby-2.3 +rvm install ruby-2.4 rvm osx-ssl-certs status all rvm osx-ssl-certs update all set -ex diff --git a/tools/internal_ci/macos/grpc_build_artifacts.sh b/tools/internal_ci/macos/grpc_build_artifacts.sh index 3884a4f2e50..603c15f210f 100755 --- a/tools/internal_ci/macos/grpc_build_artifacts.sh +++ b/tools/internal_ci/macos/grpc_build_artifacts.sh @@ -37,5 +37,12 @@ npm install -g node-gyp curl -O http://pear.php.net/go-pear.phar sudo php -d detect_unicode=0 go-pear.phar +# needed to build ruby artifacts +gem install rake-compiler +wget https://raw.githubusercontent.com/grpc/grpc/master/tools/distrib/build_ruby_environment_macos.sh +bash build_ruby_environment_macos.sh + +gem install rubygems-update +update_rubygems tools/run_tests/task_runner.py -f artifact macos From e5de5e5ffa2c664ca1d6ac09c3761a03a1500cb0 Mon Sep 17 00:00:00 2001 From: Eric Gribkoff Date: Thu, 29 Jun 2017 15:23:43 -0700 Subject: [PATCH 68/69] Run Android interops on Firebase --- .../Dockerfile.template | 78 +++++++++++++++++++ .../grpc_interop_android_java/Dockerfile | 76 ++++++++++++++++++ .../interop/android/android_interop_helper.sh | 36 +++++++++ .../android/run_android_tests_on_firebase.sh | 30 +++++++ 4 files changed, 220 insertions(+) create mode 100644 templates/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile.template create mode 100644 tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile create mode 100755 tools/run_tests/interop/android/android_interop_helper.sh create mode 100755 tools/run_tests/interop/android/run_android_tests_on_firebase.sh diff --git a/templates/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile.template b/templates/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile.template new file mode 100644 index 00000000000..3f5b6cf6ce6 --- /dev/null +++ b/templates/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile.template @@ -0,0 +1,78 @@ +%YAML 1.2 +--- | + # Copyright 2017 gRPC authors. + # + # Licensed under the Apache License, Version 2.0 (the "License"); + # you may not use this file except in compliance with the License. + # You may obtain a copy of the License at + # + # http://www.apache.org/licenses/LICENSE-2.0 + # + # Unless required by applicable law or agreed to in writing, software + # distributed under the License is distributed on an "AS IS" BASIS, + # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + # See the License for the specific language governing permissions and + # limitations under the License. + + FROM debian:jessie + + # Install JDK 8 and Git + RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && ${'\\'} + echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'} + echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && ${'\\'} + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 + RUN apt-get update && apt-get -y install ${'\\'} + git ${'\\'} + libapr1 ${'\\'} + oracle-java8-installer ${'\\'} + && ${'\\'} + apt-get clean && rm -r /var/cache/oracle-jdk8-installer/ + ENV JAVA_HOME /usr/lib/jvm/java-8-oracle + ENV PATH $PATH:$JAVA_HOME/bin + + # Install protobuf + RUN apt-get update && apt-get install -y ${'\\'} + autoconf ${'\\'} + build-essential ${'\\'} + curl ${'\\'} + gcc ${'\\'} + libtool ${'\\'} + unzip ${'\\'} + && ${'\\'} + apt-get clean + WORKDIR / + RUN git clone https://github.com/google/protobuf.git + WORKDIR /protobuf + RUN git checkout v3.3.1 && ${'\\'} + ./autogen.sh && ${'\\'} + ./configure && ${'\\'} + make && ${'\\'} + make check && ${'\\'} + make install + + # Install gcloud command line tools + ENV CLOUD_SDK_REPO "cloud-sdk-jessie" + RUN echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && ${'\\'} + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && ${'\\'} + apt-get update && apt-get install -y google-cloud-sdk && apt-get clean && ${'\\'} + gcloud config set component_manager/disable_update_check true + + # Download and install grpc-java + WORKDIR / + RUN git clone https://github.com/grpc/grpc-java.git + WORKDIR /grpc-java + RUN ./gradlew install + + # Setup the Android SDK licenses + ENV ANDROID_HOME "/grpc-java/android-interop-testing/.android" + RUN mkdir -p "<%text>${ANDROID_HOME}/licenses" + RUN echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "<%text>${ANDROID_HOME}/licenses/android-sdk-license" + RUN echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "<%text>${ANDROID_HOME}/licenses/android-sdk-preview-license" + + # Build the Android interop apks + WORKDIR /grpc-java/android-interop-testing + RUN ../gradlew assembleDebug + RUN ../gradlew assembleDebugAndroidTest + + # Define the default command. + CMD ["bash"] diff --git a/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile b/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile new file mode 100644 index 00000000000..35998a3cb27 --- /dev/null +++ b/tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile @@ -0,0 +1,76 @@ +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +FROM debian:jessie + +# Install JDK 8 and Git +RUN echo oracle-java8-installer shared/accepted-oracle-license-v1-1 select true | /usr/bin/debconf-set-selections && \ + echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee /etc/apt/sources.list.d/webupd8team-java.list && \ + echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" | tee -a /etc/apt/sources.list.d/webupd8team-java.list && \ + apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys EEA14886 +RUN apt-get update && apt-get -y install \ + git \ + libapr1 \ + oracle-java8-installer \ + && \ + apt-get clean && rm -r /var/cache/oracle-jdk8-installer/ +ENV JAVA_HOME /usr/lib/jvm/java-8-oracle +ENV PATH $PATH:$JAVA_HOME/bin + +# Install protobuf +RUN apt-get update && apt-get install -y \ + autoconf \ + build-essential \ + curl \ + gcc \ + libtool \ + unzip \ + && \ + apt-get clean +WORKDIR / +RUN git clone https://github.com/google/protobuf.git +WORKDIR /protobuf +RUN git checkout v3.3.1 && \ + ./autogen.sh && \ + ./configure && \ + make && \ + make check && \ + make install + +# Install gcloud command line tools +ENV CLOUD_SDK_REPO "cloud-sdk-jessie" +RUN echo "deb http://packages.cloud.google.com/apt $CLOUD_SDK_REPO main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \ + curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add - && \ + apt-get update && apt-get install -y google-cloud-sdk && apt-get clean && \ + gcloud config set component_manager/disable_update_check true + +# Download and install grpc-java +WORKDIR / +RUN git clone https://github.com/grpc/grpc-java.git +WORKDIR /grpc-java +RUN ./gradlew install + +# Setup the Android SDK licenses +ENV ANDROID_HOME "/grpc-java/android-interop-testing/.android" +RUN mkdir -p "${ANDROID_HOME}/licenses" +RUN echo -e "\n8933bad161af4178b1185d1a37fbf41ea5269c55" > "${ANDROID_HOME}/licenses/android-sdk-license" +RUN echo -e "\n84831b9409646a918e30573bab4c9c91346d8abd" > "${ANDROID_HOME}/licenses/android-sdk-preview-license" + +# Build the Android interop apks +WORKDIR /grpc-java/android-interop-testing +RUN ../gradlew assembleDebug +RUN ../gradlew assembleDebugAndroidTest + +# Define the default command. +CMD ["bash"] diff --git a/tools/run_tests/interop/android/android_interop_helper.sh b/tools/run_tests/interop/android/android_interop_helper.sh new file mode 100755 index 00000000000..9c0d18fba37 --- /dev/null +++ b/tools/run_tests/interop/android/android_interop_helper.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Helper that runs inside the docker container and builds the APKs and +# invokes Firebase Test Lab via gcloud. + +SERVICE_KEY=$1 + +gcloud auth activate-service-account --key-file=$SERVICE_KEY || exit 1 +gcloud config set project grpc-testing || exit 1 + +rm -rf grpc-java +git clone https://github.com/grpc/grpc-java.git +cd grpc-java +./gradlew install || exit 1 +cd android-interop-testing +../gradlew assembleDebug +../gradlew assembleDebugAndroidTest + +gcloud firebase test android run \ + --type instrumentation \ + --app app/build/outputs/apk/app-debug.apk \ + --test app/build/outputs/apk/app-debug-androidTest.apk \ + --device model=Nexus6,version=21,locale=en,orientation=portrait diff --git a/tools/run_tests/interop/android/run_android_tests_on_firebase.sh b/tools/run_tests/interop/android/run_android_tests_on_firebase.sh new file mode 100755 index 00000000000..0b4811355c5 --- /dev/null +++ b/tools/run_tests/interop/android/run_android_tests_on_firebase.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright 2017 gRPC authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Builds the gRPC Android instrumented interop tests inside a docker container +# and runs them on Firebase Test Lab + +DOCKERFILE=tools/dockerfile/interoptest/grpc_interop_android_java/Dockerfile +DOCKER_TAG=android_interop_test +SERVICE_KEY=~/android-interops-service-key.json +HELPER=$(pwd)/tools/run_tests/interop/android/android_interop_helper.sh + +docker build -t $DOCKER_TAG -f $DOCKERFILE . + +docker run --interactive --rm \ + --volume="$SERVICE_KEY":/service-key.json:ro \ + --volume="$HELPER":/android_interop_helper.sh:ro \ + $DOCKER_TAG \ + /bin/bash -c "/android_interop_helper.sh /service-key.json" From c87cbba379b3c9320668f5277e23c9e9e64047b6 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Wed, 5 Jul 2017 13:04:49 -0700 Subject: [PATCH 69/69] Add return code as a field in BQ results uplaod --- tools/run_tests/python_utils/upload_test_results.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/run_tests/python_utils/upload_test_results.py b/tools/run_tests/python_utils/upload_test_results.py index 24c3ec94aea..580e7f7d810 100644 --- a/tools/run_tests/python_utils/upload_test_results.py +++ b/tools/run_tests/python_utils/upload_test_results.py @@ -49,6 +49,7 @@ _RESULTS_SCHEMA = [ ('elapsed_time', 'FLOAT', 'How long test took to run'), ('cpu_estimated', 'FLOAT', 'Estimated CPU usage of test'), ('cpu_measured', 'FLOAT', 'Actual CPU usage of test'), + ('return_code', 'INTEGER', 'Exit code of test'), ] @@ -96,6 +97,7 @@ def upload_results_to_bq(resultset, bq_table, args, platform): test_results['language'] = args.language[0] test_results['platform'] = platform test_results['result'] = result.state + test_results['return_code'] = result.returncode test_results['test_name'] = shortname test_results['timestamp'] = time.strftime('%Y-%m-%d %H:%M:%S')