From 93d802b98615570ada842aef514949780cb83988 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 25 Oct 2016 21:05:49 -0700 Subject: [PATCH 001/119] Add full stack microbenchmark --- Makefile | 46 ++++ build.yaml | 14 ++ test/cpp/microbenchmarks/bm_fullstack.cc | 153 +++++++++++++ tools/run_tests/sources_and_headers.json | 20 ++ .../test/bm_fullstack/bm_fullstack.vcxproj | 210 ++++++++++++++++++ .../bm_fullstack/bm_fullstack.vcxproj.filters | 21 ++ 6 files changed, 464 insertions(+) create mode 100644 test/cpp/microbenchmarks/bm_fullstack.cc create mode 100644 vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj create mode 100644 vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters diff --git a/Makefile b/Makefile index 721a795dae7..e1c03a23dfa 100644 --- a/Makefile +++ b/Makefile @@ -1029,6 +1029,7 @@ wakeup_fd_cv_test: $(BINDIR)/$(CONFIG)/wakeup_fd_cv_test alarm_cpp_test: $(BINDIR)/$(CONFIG)/alarm_cpp_test async_end2end_test: $(BINDIR)/$(CONFIG)/async_end2end_test auth_property_iterator_test: $(BINDIR)/$(CONFIG)/auth_property_iterator_test +bm_fullstack: $(BINDIR)/$(CONFIG)/bm_fullstack channel_arguments_test: $(BINDIR)/$(CONFIG)/channel_arguments_test cli_call_test: $(BINDIR)/$(CONFIG)/cli_call_test client_crash_test: $(BINDIR)/$(CONFIG)/client_crash_test @@ -1411,6 +1412,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/alarm_cpp_test \ $(BINDIR)/$(CONFIG)/async_end2end_test \ $(BINDIR)/$(CONFIG)/auth_property_iterator_test \ + $(BINDIR)/$(CONFIG)/bm_fullstack \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_crash_test \ @@ -1500,6 +1502,7 @@ buildtests_cxx: privatelibs_cxx \ $(BINDIR)/$(CONFIG)/alarm_cpp_test \ $(BINDIR)/$(CONFIG)/async_end2end_test \ $(BINDIR)/$(CONFIG)/auth_property_iterator_test \ + $(BINDIR)/$(CONFIG)/bm_fullstack \ $(BINDIR)/$(CONFIG)/channel_arguments_test \ $(BINDIR)/$(CONFIG)/cli_call_test \ $(BINDIR)/$(CONFIG)/client_crash_test \ @@ -11247,6 +11250,49 @@ endif endif +BM_FULLSTACK_SRC = \ + test/cpp/microbenchmarks/bm_fullstack.cc \ + +BM_FULLSTACK_OBJS = $(addprefix $(OBJDIR)/$(CONFIG)/, $(addsuffix .o, $(basename $(BM_FULLSTACK_SRC)))) +ifeq ($(NO_SECURE),true) + +# You can't build secure targets if you don't have OpenSSL. + +$(BINDIR)/$(CONFIG)/bm_fullstack: openssl_dep_error + +else + + + + +ifeq ($(NO_PROTOBUF),true) + +# You can't build the protoc plugins or protobuf-enabled targets if you don't have protobuf 3.0.0+. + +$(BINDIR)/$(CONFIG)/bm_fullstack: protobuf_dep_error + +else + +$(BINDIR)/$(CONFIG)/bm_fullstack: $(PROTOBUF_DEP) $(BM_FULLSTACK_OBJS) $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + $(E) "[LD] Linking $@" + $(Q) mkdir -p `dirname $@` + $(Q) $(LDXX) $(LDFLAGS) $(BM_FULLSTACK_OBJS) $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBSXX) $(LDLIBS_PROTOBUF) $(LDLIBS) $(LDLIBS_SECURE) $(GTEST_LIB) -o $(BINDIR)/$(CONFIG)/bm_fullstack + +endif + +endif + +$(OBJDIR)/$(CONFIG)/test/cpp/microbenchmarks/bm_fullstack.o: $(LIBDIR)/$(CONFIG)/libgoogle_benchmark.a $(LIBDIR)/$(CONFIG)/libgrpc++_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc_test_util.a $(LIBDIR)/$(CONFIG)/libgrpc++.a $(LIBDIR)/$(CONFIG)/libgrpc.a $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a + +deps_bm_fullstack: $(BM_FULLSTACK_OBJS:.o=.dep) + +ifneq ($(NO_SECURE),true) +ifneq ($(NO_DEPS),true) +-include $(BM_FULLSTACK_OBJS:.o=.dep) +endif +endif + + CHANNEL_ARGUMENTS_TEST_SRC = \ test/cpp/common/channel_arguments_test.cc \ diff --git a/build.yaml b/build.yaml index f2021dbf93d..8bb1e450c81 100644 --- a/build.yaml +++ b/build.yaml @@ -2678,6 +2678,20 @@ targets: - grpc - gpr_test_util - gpr +- name: bm_fullstack + build: test + run: false + language: c++ + src: + - test/cpp/microbenchmarks/bm_fullstack.cc + deps: + - google_benchmark + - grpc++_test_util + - grpc_test_util + - grpc++ + - grpc + - gpr_test_util + - gpr - name: channel_arguments_test gtest: true build: test diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc new file mode 100644 index 00000000000..33f2bf63468 --- /dev/null +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -0,0 +1,153 @@ +/* + * + * 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. + * + */ + +/* Benchmark gRPC end2end in various configurations */ + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "src/proto/grpc/testing/echo.grpc.pb.h" +#include "test/core/util/port.h" +#include "third_party/google_benchmark/include/benchmark/benchmark.h" + +namespace grpc { +namespace testing { + +/******************************************************************************* + * FIXTURES + */ + +class TCPFixture { + public: + TCPFixture(EchoTestService::AsyncService* service) { + ServerBuilder b; + int port = grpc_pick_unused_port_or_die(); + std::stringstream addr; + addr << "localhost:" << port; + b.AddListeningPort(addr.str(), InsecureServerCredentials()); + cq_ = b.AddCompletionQueue(true); + b.RegisterService(service); + server_ = b.BuildAndStart(); + channel_ = CreateChannel(addr.str(), InsecureChannelCredentials()); + } + + ServerCompletionQueue* cq() { return cq_.get(); } + + std::shared_ptr channel() { return channel_; } + + private: + std::unique_ptr server_; + std::unique_ptr cq_; + std::shared_ptr channel_; +}; + +/******************************************************************************* + * BENCHMARKING KERNELS + */ + +static void* tag(intptr_t x) { return reinterpret_cast(x); } + +template +static void BM_UnaryPingPong(benchmark::State& state) { + EchoTestService::AsyncService service; + Fixture fixture(&service); + EchoRequest send_request; + EchoResponse send_response; + EchoResponse recv_response; + Status recv_status; + struct ServerEnv { + ServerContext ctx; + EchoRequest recv_request; + grpc::ServerAsyncResponseWriter response_writer; + ServerEnv() : response_writer(&ctx) {} + }; + uint8_t server_env_buffer[2 * sizeof(ServerEnv)]; + ServerEnv* server_env[2] = { + reinterpret_cast(server_env_buffer), + reinterpret_cast(server_env_buffer + sizeof(ServerEnv))}; + new (server_env[0]) ServerEnv; + new (server_env[1]) ServerEnv; + service.RequestEcho(&server_env[0]->ctx, &server_env[0]->recv_request, + &server_env[0]->response_writer, fixture.cq(), + fixture.cq(), tag(0)); + service.RequestEcho(&server_env[1]->ctx, &server_env[1]->recv_request, + &server_env[1]->response_writer, fixture.cq(), + fixture.cq(), tag(1)); + std::unique_ptr stub( + EchoTestService::NewStub(fixture.channel())); + while (state.KeepRunning()) { + ClientContext cli_ctx; + std::unique_ptr> response_reader( + stub->AsyncEcho(&cli_ctx, send_request, fixture.cq())); + void* t; + bool ok; + GPR_ASSERT(fixture.cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + GPR_ASSERT(t == tag(0) || t == tag(1)); + intptr_t slot = reinterpret_cast(t); + ServerEnv* senv = server_env[slot]; + senv->response_writer.Finish(send_response, Status::OK, tag(3)); + response_reader->Finish(&recv_response, &recv_status, tag(4)); + for (int i = (1 << 3) | (1 << 4); i != 0;) { + GPR_ASSERT(fixture.cq()->Next(&t, &ok)); + GPR_ASSERT(ok); + int tagnum = (int)reinterpret_cast(t); + GPR_ASSERT(i & (1 << tagnum)); + i -= 1 << tagnum; + } + GPR_ASSERT(recv_status.ok()); + + senv->~ServerEnv(); + senv = new (senv) ServerEnv(); + service.RequestEcho(&senv->ctx, &senv->recv_request, &senv->response_writer, + fixture.cq(), fixture.cq(), tag(slot)); + } +} + +/******************************************************************************* + * CONFIGURATIONS + */ + +BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCPFixture); + +} // namespace testing +} // namespace grpc + +BENCHMARK_MAIN(); diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 2d3e669eb82..56cf96873ea 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -2153,6 +2153,26 @@ "third_party": false, "type": "target" }, + { + "deps": [ + "google_benchmark", + "gpr", + "gpr_test_util", + "grpc", + "grpc++", + "grpc++_test_util", + "grpc_test_util" + ], + "headers": [], + "is_filegroup": false, + "language": "c++", + "name": "bm_fullstack", + "src": [ + "test/cpp/microbenchmarks/bm_fullstack.cc" + ], + "third_party": false, + "type": "target" + }, { "deps": [ "gpr", diff --git a/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj b/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj new file mode 100644 index 00000000000..1ce993e3230 --- /dev/null +++ b/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj @@ -0,0 +1,210 @@ + + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {4AAFDA9D-A596-DE6D-8288-A9219D7EBD93} + true + $(SolutionDir)IntDir\$(MSBuildProjectName)\ + + + + v100 + + + v110 + + + v120 + + + v140 + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + + + + bm_fullstack + static + Debug + static + Debug + + + bm_fullstack + static + Release + static + Release + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + Disabled + WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) + true + MultiThreadedDebug + true + None + false + + + Console + true + false + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + NotUsing + Level3 + MaxSpeed + WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) + true + true + true + MultiThreaded + true + None + false + + + Console + true + false + true + true + + + + + + + + + + {AAD4AEF3-DF1E-7A6D-EC35-233BD1031BF4} + + + {0BE77741-552A-929B-A497-4EF7ECE17A64} + + + {17BCAFC0-5FDC-4C94-AEB9-95F3E220614B} + + + {C187A093-A0FE-489D-A40A-6E33DE0F9FEB} + + + {29D16885-7228-4C31-81ED-5F9187C7F2A9} + + + {EAB0A629-17A9-44DB-B5FF-E91A721FE037} + + + {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} + + + + + + + + + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + + + + + diff --git a/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters b/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters new file mode 100644 index 00000000000..76b29ad3bd5 --- /dev/null +++ b/vsprojects/vcxproj/test/bm_fullstack/bm_fullstack.vcxproj.filters @@ -0,0 +1,21 @@ + + + + + test\cpp\microbenchmarks + + + + + + {a2580d22-fbdd-9841-08c9-3173349c0837} + + + {3d07ea20-516b-1ac1-4564-f1f04c929e99} + + + {c130900b-fb0a-d96a-530e-f837d1a9582e} + + + + From 1d0fce9d60494936aa0e79c6b262d113b5b1acd5 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 26 Oct 2016 08:26:22 -0700 Subject: [PATCH 002/119] Add some endpoint pair tests --- include/grpc++/support/channel_arguments.h | 7 ++ src/core/lib/surface/server.c | 11 +- test/cpp/microbenchmarks/bm_fullstack.cc | 131 +++++++++++++++++++-- 3 files changed, 138 insertions(+), 11 deletions(-) diff --git a/include/grpc++/support/channel_arguments.h b/include/grpc++/support/channel_arguments.h index ae243939e9a..79a76d02ea6 100644 --- a/include/grpc++/support/channel_arguments.h +++ b/include/grpc++/support/channel_arguments.h @@ -91,6 +91,13 @@ class ChannelArguments { /// Set a textual argument \a value under \a key. void SetString(const grpc::string& key, const grpc::string& value); + grpc_channel_args c_args() { + grpc_channel_args out; + out.num_args = args_.size(); + out.args = args_.empty() ? NULL : &args_[0]; + return out; + } + private: friend class SecureChannelCredentials; friend class testing::ChannelArgumentsTest; diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 3a90308058c..648c23580a6 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -195,6 +195,7 @@ struct grpc_server { grpc_completion_queue **cqs; grpc_pollset **pollsets; size_t cq_count; + size_t pollset_count; bool started; /* The two following mutexes control access to server-state @@ -1084,7 +1085,7 @@ void grpc_server_start(grpc_server *server) { GRPC_API_TRACE("grpc_server_start(server=%p)", 1, (server)); server->started = true; - size_t pollset_count = 0; + server->pollset_count = 0; server->pollsets = gpr_malloc(sizeof(grpc_pollset *) * server->cq_count); server->request_freelist_per_cq = gpr_malloc(sizeof(*server->request_freelist_per_cq) * server->cq_count); @@ -1092,7 +1093,8 @@ void grpc_server_start(grpc_server *server) { gpr_malloc(sizeof(*server->requested_calls_per_cq) * server->cq_count); for (i = 0; i < server->cq_count; i++) { if (!grpc_cq_is_non_listening_server_cq(server->cqs[i])) { - server->pollsets[pollset_count++] = grpc_cq_pollset(server->cqs[i]); + server->pollsets[server->pollset_count++] = + grpc_cq_pollset(server->cqs[i]); } server->request_freelist_per_cq[i] = gpr_stack_lockfree_create((size_t)server->max_requested_calls_per_cq); @@ -1111,7 +1113,8 @@ void grpc_server_start(grpc_server *server) { } for (l = server->listeners; l; l = l->next) { - l->start(&exec_ctx, server, l->arg, server->pollsets, pollset_count); + l->start(&exec_ctx, server, l->arg, server->pollsets, + server->pollset_count); } grpc_exec_ctx_finish(&exec_ctx); @@ -1119,7 +1122,7 @@ void grpc_server_start(grpc_server *server) { void grpc_server_get_pollsets(grpc_server *server, grpc_pollset ***pollsets, size_t *pollset_count) { - *pollset_count = server->cq_count; + *pollset_count = server->pollset_count; *pollsets = server->pollsets; } diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index 33f2bf63468..11025caa44c 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -37,39 +37,133 @@ #include #include +#include #include #include #include #include #include -#include "src/proto/grpc/testing/echo.grpc.pb.h" +extern "C" { +#include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/iomgr/endpoint.h" +#include "src/core/lib/iomgr/endpoint_pair.h" +#include "src/core/lib/iomgr/exec_ctx.h" +#include "src/core/lib/iomgr/tcp_posix.h" +#include "src/core/lib/surface/channel.h" +#include "src/core/lib/surface/completion_queue.h" +#include "src/core/lib/surface/server.h" +#include "test/core/util/passthru_endpoint.h" #include "test/core/util/port.h" +} +#include "src/cpp/client/create_channel_internal.h" +#include "src/proto/grpc/testing/echo.grpc.pb.h" #include "third_party/google_benchmark/include/benchmark/benchmark.h" namespace grpc { namespace testing { +static class InitializeStuff { + public: + InitializeStuff() { init_lib.init(); } + + private: + internal::GrpcLibrary init_lib; +} initialize_stuff; + /******************************************************************************* * FIXTURES */ -class TCPFixture { +class FullstackFixture { public: - TCPFixture(EchoTestService::AsyncService* service) { + FullstackFixture(Service* service, const grpc::string& address) { ServerBuilder b; + b.AddListeningPort(address, InsecureServerCredentials()); + cq_ = b.AddCompletionQueue(true); + b.RegisterService(service); + server_ = b.BuildAndStart(); + channel_ = CreateChannel(address, InsecureChannelCredentials()); + } + + ServerCompletionQueue* cq() { return cq_.get(); } + std::shared_ptr channel() { return channel_; } + + private: + std::unique_ptr server_; + std::unique_ptr cq_; + std::shared_ptr channel_; +}; + +class TCP : public FullstackFixture { + public: + TCP(Service* service) : FullstackFixture(service, MakeAddress()) {} + + private: + static grpc::string MakeAddress() { int port = grpc_pick_unused_port_or_die(); std::stringstream addr; addr << "localhost:" << port; - b.AddListeningPort(addr.str(), InsecureServerCredentials()); + return addr.str(); + } +}; + +class UDS : public FullstackFixture { + public: + UDS(Service* service) : FullstackFixture(service, "unix:bm_fullstack") {} +}; + +class EndpointPairFixture { + public: + EndpointPairFixture(Service* service, grpc_endpoint_pair endpoints) { + ServerBuilder b; cq_ = b.AddCompletionQueue(true); b.RegisterService(service); server_ = b.BuildAndStart(); - channel_ = CreateChannel(addr.str(), InsecureChannelCredentials()); + + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + + /* add server endpoint to server_ */ + { + const grpc_channel_args* server_args = + grpc_server_get_channel_args(server_->c_server()); + grpc_transport* transport = grpc_create_chttp2_transport( + &exec_ctx, server_args, endpoints.server, 0 /* is_client */); + + grpc_pollset** pollsets; + size_t num_pollsets = 0; + grpc_server_get_pollsets(server_->c_server(), &pollsets, &num_pollsets); + + for (size_t i = 0; i < num_pollsets; i++) { + grpc_endpoint_add_to_pollset(&exec_ctx, endpoints.server, pollsets[i]); + } + + grpc_server_setup_transport(&exec_ctx, server_->c_server(), transport, + NULL, server_args); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); + } + + /* create channel */ + { + ChannelArguments args; + args.SetString(GRPC_ARG_DEFAULT_AUTHORITY, "test.authority"); + + grpc_channel_args c_args = args.c_args(); + grpc_transport* transport = + grpc_create_chttp2_transport(&exec_ctx, &c_args, endpoints.client, 1); + GPR_ASSERT(transport); + grpc_channel* channel = grpc_channel_create( + &exec_ctx, "target", &c_args, GRPC_CLIENT_DIRECT_CHANNEL, transport); + grpc_chttp2_transport_start_reading(&exec_ctx, transport, NULL); + + channel_ = CreateChannelInternal("", channel); + } + + grpc_exec_ctx_finish(&exec_ctx); } ServerCompletionQueue* cq() { return cq_.get(); } - std::shared_ptr channel() { return channel_; } private: @@ -78,6 +172,26 @@ class TCPFixture { std::shared_ptr channel_; }; +class SockPair : public EndpointPairFixture { + public: + SockPair(Service* service) + : EndpointPairFixture(service, + grpc_iomgr_create_endpoint_pair("test", 8192)) {} +}; + +class InProcessCHTTP2 : public EndpointPairFixture { + public: + InProcessCHTTP2(Service* service) + : EndpointPairFixture(service, MakeEndpoints()) {} + + private: + grpc_endpoint_pair MakeEndpoints() { + grpc_endpoint_pair p; + grpc_passthru_endpoint_create(&p.client, &p.server); + return p; + } +}; + /******************************************************************************* * BENCHMARKING KERNELS */ @@ -145,7 +259,10 @@ static void BM_UnaryPingPong(benchmark::State& state) { * CONFIGURATIONS */ -BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCPFixture); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, TCP); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, UDS); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, SockPair); +BENCHMARK_TEMPLATE(BM_UnaryPingPong, InProcessCHTTP2); } // namespace testing } // namespace grpc From fb752d46b69d164a1896915fa026662e783d98a4 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 26 Oct 2016 16:55:23 -0700 Subject: [PATCH 003/119] Always run the benchmarks as tests --- Makefile | 18 +++--- build.yaml | 1 - tools/run_tests/tests.json | 21 +++++++ .../google_benchmark/google_benchmark.vcxproj | 48 +++++++-------- .../google_benchmark.vcxproj.filters | 60 +++++++++---------- 5 files changed, 85 insertions(+), 63 deletions(-) diff --git a/Makefile b/Makefile index f75d4565e75..7863857667b 100644 --- a/Makefile +++ b/Makefile @@ -1795,6 +1795,8 @@ test_cxx: buildtests_cxx $(Q) $(BINDIR)/$(CONFIG)/async_end2end_test || ( echo test async_end2end_test failed ; exit 1 ) $(E) "[RUN] Testing auth_property_iterator_test" $(Q) $(BINDIR)/$(CONFIG)/auth_property_iterator_test || ( echo test auth_property_iterator_test failed ; exit 1 ) + $(E) "[RUN] Testing bm_fullstack" + $(Q) $(BINDIR)/$(CONFIG)/bm_fullstack || ( echo test bm_fullstack failed ; exit 1 ) $(E) "[RUN] Testing channel_arguments_test" $(Q) $(BINDIR)/$(CONFIG)/channel_arguments_test || ( echo test channel_arguments_test failed ; exit 1 ) $(E) "[RUN] Testing cli_call_test" @@ -6738,19 +6740,19 @@ endif LIBGOOGLE_BENCHMARK_SRC = \ - third_party/google_benchmark/src/benchmark.cc \ third_party/google_benchmark/src/benchmark_register.cc \ - third_party/google_benchmark/src/colorprint.cc \ - third_party/google_benchmark/src/commandlineflags.cc \ - third_party/google_benchmark/src/complexity.cc \ - third_party/google_benchmark/src/console_reporter.cc \ - third_party/google_benchmark/src/csv_reporter.cc \ third_party/google_benchmark/src/json_reporter.cc \ + third_party/google_benchmark/src/string_util.cc \ + third_party/google_benchmark/src/console_reporter.cc \ third_party/google_benchmark/src/reporter.cc \ + third_party/google_benchmark/src/timers.cc \ + third_party/google_benchmark/src/commandlineflags.cc \ + third_party/google_benchmark/src/csv_reporter.cc \ + third_party/google_benchmark/src/complexity.cc \ + third_party/google_benchmark/src/benchmark.cc \ + third_party/google_benchmark/src/colorprint.cc \ third_party/google_benchmark/src/sleep.cc \ - third_party/google_benchmark/src/string_util.cc \ third_party/google_benchmark/src/sysinfo.cc \ - third_party/google_benchmark/src/timers.cc \ PUBLIC_HEADERS_CXX += \ diff --git a/build.yaml b/build.yaml index dfba93bc47e..6277f7fbfd4 100644 --- a/build.yaml +++ b/build.yaml @@ -2680,7 +2680,6 @@ targets: - gpr - name: bm_fullstack build: test - run: false language: c++ src: - test/cpp/microbenchmarks/bm_fullstack.cc diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index 06cc30b0d55..71d6017a8b9 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -2143,6 +2143,27 @@ "windows" ] }, + { + "args": [], + "ci_platforms": [ + "linux", + "mac", + "posix", + "windows" + ], + "cpu_cost": 1.0, + "exclude_configs": [], + "flaky": false, + "gtest": false, + "language": "c++", + "name": "bm_fullstack", + "platforms": [ + "linux", + "mac", + "posix", + "windows" + ] + }, { "args": [], "ci_platforms": [ diff --git a/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj b/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj index b0c8d07b236..5de36255a25 100644 --- a/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj +++ b/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj @@ -147,54 +147,54 @@ + + - - - - - - - - - - - + + + + + + + + + + - - - - - - + - + + + + + + + - + - + - + - + - - diff --git a/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj.filters b/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj.filters index 6768675b3cb..e278573ee86 100644 --- a/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj.filters +++ b/vsprojects/vcxproj/google_benchmark/google_benchmark.vcxproj.filters @@ -1,94 +1,97 @@ - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + + third_party\google_benchmark\src + + third_party\google_benchmark\src third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src third_party\google_benchmark\src - + third_party\google_benchmark\src third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - + third_party\google_benchmark\src - - third_party\google_benchmark\src + + third_party\google_benchmark\include\benchmark third_party\google_benchmark\include\benchmark @@ -96,9 +99,6 @@ third_party\google_benchmark\include\benchmark - - third_party\google_benchmark\include\benchmark - third_party\google_benchmark\include\benchmark From f964e772afcbe237cc08e7674e41e381e73a9d75 Mon Sep 17 00:00:00 2001 From: Matt Kwong Date: Thu, 27 Oct 2016 10:45:47 -0700 Subject: [PATCH 004/119] Add --inner_jobs args to run_tests_matrix.py --- tools/run_tests/run_tests_matrix.py | 84 +++++++++++++++++------------ 1 file changed, 51 insertions(+), 33 deletions(-) diff --git a/tools/run_tests/run_tests_matrix.py b/tools/run_tests/run_tests_matrix.py index 21d3dd4a0bc..af24d75236a 100755 --- a/tools/run_tests/run_tests_matrix.py +++ b/tools/run_tests/run_tests_matrix.py @@ -46,16 +46,16 @@ os.chdir(_ROOT) _RUNTESTS_TIMEOUT = 2*60*60 # Number of jobs assigned to each run_tests.py instance -_INNER_JOBS = 2 +_DEFAULT_INNER_JOBS = 2 -def _docker_jobspec(name, runtests_args=[]): +def _docker_jobspec(name, runtests_args=[], inner_jobs=_DEFAULT_INNER_JOBS): """Run a single instance of run_tests.py in a docker container""" test_job = jobset.JobSpec( cmdline=['python', 'tools/run_tests/run_tests.py', '--use_docker', '-t', - '-j', str(_INNER_JOBS), + '-j', str(inner_jobs), '-x', 'report_%s.xml' % name, '--report_suite_name', '%s' % name] + runtests_args, shortname='run_tests_%s' % name, @@ -63,7 +63,7 @@ def _docker_jobspec(name, runtests_args=[]): return test_job -def _workspace_jobspec(name, runtests_args=[], workspace_name=None): +def _workspace_jobspec(name, runtests_args=[], workspace_name=None, inner_jobs=_DEFAULT_INNER_JOBS): """Run a single instance of run_tests.py in a separate workspace""" if not workspace_name: workspace_name = 'workspace_%s' % name @@ -71,7 +71,7 @@ def _workspace_jobspec(name, runtests_args=[], workspace_name=None): test_job = jobset.JobSpec( cmdline=['tools/run_tests/run_tests_in_workspace.sh', '-t', - '-j', str(_INNER_JOBS), + '-j', str(inner_jobs), '-x', '../report_%s.xml' % name, '--report_suite_name', '%s' % name] + runtests_args, environ=env, @@ -82,7 +82,8 @@ def _workspace_jobspec(name, runtests_args=[], workspace_name=None): def _generate_jobs(languages, configs, platforms, arch=None, compiler=None, - labels=[], extra_args=[]): + labels=[], extra_args=[], + inner_jobs=_DEFAULT_INNER_JOBS): result = [] for language in languages: for platform in platforms: @@ -97,60 +98,66 @@ def _generate_jobs(languages, configs, platforms, runtests_args += extra_args if platform == 'linux': - job = _docker_jobspec(name=name, runtests_args=runtests_args) + job = _docker_jobspec(name=name, runtests_args=runtests_args, inner_jobs=inner_jobs) else: - job = _workspace_jobspec(name=name, runtests_args=runtests_args) + job = _workspace_jobspec(name=name, runtests_args=runtests_args, inner_jobs=inner_jobs) job.labels = [platform, config, language] + labels result.append(job) return result -def _create_test_jobs(extra_args=[]): +def _create_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): test_jobs = [] # supported on linux only test_jobs += _generate_jobs(languages=['sanity', 'php7'], configs=['dbg', 'opt'], platforms=['linux'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # supported on all platforms. test_jobs += _generate_jobs(languages=['c', 'csharp', 'node', 'python'], configs=['dbg', 'opt'], platforms=['linux', 'macos', 'windows'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # supported on linux and mac. test_jobs += _generate_jobs(languages=['c++', 'ruby', 'php'], configs=['dbg', 'opt'], platforms=['linux', 'macos'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # supported on mac only. test_jobs += _generate_jobs(languages=['objc'], configs=['dbg', 'opt'], platforms=['macos'], labels=['basictests'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # sanitizers test_jobs += _generate_jobs(languages=['c'], configs=['msan', 'asan', 'tsan'], platforms=['linux'], labels=['sanitizers'], - extra_args=extra_args) + extra_args=extra_args, + inner_jobs=inner_jobs) test_jobs += _generate_jobs(languages=['c++'], configs=['asan', 'tsan'], platforms=['linux'], labels=['sanitizers'], - extra_args=extra_args) + extra_args=extra_args, + inner_jobs=inner_jobs) return test_jobs - -def _create_portability_test_jobs(extra_args=[]): + +def _create_portability_test_jobs(extra_args=[], inner_jobs=_DEFAULT_INNER_JOBS): test_jobs = [] # portability C x86 test_jobs += _generate_jobs(languages=['c'], @@ -159,8 +166,9 @@ def _create_portability_test_jobs(extra_args=[]): arch='x86', compiler='default', labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # portability C and C++ on x64 for compiler in ['gcc4.4', 'gcc4.6', 'gcc5.3', 'clang3.5', 'clang3.6', 'clang3.7']: @@ -170,8 +178,9 @@ def _create_portability_test_jobs(extra_args=[]): arch='x64', compiler=compiler, labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + # portability C on Windows for arch in ['x86', 'x64']: for compiler in ['vs2013', 'vs2015']: @@ -181,24 +190,27 @@ def _create_portability_test_jobs(extra_args=[]): arch=arch, compiler=compiler, labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + test_jobs += _generate_jobs(languages=['python'], configs=['dbg'], platforms=['linux'], arch='default', compiler='python3.4', labels=['portability'], - extra_args=extra_args) - + extra_args=extra_args, + inner_jobs=inner_jobs) + test_jobs += _generate_jobs(languages=['csharp'], configs=['dbg'], platforms=['linux'], arch='default', compiler='coreclr', labels=['portability'], - extra_args=extra_args) - return test_jobs + extra_args=extra_args, + inner_jobs=inner_jobs) + return test_jobs def _allowed_labels(): @@ -212,7 +224,7 @@ def _allowed_labels(): argp = argparse.ArgumentParser(description='Run a matrix of run_tests.py tests.') argp.add_argument('-j', '--jobs', - default=multiprocessing.cpu_count()/_INNER_JOBS, + default=multiprocessing.cpu_count()/_DEFAULT_INNER_JOBS, type=int, help='Number of concurrent run_tests.py instances.') argp.add_argument('-f', '--filter', @@ -241,15 +253,21 @@ argp.add_argument('--base_branch', default='origin/master', type=str, help='Branch that pull request is requesting to merge into') +argp.add_argument('--inner_jobs', + default=_DEFAULT_INNER_JOBS, + type=int, + help='Number of jobs in each run_tests.py instance') args = argp.parse_args() + extra_args = [] if args.build_only: extra_args.append('--build_only') if args.force_default_poller: extra_args.append('--force_default_poller') -all_jobs = _create_test_jobs(extra_args=extra_args) + _create_portability_test_jobs(extra_args=extra_args) +all_jobs = _create_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) + \ + _create_portability_test_jobs(extra_args=extra_args, inner_jobs=args.inner_jobs) jobs = [] for job in all_jobs: From 63ec293d73f7701bca5ecbad82acfa21e1d53d73 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 1 Nov 2016 15:00:41 -0700 Subject: [PATCH 005/119] Integrate resource quotas --- test/cpp/microbenchmarks/bm_fullstack.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index 11025caa44c..5795c7f4f40 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -66,10 +66,16 @@ namespace testing { static class InitializeStuff { public: - InitializeStuff() { init_lib.init(); } + InitializeStuff() { + init_lib_.init(); + rq_ = grpc_resource_quota_create("bm"); + } + + grpc_resource_quota* rq() { return rq_; } private: - internal::GrpcLibrary init_lib; + internal::GrpcLibrary init_lib_; + grpc_resource_quota* rq_; } initialize_stuff; /******************************************************************************* @@ -175,8 +181,9 @@ class EndpointPairFixture { class SockPair : public EndpointPairFixture { public: SockPair(Service* service) - : EndpointPairFixture(service, - grpc_iomgr_create_endpoint_pair("test", 8192)) {} + : EndpointPairFixture(service, grpc_iomgr_create_endpoint_pair( + "test", initialize_stuff.rq(), 8192)) { + } }; class InProcessCHTTP2 : public EndpointPairFixture { @@ -187,7 +194,7 @@ class InProcessCHTTP2 : public EndpointPairFixture { private: grpc_endpoint_pair MakeEndpoints() { grpc_endpoint_pair p; - grpc_passthru_endpoint_create(&p.client, &p.server); + grpc_passthru_endpoint_create(&p.client, &p.server, initialize_stuff.rq()); return p; } }; From b4d883bfc2e474f928e0f52dd225f69c561966b6 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 1 Nov 2016 15:10:22 -0700 Subject: [PATCH 006/119] Make ASAN pass --- test/cpp/microbenchmarks/bm_fullstack.cc | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index 5795c7f4f40..153e9cf1e4c 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -93,6 +93,15 @@ class FullstackFixture { channel_ = CreateChannel(address, InsecureChannelCredentials()); } + virtual ~FullstackFixture() { + server_->Shutdown(); + cq_->Shutdown(); + void* tag; + bool ok; + while (cq_->Next(&tag, &ok)) { + } + } + ServerCompletionQueue* cq() { return cq_.get(); } std::shared_ptr channel() { return channel_; } @@ -169,6 +178,15 @@ class EndpointPairFixture { grpc_exec_ctx_finish(&exec_ctx); } + virtual ~EndpointPairFixture() { + server_->Shutdown(); + cq_->Shutdown(); + void* tag; + bool ok; + while (cq_->Next(&tag, &ok)) { + } + } + ServerCompletionQueue* cq() { return cq_.get(); } std::shared_ptr channel() { return channel_; } @@ -260,6 +278,8 @@ static void BM_UnaryPingPong(benchmark::State& state) { service.RequestEcho(&senv->ctx, &senv->recv_request, &senv->response_writer, fixture.cq(), fixture.cq(), tag(slot)); } + server_env[0]->~ServerEnv(); + server_env[1]->~ServerEnv(); } /******************************************************************************* From ff8e43aa6cd93ed0082017eda7f4161c814019ba Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 1 Nov 2016 15:13:31 -0700 Subject: [PATCH 007/119] Fix memory corruption --- test/cpp/microbenchmarks/bm_fullstack.cc | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/test/cpp/microbenchmarks/bm_fullstack.cc b/test/cpp/microbenchmarks/bm_fullstack.cc index 153e9cf1e4c..07cff885442 100644 --- a/test/cpp/microbenchmarks/bm_fullstack.cc +++ b/test/cpp/microbenchmarks/bm_fullstack.cc @@ -226,7 +226,7 @@ static void* tag(intptr_t x) { return reinterpret_cast(x); } template static void BM_UnaryPingPong(benchmark::State& state) { EchoTestService::AsyncService service; - Fixture fixture(&service); + std::unique_ptr fixture(new Fixture(&service)); EchoRequest send_request; EchoResponse send_response; EchoResponse recv_response; @@ -244,20 +244,20 @@ static void BM_UnaryPingPong(benchmark::State& state) { new (server_env[0]) ServerEnv; new (server_env[1]) ServerEnv; service.RequestEcho(&server_env[0]->ctx, &server_env[0]->recv_request, - &server_env[0]->response_writer, fixture.cq(), - fixture.cq(), tag(0)); + &server_env[0]->response_writer, fixture->cq(), + fixture->cq(), tag(0)); service.RequestEcho(&server_env[1]->ctx, &server_env[1]->recv_request, - &server_env[1]->response_writer, fixture.cq(), - fixture.cq(), tag(1)); + &server_env[1]->response_writer, fixture->cq(), + fixture->cq(), tag(1)); std::unique_ptr stub( - EchoTestService::NewStub(fixture.channel())); + EchoTestService::NewStub(fixture->channel())); while (state.KeepRunning()) { ClientContext cli_ctx; std::unique_ptr> response_reader( - stub->AsyncEcho(&cli_ctx, send_request, fixture.cq())); + stub->AsyncEcho(&cli_ctx, send_request, fixture->cq())); void* t; bool ok; - GPR_ASSERT(fixture.cq()->Next(&t, &ok)); + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); GPR_ASSERT(ok); GPR_ASSERT(t == tag(0) || t == tag(1)); intptr_t slot = reinterpret_cast(t); @@ -265,7 +265,7 @@ static void BM_UnaryPingPong(benchmark::State& state) { senv->response_writer.Finish(send_response, Status::OK, tag(3)); response_reader->Finish(&recv_response, &recv_status, tag(4)); for (int i = (1 << 3) | (1 << 4); i != 0;) { - GPR_ASSERT(fixture.cq()->Next(&t, &ok)); + GPR_ASSERT(fixture->cq()->Next(&t, &ok)); GPR_ASSERT(ok); int tagnum = (int)reinterpret_cast(t); GPR_ASSERT(i & (1 << tagnum)); @@ -276,8 +276,9 @@ static void BM_UnaryPingPong(benchmark::State& state) { senv->~ServerEnv(); senv = new (senv) ServerEnv(); service.RequestEcho(&senv->ctx, &senv->recv_request, &senv->response_writer, - fixture.cq(), fixture.cq(), tag(slot)); + fixture->cq(), fixture->cq(), tag(slot)); } + fixture.reset(); server_env[0]->~ServerEnv(); server_env[1]->~ServerEnv(); } From 84be265239bbc1d1313aa5a0a79b724a847ff5f1 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 27 Oct 2016 23:52:16 -0700 Subject: [PATCH 008/119] strong name sign csharp nuget builds with dotnet on windows --- src/csharp/Grpc.Auth/project.json | 1 - src/csharp/Grpc.Core.Tests/project.json | 2 - src/csharp/Grpc.Core/project.json | 1 - .../Grpc.Examples.MathClient/project.json | 2 - .../Grpc.Examples.MathServer/project.json | 2 - src/csharp/Grpc.Examples.Tests/project.json | 2 - .../Grpc.HealthCheck.Tests/project.json | 2 - src/csharp/Grpc.HealthCheck/project.json | 1 - .../project.json | 2 - .../project.json | 2 - .../project.json | 2 - .../project.json | 2 - .../Grpc.IntegrationTesting/project.json | 2 - src/csharp/build_packages_dotnetcli.bat | 79 +++++++++++++++++++ .../csharp/Grpc.Auth/project.json.template | 1 - .../csharp/Grpc.Core/project.json.template | 1 - .../Grpc.HealthCheck/project.json.template | 1 - templates/src/csharp/build_options.include | 2 - tools/run_tests/package_targets.py | 11 +-- 19 files changed, 81 insertions(+), 37 deletions(-) create mode 100755 src/csharp/build_packages_dotnetcli.bat diff --git a/src/csharp/Grpc.Auth/project.json b/src/csharp/Grpc.Auth/project.json index 6b0df9045a1..06e76b3b7f7 100644 --- a/src/csharp/Grpc.Auth/project.json +++ b/src/csharp/Grpc.Auth/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core.Tests/project.json b/src/csharp/Grpc.Core.Tests/project.json index faf28dcee84..509084a71a6 100644 --- a/src/csharp/Grpc.Core.Tests/project.json +++ b/src/csharp/Grpc.Core.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Core/project.json b/src/csharp/Grpc.Core/project.json index 29d35555c07..dabc05ad276 100644 --- a/src/csharp/Grpc.Core/project.json +++ b/src/csharp/Grpc.Core/project.json @@ -27,7 +27,6 @@ "embed": [ "../../../etc/roots.pem" ], "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true }, "dependencies": { diff --git a/src/csharp/Grpc.Examples.MathClient/project.json b/src/csharp/Grpc.Examples.MathClient/project.json index 628f5329661..9a8880b5d42 100644 --- a/src/csharp/Grpc.Examples.MathClient/project.json +++ b/src/csharp/Grpc.Examples.MathClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.MathServer/project.json b/src/csharp/Grpc.Examples.MathServer/project.json index 628f5329661..9a8880b5d42 100644 --- a/src/csharp/Grpc.Examples.MathServer/project.json +++ b/src/csharp/Grpc.Examples.MathServer/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.Examples.Tests/project.json b/src/csharp/Grpc.Examples.Tests/project.json index 0109617e6b5..3e130beeac9 100644 --- a/src/csharp/Grpc.Examples.Tests/project.json +++ b/src/csharp/Grpc.Examples.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.HealthCheck.Tests/project.json b/src/csharp/Grpc.HealthCheck.Tests/project.json index 66dcd79a397..addc782afe8 100644 --- a/src/csharp/Grpc.HealthCheck.Tests/project.json +++ b/src/csharp/Grpc.HealthCheck.Tests/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -26,7 +25,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.HealthCheck/project.json b/src/csharp/Grpc.HealthCheck/project.json index 62aa361efa2..72ab64a06d5 100644 --- a/src/csharp/Grpc.HealthCheck/project.json +++ b/src/csharp/Grpc.HealthCheck/project.json @@ -15,7 +15,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Client/project.json b/src/csharp/Grpc.IntegrationTesting.Client/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.Client/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Client/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json +++ b/src/csharp/Grpc.IntegrationTesting.QpsWorker/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.Server/project.json b/src/csharp/Grpc.IntegrationTesting.Server/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.Server/project.json +++ b/src/csharp/Grpc.IntegrationTesting.Server/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json index 1b900c8af32..ad81cbc48b3 100644 --- a/src/csharp/Grpc.IntegrationTesting.StressClient/project.json +++ b/src/csharp/Grpc.IntegrationTesting.StressClient/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/Grpc.IntegrationTesting/project.json b/src/csharp/Grpc.IntegrationTesting/project.json index 0225abb4148..e47b5953da0 100644 --- a/src/csharp/Grpc.IntegrationTesting/project.json +++ b/src/csharp/Grpc.IntegrationTesting/project.json @@ -7,7 +7,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -29,7 +28,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/src/csharp/build_packages_dotnetcli.bat b/src/csharp/build_packages_dotnetcli.bat new file mode 100755 index 00000000000..b0e358fdff9 --- /dev/null +++ b/src/csharp/build_packages_dotnetcli.bat @@ -0,0 +1,79 @@ +@rem Copyright 2016, Google Inc. +@rem All rights reserved. +@rem +@rem Redistribution and use in source and binary forms, with or without +@rem modification, are permitted provided that the following conditions are +@rem met: +@rem +@rem * Redistributions of source code must retain the above copyright +@rem notice, this list of conditions and the following disclaimer. +@rem * Redistributions in binary form must reproduce the above +@rem copyright notice, this list of conditions and the following disclaimer +@rem in the documentation and/or other materials provided with the +@rem distribution. +@rem * Neither the name of Google Inc. nor the names of its +@rem contributors may be used to endorse or promote products derived from +@rem this software without specific prior written permission. +@rem +@rem THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +@rem "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +@rem LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +@rem A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +@rem OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +@rem SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +@rem LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +@rem DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +@rem THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +@rem (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +@rem OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +@rem Current package versions +set VERSION=1.0.1 +set PROTOBUF_VERSION=3.0.0 + +@rem Adjust the location of nuget.exe +set NUGET=C:\nuget\nuget.exe +set DOTNET=C:\dotnet\dotnet.exe + +set -ex + +mkdir -p ..\..\artifacts\ + +@rem Collect the artifacts built by the previous build step if running on Jenkins +@rem TODO(jtattermusch): is there a better way to do this? +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=windows\artifacts\* nativelibs\windows_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=windows\artifacts\* nativelibs\windows_x64\ +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=linux\artifacts\* nativelibs\linux_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=linux\artifacts\* nativelibs\linux_x64\ +xcopy /Y /I ..\..\architecture=x86,language=csharp,platform=macos\artifacts\* nativelibs\macosx_x86\ +xcopy /Y /I ..\..\architecture=x64,language=csharp,platform=macos\artifacts\* nativelibs\macosx_x64\ + +@rem Collect protoc artifacts built by the previous build step +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=windows\artifacts\* protoc_plugins\windows_x64\ +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=linux\artifacts\* protoc_plugins\linux_x64\ +xcopy /Y /I ..\..\architecture=x86,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x86\ +xcopy /Y /I ..\..\architecture=x64,language=protoc,platform=macos\artifacts\* protoc_plugins\macosx_x64\ + +%DOTNET% restore . || goto :error + +%DOTNET% pack --configuration Release Grpc.Core\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.Auth\project.json --output ..\..\artifacts || goto :error +%DOTNET% pack --configuration Release Grpc.HealthCheck\project.json --output ..\..\artifacts || goto :error + +%NUGET% pack Grpc.nuspec -Version "1.0.1" -OutputDirectory ..\..\artifacts || goto :error +%NUGET% pack Grpc.Tools.nuspec -Version "1.0.1" -OutputDirectory ..\..\artifacts + +@rem copy resulting nuget packages to artifacts directory +xcopy /Y /I *.nupkg ..\..\artifacts\ || goto :error + +@rem create a zipfile with the artifacts as well +powershell -Command "Add-Type -Assembly 'System.IO.Compression.FileSystem'; [System.IO.Compression.ZipFile]::CreateFromDirectory('..\..\artifacts', 'csharp_nugets_windows_dotnetcli.zip');" +xcopy /Y /I csharp_nugets_windows_dotnetcli.zip ..\..\artifacts\ || goto :error + +goto :EOF + +:error +echo Failed! +exit /b %errorlevel% diff --git a/templates/src/csharp/Grpc.Auth/project.json.template b/templates/src/csharp/Grpc.Auth/project.json.template index 939a0c8d280..8bcac1ac740 100644 --- a/templates/src/csharp/Grpc.Auth/project.json.template +++ b/templates/src/csharp/Grpc.Auth/project.json.template @@ -17,7 +17,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/templates/src/csharp/Grpc.Core/project.json.template b/templates/src/csharp/Grpc.Core/project.json.template index fcbef536c63..88895e7b6ca 100644 --- a/templates/src/csharp/Grpc.Core/project.json.template +++ b/templates/src/csharp/Grpc.Core/project.json.template @@ -29,7 +29,6 @@ "embed": [ "../../../etc/roots.pem" ], "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true }, "dependencies": { diff --git a/templates/src/csharp/Grpc.HealthCheck/project.json.template b/templates/src/csharp/Grpc.HealthCheck/project.json.template index 46307dda002..cba68940153 100644 --- a/templates/src/csharp/Grpc.HealthCheck/project.json.template +++ b/templates/src/csharp/Grpc.HealthCheck/project.json.template @@ -17,7 +17,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/templates/src/csharp/build_options.include b/templates/src/csharp/build_options.include index bda2d760747..9a32b7c6f45 100644 --- a/templates/src/csharp/build_options.include +++ b/templates/src/csharp/build_options.include @@ -10,7 +10,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] @@ -34,7 +33,6 @@ "buildOptions": { "define": [ "SIGNED" ], "keyFile": "../keys/Grpc.snk", - "publicSign": true, "xmlDoc": true, "compile": { "includeFiles": [ "../Grpc.Core/Version.cs" ] diff --git a/tools/run_tests/package_targets.py b/tools/run_tests/package_targets.py index 14d30cf06d6..1b66b5d9357 100644 --- a/tools/run_tests/package_targets.py +++ b/tools/run_tests/package_targets.py @@ -81,14 +81,7 @@ class CSharpPackage: self.labels += ['windows'] def pre_build_jobspecs(self): - if 'windows' in self.labels: - return [create_jobspec('prebuild_%s' % self.name, - ['tools\\run_tests\\pre_build_csharp.bat'], - shell=True, - flake_retries=5, - timeout_retries=2)] - else: - return [] + return [] # now using dotnet cli to build all packages def build_jobspec(self): if self.use_dotnet_cli: @@ -98,7 +91,7 @@ class CSharpPackage: 'src/csharp/build_packages_dotnetcli.sh') else: return create_jobspec(self.name, - ['build_packages.bat'], + ['build_packages_dotnetcli.bat'], cwd='src\\csharp', shell=True) From c064ff4e5667282545d23954b90b912da5362799 Mon Sep 17 00:00:00 2001 From: Alex Polcyn Date: Tue, 1 Nov 2016 18:58:56 -0700 Subject: [PATCH 009/119] keep old obsolete csharp package builds but add windows dotnetcli package build. change names of package build targets too --- tools/run_tests/package_targets.py | 40 ++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/tools/run_tests/package_targets.py b/tools/run_tests/package_targets.py index 1b66b5d9357..05183db87cc 100644 --- a/tools/run_tests/package_targets.py +++ b/tools/run_tests/package_targets.py @@ -71,29 +71,52 @@ def create_jobspec(name, cmdline, environ=None, cwd=None, shell=False, class CSharpPackage: """Builds C# nuget packages.""" - def __init__(self, use_dotnet_cli=False): + def __init__(self, linux=False, use_dotnet_cli=True): + self.linux = linux self.use_dotnet_cli = use_dotnet_cli - self.name = 'csharp_package_dotnetcli' if use_dotnet_cli else 'csharp_package' + self.labels = ['package', 'csharp'] + if use_dotnet_cli: - self.labels += ['linux'] + if linux: + self.name = 'csharp_package_dotnetcli_linux' + self.labels += ['linux'] + else: + self.name = 'csharp_package_dotnetcli_windows' + self.labels += ['windows'] else: - self.labels += ['windows'] + # official packages built with dotnet cli rather than nuget pack + self.name = 'csharp_package_obsolete' + self.labels += ['obsolete'] + def pre_build_jobspecs(self): - return [] # now using dotnet cli to build all packages + # The older, obsolete build uses nuget only instead of dotnet cli + if 'obsolete' in self.labels: + return [create_jobspec('prebuild_%s' % self.name, + ['tools\\run_tests\\pre_build_csharp.bat'], + shell=True, + flake_retries=5, + timeout_retries=2)] + else: + return [] def build_jobspec(self): - if self.use_dotnet_cli: + if self.use_dotnet_cli and self.linux: return create_docker_jobspec( self.name, 'tools/dockerfile/test/csharp_coreclr_x64', 'src/csharp/build_packages_dotnetcli.sh') - else: + elif self.use_dotnet_cli: return create_jobspec(self.name, ['build_packages_dotnetcli.bat'], cwd='src\\csharp', shell=True) + else: + return create_jobspec(self.name, + ['build_packages.bat'], + cwd='src\\csharp', + shell=True) def __str__(self): return self.name @@ -170,7 +193,8 @@ class PHPPackage: def targets(): """Gets list of supported targets""" return [CSharpPackage(), - CSharpPackage(use_dotnet_cli=True), + CSharpPackage(linux=True), + CSharpPackage(use_dotnet_cli=False), NodePackage(), RubyPackage(), PythonPackage(), From c968e60e2ef60cd20353c34fb6260a63ce9db031 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Wed, 2 Nov 2016 14:07:36 -0700 Subject: [PATCH 010/119] Use JSON for service config channel arg. --- src/core/ext/client_channel/client_channel.c | 51 ++++++-- src/core/lib/channel/message_size_filter.c | 34 ++++-- src/core/lib/support/string.c | 9 ++ src/core/lib/support/string.h | 3 + src/core/lib/transport/method_config.c | 122 +++++++++++++++++++ src/core/lib/transport/method_config.h | 7 ++ 6 files changed, 202 insertions(+), 24 deletions(-) diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index ff773ac3348..e569af68e93 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -94,17 +94,44 @@ static int method_parameters_cmp(void *value1, void *value2) { static const grpc_mdstr_hash_table_vtable method_parameters_vtable = { gpr_free, method_parameters_copy, method_parameters_cmp}; -static void *method_config_convert_value( - const grpc_method_config *method_config) { +static void *method_config_convert_value(const grpc_json *json) { + wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET; + gpr_timespec timeout = { 0, 0, GPR_TIMESPAN }; + for (grpc_json* field = json->child; field != NULL; field = field->next) { + if (field->key == NULL) continue; + if (strcmp(field->key, "wait_for_ready") == 0) { + if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate. + if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) { + return NULL; + } + wait_for_ready = field->type == GRPC_JSON_TRUE; + } else if (strcmp(field->key, "timeout") == 0) { + if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate. + if (field->type != GRPC_JSON_OBJECT) return NULL; + if (field->child == NULL) return NULL; + for (grpc_json* subfield = field->child; subfield != NULL; + subfield = subfield->next) { + if (subfield->key == NULL) return NULL; + if (strcmp(subfield->key, "seconds") == 0) { + if (timeout.tv_sec > 0) return NULL; // Duplicate. + if (subfield->type != GRPC_JSON_NUMBER) return NULL; + timeout.tv_sec = gpr_parse_nonnegative_number(subfield->value); + if (timeout.tv_sec == -1) return NULL; + } else if (strcmp(subfield->key, "nanos") == 0) { + if (timeout.tv_nsec > 0) return NULL; // Duplicate. + if (subfield->type != GRPC_JSON_NUMBER) return NULL; + timeout.tv_nsec = gpr_parse_nonnegative_number(subfield->value); + if (timeout.tv_nsec == -1) return NULL; + } else { + // Unknown key. + return NULL; + } + } + } + } method_parameters *value = gpr_malloc(sizeof(method_parameters)); - const gpr_timespec *timeout = grpc_method_config_get_timeout(method_config); - value->timeout = timeout != NULL ? *timeout : gpr_time_0(GPR_TIMESPAN); - const bool *wait_for_ready = - grpc_method_config_get_wait_for_ready(method_config); - value->wait_for_ready = - wait_for_ready == NULL - ? WAIT_FOR_READY_UNSET - : (wait_for_ready ? WAIT_FOR_READY_TRUE : WAIT_FOR_READY_FALSE); + value->timeout = timeout; + value->wait_for_ready = wait_for_ready; return value; } @@ -285,8 +312,8 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); - method_params_table = grpc_method_config_table_convert( - (grpc_method_config_table *)channel_arg->value.pointer.p, + method_params_table = grpc_method_config_table_create_from_json( + (grpc_json *)channel_arg->value.pointer.p, method_config_convert_value, &method_parameters_vtable); } grpc_channel_args_destroy(chand->resolver_result); diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 7dc5ae0df15..4723ab80981 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -39,6 +39,7 @@ #include #include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/support/string.h" #include "src/core/lib/transport/method_config.h" #define DEFAULT_MAX_SEND_MESSAGE_LENGTH -1 // Unlimited. @@ -69,17 +70,26 @@ static int message_size_limits_cmp(void* value1, void* value2) { static const grpc_mdstr_hash_table_vtable message_size_limits_vtable = { gpr_free, message_size_limits_copy, message_size_limits_cmp}; -static void* method_config_convert_value( - const grpc_method_config* method_config) { +static void* method_config_convert_value(const grpc_json* json) { + int max_request_message_bytes = -1; + int max_response_message_bytes = -1; + for (grpc_json* field = json->child; field != NULL; field = field->next) { + if (field->key == NULL) continue; + if (strcmp(field->key, "max_request_message_bytes") == 0) { + if (max_request_message_bytes >= 0) return NULL; // Duplicate. + if (field->type != GRPC_JSON_NUMBER) return NULL; + max_request_message_bytes = gpr_parse_nonnegative_number(field->value); + if (max_request_message_bytes == -1) return NULL; + } else if (strcmp(field->key, "max_response_message_bytes") == 0) { + if (max_response_message_bytes >= 0) return NULL; // Duplicate. + if (field->type != GRPC_JSON_NUMBER) return NULL; + max_response_message_bytes = gpr_parse_nonnegative_number(field->value); + if (max_response_message_bytes == -1) return NULL; + } + } message_size_limits* value = gpr_malloc(sizeof(message_size_limits)); - const int32_t* max_request_message_bytes = - grpc_method_config_get_max_request_message_bytes(method_config); - value->max_send_size = - max_request_message_bytes != NULL ? *max_request_message_bytes : -1; - const int32_t* max_response_message_bytes = - grpc_method_config_get_max_response_message_bytes(method_config); - value->max_recv_size = - max_response_message_bytes != NULL ? *max_response_message_bytes : -1; + value->max_send_size = max_request_message_bytes; + value->max_recv_size = max_response_message_bytes; return value; } @@ -224,8 +234,8 @@ static void init_channel_elem(grpc_exec_ctx* exec_ctx, grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); - chand->method_limit_table = grpc_method_config_table_convert( - (grpc_method_config_table*)channel_arg->value.pointer.p, + chand->method_limit_table = grpc_method_config_table_create_from_json( + (grpc_json*)channel_arg->value.pointer.p, method_config_convert_value, &message_size_limits_vtable); } } diff --git a/src/core/lib/support/string.c b/src/core/lib/support/string.c index d17fb9da4b0..56f29492bf0 100644 --- a/src/core/lib/support/string.c +++ b/src/core/lib/support/string.c @@ -34,7 +34,9 @@ #include "src/core/lib/support/string.h" #include +#include #include +#include #include #include @@ -194,6 +196,13 @@ int int64_ttoa(int64_t value, char *string) { return i; } +int gpr_parse_nonnegative_number(const char* value) { + char* end; + long result = strtol(value, &end, 0); + if (*end != '\0' || result < 0 || result > INT_MAX) return -1; + return (int)result; +} + char *gpr_leftpad(const char *str, char flag, size_t length) { const size_t str_length = strlen(str); const size_t out_length = str_length > length ? str_length : length; diff --git a/src/core/lib/support/string.h b/src/core/lib/support/string.h index 9a94e9471cf..3a5a8ed826f 100644 --- a/src/core/lib/support/string.h +++ b/src/core/lib/support/string.h @@ -80,6 +80,9 @@ NOTE: This function ensures sufficient bit width even on Win x64, where long is 32bit is size.*/ int int64_ttoa(int64_t value, char *output); +// Parses a non-negative number from a value string. Returns -1 on error. +int gpr_parse_nonnegative_number(const char* value); + /* Reverse a run of bytes */ void gpr_reverse_bytes(char *str, int len); diff --git a/src/core/lib/transport/method_config.c b/src/core/lib/transport/method_config.c index 57d97700bfe..23cab2b96b0 100644 --- a/src/core/lib/transport/method_config.c +++ b/src/core/lib/transport/method_config.c @@ -39,6 +39,8 @@ #include #include +#include "src/core/lib/json/json.h" +#include "src/core/lib/support/string.h" #include "src/core/lib/transport/mdstr_hash_table.h" #include "src/core/lib/transport/metadata.h" @@ -338,3 +340,123 @@ grpc_mdstr_hash_table* grpc_method_config_table_convert( // Return the new table. return new_table; } + +// Returns the number of names specified in the method config \a json. +static size_t count_names_in_method_config_json(grpc_json* json) { + size_t num_names = 0; + for (grpc_json* field = json->child; field != NULL; field = field->next) { + if (field->key != NULL && strcmp(field->key, "name") == 0) ++num_names; + } + return num_names; +} + +// Returns a path string for the name specified by \a json. +// Returns NULL on error. Caller takes ownership of result. +static char* parse_json_method_name(grpc_json* json) { + if (json->type != GRPC_JSON_OBJECT) return NULL; + const char* service_name = NULL; + const char* method_name = NULL; + for (grpc_json* child = json->child; child != NULL; child = child->next) { + if (child->key == NULL) return NULL; + if (child->type != GRPC_JSON_STRING) return NULL; + if (strcmp(child->key, "service") == 0) { + if (service_name != NULL) return NULL; // Duplicate. + if (child->value == NULL) return NULL; + service_name = child->value; + } else if (strcmp(child->key, "method") == 0) { + if (method_name != NULL) return NULL; // Duplicate. + if (child->value == NULL) return NULL; + method_name = child->value; + } + } + if (service_name == NULL) return NULL; // Required field. + char* path; + gpr_asprintf(&path, "/%s/%s", service_name, + method_name == NULL ? "*" : method_name); + return path; +} + +// Parses the method config from \a json. Adds an entry to \a entries for +// each name found, incrementing \a idx for each entry added. +static bool parse_json_method_config( + grpc_json* json, + void* (*create_value)(const grpc_json* method_config_json), + const grpc_mdstr_hash_table_vtable* vtable, + grpc_mdstr_hash_table_entry* entries, size_t *idx) { + // Construct value. + void* method_config = create_value(json); + if (method_config == NULL) return NULL; + // Construct list of paths. + bool retval = false; + gpr_strvec paths; + gpr_strvec_init(&paths); + for (grpc_json* child = json->child; child != NULL; child = child->next) { + if (child->key == NULL) continue; + if (strcmp(child->key, "name") == 0) { + if (child->type != GRPC_JSON_ARRAY) goto done; + for (grpc_json* name = child->child; name != NULL; name = name->next) { + char* path = parse_json_method_name(name); + gpr_strvec_add(&paths, path); + } + } + } + if (paths.count == 0) goto done; // No names specified. + // Add entry for each path. + for (size_t i = 0; i < paths.count; ++i) { + entries[*idx].key = grpc_mdstr_from_string(paths.strs[i]); + entries[*idx].value = vtable->copy_value(method_config); + entries[*idx].vtable = vtable; + ++*idx; + } + retval = true; +done: + vtable->destroy_value(method_config); + gpr_strvec_destroy(&paths); + return retval; +} + +grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( + const grpc_json* json, + void* (*create_value)(const grpc_json* method_config_json), + const grpc_mdstr_hash_table_vtable* vtable) { + // Traverse parsed JSON tree. + if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL; + size_t num_entries = 0; + grpc_mdstr_hash_table_entry* entries = NULL; + for (grpc_json* field = json->child; field != NULL; field = field->next) { + if (field->key == NULL) return NULL; + if (strcmp(field->key, "method_config") == 0) { + if (entries != NULL) return NULL; // Duplicate. + if (field->type != GRPC_JSON_ARRAY) return NULL; + // Find number of entries. + for (grpc_json* method = field->child; method != NULL; + method = method->next) { + num_entries += count_names_in_method_config_json(method); + } + // Populate method config table entries. + entries = + gpr_malloc(num_entries * sizeof(grpc_method_config_table_entry)); + size_t idx = 0; + for (grpc_json* method = field->child; method != NULL; + method = method->next) { + if (!parse_json_method_config(method, create_value, vtable, entries, + &idx)) { + return NULL; + } + } + GPR_ASSERT(idx == num_entries); + } + } + // Instantiate method config table. + grpc_mdstr_hash_table* method_config_table = NULL; + if (entries != NULL) { + method_config_table = grpc_mdstr_hash_table_create(num_entries, entries); + // Clean up. + for (size_t i = 0; i < num_entries; ++i) { + GRPC_MDSTR_UNREF(entries[i].key); + vtable->destroy_value(entries[i].value); + } + gpr_free(entries); + } + return method_config_table; +} diff --git a/src/core/lib/transport/method_config.h b/src/core/lib/transport/method_config.h index 58fedd94366..eac05f8173a 100644 --- a/src/core/lib/transport/method_config.h +++ b/src/core/lib/transport/method_config.h @@ -37,6 +37,7 @@ #include #include +#include "src/core/lib/json/json.h" #include "src/core/lib/transport/mdstr_hash_table.h" #include "src/core/lib/transport/metadata.h" @@ -133,4 +134,10 @@ grpc_mdstr_hash_table* grpc_method_config_table_convert( void* (*convert_value)(const grpc_method_config* method_config), const grpc_mdstr_hash_table_vtable* vtable); +// FIXME: document +grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( + const grpc_json* json, + void* (*create_value)(const grpc_json* method_config_json), + const grpc_mdstr_hash_table_vtable* vtable); + #endif /* GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H */ From 896d92568b1b615a19dec26035596de244cbf535 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 07:58:25 -0700 Subject: [PATCH 011/119] Add grpc_json_tree to handle refcounting for channel arg. --- src/core/ext/client_channel/client_channel.c | 8 ++- src/core/lib/channel/message_size_filter.c | 5 +- src/core/lib/json/json.c | 59 +++++++++++++++++++ src/core/lib/json/json.h | 19 ++++++ src/core/lib/transport/method_config.c | 23 ++++++++ src/core/lib/transport/method_config.h | 2 + test/core/end2end/connection_refused_test.c | 22 +++---- test/core/end2end/tests/cancel_after_accept.c | 23 ++++---- test/core/end2end/tests/max_message_length.c | 47 +++++++-------- 9 files changed, 155 insertions(+), 53 deletions(-) diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index e569af68e93..4a1c0ae1a22 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -104,7 +104,8 @@ static void *method_config_convert_value(const grpc_json *json) { if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) { return NULL; } - wait_for_ready = field->type == GRPC_JSON_TRUE; + wait_for_ready = field->type == GRPC_JSON_TRUE + ? WAIT_FOR_READY_TRUE : WAIT_FOR_READY_FALSE; } else if (strcmp(field->key, "timeout") == 0) { if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate. if (field->type != GRPC_JSON_OBJECT) return NULL; @@ -312,9 +313,10 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); + grpc_json_tree* json_tree = channel_arg->value.pointer.p; method_params_table = grpc_method_config_table_create_from_json( - (grpc_json *)channel_arg->value.pointer.p, - method_config_convert_value, &method_parameters_vtable); + json_tree->root, method_config_convert_value, + &method_parameters_vtable); } grpc_channel_args_destroy(chand->resolver_result); chand->resolver_result = NULL; diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 4723ab80981..86fdf72684d 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -234,9 +234,10 @@ static void init_channel_elem(grpc_exec_ctx* exec_ctx, grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); + grpc_json_tree* json_tree = channel_arg->value.pointer.p; chand->method_limit_table = grpc_method_config_table_create_from_json( - (grpc_json*)channel_arg->value.pointer.p, - method_config_convert_value, &message_size_limits_vtable); + json_tree->root, method_config_convert_value, + &message_size_limits_vtable); } } diff --git a/src/core/lib/json/json.c b/src/core/lib/json/json.c index 5b583a1f2e0..c1a99df6c37 100644 --- a/src/core/lib/json/json.c +++ b/src/core/lib/json/json.c @@ -34,6 +34,8 @@ #include #include +#include +#include #include "src/core/lib/json/json.h" @@ -62,3 +64,60 @@ void grpc_json_destroy(grpc_json *json) { gpr_free(json); } + +int grpc_json_cmp(const grpc_json* json1, const grpc_json* json2) { + if (json1 == NULL) { + if (json2 != NULL) return 1; + return 0; // Both NULL. + } else { + if (json2 == NULL) return -1; + } + // Compare type. + if (json1->type > json2->type) return 1; + if (json1->type < json2->type) return -1; + // Compare key. + if (json1->key == NULL) { + if (json2->key != NULL) return -1; + } else { + if (json2->key == NULL) return 1; + int retval = strcmp(json1->key, json2->key); + if (retval != 0) return retval; + } + // Compare value. + if (json1->value == NULL) { + if (json2->value != NULL) return -1; + } else { + if (json2->value == NULL) return 1; + int retval = strcmp(json1->value, json2->value); + if (retval != 0) return retval; + } + // Recursively compare the next pointer. + int retval = grpc_json_cmp(json1->next, json2->next); + if (retval != 0) return retval; + // Recursively compare the child pointer. + retval = grpc_json_cmp(json1->child, json2->child); + if (retval != 0) return retval; + // Both are the same. + return 0; +} + +grpc_json_tree* grpc_json_tree_create(const char* json_string) { + grpc_json_tree* tree = gpr_malloc(sizeof(*tree)); + tree->string = gpr_strdup(json_string); + tree->root = grpc_json_parse_string(tree->string); + gpr_ref_init(&tree->refs, 1); + return tree; +} + +grpc_json_tree* grpc_json_tree_ref(grpc_json_tree* tree) { + gpr_ref(&tree->refs); + return tree; +} + +void grpc_json_tree_unref(grpc_json_tree* tree) { + if (gpr_unref(&tree->refs)) { + grpc_json_destroy(tree->root); + gpr_free(tree->string); + gpr_free(tree); + } +} diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index 681df4bb77d..e18ace7547a 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -36,6 +36,8 @@ #include +#include + #include "src/core/lib/json/json_common.h" /* A tree-like structure to hold json values. The key and value pointers @@ -85,4 +87,21 @@ char *grpc_json_dump_to_string(grpc_json *json, int indent); grpc_json *grpc_json_create(grpc_json_type type); void grpc_json_destroy(grpc_json *json); +/* Compares two JSON trees. */ +int grpc_json_cmp(const grpc_json* json1, const grpc_json* json2); + +/* A wrapper that contains the string used for underlying allocation and + is refcounted. */ +typedef struct { + grpc_json* root; + char* string; + gpr_refcount refs; +} grpc_json_tree; + +/* Creates a copy of \a json_string. */ +grpc_json_tree* grpc_json_tree_create(const char* json_string); + +grpc_json_tree* grpc_json_tree_ref(grpc_json_tree* tree); +void grpc_json_tree_unref(grpc_json_tree* tree); + #endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/src/core/lib/transport/method_config.c b/src/core/lib/transport/method_config.c index 23cab2b96b0..c2bf88a2503 100644 --- a/src/core/lib/transport/method_config.c +++ b/src/core/lib/transport/method_config.c @@ -460,3 +460,26 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( } return method_config_table; } + +static void* copy_json_tree(void* t) { return grpc_json_tree_ref(t); } + +static void destroy_json_tree(void* t) { grpc_json_tree_unref(t); } + +static int cmp_json_tree(void* t1, void* t2) { + grpc_json_tree* tree1 = t1; + grpc_json_tree* tree2 = t2; + return grpc_json_cmp(tree1->root, tree2->root); +} + +static grpc_arg_pointer_vtable service_config_arg_vtable = { + copy_json_tree, destroy_json_tree, cmp_json_tree}; + +grpc_arg grpc_service_config_create_channel_arg( + grpc_json_tree* service_config) { + grpc_arg arg; + arg.type = GRPC_ARG_POINTER; + arg.key = GRPC_ARG_SERVICE_CONFIG; + arg.value.pointer.p = service_config; + arg.value.pointer.vtable = &service_config_arg_vtable; + return arg; +} diff --git a/src/core/lib/transport/method_config.h b/src/core/lib/transport/method_config.h index eac05f8173a..84c6329415b 100644 --- a/src/core/lib/transport/method_config.h +++ b/src/core/lib/transport/method_config.h @@ -140,4 +140,6 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( void* (*create_value)(const grpc_json* method_config_json), const grpc_mdstr_hash_table_vtable* vtable); +grpc_arg grpc_service_config_create_channel_arg(grpc_json_tree* service_config); + #endif /* GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H */ diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c index 13414c0378b..ba9fb3d30a0 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -76,18 +76,18 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_channel_args *args = NULL; if (use_service_config) { GPR_ASSERT(wait_for_ready); - grpc_method_config_table_entry entry = { - grpc_mdstr_from_string("/service/method"), - grpc_method_config_create(&wait_for_ready, NULL, NULL, NULL), - }; - grpc_method_config_table *method_config_table = - grpc_method_config_table_create(1, &entry); - GRPC_MDSTR_UNREF(entry.method_name); - grpc_method_config_unref(entry.method_config); - grpc_arg arg = - grpc_method_config_table_create_channel_arg(method_config_table); + grpc_json_tree* service_config_json = grpc_json_tree_create( + "{\n" + " \"method_config\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"wait_for_ready\": true\n" + " } ]\n" + "}"); + grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); args = grpc_channel_args_copy_and_add(args, &arg, 1); - grpc_method_config_table_unref(method_config_table); + grpc_json_tree_unref(service_config_json); } /* create a call, channel to a port which will refuse connection */ diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 104d8fd54fd..68a82560927 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -132,19 +132,18 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_channel_args *args = NULL; if (use_service_config) { - gpr_timespec timeout = {5, 0, GPR_TIMESPAN}; - grpc_method_config_table_entry entry = { - grpc_mdstr_from_string("/service/method"), - grpc_method_config_create(NULL, &timeout, NULL, NULL), - }; - grpc_method_config_table *method_config_table = - grpc_method_config_table_create(1, &entry); - GRPC_MDSTR_UNREF(entry.method_name); - grpc_method_config_unref(entry.method_config); - grpc_arg arg = - grpc_method_config_table_create_channel_arg(method_config_table); + grpc_json_tree* service_config_json = grpc_json_tree_create( + "{\n" + " \"method_config\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"timeout\": { \"seconds\": 5 }\n" + " } ]\n" + "}"); + grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); args = grpc_channel_args_copy_and_add(args, &arg, 1); - grpc_method_config_table_unref(method_config_table); + grpc_json_tree_unref(service_config_json); } grpc_end2end_test_fixture f = diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 3a927ddcbc6..f0bc7acdff3 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -137,19 +137,18 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(send_limit); - int32_t max_request_message_bytes = 5; - grpc_method_config_table_entry entry = { - grpc_mdstr_from_string("/service/method"), - grpc_method_config_create(NULL, NULL, &max_request_message_bytes, NULL), - }; - grpc_method_config_table *method_config_table = - grpc_method_config_table_create(1, &entry); - GRPC_MDSTR_UNREF(entry.method_name); - grpc_method_config_unref(entry.method_config); - grpc_arg arg = - grpc_method_config_table_create_channel_arg(method_config_table); + grpc_json_tree* service_config_json = grpc_json_tree_create( + "{\n" + " \"method_config\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"max_request_message_bytes\": 5\n" + " } ]\n" + "}"); + grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1); - grpc_method_config_table_unref(method_config_table); + grpc_json_tree_unref(service_config_json); } else { // Set limit via channel args. grpc_arg arg; @@ -309,20 +308,18 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(!send_limit); - int32_t max_response_message_bytes = 5; - grpc_method_config_table_entry entry = { - grpc_mdstr_from_string("/service/method"), - grpc_method_config_create(NULL, NULL, NULL, - &max_response_message_bytes), - }; - grpc_method_config_table *method_config_table = - grpc_method_config_table_create(1, &entry); - GRPC_MDSTR_UNREF(entry.method_name); - grpc_method_config_unref(entry.method_config); - grpc_arg arg = - grpc_method_config_table_create_channel_arg(method_config_table); + grpc_json_tree* service_config_json = grpc_json_tree_create( + "{\n" + " \"method_config\": [ {\n" + " \"name\": [\n" + " { \"service\": \"service\", \"method\": \"method\" }\n" + " ],\n" + " \"max_response_message_bytes\": 5\n" + " } ]\n" + "}"); + grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1); - grpc_method_config_table_unref(method_config_table); + grpc_json_tree_unref(service_config_json); } else { // Set limit via channel args. grpc_arg arg; From 638c38a79cf69577d2fa2ff4b546bc3ea97da860 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 08:09:34 -0700 Subject: [PATCH 012/119] Remove now-unnecessary code. --- src/core/lib/transport/method_config.c | 322 ++----------------------- src/core/lib/transport/method_config.h | 105 +------- 2 files changed, 32 insertions(+), 395 deletions(-) diff --git a/src/core/lib/transport/method_config.c b/src/core/lib/transport/method_config.c index c2bf88a2503..a163af91d65 100644 --- a/src/core/lib/transport/method_config.c +++ b/src/core/lib/transport/method_config.c @@ -37,309 +37,10 @@ #include #include #include -#include #include "src/core/lib/json/json.h" #include "src/core/lib/support/string.h" #include "src/core/lib/transport/mdstr_hash_table.h" -#include "src/core/lib/transport/metadata.h" - -// -// grpc_method_config -// - -// bool vtable - -static void* bool_copy(void* valuep) { - bool value = *(bool*)valuep; - bool* new_value = gpr_malloc(sizeof(bool)); - *new_value = value; - return new_value; -} - -static int bool_cmp(void* v1, void* v2) { - bool b1 = *(bool*)v1; - bool b2 = *(bool*)v2; - if (!b1 && b2) return -1; - if (b1 && !b2) return 1; - return 0; -} - -static grpc_mdstr_hash_table_vtable bool_vtable = {gpr_free, bool_copy, - bool_cmp}; - -// timespec vtable - -static void* timespec_copy(void* valuep) { - gpr_timespec value = *(gpr_timespec*)valuep; - gpr_timespec* new_value = gpr_malloc(sizeof(gpr_timespec)); - *new_value = value; - return new_value; -} - -static int timespec_cmp(void* v1, void* v2) { - return gpr_time_cmp(*(gpr_timespec*)v1, *(gpr_timespec*)v2); -} - -static grpc_mdstr_hash_table_vtable timespec_vtable = {gpr_free, timespec_copy, - timespec_cmp}; - -// int32 vtable - -static void* int32_copy(void* valuep) { - int32_t value = *(int32_t*)valuep; - int32_t* new_value = gpr_malloc(sizeof(int32_t)); - *new_value = value; - return new_value; -} - -static int int32_cmp(void* v1, void* v2) { - int32_t i1 = *(int32_t*)v1; - int32_t i2 = *(int32_t*)v2; - if (i1 < i2) return -1; - if (i1 > i2) return 1; - return 0; -} - -static grpc_mdstr_hash_table_vtable int32_vtable = {gpr_free, int32_copy, - int32_cmp}; - -// Hash table keys. -#define GRPC_METHOD_CONFIG_WAIT_FOR_READY "grpc.wait_for_ready" // bool -#define GRPC_METHOD_CONFIG_TIMEOUT "grpc.timeout" // gpr_timespec -#define GRPC_METHOD_CONFIG_MAX_REQUEST_MESSAGE_BYTES \ - "grpc.max_request_message_bytes" // int32 -#define GRPC_METHOD_CONFIG_MAX_RESPONSE_MESSAGE_BYTES \ - "grpc.max_response_message_bytes" // int32 - -struct grpc_method_config { - grpc_mdstr_hash_table* table; - grpc_mdstr* wait_for_ready_key; - grpc_mdstr* timeout_key; - grpc_mdstr* max_request_message_bytes_key; - grpc_mdstr* max_response_message_bytes_key; -}; - -grpc_method_config* grpc_method_config_create( - bool* wait_for_ready, gpr_timespec* timeout, - int32_t* max_request_message_bytes, int32_t* max_response_message_bytes) { - grpc_method_config* method_config = gpr_malloc(sizeof(grpc_method_config)); - memset(method_config, 0, sizeof(grpc_method_config)); - method_config->wait_for_ready_key = - grpc_mdstr_from_string(GRPC_METHOD_CONFIG_WAIT_FOR_READY); - method_config->timeout_key = - grpc_mdstr_from_string(GRPC_METHOD_CONFIG_TIMEOUT); - method_config->max_request_message_bytes_key = - grpc_mdstr_from_string(GRPC_METHOD_CONFIG_MAX_REQUEST_MESSAGE_BYTES); - method_config->max_response_message_bytes_key = - grpc_mdstr_from_string(GRPC_METHOD_CONFIG_MAX_RESPONSE_MESSAGE_BYTES); - grpc_mdstr_hash_table_entry entries[4]; - size_t num_entries = 0; - if (wait_for_ready != NULL) { - entries[num_entries].key = method_config->wait_for_ready_key; - entries[num_entries].value = wait_for_ready; - entries[num_entries].vtable = &bool_vtable; - ++num_entries; - } - if (timeout != NULL) { - entries[num_entries].key = method_config->timeout_key; - entries[num_entries].value = timeout; - entries[num_entries].vtable = ×pec_vtable; - ++num_entries; - } - if (max_request_message_bytes != NULL) { - entries[num_entries].key = method_config->max_request_message_bytes_key; - entries[num_entries].value = max_request_message_bytes; - entries[num_entries].vtable = &int32_vtable; - ++num_entries; - } - if (max_response_message_bytes != NULL) { - entries[num_entries].key = method_config->max_response_message_bytes_key; - entries[num_entries].value = max_response_message_bytes; - entries[num_entries].vtable = &int32_vtable; - ++num_entries; - } - method_config->table = grpc_mdstr_hash_table_create(num_entries, entries); - return method_config; -} - -grpc_method_config* grpc_method_config_ref(grpc_method_config* method_config) { - grpc_mdstr_hash_table_ref(method_config->table); - return method_config; -} - -void grpc_method_config_unref(grpc_method_config* method_config) { - if (grpc_mdstr_hash_table_unref(method_config->table)) { - GRPC_MDSTR_UNREF(method_config->wait_for_ready_key); - GRPC_MDSTR_UNREF(method_config->timeout_key); - GRPC_MDSTR_UNREF(method_config->max_request_message_bytes_key); - GRPC_MDSTR_UNREF(method_config->max_response_message_bytes_key); - gpr_free(method_config); - } -} - -int grpc_method_config_cmp(const grpc_method_config* method_config1, - const grpc_method_config* method_config2) { - return grpc_mdstr_hash_table_cmp(method_config1->table, - method_config2->table); -} - -const bool* grpc_method_config_get_wait_for_ready( - const grpc_method_config* method_config) { - return grpc_mdstr_hash_table_get(method_config->table, - method_config->wait_for_ready_key); -} - -const gpr_timespec* grpc_method_config_get_timeout( - const grpc_method_config* method_config) { - return grpc_mdstr_hash_table_get(method_config->table, - method_config->timeout_key); -} - -const int32_t* grpc_method_config_get_max_request_message_bytes( - const grpc_method_config* method_config) { - return grpc_mdstr_hash_table_get( - method_config->table, method_config->max_request_message_bytes_key); -} - -const int32_t* grpc_method_config_get_max_response_message_bytes( - const grpc_method_config* method_config) { - return grpc_mdstr_hash_table_get( - method_config->table, method_config->max_response_message_bytes_key); -} - -// -// grpc_method_config_table -// - -static void method_config_unref(void* valuep) { - grpc_method_config_unref(valuep); -} - -static void* method_config_ref(void* valuep) { - return grpc_method_config_ref(valuep); -} - -static int method_config_cmp(void* valuep1, void* valuep2) { - return grpc_method_config_cmp(valuep1, valuep2); -} - -static const grpc_mdstr_hash_table_vtable method_config_table_vtable = { - method_config_unref, method_config_ref, method_config_cmp}; - -grpc_method_config_table* grpc_method_config_table_create( - size_t num_entries, grpc_method_config_table_entry* entries) { - grpc_mdstr_hash_table_entry* hash_table_entries = - gpr_malloc(sizeof(grpc_mdstr_hash_table_entry) * num_entries); - for (size_t i = 0; i < num_entries; ++i) { - hash_table_entries[i].key = entries[i].method_name; - hash_table_entries[i].value = entries[i].method_config; - hash_table_entries[i].vtable = &method_config_table_vtable; - } - grpc_method_config_table* method_config_table = - grpc_mdstr_hash_table_create(num_entries, hash_table_entries); - gpr_free(hash_table_entries); - return method_config_table; -} - -grpc_method_config_table* grpc_method_config_table_ref( - grpc_method_config_table* table) { - return grpc_mdstr_hash_table_ref(table); -} - -void grpc_method_config_table_unref(grpc_method_config_table* table) { - grpc_mdstr_hash_table_unref(table); -} - -int grpc_method_config_table_cmp(const grpc_method_config_table* table1, - const grpc_method_config_table* table2) { - return grpc_mdstr_hash_table_cmp(table1, table2); -} - -void* grpc_method_config_table_get(const grpc_mdstr_hash_table* table, - const grpc_mdstr* path) { - void* value = grpc_mdstr_hash_table_get(table, path); - // If we didn't find a match for the path, try looking for a wildcard - // entry (i.e., change "/service/method" to "/service/*"). - if (value == NULL) { - const char* path_str = grpc_mdstr_as_c_string(path); - const char* sep = strrchr(path_str, '/') + 1; - const size_t len = (size_t)(sep - path_str); - char* buf = gpr_malloc(len + 2); // '*' and NUL - memcpy(buf, path_str, len); - buf[len] = '*'; - buf[len + 1] = '\0'; - grpc_mdstr* wildcard_path = grpc_mdstr_from_string(buf); - gpr_free(buf); - value = grpc_mdstr_hash_table_get(table, wildcard_path); - GRPC_MDSTR_UNREF(wildcard_path); - } - return value; -} - -static void* copy_arg(void* p) { return grpc_method_config_table_ref(p); } - -static void destroy_arg(void* p) { grpc_method_config_table_unref(p); } - -static int cmp_arg(void* p1, void* p2) { - return grpc_method_config_table_cmp(p1, p2); -} - -static grpc_arg_pointer_vtable arg_vtable = {copy_arg, destroy_arg, cmp_arg}; - -grpc_arg grpc_method_config_table_create_channel_arg( - grpc_method_config_table* table) { - grpc_arg arg; - arg.type = GRPC_ARG_POINTER; - arg.key = GRPC_ARG_SERVICE_CONFIG; - arg.value.pointer.p = table; - arg.value.pointer.vtable = &arg_vtable; - return arg; -} - -// State used by convert_entry() below. -typedef struct conversion_state { - void* (*convert_value)(const grpc_method_config* method_config); - const grpc_mdstr_hash_table_vtable* vtable; - size_t num_entries; - grpc_mdstr_hash_table_entry* entries; -} conversion_state; - -// A function to be passed to grpc_mdstr_hash_table_iterate() to create -// a copy of the entries. -static void convert_entry(const grpc_mdstr_hash_table_entry* entry, - void* user_data) { - conversion_state* state = user_data; - state->entries[state->num_entries].key = GRPC_MDSTR_REF(entry->key); - state->entries[state->num_entries].value = state->convert_value(entry->value); - state->entries[state->num_entries].vtable = state->vtable; - ++state->num_entries; -} - -grpc_mdstr_hash_table* grpc_method_config_table_convert( - const grpc_method_config_table* table, - void* (*convert_value)(const grpc_method_config* method_config), - const grpc_mdstr_hash_table_vtable* vtable) { - // Create an array of the entries in the table with converted values. - conversion_state state; - state.convert_value = convert_value; - state.vtable = vtable; - state.num_entries = 0; - state.entries = gpr_malloc(sizeof(grpc_mdstr_hash_table_entry) * - grpc_mdstr_hash_table_num_entries(table)); - grpc_mdstr_hash_table_iterate(table, convert_entry, &state); - // Create a new table based on the array we just constructed. - grpc_mdstr_hash_table* new_table = - grpc_mdstr_hash_table_create(state.num_entries, state.entries); - // Clean up the array. - for (size_t i = 0; i < state.num_entries; ++i) { - GRPC_MDSTR_UNREF(state.entries[i].key); - vtable->destroy_value(state.entries[i].value); - } - gpr_free(state.entries); - // Return the new table. - return new_table; -} // Returns the number of names specified in the method config \a json. static size_t count_names_in_method_config_json(grpc_json* json) { @@ -435,7 +136,7 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( } // Populate method config table entries. entries = - gpr_malloc(num_entries * sizeof(grpc_method_config_table_entry)); + gpr_malloc(num_entries * sizeof(grpc_mdstr_hash_table_entry)); size_t idx = 0; for (grpc_json* method = field->child; method != NULL; method = method->next) { @@ -461,6 +162,27 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( return method_config_table; } +void* grpc_method_config_table_get(const grpc_mdstr_hash_table* table, + const grpc_mdstr* path) { + void* value = grpc_mdstr_hash_table_get(table, path); + // If we didn't find a match for the path, try looking for a wildcard + // entry (i.e., change "/service/method" to "/service/*"). + if (value == NULL) { + const char* path_str = grpc_mdstr_as_c_string(path); + const char* sep = strrchr(path_str, '/') + 1; + const size_t len = (size_t)(sep - path_str); + char* buf = gpr_malloc(len + 2); // '*' and NUL + memcpy(buf, path_str, len); + buf[len] = '*'; + buf[len + 1] = '\0'; + grpc_mdstr* wildcard_path = grpc_mdstr_from_string(buf); + gpr_free(buf); + value = grpc_mdstr_hash_table_get(table, wildcard_path); + GRPC_MDSTR_UNREF(wildcard_path); + } + return value; +} + static void* copy_json_tree(void* t) { return grpc_json_tree_ref(t); } static void destroy_json_tree(void* t) { grpc_json_tree_unref(t); } diff --git a/src/core/lib/transport/method_config.h b/src/core/lib/transport/method_config.h index 84c6329415b..f33f4279d6d 100644 --- a/src/core/lib/transport/method_config.h +++ b/src/core/lib/transport/method_config.h @@ -32,114 +32,29 @@ #ifndef GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H #define GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H -#include - -#include #include #include "src/core/lib/json/json.h" #include "src/core/lib/transport/mdstr_hash_table.h" -#include "src/core/lib/transport/metadata.h" - -/// Per-method configuration. -typedef struct grpc_method_config grpc_method_config; - -/// Creates a grpc_method_config with the specified parameters. -/// Any parameter may be NULL to indicate that the value is unset. -/// -/// \a wait_for_ready indicates whether the client should wait until the -/// request deadline for the channel to become ready, even if there is a -/// temporary failure before the deadline while attempting to connect. -/// -/// \a timeout indicates the timeout for calls. -/// -/// \a max_request_message_bytes and \a max_response_message_bytes -/// indicate the maximum sizes of the request (checked when sending) and -/// response (checked when receiving) messages. -grpc_method_config* grpc_method_config_create( - bool* wait_for_ready, gpr_timespec* timeout, - int32_t* max_request_message_bytes, int32_t* max_response_message_bytes); - -grpc_method_config* grpc_method_config_ref(grpc_method_config* method_config); -void grpc_method_config_unref(grpc_method_config* method_config); - -/// Compares two grpc_method_configs. -/// The sort order is stable but undefined. -int grpc_method_config_cmp(const grpc_method_config* method_config1, - const grpc_method_config* method_config2); - -/// These methods return NULL if the requested field is unset. -/// The caller does NOT take ownership of the result. -const bool* grpc_method_config_get_wait_for_ready( - const grpc_method_config* method_config); -const gpr_timespec* grpc_method_config_get_timeout( - const grpc_method_config* method_config); -const int32_t* grpc_method_config_get_max_request_message_bytes( - const grpc_method_config* method_config); -const int32_t* grpc_method_config_get_max_response_message_bytes( - const grpc_method_config* method_config); -/// A table of method configs. -typedef grpc_mdstr_hash_table grpc_method_config_table; - -typedef struct grpc_method_config_table_entry { - /// The name is of one of the following forms: - /// service/method -- specifies exact service and method name - /// service/* -- matches all methods for the specified service - grpc_mdstr* method_name; - grpc_method_config* method_config; -} grpc_method_config_table_entry; - -/// Takes new references to all keys and values in \a entries. -grpc_method_config_table* grpc_method_config_table_create( - size_t num_entries, grpc_method_config_table_entry* entries); - -grpc_method_config_table* grpc_method_config_table_ref( - grpc_method_config_table* table); -void grpc_method_config_table_unref(grpc_method_config_table* table); - -/// Compares two grpc_method_config_tables. -/// The sort order is stable but undefined. -int grpc_method_config_table_cmp(const grpc_method_config_table* table1, - const grpc_method_config_table* table2); +/// Creates a method config table based on the data in \a json. +/// The table's keys are request paths. The table's value type is +/// returned by \a create_value(), based on data parsed from the JSON tree. +/// \a vtable provides methods used to manage the values. +/// Returns NULL on error. +grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( + const grpc_json* json, + void* (*create_value)(const grpc_json* method_config_json), + const grpc_mdstr_hash_table_vtable* vtable); /// Gets the method config for the specified \a path, which should be of /// the form "/service/method". /// Returns NULL if the method has no config. /// Caller does NOT own a reference to the result. -/// -/// Note: This returns a void* instead of a grpc_method_config* so that -/// it can also be used for tables constructed via -/// grpc_method_config_table_convert(). void* grpc_method_config_table_get(const grpc_mdstr_hash_table* table, const grpc_mdstr* path); -/// Returns a channel arg containing \a table. -grpc_arg grpc_method_config_table_create_channel_arg( - grpc_method_config_table* table); - -/// Generates a new table from \a table whose values are converted to a -/// new form via the \a convert_value function. The new table will use -/// \a vtable for its values. -/// -/// This is generally used to convert the table's value type from -/// grpc_method_config to a simple struct containing only the parameters -/// relevant to a particular filter, thus avoiding the need for a hash -/// table lookup on the fast path. In that scenario, \a convert_value -/// will return a new instance of the struct containing the values from -/// the grpc_method_config, and \a vtable provides the methods for -/// operating on the struct type. -grpc_mdstr_hash_table* grpc_method_config_table_convert( - const grpc_method_config_table* table, - void* (*convert_value)(const grpc_method_config* method_config), - const grpc_mdstr_hash_table_vtable* vtable); - -// FIXME: document -grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( - const grpc_json* json, - void* (*create_value)(const grpc_json* method_config_json), - const grpc_mdstr_hash_table_vtable* vtable); - +/// Creates a channel arg containing \a service_config. grpc_arg grpc_service_config_create_channel_arg(grpc_json_tree* service_config); #endif /* GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H */ From e30baeb6a3de046ccd4d6120a2b2a2dba67aef82 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 08:16:19 -0700 Subject: [PATCH 013/119] Minor cleanups. --- src/core/ext/client_channel/client_channel.c | 4 ++-- src/core/lib/channel/message_size_filter.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index 4a1c0ae1a22..1f27761b652 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -94,7 +94,7 @@ static int method_parameters_cmp(void *value1, void *value2) { static const grpc_mdstr_hash_table_vtable method_parameters_vtable = { gpr_free, method_parameters_copy, method_parameters_cmp}; -static void *method_config_convert_value(const grpc_json *json) { +static void *method_parameters_create_from_json(const grpc_json *json) { wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET; gpr_timespec timeout = { 0, 0, GPR_TIMESPAN }; for (grpc_json* field = json->child; field != NULL; field = field->next) { @@ -315,7 +315,7 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); grpc_json_tree* json_tree = channel_arg->value.pointer.p; method_params_table = grpc_method_config_table_create_from_json( - json_tree->root, method_config_convert_value, + json_tree->root, method_parameters_create_from_json, &method_parameters_vtable); } grpc_channel_args_destroy(chand->resolver_result); diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 86fdf72684d..726bc4f1655 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -70,7 +70,7 @@ static int message_size_limits_cmp(void* value1, void* value2) { static const grpc_mdstr_hash_table_vtable message_size_limits_vtable = { gpr_free, message_size_limits_copy, message_size_limits_cmp}; -static void* method_config_convert_value(const grpc_json* json) { +static void* message_size_limits_create_from_json(const grpc_json* json) { int max_request_message_bytes = -1; int max_response_message_bytes = -1; for (grpc_json* field = json->child; field != NULL; field = field->next) { @@ -236,7 +236,7 @@ static void init_channel_elem(grpc_exec_ctx* exec_ctx, GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); grpc_json_tree* json_tree = channel_arg->value.pointer.p; chand->method_limit_table = grpc_method_config_table_create_from_json( - json_tree->root, method_config_convert_value, + json_tree->root, message_size_limits_create_from_json, &message_size_limits_vtable); } } From 6ad80579de9f995ec210f40447bffe986cd4cb98 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 08:33:17 -0700 Subject: [PATCH 014/119] Remove more now-unnecessary code. --- src/core/ext/client_channel/client_channel.c | 12 +----- src/core/lib/channel/message_size_filter.c | 12 +----- src/core/lib/transport/mdstr_hash_table.c | 42 +------------------- src/core/lib/transport/mdstr_hash_table.h | 18 +-------- 4 files changed, 4 insertions(+), 80 deletions(-) diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index 1f27761b652..d53265bc9c7 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -81,18 +81,8 @@ static void *method_parameters_copy(void *value) { return new_value; } -static int method_parameters_cmp(void *value1, void *value2) { - const method_parameters *v1 = value1; - const method_parameters *v2 = value2; - const int retval = gpr_time_cmp(v1->timeout, v2->timeout); - if (retval != 0) return retval; - if (v1->wait_for_ready > v2->wait_for_ready) return 1; - if (v1->wait_for_ready < v2->wait_for_ready) return -1; - return 0; -} - static const grpc_mdstr_hash_table_vtable method_parameters_vtable = { - gpr_free, method_parameters_copy, method_parameters_cmp}; + gpr_free, method_parameters_copy}; static void *method_parameters_create_from_json(const grpc_json *json) { wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET; diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 726bc4f1655..2950eef87e2 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -57,18 +57,8 @@ static void* message_size_limits_copy(void* value) { return new_value; } -static int message_size_limits_cmp(void* value1, void* value2) { - const message_size_limits* v1 = value1; - const message_size_limits* v2 = value2; - if (v1->max_send_size > v2->max_send_size) return 1; - if (v1->max_send_size < v2->max_send_size) return -1; - if (v1->max_recv_size > v2->max_recv_size) return 1; - if (v1->max_recv_size < v2->max_recv_size) return -1; - return 0; -} - static const grpc_mdstr_hash_table_vtable message_size_limits_vtable = { - gpr_free, message_size_limits_copy, message_size_limits_cmp}; + gpr_free, message_size_limits_copy}; static void* message_size_limits_create_from_json(const grpc_json* json) { int max_request_message_bytes = -1; diff --git a/src/core/lib/transport/mdstr_hash_table.c b/src/core/lib/transport/mdstr_hash_table.c index 8e914c420b1..3d01e56df7e 100644 --- a/src/core/lib/transport/mdstr_hash_table.c +++ b/src/core/lib/transport/mdstr_hash_table.c @@ -41,7 +41,6 @@ struct grpc_mdstr_hash_table { gpr_refcount refs; - size_t num_entries; size_t size; grpc_mdstr_hash_table_entry* entries; }; @@ -77,7 +76,6 @@ grpc_mdstr_hash_table* grpc_mdstr_hash_table_create( grpc_mdstr_hash_table* table = gpr_malloc(sizeof(*table)); memset(table, 0, sizeof(*table)); gpr_ref_init(&table->refs, 1); - table->num_entries = num_entries; // Quadratic probing gets best performance when the table is no more // than half full. table->size = num_entries * 2; @@ -96,7 +94,7 @@ grpc_mdstr_hash_table* grpc_mdstr_hash_table_ref(grpc_mdstr_hash_table* table) { return table; } -int grpc_mdstr_hash_table_unref(grpc_mdstr_hash_table* table) { +void grpc_mdstr_hash_table_unref(grpc_mdstr_hash_table* table) { if (table != NULL && gpr_unref(&table->refs)) { for (size_t i = 0; i < table->size; ++i) { grpc_mdstr_hash_table_entry* entry = &table->entries[i]; @@ -107,13 +105,7 @@ int grpc_mdstr_hash_table_unref(grpc_mdstr_hash_table* table) { } gpr_free(table->entries); gpr_free(table); - return 1; } - return 0; -} - -size_t grpc_mdstr_hash_table_num_entries(const grpc_mdstr_hash_table* table) { - return table->num_entries; } void* grpc_mdstr_hash_table_get(const grpc_mdstr_hash_table* table, @@ -123,35 +115,3 @@ void* grpc_mdstr_hash_table_get(const grpc_mdstr_hash_table* table, if (idx == table->size) return NULL; // Not found. return table->entries[idx].value; } - -int grpc_mdstr_hash_table_cmp(const grpc_mdstr_hash_table* table1, - const grpc_mdstr_hash_table* table2) { - // Compare by num_entries. - if (table1->num_entries < table2->num_entries) return -1; - if (table1->num_entries > table2->num_entries) return 1; - for (size_t i = 0; i < table1->num_entries; ++i) { - grpc_mdstr_hash_table_entry* e1 = &table1->entries[i]; - grpc_mdstr_hash_table_entry* e2 = &table2->entries[i]; - // Compare keys by hash value. - if (e1->key->hash < e2->key->hash) return -1; - if (e1->key->hash > e2->key->hash) return 1; - // Compare by vtable (pointer equality). - if (e1->vtable < e2->vtable) return -1; - if (e1->vtable > e2->vtable) return 1; - // Compare values via vtable. - const int value_result = e1->vtable->compare_value(e1->value, e2->value); - if (value_result != 0) return value_result; - } - return 0; -} - -void grpc_mdstr_hash_table_iterate( - const grpc_mdstr_hash_table* table, - void (*func)(const grpc_mdstr_hash_table_entry* entry, void* user_data), - void* user_data) { - for (size_t i = 0; i < table->size; ++i) { - if (table->entries[i].key != NULL) { - func(&table->entries[i], user_data); - } - } -} diff --git a/src/core/lib/transport/mdstr_hash_table.h b/src/core/lib/transport/mdstr_hash_table.h index bceb4df93de..8982ec3a8dc 100644 --- a/src/core/lib/transport/mdstr_hash_table.h +++ b/src/core/lib/transport/mdstr_hash_table.h @@ -51,7 +51,6 @@ typedef struct grpc_mdstr_hash_table grpc_mdstr_hash_table; typedef struct grpc_mdstr_hash_table_vtable { void (*destroy_value)(void* value); void* (*copy_value)(void* value); - int (*compare_value)(void* value1, void* value2); } grpc_mdstr_hash_table_vtable; typedef struct grpc_mdstr_hash_table_entry { @@ -67,26 +66,11 @@ grpc_mdstr_hash_table* grpc_mdstr_hash_table_create( size_t num_entries, grpc_mdstr_hash_table_entry* entries); grpc_mdstr_hash_table* grpc_mdstr_hash_table_ref(grpc_mdstr_hash_table* table); -/** Returns 1 when \a table is destroyed. */ -int grpc_mdstr_hash_table_unref(grpc_mdstr_hash_table* table); - -/** Returns the number of entries in \a table. */ -size_t grpc_mdstr_hash_table_num_entries(const grpc_mdstr_hash_table* table); +void grpc_mdstr_hash_table_unref(grpc_mdstr_hash_table* table); /** Returns the value from \a table associated with \a key. Returns NULL if \a key is not found. */ void* grpc_mdstr_hash_table_get(const grpc_mdstr_hash_table* table, const grpc_mdstr* key); -/** Compares two hash tables. - The sort order is stable but undefined. */ -int grpc_mdstr_hash_table_cmp(const grpc_mdstr_hash_table* table1, - const grpc_mdstr_hash_table* table2); - -/** Iterates over the entries in \a table, calling \a func for each entry. */ -void grpc_mdstr_hash_table_iterate( - const grpc_mdstr_hash_table* table, - void (*func)(const grpc_mdstr_hash_table_entry* entry, void* user_data), - void* user_data); - #endif /* GRPC_CORE_LIB_TRANSPORT_MDSTR_HASH_TABLE_H */ From 47f1084ce835d4288ddfa9f280e07d0a8d5719c5 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 08:45:27 -0700 Subject: [PATCH 015/119] clang-format --- src/core/ext/client_channel/client_channel.c | 12 +++++----- src/core/lib/json/json.c | 6 ++--- src/core/lib/json/json.h | 22 +++++++++---------- src/core/lib/support/string.c | 4 ++-- src/core/lib/support/string.h | 2 +- src/core/lib/transport/method_config.c | 8 +++---- test/core/end2end/connection_refused_test.c | 2 +- test/core/end2end/tests/cancel_after_accept.c | 2 +- test/core/end2end/tests/max_message_length.c | 4 ++-- 9 files changed, 30 insertions(+), 32 deletions(-) diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index d53265bc9c7..4ca24c4dbcf 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -86,21 +86,21 @@ static const grpc_mdstr_hash_table_vtable method_parameters_vtable = { static void *method_parameters_create_from_json(const grpc_json *json) { wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET; - gpr_timespec timeout = { 0, 0, GPR_TIMESPAN }; - for (grpc_json* field = json->child; field != NULL; field = field->next) { + gpr_timespec timeout = {0, 0, GPR_TIMESPAN}; + for (grpc_json *field = json->child; field != NULL; field = field->next) { if (field->key == NULL) continue; if (strcmp(field->key, "wait_for_ready") == 0) { if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate. if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) { return NULL; } - wait_for_ready = field->type == GRPC_JSON_TRUE - ? WAIT_FOR_READY_TRUE : WAIT_FOR_READY_FALSE; + wait_for_ready = field->type == GRPC_JSON_TRUE ? WAIT_FOR_READY_TRUE + : WAIT_FOR_READY_FALSE; } else if (strcmp(field->key, "timeout") == 0) { if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate. if (field->type != GRPC_JSON_OBJECT) return NULL; if (field->child == NULL) return NULL; - for (grpc_json* subfield = field->child; subfield != NULL; + for (grpc_json *subfield = field->child; subfield != NULL; subfield = subfield->next) { if (subfield->key == NULL) return NULL; if (strcmp(subfield->key, "seconds") == 0) { @@ -303,7 +303,7 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); - grpc_json_tree* json_tree = channel_arg->value.pointer.p; + grpc_json_tree *json_tree = channel_arg->value.pointer.p; method_params_table = grpc_method_config_table_create_from_json( json_tree->root, method_parameters_create_from_json, &method_parameters_vtable); diff --git a/src/core/lib/json/json.c b/src/core/lib/json/json.c index c1a99df6c37..9acf3b04388 100644 --- a/src/core/lib/json/json.c +++ b/src/core/lib/json/json.c @@ -39,15 +39,15 @@ #include "src/core/lib/json/json.h" -grpc_json *grpc_json_create(grpc_json_type type) { - grpc_json *json = gpr_malloc(sizeof(*json)); +grpc_json* grpc_json_create(grpc_json_type type) { + grpc_json* json = gpr_malloc(sizeof(*json)); memset(json, 0, sizeof(*json)); json->type = type; return json; } -void grpc_json_destroy(grpc_json *json) { +void grpc_json_destroy(grpc_json* json) { while (json->child) { grpc_json_destroy(json->child); } diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index e18ace7547a..1663c690e52 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -44,14 +44,14 @@ * are not owned by it. */ typedef struct grpc_json { - struct grpc_json *next; - struct grpc_json *prev; - struct grpc_json *child; - struct grpc_json *parent; + struct grpc_json* next; + struct grpc_json* prev; + struct grpc_json* child; + struct grpc_json* parent; grpc_json_type type; - const char *key; - const char *value; + const char* key; + const char* value; } grpc_json; /* The next two functions are going to parse the input string, and @@ -67,8 +67,8 @@ typedef struct grpc_json { * * Delete the allocated tree afterward using grpc_json_destroy(). */ -grpc_json *grpc_json_parse_string_with_len(char *input, size_t size); -grpc_json *grpc_json_parse_string(char *input); +grpc_json* grpc_json_parse_string_with_len(char* input, size_t size); +grpc_json* grpc_json_parse_string(char* input); /* This function will create a new string using gpr_realloc, and will * deserialize the grpc_json tree into it. It'll be zero-terminated, @@ -78,14 +78,14 @@ grpc_json *grpc_json_parse_string(char *input); * If indent is 0, then newlines will be suppressed as well, and the * output will be condensed at its maximum. */ -char *grpc_json_dump_to_string(grpc_json *json, int indent); +char* grpc_json_dump_to_string(grpc_json* json, int indent); /* Use these to create or delete a grpc_json object. * Deletion is recursive. We will not attempt to free any of the strings * in any of the objects of that tree. */ -grpc_json *grpc_json_create(grpc_json_type type); -void grpc_json_destroy(grpc_json *json); +grpc_json* grpc_json_create(grpc_json_type type); +void grpc_json_destroy(grpc_json* json); /* Compares two JSON trees. */ int grpc_json_cmp(const grpc_json* json1, const grpc_json* json2); diff --git a/src/core/lib/support/string.c b/src/core/lib/support/string.c index 56f29492bf0..165b3189a59 100644 --- a/src/core/lib/support/string.c +++ b/src/core/lib/support/string.c @@ -196,8 +196,8 @@ int int64_ttoa(int64_t value, char *string) { return i; } -int gpr_parse_nonnegative_number(const char* value) { - char* end; +int gpr_parse_nonnegative_number(const char *value) { + char *end; long result = strtol(value, &end, 0); if (*end != '\0' || result < 0 || result > INT_MAX) return -1; return (int)result; diff --git a/src/core/lib/support/string.h b/src/core/lib/support/string.h index 3a5a8ed826f..34fd154a833 100644 --- a/src/core/lib/support/string.h +++ b/src/core/lib/support/string.h @@ -81,7 +81,7 @@ where long is 32bit is size.*/ int int64_ttoa(int64_t value, char *output); // Parses a non-negative number from a value string. Returns -1 on error. -int gpr_parse_nonnegative_number(const char* value); +int gpr_parse_nonnegative_number(const char *value); /* Reverse a run of bytes */ void gpr_reverse_bytes(char *str, int len); diff --git a/src/core/lib/transport/method_config.c b/src/core/lib/transport/method_config.c index a163af91d65..1ce43ca13fc 100644 --- a/src/core/lib/transport/method_config.c +++ b/src/core/lib/transport/method_config.c @@ -80,10 +80,9 @@ static char* parse_json_method_name(grpc_json* json) { // Parses the method config from \a json. Adds an entry to \a entries for // each name found, incrementing \a idx for each entry added. static bool parse_json_method_config( - grpc_json* json, - void* (*create_value)(const grpc_json* method_config_json), + grpc_json* json, void* (*create_value)(const grpc_json* method_config_json), const grpc_mdstr_hash_table_vtable* vtable, - grpc_mdstr_hash_table_entry* entries, size_t *idx) { + grpc_mdstr_hash_table_entry* entries, size_t* idx) { // Construct value. void* method_config = create_value(json); if (method_config == NULL) return NULL; @@ -135,8 +134,7 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( num_entries += count_names_in_method_config_json(method); } // Populate method config table entries. - entries = - gpr_malloc(num_entries * sizeof(grpc_mdstr_hash_table_entry)); + entries = gpr_malloc(num_entries * sizeof(grpc_mdstr_hash_table_entry)); size_t idx = 0; for (grpc_json* method = field->child; method != NULL; method = method->next) { diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c index ba9fb3d30a0..2857ca70e8f 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -76,7 +76,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_channel_args *args = NULL; if (use_service_config) { GPR_ASSERT(wait_for_ready); - grpc_json_tree* service_config_json = grpc_json_tree_create( + grpc_json_tree *service_config_json = grpc_json_tree_create( "{\n" " \"method_config\": [ {\n" " \"name\": [\n" diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 68a82560927..bef33f2a334 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -132,7 +132,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_channel_args *args = NULL; if (use_service_config) { - grpc_json_tree* service_config_json = grpc_json_tree_create( + grpc_json_tree *service_config_json = grpc_json_tree_create( "{\n" " \"method_config\": [ {\n" " \"name\": [\n" diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index f0bc7acdff3..4cffff915e8 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -137,7 +137,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(send_limit); - grpc_json_tree* service_config_json = grpc_json_tree_create( + grpc_json_tree *service_config_json = grpc_json_tree_create( "{\n" " \"method_config\": [ {\n" " \"name\": [\n" @@ -308,7 +308,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(!send_limit); - grpc_json_tree* service_config_json = grpc_json_tree_create( + grpc_json_tree *service_config_json = grpc_json_tree_create( "{\n" " \"method_config\": [ {\n" " \"name\": [\n" From 660e4b082c4d53bd5fddce2447986de130155e15 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 10:15:19 -0700 Subject: [PATCH 016/119] generate partial c# client stubs as partial classes --- src/compiler/csharp_generator.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index f5a0876cf98..3d4a8cb9c28 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -327,7 +327,7 @@ void GenerateClientStub(Printer* out, const ServiceDescriptor *service) { out->Print("/// Client for $servicename$\n", "servicename", GetServiceClassName(service)); out->Print( - "public class $name$ : ClientBase<$name$>\n", + "public partial class $name$ : ClientBase<$name$>\n", "name", GetClientClassName(service)); out->Print("{\n"); out->Indent(); @@ -495,7 +495,7 @@ void GenerateService(Printer* out, const ServiceDescriptor *service, bool generate_client, bool generate_server, bool internal_access) { GenerateDocCommentBody(out, service); - out->Print("$access_level$ static class $classname$\n", "access_level", + out->Print("$access_level$ static partial class $classname$\n", "access_level", GetAccessLevel(internal_access), "classname", GetServiceClassName(service)); out->Print("{\n"); From d09d24d044f3fcf241c429d94c3ca0da32abed43 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 10:25:47 -0700 Subject: [PATCH 017/119] regenerate example code with changed c# plugin --- .../helloworld-from-cli/Greeter/Helloworld.cs | 33 ++++++- .../Greeter/HelloworldGrpc.cs | 4 +- .../csharp/helloworld/Greeter/Helloworld.cs | 33 ++++++- .../helloworld/Greeter/HelloworldGrpc.cs | 4 +- .../route_guide/RouteGuide/RouteGuide.cs | 88 +++++++++++++++++-- .../route_guide/RouteGuide/RouteGuideGrpc.cs | 4 +- 6 files changed, 148 insertions(+), 18 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs index 6477b4f35be..d38ac5f26d1 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -43,29 +42,34 @@ namespace Helloworld { /// /// The request message containing the user's name. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -73,6 +77,7 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -80,10 +85,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -95,16 +102,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.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 (Name.Length != 0) { output.WriteRawTag(10); @@ -112,6 +122,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -120,6 +131,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -129,6 +141,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -149,29 +162,34 @@ namespace Helloworld { /// /// The response message containing the greetings /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -179,6 +197,7 @@ namespace Helloworld { /// 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 { @@ -186,10 +205,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -201,16 +222,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.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); @@ -218,6 +242,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -226,6 +251,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -235,6 +261,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs index 041f5a78d75..297e030a650 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs @@ -41,7 +41,7 @@ namespace Helloworld { /// /// The greeting service definition. /// - public static class Greeter + public static partial class Greeter { static readonly string __ServiceName = "helloworld.Greeter"; @@ -75,7 +75,7 @@ namespace Helloworld { } /// Client for Greeter - public class GreeterClient : ClientBase + public partial class GreeterClient : ClientBase { /// Creates a new client for Greeter /// The channel to use to make remote calls. diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/helloworld/Greeter/Helloworld.cs index 6477b4f35be..d38ac5f26d1 100644 --- a/examples/csharp/helloworld/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld/Greeter/Helloworld.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -43,29 +42,34 @@ namespace Helloworld { /// /// The request message containing the user's name. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -73,6 +77,7 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -80,10 +85,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -95,16 +102,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.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 (Name.Length != 0) { output.WriteRawTag(10); @@ -112,6 +122,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -120,6 +131,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -129,6 +141,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -149,29 +162,34 @@ namespace Helloworld { /// /// The response message containing the greetings /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -179,6 +197,7 @@ namespace Helloworld { /// 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 { @@ -186,10 +205,12 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -201,16 +222,19 @@ namespace Helloworld { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.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); @@ -218,6 +242,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -226,6 +251,7 @@ namespace Helloworld { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -235,6 +261,7 @@ namespace Helloworld { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs index 041f5a78d75..297e030a650 100644 --- a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs @@ -41,7 +41,7 @@ namespace Helloworld { /// /// The greeting service definition. /// - public static class Greeter + public static partial class Greeter { static readonly string __ServiceName = "helloworld.Greeter"; @@ -75,7 +75,7 @@ namespace Helloworld { } /// Client for Greeter - public class GreeterClient : ClientBase + public partial class GreeterClient : ClientBase { /// Creates a new client for Greeter /// The channel to use to make remote calls. diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs index 446113de9d5..54cb823983e 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Routeguide { /// Holder for reflection information generated from route_guide.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class RouteGuideReflection { #region Descriptor @@ -59,30 +58,35 @@ namespace Routeguide { /// Latitudes should be in the range +/- 90 degrees and longitude should be in /// the range +/- 180 degrees (inclusive). /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Point : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Point()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point(Point other) : this() { latitude_ = other.latitude_; longitude_ = other.longitude_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point Clone() { return new Point(this); } @@ -90,6 +94,7 @@ namespace Routeguide { /// Field number for the "latitude" field. public const int LatitudeFieldNumber = 1; private int latitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Latitude { get { return latitude_; } set { @@ -100,6 +105,7 @@ namespace Routeguide { /// Field number for the "longitude" field. public const int LongitudeFieldNumber = 2; private int longitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Longitude { get { return longitude_; } set { @@ -107,10 +113,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Point); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Point other) { if (ReferenceEquals(other, null)) { return false; @@ -123,6 +131,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Latitude != 0) hash ^= Latitude.GetHashCode(); @@ -130,10 +139,12 @@ namespace Routeguide { 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 (Latitude != 0) { output.WriteRawTag(8); @@ -145,6 +156,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Latitude != 0) { @@ -156,6 +168,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Point other) { if (other == null) { return; @@ -168,6 +181,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -193,30 +207,35 @@ namespace Routeguide { /// A latitude-longitude rectangle, represented as two diagonally opposite /// points "lo" and "hi". /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Rectangle : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Rectangle()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle(Rectangle other) : this() { Lo = other.lo_ != null ? other.Lo.Clone() : null; Hi = other.hi_ != null ? other.Hi.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle Clone() { return new Rectangle(this); } @@ -227,6 +246,7 @@ namespace Routeguide { /// /// One corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Lo { get { return lo_; } set { @@ -240,6 +260,7 @@ namespace Routeguide { /// /// The other corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Hi { get { return hi_; } set { @@ -247,10 +268,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Rectangle); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Rectangle other) { if (ReferenceEquals(other, null)) { return false; @@ -263,6 +286,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (lo_ != null) hash ^= Lo.GetHashCode(); @@ -270,10 +294,12 @@ namespace Routeguide { 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 (lo_ != null) { output.WriteRawTag(10); @@ -285,6 +311,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (lo_ != null) { @@ -296,6 +323,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Rectangle other) { if (other == null) { return; @@ -314,6 +342,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -346,30 +375,35 @@ namespace Routeguide { /// /// If a feature could not be named, the name is empty. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Feature : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Feature()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature(Feature other) : this() { name_ = other.name_; Location = other.location_ != null ? other.Location.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature Clone() { return new Feature(this); } @@ -380,6 +414,7 @@ namespace Routeguide { /// /// The name of the feature. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -393,6 +428,7 @@ namespace Routeguide { /// /// The point where the feature is detected. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -400,10 +436,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Feature); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Feature other) { if (ReferenceEquals(other, null)) { return false; @@ -416,6 +454,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -423,10 +462,12 @@ namespace Routeguide { 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 (Name.Length != 0) { output.WriteRawTag(10); @@ -438,6 +479,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -449,6 +491,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Feature other) { if (other == null) { return; @@ -464,6 +507,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -491,30 +535,35 @@ namespace Routeguide { /// /// A RouteNote is a message sent while at a given point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteNote : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteNote()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote(RouteNote other) : this() { Location = other.location_ != null ? other.Location.Clone() : null; message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote Clone() { return new RouteNote(this); } @@ -525,6 +574,7 @@ namespace Routeguide { /// /// The location from which the message is sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -538,6 +588,7 @@ namespace Routeguide { /// /// The message to be sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -545,10 +596,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteNote); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteNote other) { if (ReferenceEquals(other, null)) { return false; @@ -561,6 +614,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (location_ != null) hash ^= Location.GetHashCode(); @@ -568,10 +622,12 @@ namespace Routeguide { 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 (location_ != null) { output.WriteRawTag(10); @@ -583,6 +639,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (location_ != null) { @@ -594,6 +651,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteNote other) { if (other == null) { return; @@ -609,6 +667,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -640,25 +699,29 @@ namespace Routeguide { /// detected features, and the total distance covered as the cumulative sum of /// the distance between each point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteSummary : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteSummary()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary(RouteSummary other) : this() { pointCount_ = other.pointCount_; featureCount_ = other.featureCount_; @@ -666,6 +729,7 @@ namespace Routeguide { elapsedTime_ = other.elapsedTime_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary Clone() { return new RouteSummary(this); } @@ -676,6 +740,7 @@ namespace Routeguide { /// /// The number of points received. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PointCount { get { return pointCount_; } set { @@ -689,6 +754,7 @@ namespace Routeguide { /// /// The number of known features passed while traversing the route. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int FeatureCount { get { return featureCount_; } set { @@ -702,6 +768,7 @@ namespace Routeguide { /// /// The distance covered in metres. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Distance { get { return distance_; } set { @@ -715,6 +782,7 @@ namespace Routeguide { /// /// The duration of the traversal in seconds. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int ElapsedTime { get { return elapsedTime_; } set { @@ -722,10 +790,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteSummary); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteSummary other) { if (ReferenceEquals(other, null)) { return false; @@ -740,6 +810,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PointCount != 0) hash ^= PointCount.GetHashCode(); @@ -749,10 +820,12 @@ namespace Routeguide { 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 (PointCount != 0) { output.WriteRawTag(8); @@ -772,6 +845,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PointCount != 0) { @@ -789,6 +863,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteSummary other) { if (other == null) { return; @@ -807,6 +882,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs index eb70c8e2db5..3cca24a9442 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs @@ -41,7 +41,7 @@ namespace Routeguide { /// /// Interface exported by the server. /// - public static class RouteGuide + public static partial class RouteGuide { static readonly string __ServiceName = "routeguide.RouteGuide"; @@ -139,7 +139,7 @@ namespace Routeguide { } /// Client for RouteGuide - public class RouteGuideClient : ClientBase + public partial class RouteGuideClient : ClientBase { /// Creates a new client for RouteGuide /// The channel to use to make remote calls. From c75fdea628ce942fadd857b46f1bd9a92d5cc10e Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 10:32:05 -0700 Subject: [PATCH 018/119] revert code changes to example files generated by only protobuf --- .../helloworld-from-cli/Greeter/Helloworld.cs | 33 +------ .../csharp/helloworld/Greeter/Helloworld.cs | 33 +------ .../route_guide/RouteGuide/RouteGuide.cs | 88 ++----------------- 3 files changed, 12 insertions(+), 142 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs index d38ac5f26d1..6477b4f35be 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs @@ -10,6 +10,7 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -42,34 +43,29 @@ namespace Helloworld { /// /// The request message containing the user's name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -77,7 +73,6 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -85,12 +80,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -102,19 +95,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.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 (Name.Length != 0) { output.WriteRawTag(10); @@ -122,7 +112,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -131,7 +120,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -141,7 +129,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -162,34 +149,29 @@ namespace Helloworld { /// /// The response message containing the greetings /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -197,7 +179,6 @@ namespace Helloworld { /// 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 { @@ -205,12 +186,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -222,19 +201,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.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); @@ -242,7 +218,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -251,7 +226,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -261,7 +235,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/helloworld/Greeter/Helloworld.cs b/examples/csharp/helloworld/Greeter/Helloworld.cs index d38ac5f26d1..6477b4f35be 100644 --- a/examples/csharp/helloworld/Greeter/Helloworld.cs +++ b/examples/csharp/helloworld/Greeter/Helloworld.cs @@ -10,6 +10,7 @@ using scg = global::System.Collections.Generic; namespace Helloworld { /// Holder for reflection information generated from helloworld.proto + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class HelloworldReflection { #region Descriptor @@ -42,34 +43,29 @@ namespace Helloworld { /// /// The request message containing the user's name. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloRequest : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloRequest()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[0]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest(HelloRequest other) : this() { name_ = other.name_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloRequest Clone() { return new HelloRequest(this); } @@ -77,7 +73,6 @@ namespace Helloworld { /// Field number for the "name" field. public const int NameFieldNumber = 1; private string name_ = ""; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -85,12 +80,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloRequest); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloRequest other) { if (ReferenceEquals(other, null)) { return false; @@ -102,19 +95,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.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 (Name.Length != 0) { output.WriteRawTag(10); @@ -122,7 +112,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -131,7 +120,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloRequest other) { if (other == null) { return; @@ -141,7 +129,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -162,34 +149,29 @@ namespace Helloworld { /// /// The response message containing the greetings /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class HelloReply : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new HelloReply()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Helloworld.HelloworldReflection.Descriptor.MessageTypes[1]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply(HelloReply other) : this() { message_ = other.message_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public HelloReply Clone() { return new HelloReply(this); } @@ -197,7 +179,6 @@ namespace Helloworld { /// 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 { @@ -205,12 +186,10 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as HelloReply); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(HelloReply other) { if (ReferenceEquals(other, null)) { return false; @@ -222,19 +201,16 @@ namespace Helloworld { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Message.Length != 0) hash ^= Message.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); @@ -242,7 +218,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Message.Length != 0) { @@ -251,7 +226,6 @@ namespace Helloworld { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(HelloReply other) { if (other == null) { return; @@ -261,7 +235,6 @@ namespace Helloworld { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs index 54cb823983e..446113de9d5 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs @@ -10,6 +10,7 @@ using scg = global::System.Collections.Generic; namespace Routeguide { /// Holder for reflection information generated from route_guide.proto + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class RouteGuideReflection { #region Descriptor @@ -58,35 +59,30 @@ namespace Routeguide { /// Latitudes should be in the range +/- 90 degrees and longitude should be in /// the range +/- 180 degrees (inclusive). /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Point : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Point()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[0]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point(Point other) : this() { latitude_ = other.latitude_; longitude_ = other.longitude_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point Clone() { return new Point(this); } @@ -94,7 +90,6 @@ namespace Routeguide { /// Field number for the "latitude" field. public const int LatitudeFieldNumber = 1; private int latitude_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Latitude { get { return latitude_; } set { @@ -105,7 +100,6 @@ namespace Routeguide { /// Field number for the "longitude" field. public const int LongitudeFieldNumber = 2; private int longitude_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Longitude { get { return longitude_; } set { @@ -113,12 +107,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Point); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Point other) { if (ReferenceEquals(other, null)) { return false; @@ -131,7 +123,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Latitude != 0) hash ^= Latitude.GetHashCode(); @@ -139,12 +130,10 @@ namespace Routeguide { 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 (Latitude != 0) { output.WriteRawTag(8); @@ -156,7 +145,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Latitude != 0) { @@ -168,7 +156,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Point other) { if (other == null) { return; @@ -181,7 +168,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -207,35 +193,30 @@ namespace Routeguide { /// A latitude-longitude rectangle, represented as two diagonally opposite /// points "lo" and "hi". /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Rectangle : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Rectangle()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[1]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle(Rectangle other) : this() { Lo = other.lo_ != null ? other.Lo.Clone() : null; Hi = other.hi_ != null ? other.Hi.Clone() : null; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle Clone() { return new Rectangle(this); } @@ -246,7 +227,6 @@ namespace Routeguide { /// /// One corner of the rectangle. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Lo { get { return lo_; } set { @@ -260,7 +240,6 @@ namespace Routeguide { /// /// The other corner of the rectangle. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Hi { get { return hi_; } set { @@ -268,12 +247,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Rectangle); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Rectangle other) { if (ReferenceEquals(other, null)) { return false; @@ -286,7 +263,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (lo_ != null) hash ^= Lo.GetHashCode(); @@ -294,12 +270,10 @@ namespace Routeguide { 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 (lo_ != null) { output.WriteRawTag(10); @@ -311,7 +285,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (lo_ != null) { @@ -323,7 +296,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Rectangle other) { if (other == null) { return; @@ -342,7 +314,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -375,35 +346,30 @@ namespace Routeguide { /// /// If a feature could not be named, the name is empty. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Feature : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Feature()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[2]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature(Feature other) : this() { name_ = other.name_; Location = other.location_ != null ? other.Location.Clone() : null; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature Clone() { return new Feature(this); } @@ -414,7 +380,6 @@ namespace Routeguide { /// /// The name of the feature. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -428,7 +393,6 @@ namespace Routeguide { /// /// The point where the feature is detected. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -436,12 +400,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Feature); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Feature other) { if (ReferenceEquals(other, null)) { return false; @@ -454,7 +416,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -462,12 +423,10 @@ namespace Routeguide { 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 (Name.Length != 0) { output.WriteRawTag(10); @@ -479,7 +438,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -491,7 +449,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Feature other) { if (other == null) { return; @@ -507,7 +464,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -535,35 +491,30 @@ namespace Routeguide { /// /// A RouteNote is a message sent while at a given point. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteNote : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteNote()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[3]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote(RouteNote other) : this() { Location = other.location_ != null ? other.Location.Clone() : null; message_ = other.message_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote Clone() { return new RouteNote(this); } @@ -574,7 +525,6 @@ namespace Routeguide { /// /// The location from which the message is sent. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -588,7 +538,6 @@ namespace Routeguide { /// /// The message to be sent. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -596,12 +545,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteNote); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteNote other) { if (ReferenceEquals(other, null)) { return false; @@ -614,7 +561,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (location_ != null) hash ^= Location.GetHashCode(); @@ -622,12 +568,10 @@ namespace Routeguide { 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 (location_ != null) { output.WriteRawTag(10); @@ -639,7 +583,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (location_ != null) { @@ -651,7 +594,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteNote other) { if (other == null) { return; @@ -667,7 +609,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -699,29 +640,25 @@ namespace Routeguide { /// detected features, and the total distance covered as the cumulative sum of /// the distance between each point. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteSummary : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteSummary()); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[4]; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary() { OnConstruction(); } partial void OnConstruction(); - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary(RouteSummary other) : this() { pointCount_ = other.pointCount_; featureCount_ = other.featureCount_; @@ -729,7 +666,6 @@ namespace Routeguide { elapsedTime_ = other.elapsedTime_; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary Clone() { return new RouteSummary(this); } @@ -740,7 +676,6 @@ namespace Routeguide { /// /// The number of points received. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PointCount { get { return pointCount_; } set { @@ -754,7 +689,6 @@ namespace Routeguide { /// /// The number of known features passed while traversing the route. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int FeatureCount { get { return featureCount_; } set { @@ -768,7 +702,6 @@ namespace Routeguide { /// /// The distance covered in metres. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Distance { get { return distance_; } set { @@ -782,7 +715,6 @@ namespace Routeguide { /// /// The duration of the traversal in seconds. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int ElapsedTime { get { return elapsedTime_; } set { @@ -790,12 +722,10 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteSummary); } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteSummary other) { if (ReferenceEquals(other, null)) { return false; @@ -810,7 +740,6 @@ namespace Routeguide { return true; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PointCount != 0) hash ^= PointCount.GetHashCode(); @@ -820,12 +749,10 @@ namespace Routeguide { 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 (PointCount != 0) { output.WriteRawTag(8); @@ -845,7 +772,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PointCount != 0) { @@ -863,7 +789,6 @@ namespace Routeguide { return size; } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteSummary other) { if (other == null) { return; @@ -882,7 +807,6 @@ namespace Routeguide { } } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { From 333658177dad958fd3b4402d2b351b3a4c4b170f Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 11:07:42 -0700 Subject: [PATCH 019/119] generate server base class as partial too --- examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs | 2 +- examples/csharp/helloworld/Greeter/HelloworldGrpc.cs | 2 +- examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs | 2 +- src/compiler/csharp_generator.cc | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs index 297e030a650..9974620da4f 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs @@ -62,7 +62,7 @@ namespace Helloworld { } /// Base class for server-side implementations of Greeter - public abstract class GreeterBase + public abstract partial class GreeterBase { /// /// Sends a greeting diff --git a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs index 297e030a650..9974620da4f 100644 --- a/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs +++ b/examples/csharp/helloworld/Greeter/HelloworldGrpc.cs @@ -62,7 +62,7 @@ namespace Helloworld { } /// Base class for server-side implementations of Greeter - public abstract class GreeterBase + public abstract partial class GreeterBase { /// /// Sends a greeting diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs index 3cca24a9442..aaaac0d1b63 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuideGrpc.cs @@ -86,7 +86,7 @@ namespace Routeguide { } /// Base class for server-side implementations of RouteGuide - public abstract class RouteGuideBase + public abstract partial class RouteGuideBase { /// /// A simple RPC. diff --git a/src/compiler/csharp_generator.cc b/src/compiler/csharp_generator.cc index 3d4a8cb9c28..977600ffb24 100644 --- a/src/compiler/csharp_generator.cc +++ b/src/compiler/csharp_generator.cc @@ -297,7 +297,7 @@ void GenerateServiceDescriptorProperty(Printer* out, const ServiceDescriptor *se void GenerateServerClass(Printer* out, const ServiceDescriptor *service) { out->Print("/// Base class for server-side implementations of $servicename$\n", "servicename", GetServiceClassName(service)); - out->Print("public abstract class $name$\n", "name", + out->Print("public abstract partial class $name$\n", "name", GetServerClassName(service)); out->Print("{\n"); out->Indent(); From 4112499c2822d37efdb6c5dfb73438c8ad606247 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 11:22:20 -0700 Subject: [PATCH 020/119] Minor cleanups. --- src/core/ext/client_channel/client_channel.c | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index 4ca24c4dbcf..d96ec57f04a 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -249,14 +249,10 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *state_error = GRPC_ERROR_CREATE("No load balancing policy"); if (chand->resolver_result != NULL) { - grpc_lb_policy_args lb_policy_args; - lb_policy_args.args = chand->resolver_result; - lb_policy_args.client_channel_factory = chand->client_channel_factory; - // Find LB policy name. const char *lb_policy_name = NULL; const grpc_arg *channel_arg = - grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_LB_POLICY_NAME); + grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_POLICY_NAME); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); lb_policy_name = channel_arg->value.string; @@ -265,7 +261,7 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, // assume that we should use the grpclb policy, regardless of what the // resolver actually specified. channel_arg = - grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_LB_ADDRESSES); + grpc_channel_args_find(chand->resolver_result, GRPC_ARG_LB_ADDRESSES); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); grpc_lb_addresses *addresses = channel_arg->value.pointer.p; @@ -290,7 +286,10 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, // Use pick_first if nothing was specified and we didn't select grpclb // above. if (lb_policy_name == NULL) lb_policy_name = "pick_first"; - + // Instantiate LB policy. + grpc_lb_policy_args lb_policy_args; + lb_policy_args.args = chand->resolver_result; + lb_policy_args.client_channel_factory = chand->client_channel_factory; lb_policy = grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args); if (lb_policy != NULL) { @@ -299,15 +298,17 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, state = grpc_lb_policy_check_connectivity(exec_ctx, lb_policy, &state_error); } + // Find service config. channel_arg = - grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_SERVICE_CONFIG); + grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); - grpc_json_tree *json_tree = channel_arg->value.pointer.p; + grpc_json_tree *service_config_json = channel_arg->value.pointer.p; method_params_table = grpc_method_config_table_create_from_json( - json_tree->root, method_parameters_create_from_json, + service_config_json->root, method_parameters_create_from_json, &method_parameters_vtable); } + // Clean up. grpc_channel_args_destroy(chand->resolver_result); chand->resolver_result = NULL; } From f2e8a6a138d4d5988ffef3c79a7a64d586c041fc Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 11:25:22 -0700 Subject: [PATCH 021/119] Add method to extract LB policy name from service config JSON. --- src/core/lib/transport/method_config.c | 16 ++++++++++++++++ src/core/lib/transport/method_config.h | 6 ++++++ 2 files changed, 22 insertions(+) diff --git a/src/core/lib/transport/method_config.c b/src/core/lib/transport/method_config.c index 1ce43ca13fc..49e60a47bc4 100644 --- a/src/core/lib/transport/method_config.c +++ b/src/core/lib/transport/method_config.c @@ -181,6 +181,22 @@ void* grpc_method_config_table_get(const grpc_mdstr_hash_table* table, return value; } +const char* grpc_service_config_get_lb_policy_name( + grpc_json_tree* service_config) { + grpc_json* json = service_config->root; + if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL; + const char* lb_policy_name = NULL; + for (grpc_json* field = json->child; field != NULL; field = field->next) { + if (field->key == NULL) return NULL; + if (strcmp(field->key, "lb_policy_name") == 0) { + if (lb_policy_name != NULL) return NULL; // Duplicate. + if (field->type != GRPC_JSON_STRING) return NULL; + lb_policy_name = field->value; + } + } + return lb_policy_name; +} + static void* copy_json_tree(void* t) { return grpc_json_tree_ref(t); } static void destroy_json_tree(void* t) { grpc_json_tree_unref(t); } diff --git a/src/core/lib/transport/method_config.h b/src/core/lib/transport/method_config.h index f33f4279d6d..9922a7a657d 100644 --- a/src/core/lib/transport/method_config.h +++ b/src/core/lib/transport/method_config.h @@ -54,6 +54,12 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( void* grpc_method_config_table_get(const grpc_mdstr_hash_table* table, const grpc_mdstr* path); +/// Gets the LB policy name from \a service_config. +/// Returns NULL if no LB policy name was specified. +/// Caller does NOT take ownership. +const char* grpc_service_config_get_lb_policy_name( + grpc_json_tree* service_config); + /// Creates a channel arg containing \a service_config. grpc_arg grpc_service_config_create_channel_arg(grpc_json_tree* service_config); From ea846a08004501fa4b63dbb5bd7bb12bd1017a33 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 11:32:54 -0700 Subject: [PATCH 022/119] Rename method_config.[ch] to service_config.[ch]. --- BUILD | 16 ++++++++-------- CMakeLists.txt | 6 +++--- Makefile | 8 ++++---- binding.gyp | 2 +- build.yaml | 4 ++-- config.m4 | 2 +- gRPC-Core.podspec | 6 +++--- grpc.gemspec | 4 ++-- package.xml | 4 ++-- src/core/ext/client_channel/client_channel.c | 2 +- src/core/lib/channel/message_size_filter.c | 2 +- .../{method_config.c => service_config.c} | 2 +- .../{method_config.h => service_config.h} | 6 +++--- src/python/grpcio/grpc_core_dependencies.py | 2 +- test/core/end2end/connection_refused_test.c | 2 +- test/core/end2end/tests/cancel_after_accept.c | 2 +- test/core/end2end/tests/max_message_length.c | 2 +- tools/doxygen/Doxyfile.core.internal | 4 ++-- tools/run_tests/sources_and_headers.json | 6 +++--- vsprojects/vcxproj/grpc/grpc.vcxproj | 4 ++-- vsprojects/vcxproj/grpc/grpc.vcxproj.filters | 4 ++-- .../grpc_test_util/grpc_test_util.vcxproj | 4 ++-- .../grpc_test_util.vcxproj.filters | 4 ++-- .../vcxproj/grpc_unsecure/grpc_unsecure.vcxproj | 4 ++-- .../grpc_unsecure/grpc_unsecure.vcxproj.filters | 4 ++-- 25 files changed, 53 insertions(+), 53 deletions(-) rename src/core/lib/transport/{method_config.c => service_config.c} (99%) rename src/core/lib/transport/{method_config.h => service_config.h} (95%) diff --git a/BUILD b/BUILD index 97ddc56b419..d747e71dde3 100644 --- a/BUILD +++ b/BUILD @@ -251,7 +251,7 @@ cc_library( "src/core/lib/transport/mdstr_hash_table.h", "src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/method_config.h", + "src/core/lib/transport/service_config.h", "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/transport.h", @@ -435,7 +435,7 @@ cc_library( "src/core/lib/transport/mdstr_hash_table.c", "src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata_batch.c", - "src/core/lib/transport/method_config.c", + "src/core/lib/transport/service_config.c", "src/core/lib/transport/static_metadata.c", "src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/transport.c", @@ -675,7 +675,7 @@ cc_library( "src/core/lib/transport/mdstr_hash_table.h", "src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/method_config.h", + "src/core/lib/transport/service_config.h", "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/transport.h", @@ -844,7 +844,7 @@ cc_library( "src/core/lib/transport/mdstr_hash_table.c", "src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata_batch.c", - "src/core/lib/transport/method_config.c", + "src/core/lib/transport/service_config.c", "src/core/lib/transport/static_metadata.c", "src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/transport.c", @@ -1054,7 +1054,7 @@ cc_library( "src/core/lib/transport/mdstr_hash_table.h", "src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/method_config.h", + "src/core/lib/transport/service_config.h", "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/transport.h", @@ -1215,7 +1215,7 @@ cc_library( "src/core/lib/transport/mdstr_hash_table.c", "src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata_batch.c", - "src/core/lib/transport/method_config.c", + "src/core/lib/transport/service_config.c", "src/core/lib/transport/static_metadata.c", "src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/transport.c", @@ -2072,7 +2072,7 @@ objc_library( "src/core/lib/transport/mdstr_hash_table.c", "src/core/lib/transport/metadata.c", "src/core/lib/transport/metadata_batch.c", - "src/core/lib/transport/method_config.c", + "src/core/lib/transport/service_config.c", "src/core/lib/transport/static_metadata.c", "src/core/lib/transport/timeout_encoding.c", "src/core/lib/transport/transport.c", @@ -2291,7 +2291,7 @@ objc_library( "src/core/lib/transport/mdstr_hash_table.h", "src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/method_config.h", + "src/core/lib/transport/service_config.h", "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/transport.h", diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b073b0d684..dec3c8a7f97 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -392,7 +392,7 @@ add_library(grpc src/core/lib/transport/mdstr_hash_table.c src/core/lib/transport/metadata.c src/core/lib/transport/metadata_batch.c - src/core/lib/transport/method_config.c + src/core/lib/transport/service_config.c src/core/lib/transport/static_metadata.c src/core/lib/transport/timeout_encoding.c src/core/lib/transport/transport.c @@ -664,7 +664,7 @@ add_library(grpc_cronet src/core/lib/transport/mdstr_hash_table.c src/core/lib/transport/metadata.c src/core/lib/transport/metadata_batch.c - src/core/lib/transport/method_config.c + src/core/lib/transport/service_config.c src/core/lib/transport/static_metadata.c src/core/lib/transport/timeout_encoding.c src/core/lib/transport/transport.c @@ -908,7 +908,7 @@ add_library(grpc_unsecure src/core/lib/transport/mdstr_hash_table.c src/core/lib/transport/metadata.c src/core/lib/transport/metadata_batch.c - src/core/lib/transport/method_config.c + src/core/lib/transport/service_config.c src/core/lib/transport/static_metadata.c src/core/lib/transport/timeout_encoding.c src/core/lib/transport/transport.c diff --git a/Makefile b/Makefile index 4b713cef3b8..2d4acb87573 100644 --- a/Makefile +++ b/Makefile @@ -2687,7 +2687,7 @@ LIBGRPC_SRC = \ src/core/lib/transport/mdstr_hash_table.c \ src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata_batch.c \ - src/core/lib/transport/method_config.c \ + src/core/lib/transport/service_config.c \ src/core/lib/transport/static_metadata.c \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ @@ -2977,7 +2977,7 @@ LIBGRPC_CRONET_SRC = \ src/core/lib/transport/mdstr_hash_table.c \ src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata_batch.c \ - src/core/lib/transport/method_config.c \ + src/core/lib/transport/service_config.c \ src/core/lib/transport/static_metadata.c \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ @@ -3258,7 +3258,7 @@ LIBGRPC_TEST_UTIL_SRC = \ src/core/lib/transport/mdstr_hash_table.c \ src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata_batch.c \ - src/core/lib/transport/method_config.c \ + src/core/lib/transport/service_config.c \ src/core/lib/transport/static_metadata.c \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ @@ -3468,7 +3468,7 @@ LIBGRPC_UNSECURE_SRC = \ src/core/lib/transport/mdstr_hash_table.c \ src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata_batch.c \ - src/core/lib/transport/method_config.c \ + src/core/lib/transport/service_config.c \ src/core/lib/transport/static_metadata.c \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ diff --git a/binding.gyp b/binding.gyp index 9f3b75aaf3d..7f6e06b1c30 100644 --- a/binding.gyp +++ b/binding.gyp @@ -670,7 +670,7 @@ 'src/core/lib/transport/mdstr_hash_table.c', 'src/core/lib/transport/metadata.c', 'src/core/lib/transport/metadata_batch.c', - 'src/core/lib/transport/method_config.c', + 'src/core/lib/transport/service_config.c', 'src/core/lib/transport/static_metadata.c', 'src/core/lib/transport/timeout_encoding.c', 'src/core/lib/transport/transport.c', diff --git a/build.yaml b/build.yaml index 56c220d4aba..c7bfc58ea41 100644 --- a/build.yaml +++ b/build.yaml @@ -255,7 +255,7 @@ filegroups: - src/core/lib/transport/mdstr_hash_table.h - src/core/lib/transport/metadata.h - src/core/lib/transport/metadata_batch.h - - src/core/lib/transport/method_config.h + - src/core/lib/transport/service_config.h - src/core/lib/transport/static_metadata.h - src/core/lib/transport/timeout_encoding.h - src/core/lib/transport/transport.h @@ -363,7 +363,7 @@ filegroups: - src/core/lib/transport/mdstr_hash_table.c - src/core/lib/transport/metadata.c - src/core/lib/transport/metadata_batch.c - - src/core/lib/transport/method_config.c + - src/core/lib/transport/service_config.c - src/core/lib/transport/static_metadata.c - src/core/lib/transport/timeout_encoding.c - src/core/lib/transport/transport.c diff --git a/config.m4 b/config.m4 index 8f26e426789..ff94bbc79a9 100644 --- a/config.m4 +++ b/config.m4 @@ -186,7 +186,7 @@ if test "$PHP_GRPC" != "no"; then src/core/lib/transport/mdstr_hash_table.c \ src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata_batch.c \ - src/core/lib/transport/method_config.c \ + src/core/lib/transport/service_config.c \ src/core/lib/transport/static_metadata.c \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 43aedecd06f..a6abebcac73 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -338,7 +338,7 @@ Pod::Spec.new do |s| 'src/core/lib/transport/mdstr_hash_table.h', 'src/core/lib/transport/metadata.h', 'src/core/lib/transport/metadata_batch.h', - 'src/core/lib/transport/method_config.h', + 'src/core/lib/transport/service_config.h', 'src/core/lib/transport/static_metadata.h', 'src/core/lib/transport/timeout_encoding.h', 'src/core/lib/transport/transport.h', @@ -526,7 +526,7 @@ Pod::Spec.new do |s| 'src/core/lib/transport/mdstr_hash_table.c', 'src/core/lib/transport/metadata.c', 'src/core/lib/transport/metadata_batch.c', - 'src/core/lib/transport/method_config.c', + 'src/core/lib/transport/service_config.c', 'src/core/lib/transport/static_metadata.c', 'src/core/lib/transport/timeout_encoding.c', 'src/core/lib/transport/transport.c', @@ -734,7 +734,7 @@ Pod::Spec.new do |s| 'src/core/lib/transport/mdstr_hash_table.h', 'src/core/lib/transport/metadata.h', 'src/core/lib/transport/metadata_batch.h', - 'src/core/lib/transport/method_config.h', + 'src/core/lib/transport/service_config.h', 'src/core/lib/transport/static_metadata.h', 'src/core/lib/transport/timeout_encoding.h', 'src/core/lib/transport/transport.h', diff --git a/grpc.gemspec b/grpc.gemspec index 615a962cdb6..16f8381859b 100755 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -258,7 +258,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/transport/mdstr_hash_table.h ) s.files += %w( src/core/lib/transport/metadata.h ) s.files += %w( src/core/lib/transport/metadata_batch.h ) - s.files += %w( src/core/lib/transport/method_config.h ) + s.files += %w( src/core/lib/transport/service_config.h ) s.files += %w( src/core/lib/transport/static_metadata.h ) s.files += %w( src/core/lib/transport/timeout_encoding.h ) s.files += %w( src/core/lib/transport/transport.h ) @@ -446,7 +446,7 @@ Gem::Specification.new do |s| s.files += %w( src/core/lib/transport/mdstr_hash_table.c ) s.files += %w( src/core/lib/transport/metadata.c ) s.files += %w( src/core/lib/transport/metadata_batch.c ) - s.files += %w( src/core/lib/transport/method_config.c ) + s.files += %w( src/core/lib/transport/service_config.c ) s.files += %w( src/core/lib/transport/static_metadata.c ) s.files += %w( src/core/lib/transport/timeout_encoding.c ) s.files += %w( src/core/lib/transport/transport.c ) diff --git a/package.xml b/package.xml index a60eac68205..d4021544348 100644 --- a/package.xml +++ b/package.xml @@ -265,7 +265,7 @@ - + @@ -453,7 +453,7 @@ - + diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index d96ec57f04a..d9161f47cdd 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -55,7 +55,7 @@ #include "src/core/lib/transport/connectivity_state.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/metadata_batch.h" -#include "src/core/lib/transport/method_config.h" +#include "src/core/lib/transport/service_config.h" #include "src/core/lib/transport/static_metadata.h" /* Client channel implementation */ diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 2950eef87e2..f826c74f89a 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -40,7 +40,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/support/string.h" -#include "src/core/lib/transport/method_config.h" +#include "src/core/lib/transport/service_config.h" #define DEFAULT_MAX_SEND_MESSAGE_LENGTH -1 // Unlimited. // The protobuf library will (by default) start warning at 100 megs. diff --git a/src/core/lib/transport/method_config.c b/src/core/lib/transport/service_config.c similarity index 99% rename from src/core/lib/transport/method_config.c rename to src/core/lib/transport/service_config.c index 49e60a47bc4..2a717e7b9ba 100644 --- a/src/core/lib/transport/method_config.c +++ b/src/core/lib/transport/service_config.c @@ -29,7 +29,7 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#include "src/core/lib/transport/method_config.h" +#include "src/core/lib/transport/service_config.h" #include diff --git a/src/core/lib/transport/method_config.h b/src/core/lib/transport/service_config.h similarity index 95% rename from src/core/lib/transport/method_config.h rename to src/core/lib/transport/service_config.h index 9922a7a657d..c6c8e6be7fe 100644 --- a/src/core/lib/transport/method_config.h +++ b/src/core/lib/transport/service_config.h @@ -29,8 +29,8 @@ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // -#ifndef GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H -#define GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H +#ifndef GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H +#define GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H #include @@ -63,4 +63,4 @@ const char* grpc_service_config_get_lb_policy_name( /// Creates a channel arg containing \a service_config. grpc_arg grpc_service_config_create_channel_arg(grpc_json_tree* service_config); -#endif /* GRPC_CORE_LIB_TRANSPORT_METHOD_CONFIG_H */ +#endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */ diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 1ad423909f5..6ec2984721b 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -180,7 +180,7 @@ CORE_SOURCE_FILES = [ 'src/core/lib/transport/mdstr_hash_table.c', 'src/core/lib/transport/metadata.c', 'src/core/lib/transport/metadata_batch.c', - 'src/core/lib/transport/method_config.c', + 'src/core/lib/transport/service_config.c', 'src/core/lib/transport/static_metadata.c', 'src/core/lib/transport/timeout_encoding.c', 'src/core/lib/transport/transport.c', diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c index 2857ca70e8f..2814c94e2e7 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -41,7 +41,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/metadata.h" -#include "src/core/lib/transport/method_config.h" +#include "src/core/lib/transport/service_config.h" #include "test/core/end2end/cq_verifier.h" #include "test/core/util/port.h" diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index bef33f2a334..a187311b793 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -44,7 +44,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/metadata.h" -#include "src/core/lib/transport/method_config.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" diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 4cffff915e8..05ac087c134 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -44,7 +44,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/metadata.h" -#include "src/core/lib/transport/method_config.h" +#include "src/core/lib/transport/service_config.h" #include "test/core/end2end/cq_verifier.h" diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index e83298766fd..c886c884021 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -875,7 +875,7 @@ src/core/lib/transport/connectivity_state.h \ src/core/lib/transport/mdstr_hash_table.h \ src/core/lib/transport/metadata.h \ src/core/lib/transport/metadata_batch.h \ -src/core/lib/transport/method_config.h \ +src/core/lib/transport/service_config.h \ src/core/lib/transport/static_metadata.h \ src/core/lib/transport/timeout_encoding.h \ src/core/lib/transport/transport.h \ @@ -1063,7 +1063,7 @@ src/core/lib/transport/connectivity_state.c \ src/core/lib/transport/mdstr_hash_table.c \ src/core/lib/transport/metadata.c \ src/core/lib/transport/metadata_batch.c \ -src/core/lib/transport/method_config.c \ +src/core/lib/transport/service_config.c \ src/core/lib/transport/static_metadata.c \ src/core/lib/transport/timeout_encoding.c \ src/core/lib/transport/transport.c \ diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index b6c9e0ae94c..bf5a0094cc5 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -6604,7 +6604,7 @@ "src/core/lib/transport/mdstr_hash_table.h", "src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/method_config.h", + "src/core/lib/transport/service_config.h", "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/timeout_encoding.h", "src/core/lib/transport/transport.h", @@ -6812,8 +6812,8 @@ "src/core/lib/transport/metadata.h", "src/core/lib/transport/metadata_batch.c", "src/core/lib/transport/metadata_batch.h", - "src/core/lib/transport/method_config.c", - "src/core/lib/transport/method_config.h", + "src/core/lib/transport/service_config.c", + "src/core/lib/transport/service_config.h", "src/core/lib/transport/static_metadata.c", "src/core/lib/transport/static_metadata.h", "src/core/lib/transport/timeout_encoding.c", diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj b/vsprojects/vcxproj/grpc/grpc.vcxproj index d9d0d42d677..a7aecb1c98c 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj @@ -384,7 +384,7 @@ - + @@ -677,7 +677,7 @@ - + diff --git a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters index ab9b76073cf..9574f9784ae 100644 --- a/vsprojects/vcxproj/grpc/grpc.vcxproj.filters +++ b/vsprojects/vcxproj/grpc/grpc.vcxproj.filters @@ -310,7 +310,7 @@ src\core\lib\transport - + src\core\lib\transport @@ -974,7 +974,7 @@ src\core\lib\transport - + src\core\lib\transport diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj index 39c144d992f..9d3bfa808f9 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj @@ -277,7 +277,7 @@ - + @@ -528,7 +528,7 @@ - + diff --git a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters index 0fbfc3acd37..8257c731afc 100644 --- a/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_test_util/grpc_test_util.vcxproj.filters @@ -367,7 +367,7 @@ src\core\lib\transport - + src\core\lib\transport @@ -770,7 +770,7 @@ src\core\lib\transport - + src\core\lib\transport diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj index 87e3921ff96..1d334bdeee4 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj @@ -374,7 +374,7 @@ - + @@ -645,7 +645,7 @@ - + diff --git a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters index 1e719226faf..daed8db5ae7 100644 --- a/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters +++ b/vsprojects/vcxproj/grpc_unsecure/grpc_unsecure.vcxproj.filters @@ -313,7 +313,7 @@ src\core\lib\transport - + src\core\lib\transport @@ -887,7 +887,7 @@ src\core\lib\transport - + src\core\lib\transport From 9ec28af03aaad085902c65b7a59fca5abbedcbad Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 3 Nov 2016 12:32:39 -0700 Subject: [PATCH 023/119] Change value of channel arg to string form, and reparse in each place we use it. --- src/core/ext/client_channel/client_channel.c | 10 ++- src/core/lib/channel/message_size_filter.c | 10 ++- src/core/lib/json/json.c | 59 -------------- src/core/lib/json/json.h | 19 ----- src/core/lib/transport/service_config.c | 78 +++++++++---------- src/core/lib/transport/service_config.h | 26 ++++--- test/core/end2end/connection_refused_test.c | 9 ++- test/core/end2end/tests/cancel_after_accept.c | 9 ++- test/core/end2end/tests/max_message_length.c | 18 +++-- 9 files changed, 84 insertions(+), 154 deletions(-) diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index d9161f47cdd..023bd24c199 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -302,11 +302,13 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, channel_arg = grpc_channel_args_find(chand->resolver_result, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { - GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); - grpc_json_tree *service_config_json = channel_arg->value.pointer.p; - method_params_table = grpc_method_config_table_create_from_json( - service_config_json->root, method_parameters_create_from_json, + GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); + grpc_service_config* service_config = + grpc_service_config_create(channel_arg->value.string); + method_params_table = grpc_service_config_create_method_config_table( + service_config, method_parameters_create_from_json, &method_parameters_vtable); + grpc_service_config_destroy(service_config); } // Clean up. grpc_channel_args_destroy(chand->resolver_result); diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index f826c74f89a..b579fa367a9 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -223,11 +223,13 @@ static void init_channel_elem(grpc_exec_ctx* exec_ctx, const grpc_arg* channel_arg = grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG); if (channel_arg != NULL) { - GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER); - grpc_json_tree* json_tree = channel_arg->value.pointer.p; - chand->method_limit_table = grpc_method_config_table_create_from_json( - json_tree->root, message_size_limits_create_from_json, + GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); + grpc_service_config* service_config = + grpc_service_config_create(channel_arg->value.string); + chand->method_limit_table = grpc_service_config_create_method_config_table( + service_config, message_size_limits_create_from_json, &message_size_limits_vtable); + grpc_service_config_destroy(service_config); } } diff --git a/src/core/lib/json/json.c b/src/core/lib/json/json.c index 9acf3b04388..48b13686d7b 100644 --- a/src/core/lib/json/json.c +++ b/src/core/lib/json/json.c @@ -34,8 +34,6 @@ #include #include -#include -#include #include "src/core/lib/json/json.h" @@ -64,60 +62,3 @@ void grpc_json_destroy(grpc_json* json) { gpr_free(json); } - -int grpc_json_cmp(const grpc_json* json1, const grpc_json* json2) { - if (json1 == NULL) { - if (json2 != NULL) return 1; - return 0; // Both NULL. - } else { - if (json2 == NULL) return -1; - } - // Compare type. - if (json1->type > json2->type) return 1; - if (json1->type < json2->type) return -1; - // Compare key. - if (json1->key == NULL) { - if (json2->key != NULL) return -1; - } else { - if (json2->key == NULL) return 1; - int retval = strcmp(json1->key, json2->key); - if (retval != 0) return retval; - } - // Compare value. - if (json1->value == NULL) { - if (json2->value != NULL) return -1; - } else { - if (json2->value == NULL) return 1; - int retval = strcmp(json1->value, json2->value); - if (retval != 0) return retval; - } - // Recursively compare the next pointer. - int retval = grpc_json_cmp(json1->next, json2->next); - if (retval != 0) return retval; - // Recursively compare the child pointer. - retval = grpc_json_cmp(json1->child, json2->child); - if (retval != 0) return retval; - // Both are the same. - return 0; -} - -grpc_json_tree* grpc_json_tree_create(const char* json_string) { - grpc_json_tree* tree = gpr_malloc(sizeof(*tree)); - tree->string = gpr_strdup(json_string); - tree->root = grpc_json_parse_string(tree->string); - gpr_ref_init(&tree->refs, 1); - return tree; -} - -grpc_json_tree* grpc_json_tree_ref(grpc_json_tree* tree) { - gpr_ref(&tree->refs); - return tree; -} - -void grpc_json_tree_unref(grpc_json_tree* tree) { - if (gpr_unref(&tree->refs)) { - grpc_json_destroy(tree->root); - gpr_free(tree->string); - gpr_free(tree); - } -} diff --git a/src/core/lib/json/json.h b/src/core/lib/json/json.h index 1663c690e52..7111db0b52b 100644 --- a/src/core/lib/json/json.h +++ b/src/core/lib/json/json.h @@ -36,8 +36,6 @@ #include -#include - #include "src/core/lib/json/json_common.h" /* A tree-like structure to hold json values. The key and value pointers @@ -87,21 +85,4 @@ char* grpc_json_dump_to_string(grpc_json* json, int indent); grpc_json* grpc_json_create(grpc_json_type type); void grpc_json_destroy(grpc_json* json); -/* Compares two JSON trees. */ -int grpc_json_cmp(const grpc_json* json1, const grpc_json* json2); - -/* A wrapper that contains the string used for underlying allocation and - is refcounted. */ -typedef struct { - grpc_json* root; - char* string; - gpr_refcount refs; -} grpc_json_tree; - -/* Creates a copy of \a json_string. */ -grpc_json_tree* grpc_json_tree_create(const char* json_string); - -grpc_json_tree* grpc_json_tree_ref(grpc_json_tree* tree); -void grpc_json_tree_unref(grpc_json_tree* tree); - #endif /* GRPC_CORE_LIB_JSON_JSON_H */ diff --git a/src/core/lib/transport/service_config.c b/src/core/lib/transport/service_config.c index 2a717e7b9ba..a467b8c6afb 100644 --- a/src/core/lib/transport/service_config.c +++ b/src/core/lib/transport/service_config.c @@ -42,6 +42,40 @@ #include "src/core/lib/support/string.h" #include "src/core/lib/transport/mdstr_hash_table.h" +struct grpc_service_config { + char* string; + grpc_json* json; +}; + +grpc_service_config* grpc_service_config_create(const char* json_string) { + grpc_service_config* service_config = gpr_malloc(sizeof(*service_config)); + service_config->string = gpr_strdup(json_string); + service_config->json = grpc_json_parse_string(service_config->string); + return service_config; +} + +void grpc_service_config_destroy(grpc_service_config* service_config) { + grpc_json_destroy(service_config->json); + gpr_free(service_config->string); + gpr_free(service_config); +} + +const char* grpc_service_config_get_lb_policy_name( + const grpc_service_config* service_config) { + const grpc_json* json = service_config->json; + if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL; + const char* lb_policy_name = NULL; + for (grpc_json* field = json->child; field != NULL; field = field->next) { + if (field->key == NULL) return NULL; + if (strcmp(field->key, "lb_policy_name") == 0) { + if (lb_policy_name != NULL) return NULL; // Duplicate. + if (field->type != GRPC_JSON_STRING) return NULL; + lb_policy_name = field->value; + } + } + return lb_policy_name; +} + // Returns the number of names specified in the method config \a json. static size_t count_names_in_method_config_json(grpc_json* json) { size_t num_names = 0; @@ -115,10 +149,11 @@ done: return retval; } -grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( - const grpc_json* json, +grpc_mdstr_hash_table* grpc_service_config_create_method_config_table( + const grpc_service_config* service_config, void* (*create_value)(const grpc_json* method_config_json), const grpc_mdstr_hash_table_vtable* vtable) { + const grpc_json* json = service_config->json; // Traverse parsed JSON tree. if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL; size_t num_entries = 0; @@ -180,42 +215,3 @@ void* grpc_method_config_table_get(const grpc_mdstr_hash_table* table, } return value; } - -const char* grpc_service_config_get_lb_policy_name( - grpc_json_tree* service_config) { - grpc_json* json = service_config->root; - if (json->type != GRPC_JSON_OBJECT || json->key != NULL) return NULL; - const char* lb_policy_name = NULL; - for (grpc_json* field = json->child; field != NULL; field = field->next) { - if (field->key == NULL) return NULL; - if (strcmp(field->key, "lb_policy_name") == 0) { - if (lb_policy_name != NULL) return NULL; // Duplicate. - if (field->type != GRPC_JSON_STRING) return NULL; - lb_policy_name = field->value; - } - } - return lb_policy_name; -} - -static void* copy_json_tree(void* t) { return grpc_json_tree_ref(t); } - -static void destroy_json_tree(void* t) { grpc_json_tree_unref(t); } - -static int cmp_json_tree(void* t1, void* t2) { - grpc_json_tree* tree1 = t1; - grpc_json_tree* tree2 = t2; - return grpc_json_cmp(tree1->root, tree2->root); -} - -static grpc_arg_pointer_vtable service_config_arg_vtable = { - copy_json_tree, destroy_json_tree, cmp_json_tree}; - -grpc_arg grpc_service_config_create_channel_arg( - grpc_json_tree* service_config) { - grpc_arg arg; - arg.type = GRPC_ARG_POINTER; - arg.key = GRPC_ARG_SERVICE_CONFIG; - arg.value.pointer.p = service_config; - arg.value.pointer.vtable = &service_config_arg_vtable; - return arg; -} diff --git a/src/core/lib/transport/service_config.h b/src/core/lib/transport/service_config.h index c6c8e6be7fe..bf50226f96d 100644 --- a/src/core/lib/transport/service_config.h +++ b/src/core/lib/transport/service_config.h @@ -37,16 +37,29 @@ #include "src/core/lib/json/json.h" #include "src/core/lib/transport/mdstr_hash_table.h" +typedef struct grpc_service_config grpc_service_config; + +grpc_service_config* grpc_service_config_create(const char* json_string); +void grpc_service_config_destroy(grpc_service_config* service_config); + +/// Gets the LB policy name from \a service_config. +/// Returns NULL if no LB policy name was specified. +/// Caller does NOT take ownership. +const char* grpc_service_config_get_lb_policy_name( + const grpc_service_config* service_config); + /// Creates a method config table based on the data in \a json. /// The table's keys are request paths. The table's value type is /// returned by \a create_value(), based on data parsed from the JSON tree. /// \a vtable provides methods used to manage the values. /// Returns NULL on error. -grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( - const grpc_json* json, +grpc_mdstr_hash_table* grpc_service_config_create_method_config_table( + const grpc_service_config* service_config, void* (*create_value)(const grpc_json* method_config_json), const grpc_mdstr_hash_table_vtable* vtable); +/// A helper function for looking up values in the table returned by +/// grpc_service_config_create_method_config_table(). /// Gets the method config for the specified \a path, which should be of /// the form "/service/method". /// Returns NULL if the method has no config. @@ -54,13 +67,4 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json( void* grpc_method_config_table_get(const grpc_mdstr_hash_table* table, const grpc_mdstr* path); -/// Gets the LB policy name from \a service_config. -/// Returns NULL if no LB policy name was specified. -/// Caller does NOT take ownership. -const char* grpc_service_config_get_lb_policy_name( - grpc_json_tree* service_config); - -/// Creates a channel arg containing \a service_config. -grpc_arg grpc_service_config_create_channel_arg(grpc_json_tree* service_config); - #endif /* GRPC_CORE_LIB_TRANSPORT_SERVICE_CONFIG_H */ diff --git a/test/core/end2end/connection_refused_test.c b/test/core/end2end/connection_refused_test.c index 2814c94e2e7..c14d72f49e2 100644 --- a/test/core/end2end/connection_refused_test.c +++ b/test/core/end2end/connection_refused_test.c @@ -76,7 +76,10 @@ static void run_test(bool wait_for_ready, bool use_service_config) { grpc_channel_args *args = NULL; if (use_service_config) { GPR_ASSERT(wait_for_ready); - grpc_json_tree *service_config_json = grpc_json_tree_create( + grpc_arg arg; + arg.type = GRPC_ARG_STRING; + arg.key = GRPC_ARG_SERVICE_CONFIG; + arg.value.string = "{\n" " \"method_config\": [ {\n" " \"name\": [\n" @@ -84,10 +87,8 @@ static void run_test(bool wait_for_ready, bool use_service_config) { " ],\n" " \"wait_for_ready\": true\n" " } ]\n" - "}"); - grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); + "}"; args = grpc_channel_args_copy_and_add(args, &arg, 1); - grpc_json_tree_unref(service_config_json); } /* create a call, channel to a port which will refuse connection */ diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index a187311b793..d3155f1902b 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -132,7 +132,10 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, grpc_channel_args *args = NULL; if (use_service_config) { - grpc_json_tree *service_config_json = grpc_json_tree_create( + grpc_arg arg; + arg.type = GRPC_ARG_STRING; + arg.key = GRPC_ARG_SERVICE_CONFIG; + arg.value.string = "{\n" " \"method_config\": [ {\n" " \"name\": [\n" @@ -140,10 +143,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, " ],\n" " \"timeout\": { \"seconds\": 5 }\n" " } ]\n" - "}"); - grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); + "}"; args = grpc_channel_args_copy_and_add(args, &arg, 1); - grpc_json_tree_unref(service_config_json); } grpc_end2end_test_fixture f = diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 05ac087c134..f1dbc214dd1 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -137,7 +137,10 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(send_limit); - grpc_json_tree *service_config_json = grpc_json_tree_create( + grpc_arg arg; + arg.type = GRPC_ARG_STRING; + arg.key = GRPC_ARG_SERVICE_CONFIG; + arg.value.string = "{\n" " \"method_config\": [ {\n" " \"name\": [\n" @@ -145,10 +148,8 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, " ],\n" " \"max_request_message_bytes\": 5\n" " } ]\n" - "}"); - grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); + "}"; client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1); - grpc_json_tree_unref(service_config_json); } else { // Set limit via channel args. grpc_arg arg; @@ -308,7 +309,10 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, if (use_service_config) { // We don't currently support service configs on the server side. GPR_ASSERT(!send_limit); - grpc_json_tree *service_config_json = grpc_json_tree_create( + grpc_arg arg; + arg.type = GRPC_ARG_STRING; + arg.key = GRPC_ARG_SERVICE_CONFIG; + arg.value.string = "{\n" " \"method_config\": [ {\n" " \"name\": [\n" @@ -316,10 +320,8 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, " ],\n" " \"max_response_message_bytes\": 5\n" " } ]\n" - "}"); - grpc_arg arg = grpc_service_config_create_channel_arg(service_config_json); + "}"; client_args = grpc_channel_args_copy_and_add(NULL, &arg, 1); - grpc_json_tree_unref(service_config_json); } else { // Set limit via channel args. grpc_arg arg; From 0350471b2e7a3065562b00f122d883d5c4348e60 Mon Sep 17 00:00:00 2001 From: Alexander Polcyn Date: Thu, 3 Nov 2016 12:27:06 -0700 Subject: [PATCH 024/119] example changes to smoke test with 1.0.1 --- .../helloworld-from-cli/Greeter/project.json | 11 ++- .../GreeterClient/project.json | 11 ++- .../GreeterServer/project.json | 11 ++- .../csharp/helloworld/Greeter/Greeter.csproj | 8 +- .../csharp/helloworld/Greeter/packages.config | 6 +- .../GreeterClient/GreeterClient.csproj | 8 +- .../helloworld/GreeterClient/packages.config | 4 +- .../GreeterServer/GreeterServer.csproj | 8 +- .../helloworld/GreeterServer/packages.config | 4 +- .../route_guide/RouteGuide/RouteGuide.cs | 88 +++++++++++++++++-- .../route_guide/RouteGuide/RouteGuide.csproj | 8 +- .../route_guide/RouteGuide/packages.config | 4 +- .../RouteGuideClient/RouteGuideClient.csproj | 8 +- .../RouteGuideClient/packages.config | 4 +- .../RouteGuideServer/RouteGuideServer.csproj | 8 +- .../RouteGuideServer/packages.config | 6 +- 16 files changed, 150 insertions(+), 47 deletions(-) diff --git a/examples/csharp/helloworld-from-cli/Greeter/project.json b/examples/csharp/helloworld-from-cli/Greeter/project.json index 40fba7cf1f5..72254ce73e9 100644 --- a/examples/csharp/helloworld-from-cli/Greeter/project.json +++ b/examples/csharp/helloworld-from-cli/Greeter/project.json @@ -6,7 +6,7 @@ }, "dependencies": { "Google.Protobuf": "3.0.0", - "Grpc": "1.0.0", + "Grpc": "1.0.1", }, "frameworks": { "net45": { @@ -17,6 +17,15 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1" } + }, + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" } } } diff --git a/examples/csharp/helloworld-from-cli/GreeterClient/project.json b/examples/csharp/helloworld-from-cli/GreeterClient/project.json index 74962a90e90..09e156f68e8 100644 --- a/examples/csharp/helloworld-from-cli/GreeterClient/project.json +++ b/examples/csharp/helloworld-from-cli/GreeterClient/project.json @@ -7,7 +7,7 @@ }, "dependencies": { "Google.Protobuf": "3.0.0", - "Grpc": "1.0.0", + "Grpc": "1.0.1", "Greeter": { "target": "project" } @@ -21,6 +21,15 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1" } + }, + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" } } } diff --git a/examples/csharp/helloworld-from-cli/GreeterServer/project.json b/examples/csharp/helloworld-from-cli/GreeterServer/project.json index 33af2544819..8802fe32657 100644 --- a/examples/csharp/helloworld-from-cli/GreeterServer/project.json +++ b/examples/csharp/helloworld-from-cli/GreeterServer/project.json @@ -7,7 +7,7 @@ }, "dependencies": { "Google.Protobuf": "3.0.0", - "Grpc": "1.0.0", + "Grpc": "1.0.1", "Greeter": { "target": "project" } @@ -21,6 +21,15 @@ "dependencies": { "Microsoft.NETCore.Platforms": "1.0.1" } + }, + "netcoreapp1.0": { + "dependencies": { + "Microsoft.NETCore.App": { + "type": "platform", + "version": "1.0.1" + } + }, + "imports": "dnxcore50" } } } diff --git a/examples/csharp/helloworld/Greeter/Greeter.csproj b/examples/csharp/helloworld/Greeter/Greeter.csproj index 54a41d1746a..036e6b59fbc 100644 --- a/examples/csharp/helloworld/Greeter/Greeter.csproj +++ b/examples/csharp/helloworld/Greeter/Greeter.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll @@ -61,11 +61,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/examples/csharp/helloworld/Greeter/packages.config b/examples/csharp/helloworld/Greeter/packages.config index 46f7ddacb76..2bb3a182a66 100644 --- a/examples/csharp/helloworld/Greeter/packages.config +++ b/examples/csharp/helloworld/Greeter/packages.config @@ -1,8 +1,8 @@  - - + + - + diff --git a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj index 43d85e194cf..639ac0e70ca 100644 --- a/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj +++ b/examples/csharp/helloworld/GreeterClient/GreeterClient.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll @@ -59,11 +59,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/examples/csharp/helloworld/GreeterClient/packages.config b/examples/csharp/helloworld/GreeterClient/packages.config index 9f5509769a1..addcae0f173 100644 --- a/examples/csharp/helloworld/GreeterClient/packages.config +++ b/examples/csharp/helloworld/GreeterClient/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj index 5a3457fb7a2..aa7188839c5 100644 --- a/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj +++ b/examples/csharp/helloworld/GreeterServer/GreeterServer.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll @@ -59,11 +59,11 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - + diff --git a/examples/csharp/helloworld/GreeterServer/packages.config b/examples/csharp/helloworld/GreeterServer/packages.config index 9f5509769a1..addcae0f173 100644 --- a/examples/csharp/helloworld/GreeterServer/packages.config +++ b/examples/csharp/helloworld/GreeterServer/packages.config @@ -1,7 +1,7 @@  - - + + diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs index 446113de9d5..54cb823983e 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.cs +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.cs @@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic; namespace Routeguide { /// Holder for reflection information generated from route_guide.proto - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public static partial class RouteGuideReflection { #region Descriptor @@ -59,30 +58,35 @@ namespace Routeguide { /// Latitudes should be in the range +/- 90 degrees and longitude should be in /// the range +/- 180 degrees (inclusive). /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Point : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Point()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[0]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point(Point other) : this() { latitude_ = other.latitude_; longitude_ = other.longitude_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Point Clone() { return new Point(this); } @@ -90,6 +94,7 @@ namespace Routeguide { /// Field number for the "latitude" field. public const int LatitudeFieldNumber = 1; private int latitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Latitude { get { return latitude_; } set { @@ -100,6 +105,7 @@ namespace Routeguide { /// Field number for the "longitude" field. public const int LongitudeFieldNumber = 2; private int longitude_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Longitude { get { return longitude_; } set { @@ -107,10 +113,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Point); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Point other) { if (ReferenceEquals(other, null)) { return false; @@ -123,6 +131,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Latitude != 0) hash ^= Latitude.GetHashCode(); @@ -130,10 +139,12 @@ namespace Routeguide { 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 (Latitude != 0) { output.WriteRawTag(8); @@ -145,6 +156,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Latitude != 0) { @@ -156,6 +168,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Point other) { if (other == null) { return; @@ -168,6 +181,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -193,30 +207,35 @@ namespace Routeguide { /// A latitude-longitude rectangle, represented as two diagonally opposite /// points "lo" and "hi". /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Rectangle : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Rectangle()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[1]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle(Rectangle other) : this() { Lo = other.lo_ != null ? other.Lo.Clone() : null; Hi = other.hi_ != null ? other.Hi.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Rectangle Clone() { return new Rectangle(this); } @@ -227,6 +246,7 @@ namespace Routeguide { /// /// One corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Lo { get { return lo_; } set { @@ -240,6 +260,7 @@ namespace Routeguide { /// /// The other corner of the rectangle. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Hi { get { return hi_; } set { @@ -247,10 +268,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Rectangle); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Rectangle other) { if (ReferenceEquals(other, null)) { return false; @@ -263,6 +286,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (lo_ != null) hash ^= Lo.GetHashCode(); @@ -270,10 +294,12 @@ namespace Routeguide { 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 (lo_ != null) { output.WriteRawTag(10); @@ -285,6 +311,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (lo_ != null) { @@ -296,6 +323,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Rectangle other) { if (other == null) { return; @@ -314,6 +342,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -346,30 +375,35 @@ namespace Routeguide { /// /// If a feature could not be named, the name is empty. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class Feature : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new Feature()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[2]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature(Feature other) : this() { name_ = other.name_; Location = other.location_ != null ? other.Location.Clone() : null; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public Feature Clone() { return new Feature(this); } @@ -380,6 +414,7 @@ namespace Routeguide { /// /// The name of the feature. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Name { get { return name_; } set { @@ -393,6 +428,7 @@ namespace Routeguide { /// /// The point where the feature is detected. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -400,10 +436,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as Feature); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(Feature other) { if (ReferenceEquals(other, null)) { return false; @@ -416,6 +454,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (Name.Length != 0) hash ^= Name.GetHashCode(); @@ -423,10 +462,12 @@ namespace Routeguide { 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 (Name.Length != 0) { output.WriteRawTag(10); @@ -438,6 +479,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (Name.Length != 0) { @@ -449,6 +491,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(Feature other) { if (other == null) { return; @@ -464,6 +507,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -491,30 +535,35 @@ namespace Routeguide { /// /// A RouteNote is a message sent while at a given point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteNote : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteNote()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[3]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote(RouteNote other) : this() { Location = other.location_ != null ? other.Location.Clone() : null; message_ = other.message_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteNote Clone() { return new RouteNote(this); } @@ -525,6 +574,7 @@ namespace Routeguide { /// /// The location from which the message is sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public global::Routeguide.Point Location { get { return location_; } set { @@ -538,6 +588,7 @@ namespace Routeguide { /// /// The message to be sent. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public string Message { get { return message_; } set { @@ -545,10 +596,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteNote); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteNote other) { if (ReferenceEquals(other, null)) { return false; @@ -561,6 +614,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (location_ != null) hash ^= Location.GetHashCode(); @@ -568,10 +622,12 @@ namespace Routeguide { 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 (location_ != null) { output.WriteRawTag(10); @@ -583,6 +639,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (location_ != null) { @@ -594,6 +651,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteNote other) { if (other == null) { return; @@ -609,6 +667,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { @@ -640,25 +699,29 @@ namespace Routeguide { /// detected features, and the total distance covered as the cumulative sum of /// the distance between each point. /// - [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] public sealed partial class RouteSummary : pb::IMessage { private static readonly pb::MessageParser _parser = new pb::MessageParser(() => new RouteSummary()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pb::MessageParser Parser { get { return _parser; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public static pbr::MessageDescriptor Descriptor { get { return global::Routeguide.RouteGuideReflection.Descriptor.MessageTypes[4]; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] pbr::MessageDescriptor pb::IMessage.Descriptor { get { return Descriptor; } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary() { OnConstruction(); } partial void OnConstruction(); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary(RouteSummary other) : this() { pointCount_ = other.pointCount_; featureCount_ = other.featureCount_; @@ -666,6 +729,7 @@ namespace Routeguide { elapsedTime_ = other.elapsedTime_; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public RouteSummary Clone() { return new RouteSummary(this); } @@ -676,6 +740,7 @@ namespace Routeguide { /// /// The number of points received. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int PointCount { get { return pointCount_; } set { @@ -689,6 +754,7 @@ namespace Routeguide { /// /// The number of known features passed while traversing the route. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int FeatureCount { get { return featureCount_; } set { @@ -702,6 +768,7 @@ namespace Routeguide { /// /// The distance covered in metres. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int Distance { get { return distance_; } set { @@ -715,6 +782,7 @@ namespace Routeguide { /// /// The duration of the traversal in seconds. /// + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int ElapsedTime { get { return elapsedTime_; } set { @@ -722,10 +790,12 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as RouteSummary); } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public bool Equals(RouteSummary other) { if (ReferenceEquals(other, null)) { return false; @@ -740,6 +810,7 @@ namespace Routeguide { return true; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override int GetHashCode() { int hash = 1; if (PointCount != 0) hash ^= PointCount.GetHashCode(); @@ -749,10 +820,12 @@ namespace Routeguide { 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 (PointCount != 0) { output.WriteRawTag(8); @@ -772,6 +845,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public int CalculateSize() { int size = 0; if (PointCount != 0) { @@ -789,6 +863,7 @@ namespace Routeguide { return size; } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(RouteSummary other) { if (other == null) { return; @@ -807,6 +882,7 @@ namespace Routeguide { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public void MergeFrom(pb::CodedInputStream input) { uint tag; while ((tag = input.ReadTag()) != 0) { diff --git a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj index 02bca2fc725..eee8f0a1bce 100644 --- a/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj +++ b/examples/csharp/route_guide/RouteGuide/RouteGuide.csproj @@ -35,9 +35,9 @@ False ..\packages\Google.Protobuf.3.0.0\lib\net45\Google.Protobuf.dll - + False - ..\packages\Grpc.Core.1.0.0\lib\net45\Grpc.Core.dll + ..\packages\Grpc.Core.1.0.1\lib\net45\Grpc.Core.dll False @@ -74,12 +74,12 @@ - + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. - +