From 3499960070d74c0d1e770d6cd469e6e251529ef8 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Thu, 24 Aug 2017 14:09:47 -0700 Subject: Renamed load_reporting.{c,h} to load_reporting_plugin.{c,h} --- test/core/end2end/fixtures/h2_load_reporting.c | 2 +- test/core/end2end/tests/load_reporting_hook.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'test/core/end2end') diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 385e2cbf70..031e8318a8 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -28,7 +28,7 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" -#include "src/core/ext/filters/load_reporting/load_reporting.h" +#include "src/core/ext/filters/load_reporting/load_reporting_plugin.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 3584d47887..707612ad68 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -26,8 +26,8 @@ #include #include -#include "src/core/ext/filters/load_reporting/load_reporting.h" #include "src/core/ext/filters/load_reporting/load_reporting_filter.h" +#include "src/core/ext/filters/load_reporting/load_reporting_plugin.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/static_metadata.h" -- cgit v1.2.3 From 0822d331df072c303d8788abcaecfb90270cac41 Mon Sep 17 00:00:00 2001 From: David Garcia Quintas Date: Wed, 6 Sep 2017 17:40:42 -0700 Subject: s/load_reporting/server_load_reporting --- BUILD | 12 +- CMakeLists.txt | 12 +- Makefile | 12 +- binding.gyp | 4 +- build.yaml | 26 +-- config.m4 | 4 +- config.w32 | 4 +- gRPC-Core.podspec | 12 +- grpc.gemspec | 8 +- grpc.gyp | 8 +- package.xml | 8 +- .../filters/load_reporting/load_reporting_filter.c | 228 --------------------- .../filters/load_reporting/load_reporting_filter.h | 27 --- .../filters/load_reporting/load_reporting_plugin.c | 64 ------ .../filters/load_reporting/load_reporting_plugin.h | 58 ------ .../load_reporting/server_load_reporting_filter.c | 228 +++++++++++++++++++++ .../load_reporting/server_load_reporting_filter.h | 28 +++ .../load_reporting/server_load_reporting_plugin.c | 63 ++++++ .../load_reporting/server_load_reporting_plugin.h | 59 ++++++ .../plugin_registry/grpc_cronet_plugin_registry.c | 8 +- src/core/plugin_registry/grpc_plugin_registry.c | 8 +- .../grpc_unsecure_plugin_registry.c | 8 +- src/python/grpcio/grpc_core_dependencies.py | 4 +- test/core/end2end/fixtures/h2_load_reporting.c | 2 +- test/core/end2end/tests/load_reporting_hook.c | 4 +- test/cpp/microbenchmarks/bm_call_create.cc | 4 +- tools/doxygen/Doxyfile.core.internal | 8 +- tools/run_tests/generated/sources_and_headers.json | 48 ++--- 28 files changed, 480 insertions(+), 479 deletions(-) delete mode 100644 src/core/ext/filters/load_reporting/load_reporting_filter.c delete mode 100644 src/core/ext/filters/load_reporting/load_reporting_filter.h delete mode 100644 src/core/ext/filters/load_reporting/load_reporting_plugin.c delete mode 100644 src/core/ext/filters/load_reporting/load_reporting_plugin.h create mode 100644 src/core/ext/filters/load_reporting/server_load_reporting_filter.c create mode 100644 src/core/ext/filters/load_reporting/server_load_reporting_filter.h create mode 100644 src/core/ext/filters/load_reporting/server_load_reporting_plugin.c create mode 100644 src/core/ext/filters/load_reporting/server_load_reporting_plugin.h (limited to 'test/core/end2end') diff --git a/BUILD b/BUILD index b9e74d6024..039c8be233 100644 --- a/BUILD +++ b/BUILD @@ -840,7 +840,7 @@ grpc_cc_library( "grpc_deadline_filter", "grpc_lb_policy_pick_first", "grpc_lb_policy_round_robin", - "grpc_load_reporting", + "grpc_server_load_reporting", "grpc_max_age_filter", "grpc_message_size_filter", "grpc_resolver_dns_ares", @@ -1084,14 +1084,14 @@ grpc_cc_library( ) grpc_cc_library( - name = "grpc_load_reporting", + name = "grpc_server_load_reporting", srcs = [ - "src/core/ext/filters/load_reporting/load_reporting_filter.c", - "src/core/ext/filters/load_reporting/load_reporting_plugin.c", + "src/core/ext/filters/load_reporting/server_load_reporting_filter.c", + "src/core/ext/filters/load_reporting/server_load_reporting_plugin.c", ], hdrs = [ - "src/core/ext/filters/load_reporting/load_reporting_filter.h", - "src/core/ext/filters/load_reporting/load_reporting_plugin.h", + "src/core/ext/filters/load_reporting/server_load_reporting_filter.h", + "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h", ], language = "c", deps = [ diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bea36e527..6690f3ea46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1183,8 +1183,8 @@ add_library(grpc src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c - src/core/ext/filters/load_reporting/load_reporting_filter.c - src/core/ext/filters/load_reporting/load_reporting_plugin.c + src/core/ext/filters/load_reporting/server_load_reporting_filter.c + src/core/ext/filters/load_reporting/server_load_reporting_plugin.c src/core/ext/census/base_resources.c src/core/ext/census/context.c src/core/ext/census/gen/census.pb.c @@ -1508,8 +1508,8 @@ add_library(grpc_cronet src/core/tsi/transport_security.c src/core/tsi/transport_security_adapter.c src/core/ext/transport/chttp2/client/chttp2_connector.c - src/core/ext/filters/load_reporting/load_reporting_filter.c - src/core/ext/filters/load_reporting/load_reporting_plugin.c + src/core/ext/filters/load_reporting/server_load_reporting_filter.c + src/core/ext/filters/load_reporting/server_load_reporting_plugin.c src/core/plugin_registry/grpc_cronet_plugin_registry.c ) @@ -2310,8 +2310,8 @@ add_library(grpc_unsecure src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c - src/core/ext/filters/load_reporting/load_reporting_filter.c - src/core/ext/filters/load_reporting/load_reporting_plugin.c + src/core/ext/filters/load_reporting/server_load_reporting_filter.c + src/core/ext/filters/load_reporting/server_load_reporting_plugin.c src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c diff --git a/Makefile b/Makefile index befab0b02a..ab71d270ff 100644 --- a/Makefile +++ b/Makefile @@ -3130,8 +3130,8 @@ LIBGRPC_SRC = \ src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \ - src/core/ext/filters/load_reporting/load_reporting_filter.c \ - src/core/ext/filters/load_reporting/load_reporting_plugin.c \ + src/core/ext/filters/load_reporting/server_load_reporting_filter.c \ + src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \ src/core/ext/census/base_resources.c \ src/core/ext/census/context.c \ src/core/ext/census/gen/census.pb.c \ @@ -3453,8 +3453,8 @@ LIBGRPC_CRONET_SRC = \ src/core/tsi/transport_security.c \ src/core/tsi/transport_security_adapter.c \ src/core/ext/transport/chttp2/client/chttp2_connector.c \ - src/core/ext/filters/load_reporting/load_reporting_filter.c \ - src/core/ext/filters/load_reporting/load_reporting_plugin.c \ + src/core/ext/filters/load_reporting/server_load_reporting_filter.c \ + src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \ src/core/plugin_registry/grpc_cronet_plugin_registry.c \ PUBLIC_HEADERS_C += \ @@ -4217,8 +4217,8 @@ LIBGRPC_UNSECURE_SRC = \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \ src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c \ - src/core/ext/filters/load_reporting/load_reporting_filter.c \ - src/core/ext/filters/load_reporting/load_reporting_plugin.c \ + src/core/ext/filters/load_reporting/server_load_reporting_filter.c \ + src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c \ src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c \ diff --git a/binding.gyp b/binding.gyp index d1f7068e48..b84638d3c3 100644 --- a/binding.gyp +++ b/binding.gyp @@ -892,8 +892,8 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c', - 'src/core/ext/filters/load_reporting/load_reporting_filter.c', - 'src/core/ext/filters/load_reporting/load_reporting_plugin.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c', 'src/core/ext/census/base_resources.c', 'src/core/ext/census/context.c', 'src/core/ext/census/gen/census.pb.c', diff --git a/build.yaml b/build.yaml index 26c1f93793..00e94b093e 100644 --- a/build.yaml +++ b/build.yaml @@ -587,16 +587,6 @@ filegroups: uses: - grpc_base - grpc_client_channel -- name: grpc_load_reporting - headers: - - src/core/ext/filters/load_reporting/load_reporting_filter.h - - src/core/ext/filters/load_reporting/load_reporting_plugin.h - src: - - src/core/ext/filters/load_reporting/load_reporting_filter.c - - src/core/ext/filters/load_reporting/load_reporting_plugin.c - plugin: grpc_load_reporting_plugin - uses: - - grpc_base - name: grpc_max_age_filter headers: - src/core/ext/filters/max_age/max_age_filter.h @@ -709,6 +699,16 @@ filegroups: - src/core/ext/filters/workarounds/workaround_utils.c uses: - grpc_base +- name: grpc_server_load_reporting + headers: + - src/core/ext/filters/load_reporting/server_load_reporting_filter.h + - src/core/ext/filters/load_reporting/server_load_reporting_plugin.h + src: + - src/core/ext/filters/load_reporting/server_load_reporting_filter.c + - src/core/ext/filters/load_reporting/server_load_reporting_plugin.c + plugin: grpc_server_load_reporting_plugin + uses: + - grpc_base - name: grpc_test_util_base build: test headers: @@ -1152,7 +1152,7 @@ libs: - grpc_resolver_dns_native - grpc_resolver_sockaddr - grpc_resolver_fake - - grpc_load_reporting + - grpc_server_load_reporting - grpc_secure - census - grpc_max_age_filter @@ -1178,7 +1178,7 @@ libs: - grpc_base - grpc_transport_cronet_client_secure - grpc_transport_chttp2_client_secure - - grpc_load_reporting + - grpc_server_load_reporting generate_plugin_registry: true platforms: - linux @@ -1252,7 +1252,7 @@ libs: - grpc_resolver_dns_native - grpc_resolver_sockaddr - grpc_resolver_fake - - grpc_load_reporting + - grpc_server_load_reporting - grpc_lb_policy_grpclb - grpc_lb_policy_pick_first - grpc_lb_policy_round_robin diff --git a/config.m4 b/config.m4 index c3fb87d4d8..7f6b2cc427 100644 --- a/config.m4 +++ b/config.m4 @@ -321,8 +321,8 @@ if test "$PHP_GRPC" != "no"; then src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c \ src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c \ src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c \ - src/core/ext/filters/load_reporting/load_reporting_filter.c \ - src/core/ext/filters/load_reporting/load_reporting_plugin.c \ + src/core/ext/filters/load_reporting/server_load_reporting_filter.c \ + src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \ src/core/ext/census/base_resources.c \ src/core/ext/census/context.c \ src/core/ext/census/gen/census.pb.c \ diff --git a/config.w32 b/config.w32 index 2c00e3e9a8..1c216ec3c7 100644 --- a/config.w32 +++ b/config.w32 @@ -298,8 +298,8 @@ if (PHP_GRPC != "no") { "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\c_ares\\grpc_ares_wrapper_fallback.c " + "src\\core\\ext\\filters\\client_channel\\resolver\\dns\\native\\dns_resolver.c " + "src\\core\\ext\\filters\\client_channel\\resolver\\sockaddr\\sockaddr_resolver.c " + - "src\\core\\ext\\filters\\load_reporting\\load_reporting_filter.c " + - "src\\core\\ext\\filters\\load_reporting\\load_reporting_plugin.c " + + "src\\core\\ext\\filters\\load_reporting\\server_load_reporting_filter.c " + + "src\\core\\ext\\filters\\load_reporting\\server_load_reporting_plugin.c " + "src\\core\\ext\\census\\base_resources.c " + "src\\core\\ext\\census\\context.c " + "src\\core\\ext\\census\\gen\\census.pb.c " + diff --git a/gRPC-Core.podspec b/gRPC-Core.podspec index 5d42da01ce..aa2bf784b2 100644 --- a/gRPC-Core.podspec +++ b/gRPC-Core.podspec @@ -440,8 +440,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/load_reporting/load_reporting_filter.h', - 'src/core/ext/filters/load_reporting/load_reporting_plugin.h', + 'src/core/ext/filters/load_reporting/server_load_reporting_filter.h', + 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/census/aggregation.h', 'src/core/ext/census/base_resources.h', 'src/core/ext/census/census_interface.h', @@ -697,8 +697,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c', - 'src/core/ext/filters/load_reporting/load_reporting_filter.c', - 'src/core/ext/filters/load_reporting/load_reporting_plugin.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c', 'src/core/ext/census/base_resources.c', 'src/core/ext/census/context.c', 'src/core/ext/census/gen/census.pb.c', @@ -934,8 +934,8 @@ Pod::Spec.new do |s| 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h', 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h', - 'src/core/ext/filters/load_reporting/load_reporting_filter.h', - 'src/core/ext/filters/load_reporting/load_reporting_plugin.h', + 'src/core/ext/filters/load_reporting/server_load_reporting_filter.h', + 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.h', 'src/core/ext/census/aggregation.h', 'src/core/ext/census/base_resources.h', 'src/core/ext/census/census_interface.h', diff --git a/grpc.gemspec b/grpc.gemspec index 844a3782f8..8be72c8670 100644 --- a/grpc.gemspec +++ b/grpc.gemspec @@ -372,8 +372,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/fake/fake_resolver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h ) - s.files += %w( src/core/ext/filters/load_reporting/load_reporting_filter.h ) - s.files += %w( src/core/ext/filters/load_reporting/load_reporting_plugin.h ) + s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_filter.h ) + s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_plugin.h ) s.files += %w( src/core/ext/census/aggregation.h ) s.files += %w( src/core/ext/census/base_resources.h ) s.files += %w( src/core/ext/census/census_interface.h ) @@ -632,8 +632,8 @@ Gem::Specification.new do |s| s.files += %w( src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c ) s.files += %w( src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c ) s.files += %w( src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c ) - s.files += %w( src/core/ext/filters/load_reporting/load_reporting_filter.c ) - s.files += %w( src/core/ext/filters/load_reporting/load_reporting_plugin.c ) + s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_filter.c ) + s.files += %w( src/core/ext/filters/load_reporting/server_load_reporting_plugin.c ) s.files += %w( src/core/ext/census/base_resources.c ) s.files += %w( src/core/ext/census/context.c ) s.files += %w( src/core/ext/census/gen/census.pb.c ) diff --git a/grpc.gyp b/grpc.gyp index 470ce02300..f766a3a930 100644 --- a/grpc.gyp +++ b/grpc.gyp @@ -458,8 +458,8 @@ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c', - 'src/core/ext/filters/load_reporting/load_reporting_filter.c', - 'src/core/ext/filters/load_reporting/load_reporting_plugin.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c', 'src/core/ext/census/base_resources.c', 'src/core/ext/census/context.c', 'src/core/ext/census/gen/census.pb.c', @@ -1104,8 +1104,8 @@ 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c', 'src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c', - 'src/core/ext/filters/load_reporting/load_reporting_filter.c', - 'src/core/ext/filters/load_reporting/load_reporting_plugin.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.c', 'src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_channel.c', diff --git a/package.xml b/package.xml index b1f0fa90cf..f4d8e83980 100644 --- a/package.xml +++ b/package.xml @@ -382,8 +382,8 @@ - - + + @@ -642,8 +642,8 @@ - - + + diff --git a/src/core/ext/filters/load_reporting/load_reporting_filter.c b/src/core/ext/filters/load_reporting/load_reporting_filter.c deleted file mode 100644 index e9e4571231..0000000000 --- a/src/core/ext/filters/load_reporting/load_reporting_filter.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include -#include -#include -#include - -#include "src/core/ext/filters/load_reporting/load_reporting_filter.h" -#include "src/core/ext/filters/load_reporting/load_reporting_plugin.h" -#include "src/core/lib/channel/channel_args.h" -#include "src/core/lib/profiling/timers.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/transport/static_metadata.h" - -typedef struct call_data { - intptr_t id; /**< an id unique to the call */ - bool have_trailing_md_string; - grpc_slice trailing_md_string; - bool have_initial_md_string; - grpc_slice initial_md_string; - bool have_service_method; - grpc_slice service_method; - - /* stores the recv_initial_metadata op's ready closure, which we wrap with our - * own (on_initial_md_ready) in order to capture the incoming initial metadata - * */ - grpc_closure *ops_recv_initial_metadata_ready; - - /* to get notified of the availability of the incoming initial metadata. */ - grpc_closure on_initial_md_ready; - grpc_metadata_batch *recv_initial_metadata; -} call_data; - -typedef struct channel_data { - intptr_t id; /**< an id unique to the channel */ -} channel_data; - -static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data, - grpc_error *err) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - - if (err == GRPC_ERROR_NONE) { - if (calld->recv_initial_metadata->idx.named.path != NULL) { - calld->service_method = grpc_slice_ref_internal( - GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.path->md)); - calld->have_service_method = true; - } else { - err = grpc_error_add_child( - err, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing :path header")); - } - if (calld->recv_initial_metadata->idx.named.lb_token != NULL) { - calld->initial_md_string = grpc_slice_ref_internal( - GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.lb_token->md)); - calld->have_initial_md_string = true; - grpc_metadata_batch_remove( - exec_ctx, calld->recv_initial_metadata, - calld->recv_initial_metadata->idx.named.lb_token); - } - } else { - GRPC_ERROR_REF(err); - } - calld->ops_recv_initial_metadata_ready->cb( - exec_ctx, calld->ops_recv_initial_metadata_ready->cb_arg, err); - GRPC_ERROR_UNREF(err); -} - -/* Constructor for call_data */ -static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, - grpc_call_element *elem, - const grpc_call_element_args *args) { - call_data *calld = elem->call_data; - calld->id = (intptr_t)args->call_stack; - GRPC_CLOSURE_INIT(&calld->on_initial_md_ready, on_initial_md_ready, elem, - grpc_schedule_on_exec_ctx); - - /* TODO(dgq): do something with the data - channel_data *chand = elem->channel_data; - grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_CREATION, - (intptr_t)chand->id, - (intptr_t)calld->id, - NULL, - NULL, - NULL, - NULL}; - */ - - return GRPC_ERROR_NONE; -} - -/* Destructor for call_data */ -static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - const grpc_call_final_info *final_info, - grpc_closure *ignored) { - call_data *calld = elem->call_data; - - /* TODO(dgq): do something with the data - channel_data *chand = elem->channel_data; - grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_DESTRUCTION, - (intptr_t)chand->id, - (intptr_t)calld->id, - final_info, - calld->initial_md_string, - calld->trailing_md_string, - calld->service_method}; - */ - - if (calld->have_initial_md_string) { - grpc_slice_unref_internal(exec_ctx, calld->initial_md_string); - } - if (calld->have_trailing_md_string) { - grpc_slice_unref_internal(exec_ctx, calld->trailing_md_string); - } - if (calld->have_service_method) { - grpc_slice_unref_internal(exec_ctx, calld->service_method); - } -} - -/* Constructor for channel_data */ -static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem, - grpc_channel_element_args *args) { - GPR_ASSERT(!args->is_last); - - channel_data *chand = elem->channel_data; - chand->id = (intptr_t)args->channel_stack; - - /* TODO(dgq): do something with the data - grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CHANNEL_CREATION, - (intptr_t)chand, - 0, - NULL, - NULL, - NULL, - NULL}; - */ - - return GRPC_ERROR_NONE; -} - -/* Destructor for channel data */ -static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, - grpc_channel_element *elem) { - /* TODO(dgq): do something with the data - channel_data *chand = elem->channel_data; - grpc_load_reporting_call_data lr_call_data = { - GRPC_LR_POINT_CHANNEL_DESTRUCTION, - (intptr_t)chand->id, - 0, - NULL, - NULL, - NULL, - NULL}; - */ -} - -static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx, - void *user_data, - grpc_mdelem md) { - grpc_call_element *elem = user_data; - call_data *calld = elem->call_data; - if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_LB_COST_BIN)) { - calld->trailing_md_string = GRPC_MDVALUE(md); - return GRPC_FILTERED_REMOVE(); - } - return GRPC_FILTERED_MDELEM(md); -} - -static void lr_start_transport_stream_op_batch( - grpc_exec_ctx *exec_ctx, grpc_call_element *elem, - grpc_transport_stream_op_batch *op) { - GPR_TIMER_BEGIN("lr_start_transport_stream_op_batch", 0); - call_data *calld = elem->call_data; - - if (op->recv_initial_metadata) { - /* substitute our callback for the higher callback */ - calld->recv_initial_metadata = - op->payload->recv_initial_metadata.recv_initial_metadata; - calld->ops_recv_initial_metadata_ready = - op->payload->recv_initial_metadata.recv_initial_metadata_ready; - op->payload->recv_initial_metadata.recv_initial_metadata_ready = - &calld->on_initial_md_ready; - } else if (op->send_trailing_metadata) { - GRPC_LOG_IF_ERROR( - "grpc_metadata_batch_filter", - grpc_metadata_batch_filter( - exec_ctx, - op->payload->send_trailing_metadata.send_trailing_metadata, - lr_trailing_md_filter, elem, - "LR trailing metadata filtering error")); - } - grpc_call_next_op(exec_ctx, elem, op); - - GPR_TIMER_END("lr_start_transport_stream_op_batch", 0); -} - -const grpc_channel_filter grpc_load_reporting_filter = { - lr_start_transport_stream_op_batch, - grpc_channel_next_op, - sizeof(call_data), - init_call_elem, - grpc_call_stack_ignore_set_pollset_or_pollset_set, - destroy_call_elem, - sizeof(channel_data), - init_channel_elem, - destroy_channel_elem, - grpc_call_next_get_peer, - grpc_channel_next_get_info, - "load_reporting"}; diff --git a/src/core/ext/filters/load_reporting/load_reporting_filter.h b/src/core/ext/filters/load_reporting/load_reporting_filter.h deleted file mode 100644 index bdd869fcdb..0000000000 --- a/src/core/ext/filters/load_reporting/load_reporting_filter.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_FILTER_H -#define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_FILTER_H - -#include "src/core/ext/filters/load_reporting/load_reporting_plugin.h" -#include "src/core/lib/channel/channel_stack.h" - -extern const grpc_channel_filter grpc_load_reporting_filter; - -#endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_FILTER_H */ diff --git a/src/core/ext/filters/load_reporting/load_reporting_plugin.c b/src/core/ext/filters/load_reporting/load_reporting_plugin.c deleted file mode 100644 index c43dd2228c..0000000000 --- a/src/core/ext/filters/load_reporting/load_reporting_plugin.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#include - -#include -#include - -#include -#include -#include - -#include "src/core/ext/filters/load_reporting/load_reporting_filter.h" -#include "src/core/ext/filters/load_reporting/load_reporting_plugin.h" -#include "src/core/lib/channel/channel_stack_builder.h" -#include "src/core/lib/slice/slice_internal.h" -#include "src/core/lib/surface/call.h" -#include "src/core/lib/surface/channel_init.h" - -static bool is_load_reporting_enabled(const grpc_channel_args *a) { - return grpc_channel_arg_get_bool( - grpc_channel_args_find(a, GRPC_ARG_ENABLE_LOAD_REPORTING), false); -} - -static bool maybe_add_load_reporting_filter(grpc_exec_ctx *exec_ctx, - grpc_channel_stack_builder *builder, - void *arg) { - const grpc_channel_args *args = - grpc_channel_stack_builder_get_channel_arguments(builder); - if (is_load_reporting_enabled(args)) { - return grpc_channel_stack_builder_prepend_filter( - builder, (const grpc_channel_filter *)arg, NULL, NULL); - } - return true; -} - -grpc_arg grpc_load_reporting_enable_arg() { - return grpc_channel_arg_integer_create(GRPC_ARG_ENABLE_LOAD_REPORTING, 1); -} - -/* Plugin registration */ - -void grpc_load_reporting_plugin_init(void) { - grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, - maybe_add_load_reporting_filter, - (void *)&grpc_load_reporting_filter); -} - -void grpc_load_reporting_plugin_shutdown() {} diff --git a/src/core/ext/filters/load_reporting/load_reporting_plugin.h b/src/core/ext/filters/load_reporting/load_reporting_plugin.h deleted file mode 100644 index ce8039dec0..0000000000 --- a/src/core/ext/filters/load_reporting/load_reporting_plugin.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * - * Copyright 2016 gRPC authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -#ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_PLUGIN_H -#define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_PLUGIN_H - -#include - -#include "src/core/lib/channel/channel_stack.h" - -/** Identifiers for the invocation point of the users LR callback */ -typedef enum grpc_load_reporting_source { - GRPC_LR_POINT_UNKNOWN = 0, - GRPC_LR_POINT_CHANNEL_CREATION, - GRPC_LR_POINT_CHANNEL_DESTRUCTION, - GRPC_LR_POINT_CALL_CREATION, - GRPC_LR_POINT_CALL_DESTRUCTION -} grpc_load_reporting_source; - -/** Call information to be passed to the provided LR callback. */ -typedef struct grpc_load_reporting_call_data { - const grpc_load_reporting_source source; /**< point of last data update. */ - - /** Unique identifier for the channel associated with the data */ - intptr_t channel_id; - - /** Unique identifier for the call associated with the data. If the call - * hasn't been created yet, it'll have a value of zero. */ - intptr_t call_id; - - /** Only valid when \a source is \a GRPC_LR_POINT_CALL_DESTRUCTION, that is, - * once the call has completed */ - const grpc_call_final_info *final_info; - - const char *initial_md_string; /**< value string for LR's initial md key */ - const char *trailing_md_string; /**< value string for LR's trailing md key */ - const char *method_name; /**< Corresponds to :path header */ -} grpc_load_reporting_call_data; - -/** Return a \a grpc_arg enabling load reporting */ -grpc_arg grpc_load_reporting_enable_arg(); - -#endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_LOAD_REPORTING_PLUGIN_H */ diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.c b/src/core/ext/filters/load_reporting/server_load_reporting_filter.c new file mode 100644 index 0000000000..c1ee38ea1a --- /dev/null +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.c @@ -0,0 +1,228 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include +#include +#include +#include + +#include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h" +#include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" +#include "src/core/lib/channel/channel_args.h" +#include "src/core/lib/profiling/timers.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/transport/static_metadata.h" + +typedef struct call_data { + intptr_t id; /**< an id unique to the call */ + bool have_trailing_md_string; + grpc_slice trailing_md_string; + bool have_initial_md_string; + grpc_slice initial_md_string; + bool have_service_method; + grpc_slice service_method; + + /* stores the recv_initial_metadata op's ready closure, which we wrap with our + * own (on_initial_md_ready) in order to capture the incoming initial metadata + * */ + grpc_closure *ops_recv_initial_metadata_ready; + + /* to get notified of the availability of the incoming initial metadata. */ + grpc_closure on_initial_md_ready; + grpc_metadata_batch *recv_initial_metadata; +} call_data; + +typedef struct channel_data { + intptr_t id; /**< an id unique to the channel */ +} channel_data; + +static void on_initial_md_ready(grpc_exec_ctx *exec_ctx, void *user_data, + grpc_error *err) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + + if (err == GRPC_ERROR_NONE) { + if (calld->recv_initial_metadata->idx.named.path != NULL) { + calld->service_method = grpc_slice_ref_internal( + GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.path->md)); + calld->have_service_method = true; + } else { + err = grpc_error_add_child( + err, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Missing :path header")); + } + if (calld->recv_initial_metadata->idx.named.lb_token != NULL) { + calld->initial_md_string = grpc_slice_ref_internal( + GRPC_MDVALUE(calld->recv_initial_metadata->idx.named.lb_token->md)); + calld->have_initial_md_string = true; + grpc_metadata_batch_remove( + exec_ctx, calld->recv_initial_metadata, + calld->recv_initial_metadata->idx.named.lb_token); + } + } else { + GRPC_ERROR_REF(err); + } + calld->ops_recv_initial_metadata_ready->cb( + exec_ctx, calld->ops_recv_initial_metadata_ready->cb_arg, err); + GRPC_ERROR_UNREF(err); +} + +/* Constructor for call_data */ +static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, + grpc_call_element *elem, + const grpc_call_element_args *args) { + call_data *calld = elem->call_data; + calld->id = (intptr_t)args->call_stack; + GRPC_CLOSURE_INIT(&calld->on_initial_md_ready, on_initial_md_ready, elem, + grpc_schedule_on_exec_ctx); + + /* TODO(dgq): do something with the data + channel_data *chand = elem->channel_data; + grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_CREATION, + (intptr_t)chand->id, + (intptr_t)calld->id, + NULL, + NULL, + NULL, + NULL}; + */ + + return GRPC_ERROR_NONE; +} + +/* Destructor for call_data */ +static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + const grpc_call_final_info *final_info, + grpc_closure *ignored) { + call_data *calld = elem->call_data; + + /* TODO(dgq): do something with the data + channel_data *chand = elem->channel_data; + grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CALL_DESTRUCTION, + (intptr_t)chand->id, + (intptr_t)calld->id, + final_info, + calld->initial_md_string, + calld->trailing_md_string, + calld->service_method}; + */ + + if (calld->have_initial_md_string) { + grpc_slice_unref_internal(exec_ctx, calld->initial_md_string); + } + if (calld->have_trailing_md_string) { + grpc_slice_unref_internal(exec_ctx, calld->trailing_md_string); + } + if (calld->have_service_method) { + grpc_slice_unref_internal(exec_ctx, calld->service_method); + } +} + +/* Constructor for channel_data */ +static grpc_error *init_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_element_args *args) { + GPR_ASSERT(!args->is_last); + + channel_data *chand = elem->channel_data; + chand->id = (intptr_t)args->channel_stack; + + /* TODO(dgq): do something with the data + grpc_load_reporting_call_data lr_call_data = {GRPC_LR_POINT_CHANNEL_CREATION, + (intptr_t)chand, + 0, + NULL, + NULL, + NULL, + NULL}; + */ + + return GRPC_ERROR_NONE; +} + +/* Destructor for channel data */ +static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem) { + /* TODO(dgq): do something with the data + channel_data *chand = elem->channel_data; + grpc_load_reporting_call_data lr_call_data = { + GRPC_LR_POINT_CHANNEL_DESTRUCTION, + (intptr_t)chand->id, + 0, + NULL, + NULL, + NULL, + NULL}; + */ +} + +static grpc_filtered_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx, + void *user_data, + grpc_mdelem md) { + grpc_call_element *elem = user_data; + call_data *calld = elem->call_data; + if (grpc_slice_eq(GRPC_MDKEY(md), GRPC_MDSTR_LB_COST_BIN)) { + calld->trailing_md_string = GRPC_MDVALUE(md); + return GRPC_FILTERED_REMOVE(); + } + return GRPC_FILTERED_MDELEM(md); +} + +static void lr_start_transport_stream_op_batch( + grpc_exec_ctx *exec_ctx, grpc_call_element *elem, + grpc_transport_stream_op_batch *op) { + GPR_TIMER_BEGIN("lr_start_transport_stream_op_batch", 0); + call_data *calld = elem->call_data; + + if (op->recv_initial_metadata) { + /* substitute our callback for the higher callback */ + calld->recv_initial_metadata = + op->payload->recv_initial_metadata.recv_initial_metadata; + calld->ops_recv_initial_metadata_ready = + op->payload->recv_initial_metadata.recv_initial_metadata_ready; + op->payload->recv_initial_metadata.recv_initial_metadata_ready = + &calld->on_initial_md_ready; + } else if (op->send_trailing_metadata) { + GRPC_LOG_IF_ERROR( + "grpc_metadata_batch_filter", + grpc_metadata_batch_filter( + exec_ctx, + op->payload->send_trailing_metadata.send_trailing_metadata, + lr_trailing_md_filter, elem, + "LR trailing metadata filtering error")); + } + grpc_call_next_op(exec_ctx, elem, op); + + GPR_TIMER_END("lr_start_transport_stream_op_batch", 0); +} + +const grpc_channel_filter grpc_server_load_reporting_filter = { + lr_start_transport_stream_op_batch, + grpc_channel_next_op, + sizeof(call_data), + init_call_elem, + grpc_call_stack_ignore_set_pollset_or_pollset_set, + destroy_call_elem, + sizeof(channel_data), + init_channel_elem, + destroy_channel_elem, + grpc_call_next_get_peer, + grpc_channel_next_get_info, + "load_reporting"}; diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_filter.h b/src/core/ext/filters/load_reporting/server_load_reporting_filter.h new file mode 100644 index 0000000000..9527868c9f --- /dev/null +++ b/src/core/ext/filters/load_reporting/server_load_reporting_filter.h @@ -0,0 +1,28 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_FILTER_H +#define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_FILTER_H + +#include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" +#include "src/core/lib/channel/channel_stack.h" + +extern const grpc_channel_filter grpc_server_load_reporting_filter; + +#endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_FILTER_H \ + */ diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.c b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.c new file mode 100644 index 0000000000..955ecde904 --- /dev/null +++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.c @@ -0,0 +1,63 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include + +#include +#include + +#include +#include +#include + +#include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h" +#include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" +#include "src/core/lib/channel/channel_stack_builder.h" +#include "src/core/lib/slice/slice_internal.h" +#include "src/core/lib/surface/call.h" +#include "src/core/lib/surface/channel_init.h" + +static bool is_load_reporting_enabled(const grpc_channel_args *a) { + return grpc_channel_arg_get_bool( + grpc_channel_args_find(a, GRPC_ARG_ENABLE_LOAD_REPORTING), false); +} + +static bool maybe_add_server_load_reporting_filter( + grpc_exec_ctx *exec_ctx, grpc_channel_stack_builder *builder, void *arg) { + const grpc_channel_args *args = + grpc_channel_stack_builder_get_channel_arguments(builder); + if (is_load_reporting_enabled(args)) { + return grpc_channel_stack_builder_prepend_filter( + builder, (const grpc_channel_filter *)arg, NULL, NULL); + } + return true; +} + +grpc_arg grpc_load_reporting_enable_arg() { + return grpc_channel_arg_integer_create(GRPC_ARG_ENABLE_LOAD_REPORTING, 1); +} + +/* Plugin registration */ + +void grpc_server_load_reporting_plugin_init(void) { + grpc_channel_init_register_stage(GRPC_SERVER_CHANNEL, INT_MAX, + maybe_add_server_load_reporting_filter, + (void *)&grpc_server_load_reporting_filter); +} + +void grpc_server_load_reporting_plugin_shutdown() {} diff --git a/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h new file mode 100644 index 0000000000..65a6d0900e --- /dev/null +++ b/src/core/ext/filters/load_reporting/server_load_reporting_plugin.h @@ -0,0 +1,59 @@ +/* + * + * Copyright 2016 gRPC authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#ifndef GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H +#define GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H + +#include + +#include "src/core/lib/channel/channel_stack.h" + +/** Identifiers for the invocation point of the users LR callback */ +typedef enum grpc_load_reporting_source { + GRPC_LR_POINT_UNKNOWN = 0, + GRPC_LR_POINT_CHANNEL_CREATION, + GRPC_LR_POINT_CHANNEL_DESTRUCTION, + GRPC_LR_POINT_CALL_CREATION, + GRPC_LR_POINT_CALL_DESTRUCTION +} grpc_load_reporting_source; + +/** Call information to be passed to the provided LR callback. */ +typedef struct grpc_load_reporting_call_data { + const grpc_load_reporting_source source; /**< point of last data update. */ + + /** Unique identifier for the channel associated with the data */ + intptr_t channel_id; + + /** Unique identifier for the call associated with the data. If the call + * hasn't been created yet, it'll have a value of zero. */ + intptr_t call_id; + + /** Only valid when \a source is \a GRPC_LR_POINT_CALL_DESTRUCTION, that is, + * once the call has completed */ + const grpc_call_final_info *final_info; + + const char *initial_md_string; /**< value string for LR's initial md key */ + const char *trailing_md_string; /**< value string for LR's trailing md key */ + const char *method_name; /**< Corresponds to :path header */ +} grpc_load_reporting_call_data; + +/** Return a \a grpc_arg enabling load reporting */ +grpc_arg grpc_load_reporting_enable_arg(); + +#endif /* GRPC_CORE_EXT_FILTERS_LOAD_REPORTING_SERVER_LOAD_REPORTING_PLUGIN_H \ + */ diff --git a/src/core/plugin_registry/grpc_cronet_plugin_registry.c b/src/core/plugin_registry/grpc_cronet_plugin_registry.c index 322ebea111..1c09f54ad9 100644 --- a/src/core/plugin_registry/grpc_cronet_plugin_registry.c +++ b/src/core/plugin_registry/grpc_cronet_plugin_registry.c @@ -28,8 +28,8 @@ extern void grpc_client_channel_init(void); extern void grpc_client_channel_shutdown(void); extern void grpc_tsi_gts_init(void); extern void grpc_tsi_gts_shutdown(void); -extern void grpc_load_reporting_plugin_init(void); -extern void grpc_load_reporting_plugin_shutdown(void); +extern void grpc_server_load_reporting_plugin_init(void); +extern void grpc_server_load_reporting_plugin_shutdown(void); void grpc_register_built_in_plugins(void) { grpc_register_plugin(grpc_http_filters_init, @@ -42,6 +42,6 @@ void grpc_register_built_in_plugins(void) { grpc_client_channel_shutdown); grpc_register_plugin(grpc_tsi_gts_init, grpc_tsi_gts_shutdown); - grpc_register_plugin(grpc_load_reporting_plugin_init, - grpc_load_reporting_plugin_shutdown); + grpc_register_plugin(grpc_server_load_reporting_plugin_init, + grpc_server_load_reporting_plugin_shutdown); } diff --git a/src/core/plugin_registry/grpc_plugin_registry.c b/src/core/plugin_registry/grpc_plugin_registry.c index fa9974952c..9cacf3d306 100644 --- a/src/core/plugin_registry/grpc_plugin_registry.c +++ b/src/core/plugin_registry/grpc_plugin_registry.c @@ -44,8 +44,8 @@ extern void grpc_resolver_dns_native_init(void); extern void grpc_resolver_dns_native_shutdown(void); extern void grpc_resolver_sockaddr_init(void); extern void grpc_resolver_sockaddr_shutdown(void); -extern void grpc_load_reporting_plugin_init(void); -extern void grpc_load_reporting_plugin_shutdown(void); +extern void grpc_server_load_reporting_plugin_init(void); +extern void grpc_server_load_reporting_plugin_shutdown(void); extern void census_grpc_plugin_init(void); extern void census_grpc_plugin_shutdown(void); extern void grpc_max_age_filter_init(void); @@ -82,8 +82,8 @@ void grpc_register_built_in_plugins(void) { grpc_resolver_dns_native_shutdown); grpc_register_plugin(grpc_resolver_sockaddr_init, grpc_resolver_sockaddr_shutdown); - grpc_register_plugin(grpc_load_reporting_plugin_init, - grpc_load_reporting_plugin_shutdown); + grpc_register_plugin(grpc_server_load_reporting_plugin_init, + grpc_server_load_reporting_plugin_shutdown); grpc_register_plugin(census_grpc_plugin_init, census_grpc_plugin_shutdown); grpc_register_plugin(grpc_max_age_filter_init, diff --git a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c index 7eb599d81a..7b90d796d5 100644 --- a/src/core/plugin_registry/grpc_unsecure_plugin_registry.c +++ b/src/core/plugin_registry/grpc_unsecure_plugin_registry.c @@ -36,8 +36,8 @@ extern void grpc_resolver_sockaddr_init(void); extern void grpc_resolver_sockaddr_shutdown(void); extern void grpc_resolver_fake_init(void); extern void grpc_resolver_fake_shutdown(void); -extern void grpc_load_reporting_plugin_init(void); -extern void grpc_load_reporting_plugin_shutdown(void); +extern void grpc_server_load_reporting_plugin_init(void); +extern void grpc_server_load_reporting_plugin_shutdown(void); extern void grpc_lb_policy_grpclb_init(void); extern void grpc_lb_policy_grpclb_shutdown(void); extern void grpc_lb_policy_pick_first_init(void); @@ -72,8 +72,8 @@ void grpc_register_built_in_plugins(void) { grpc_resolver_sockaddr_shutdown); grpc_register_plugin(grpc_resolver_fake_init, grpc_resolver_fake_shutdown); - grpc_register_plugin(grpc_load_reporting_plugin_init, - grpc_load_reporting_plugin_shutdown); + grpc_register_plugin(grpc_server_load_reporting_plugin_init, + grpc_server_load_reporting_plugin_shutdown); grpc_register_plugin(grpc_lb_policy_grpclb_init, grpc_lb_policy_grpclb_shutdown); grpc_register_plugin(grpc_lb_policy_pick_first_init, diff --git a/src/python/grpcio/grpc_core_dependencies.py b/src/python/grpcio/grpc_core_dependencies.py index 8f25006cdc..5e37ad31fb 100644 --- a/src/python/grpcio/grpc_core_dependencies.py +++ b/src/python/grpcio/grpc_core_dependencies.py @@ -297,8 +297,8 @@ CORE_SOURCE_FILES = [ 'src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.c', 'src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.c', 'src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.c', - 'src/core/ext/filters/load_reporting/load_reporting_filter.c', - 'src/core/ext/filters/load_reporting/load_reporting_plugin.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_filter.c', + 'src/core/ext/filters/load_reporting/server_load_reporting_plugin.c', 'src/core/ext/census/base_resources.c', 'src/core/ext/census/context.c', 'src/core/ext/census/gen/census.pb.c', diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 031e8318a8..8a05bb722a 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -28,7 +28,7 @@ #include #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/http/server/http_server_filter.h" -#include "src/core/ext/filters/load_reporting/load_reporting_plugin.h" +#include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" #include "src/core/ext/transport/chttp2/transport/chttp2_transport.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/connected_channel.h" diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 707612ad68..7b503790db 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -26,8 +26,8 @@ #include #include -#include "src/core/ext/filters/load_reporting/load_reporting_filter.h" -#include "src/core/ext/filters/load_reporting/load_reporting_plugin.h" +#include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h" +#include "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/static_metadata.h" diff --git a/test/cpp/microbenchmarks/bm_call_create.cc b/test/cpp/microbenchmarks/bm_call_create.cc index 508f7f94d6..273fd18673 100644 --- a/test/cpp/microbenchmarks/bm_call_create.cc +++ b/test/cpp/microbenchmarks/bm_call_create.cc @@ -35,7 +35,7 @@ extern "C" { #include "src/core/ext/filters/http/client/http_client_filter.h" #include "src/core/ext/filters/http/message_compress/message_compress_filter.h" #include "src/core/ext/filters/http/server/http_server_filter.h" -#include "src/core/ext/filters/load_reporting/load_reporting_filter.h" +#include "src/core/ext/filters/load_reporting/server_load_reporting_filter.h" #include "src/core/ext/filters/message_size/message_size_filter.h" #include "src/core/lib/channel/channel_stack.h" #include "src/core/lib/channel/connected_channel.h" @@ -629,7 +629,7 @@ BENCHMARK_TEMPLATE(BM_IsolatedFilter, HttpServerFilter, SendEmptyMetadata); typedef Fixture<&grpc_message_size_filter, CHECKS_NOT_LAST> MessageSizeFilter; BENCHMARK_TEMPLATE(BM_IsolatedFilter, MessageSizeFilter, NoOp); BENCHMARK_TEMPLATE(BM_IsolatedFilter, MessageSizeFilter, SendEmptyMetadata); -typedef Fixture<&grpc_load_reporting_filter, CHECKS_NOT_LAST> +typedef Fixture<&grpc_server_load_reporting_filter, CHECKS_NOT_LAST> LoadReportingFilter; BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter, NoOp); BENCHMARK_TEMPLATE(BM_IsolatedFilter, LoadReportingFilter, SendEmptyMetadata); diff --git a/tools/doxygen/Doxyfile.core.internal b/tools/doxygen/Doxyfile.core.internal index b35dd92e2e..7bfaed79b7 100644 --- a/tools/doxygen/Doxyfile.core.internal +++ b/tools/doxygen/Doxyfile.core.internal @@ -976,10 +976,10 @@ src/core/ext/filters/http/message_compress/message_compress_filter.c \ src/core/ext/filters/http/message_compress/message_compress_filter.h \ src/core/ext/filters/http/server/http_server_filter.c \ src/core/ext/filters/http/server/http_server_filter.h \ -src/core/ext/filters/load_reporting/load_reporting_filter.c \ -src/core/ext/filters/load_reporting/load_reporting_filter.h \ -src/core/ext/filters/load_reporting/load_reporting_plugin.c \ -src/core/ext/filters/load_reporting/load_reporting_plugin.h \ +src/core/ext/filters/load_reporting/server_load_reporting_filter.c \ +src/core/ext/filters/load_reporting/server_load_reporting_filter.h \ +src/core/ext/filters/load_reporting/server_load_reporting_plugin.c \ +src/core/ext/filters/load_reporting/server_load_reporting_plugin.h \ src/core/ext/filters/max_age/max_age_filter.c \ src/core/ext/filters/max_age/max_age_filter.h \ src/core/ext/filters/message_size/message_size_filter.c \ diff --git a/tools/run_tests/generated/sources_and_headers.json b/tools/run_tests/generated/sources_and_headers.json index 5d9d916558..72acc9c43e 100644 --- a/tools/run_tests/generated/sources_and_headers.json +++ b/tools/run_tests/generated/sources_and_headers.json @@ -5814,7 +5814,6 @@ "grpc_lb_policy_grpclb_secure", "grpc_lb_policy_pick_first", "grpc_lb_policy_round_robin", - "grpc_load_reporting", "grpc_max_age_filter", "grpc_message_size_filter", "grpc_resolver_dns_ares", @@ -5823,6 +5822,7 @@ "grpc_resolver_sockaddr", "grpc_secure", "grpc_server_backward_compatibility", + "grpc_server_load_reporting", "grpc_transport_chttp2_client_insecure", "grpc_transport_chttp2_client_secure", "grpc_transport_chttp2_server_insecure", @@ -5844,7 +5844,7 @@ "deps": [ "gpr", "grpc_base", - "grpc_load_reporting", + "grpc_server_load_reporting", "grpc_transport_chttp2_client_secure", "grpc_transport_cronet_client_secure" ], @@ -5921,7 +5921,6 @@ "grpc_lb_policy_grpclb", "grpc_lb_policy_pick_first", "grpc_lb_policy_round_robin", - "grpc_load_reporting", "grpc_max_age_filter", "grpc_message_size_filter", "grpc_resolver_dns_ares", @@ -5929,6 +5928,7 @@ "grpc_resolver_fake", "grpc_resolver_sockaddr", "grpc_server_backward_compatibility", + "grpc_server_load_reporting", "grpc_transport_chttp2_client_insecure", "grpc_transport_chttp2_server_insecure", "grpc_transport_inproc", @@ -8457,27 +8457,6 @@ "third_party": false, "type": "filegroup" }, - { - "deps": [ - "gpr", - "grpc_base" - ], - "headers": [ - "src/core/ext/filters/load_reporting/load_reporting_filter.h", - "src/core/ext/filters/load_reporting/load_reporting_plugin.h" - ], - "is_filegroup": true, - "language": "c", - "name": "grpc_load_reporting", - "src": [ - "src/core/ext/filters/load_reporting/load_reporting_filter.c", - "src/core/ext/filters/load_reporting/load_reporting_filter.h", - "src/core/ext/filters/load_reporting/load_reporting_plugin.c", - "src/core/ext/filters/load_reporting/load_reporting_plugin.h" - ], - "third_party": false, - "type": "filegroup" - }, { "deps": [ "gpr", @@ -8688,6 +8667,27 @@ "third_party": false, "type": "filegroup" }, + { + "deps": [ + "gpr", + "grpc_base" + ], + "headers": [ + "src/core/ext/filters/load_reporting/server_load_reporting_filter.h", + "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" + ], + "is_filegroup": true, + "language": "c", + "name": "grpc_server_load_reporting", + "src": [ + "src/core/ext/filters/load_reporting/server_load_reporting_filter.c", + "src/core/ext/filters/load_reporting/server_load_reporting_filter.h", + "src/core/ext/filters/load_reporting/server_load_reporting_plugin.c", + "src/core/ext/filters/load_reporting/server_load_reporting_plugin.h" + ], + "third_party": false, + "type": "filegroup" + }, { "deps": [ "gpr", -- cgit v1.2.3