diff options
author | ncteisen <ncteisen@gmail.com> | 2018-10-19 08:57:33 -0700 |
---|---|---|
committer | ncteisen <ncteisen@gmail.com> | 2018-10-19 08:57:33 -0700 |
commit | 0a61b6f1ccda27a32f02da317cc95854188f998d (patch) | |
tree | 3f11bf27d8a075f0500b8d222d15e510547bae3c /src/core/ext | |
parent | 0582a003d5385ce16ec13d5e5d1128913f9b59c6 (diff) | |
parent | 20c848e88d3356195fa70dbb4fe1afee271b735a (diff) |
Merge branch 'master' of https://github.com/grpc/grpc into more-channel-tracing
Diffstat (limited to 'src/core/ext')
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.cc | 140 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.h | 29 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/xds/xds.cc | 33 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc (renamed from src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.cc) | 2 | ||||
-rw-r--r-- | src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h (renamed from src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.h) | 6 | ||||
-rw-r--r-- | src/core/ext/transport/chttp2/transport/parsing.cc | 6 |
6 files changed, 12 insertions, 204 deletions
diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.cc b/src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.cc deleted file mode 100644 index d79453d008..0000000000 --- a/src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.cc +++ /dev/null @@ -1,140 +0,0 @@ -/* - * - * Copyright 2018 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 <grpc/support/port_platform.h> - -#include "src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.h" - -#include <grpc/support/atm.h> -#include <grpc/support/log.h> - -#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h" -#include "src/core/lib/iomgr/error.h" -#include "src/core/lib/profiling/timers.h" - -static grpc_error* init_channel_elem(grpc_channel_element* elem, - grpc_channel_element_args* args) { - return GRPC_ERROR_NONE; -} - -static void destroy_channel_elem(grpc_channel_element* elem) {} - -namespace { - -struct call_data { - // Stats object to update. - grpc_core::RefCountedPtr<grpc_core::XdsLbClientStats> client_stats; - // State for intercepting send_initial_metadata. - grpc_closure on_complete_for_send; - grpc_closure* original_on_complete_for_send; - bool send_initial_metadata_succeeded; - // State for intercepting recv_initial_metadata. - grpc_closure recv_initial_metadata_ready; - grpc_closure* original_recv_initial_metadata_ready; - bool recv_initial_metadata_succeeded; -}; - -} // namespace - -static void on_complete_for_send(void* arg, grpc_error* error) { - call_data* calld = static_cast<call_data*>(arg); - if (error == GRPC_ERROR_NONE) { - calld->send_initial_metadata_succeeded = true; - } - GRPC_CLOSURE_RUN(calld->original_on_complete_for_send, GRPC_ERROR_REF(error)); -} - -static void recv_initial_metadata_ready(void* arg, grpc_error* error) { - call_data* calld = static_cast<call_data*>(arg); - if (error == GRPC_ERROR_NONE) { - calld->recv_initial_metadata_succeeded = true; - } - GRPC_CLOSURE_RUN(calld->original_recv_initial_metadata_ready, - GRPC_ERROR_REF(error)); -} - -static grpc_error* init_call_elem(grpc_call_element* elem, - const grpc_call_element_args* args) { - call_data* calld = static_cast<call_data*>(elem->call_data); - // Get stats object from context and take a ref. - GPR_ASSERT(args->context != nullptr); - if (args->context[GRPC_GRPCLB_CLIENT_STATS].value != nullptr) { - calld->client_stats = static_cast<grpc_core::XdsLbClientStats*>( - args->context[GRPC_GRPCLB_CLIENT_STATS].value) - ->Ref(); - // Record call started. - calld->client_stats->AddCallStarted(); - } - return GRPC_ERROR_NONE; -} - -static void destroy_call_elem(grpc_call_element* elem, - const grpc_call_final_info* final_info, - grpc_closure* ignored) { - call_data* calld = static_cast<call_data*>(elem->call_data); - if (calld->client_stats != nullptr) { - // Record call finished, optionally setting client_failed_to_send and - // received. - calld->client_stats->AddCallFinished( - !calld->send_initial_metadata_succeeded /* client_failed_to_send */, - calld->recv_initial_metadata_succeeded /* known_received */); - // All done, so unref the stats object. - // TODO(roth): Eliminate this once filter stack is converted to C++. - calld->client_stats.reset(); - } -} - -static void start_transport_stream_op_batch( - grpc_call_element* elem, grpc_transport_stream_op_batch* batch) { - call_data* calld = static_cast<call_data*>(elem->call_data); - GPR_TIMER_SCOPE("clr_start_transport_stream_op_batch", 0); - if (calld->client_stats != nullptr) { - // Intercept send_initial_metadata. - if (batch->send_initial_metadata) { - calld->original_on_complete_for_send = batch->on_complete; - GRPC_CLOSURE_INIT(&calld->on_complete_for_send, on_complete_for_send, - calld, grpc_schedule_on_exec_ctx); - batch->on_complete = &calld->on_complete_for_send; - } - // Intercept recv_initial_metadata. - if (batch->recv_initial_metadata) { - calld->original_recv_initial_metadata_ready = - batch->payload->recv_initial_metadata.recv_initial_metadata_ready; - GRPC_CLOSURE_INIT(&calld->recv_initial_metadata_ready, - recv_initial_metadata_ready, calld, - grpc_schedule_on_exec_ctx); - batch->payload->recv_initial_metadata.recv_initial_metadata_ready = - &calld->recv_initial_metadata_ready; - } - } - // Chain to next filter. - grpc_call_next_op(elem, batch); -} - -const grpc_channel_filter xds_client_load_reporting_filter = { - 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, - 0, // sizeof(channel_data) - init_channel_elem, - destroy_channel_elem, - grpc_channel_next_get_info, - "client_load_reporting"}; diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.h b/src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.h deleted file mode 100644 index 31a799154c..0000000000 --- a/src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - * - * Copyright 2018 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_CLIENT_CHANNEL_LB_POLICY_XDS_CLIENT_LOAD_REPORTING_FILTER_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_CLIENT_LOAD_REPORTING_FILTER_H - -#include <grpc/support/port_platform.h> - -#include "src/core/lib/channel/channel_stack.h" - -extern const grpc_channel_filter xds_client_load_reporting_filter; - -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_CLIENT_LOAD_REPORTING_FILTER_H \ - */ diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc index e6c94167f6..7fb4cbdcd2 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc @@ -75,11 +75,10 @@ #include "src/core/ext/filters/client_channel/client_channel.h" #include "src/core/ext/filters/client_channel/client_channel_factory.h" -#include "src/core/ext/filters/client_channel/lb_policy/xds/client_load_reporting_filter.h" -#include "src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.h" #include "src/core/ext/filters/client_channel/lb_policy/xds/xds.h" #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_channel.h" #include "src/core/ext/filters/client_channel/lb_policy/xds/xds_client_stats.h" +#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" #include "src/core/ext/filters/client_channel/lb_policy_factory.h" #include "src/core/ext/filters/client_channel/lb_policy_registry.h" #include "src/core/ext/filters/client_channel/parse_address.h" @@ -673,7 +672,7 @@ bool XdsLb::BalancerCallState::LoadReportCountersAreZero( request->client_stats.num_calls_finished_with_client_failed_to_send == 0 && request->client_stats.num_calls_finished_known_received == 0 && - (drop_entries == nullptr || drop_entries->size() == 0); + (drop_entries == nullptr || drop_entries->empty()); } void XdsLb::BalancerCallState::SendClientLoadReportLocked() { @@ -1275,9 +1274,9 @@ grpc_connectivity_state XdsLb::CheckConnectivityLocked( } void XdsLb::NotifyOnStateChangeLocked(grpc_connectivity_state* current, - grpc_closure* notify) { + grpc_closure* closure) { grpc_connectivity_state_notify_on_state_change(&state_tracker_, current, - notify); + closure); } void XdsLb::ProcessChannelArgsLocked(const grpc_channel_args& args) { @@ -1483,7 +1482,6 @@ void XdsLb::OnBalancerChannelConnectivityChangedLocked(void* arg, xdslb_policy->lb_call_backoff_.Reset(); xdslb_policy->StartBalancerCallLocked(); } - [[fallthrough]]; // Fall through. case GRPC_CHANNEL_SHUTDOWN: done: @@ -1861,34 +1859,11 @@ class XdsFactory : public LoadBalancingPolicyFactory { // Plugin registration // -namespace { - -// Only add client_load_reporting filter if the grpclb LB policy is used. -bool maybe_add_client_load_reporting_filter(grpc_channel_stack_builder* builder, - void* arg) { - const grpc_channel_args* args = - grpc_channel_stack_builder_get_channel_arguments(builder); - const grpc_arg* channel_arg = - grpc_channel_args_find(args, GRPC_ARG_LB_POLICY_NAME); - if (channel_arg != nullptr && channel_arg->type == GRPC_ARG_STRING && - strcmp(channel_arg->value.string, "grpclb") == 0) { - return grpc_channel_stack_builder_append_filter( - builder, (const grpc_channel_filter*)arg, nullptr, nullptr); - } - return true; -} - -} // namespace - void grpc_lb_policy_xds_init() { grpc_core::LoadBalancingPolicyRegistry::Builder:: RegisterLoadBalancingPolicyFactory( grpc_core::UniquePtr<grpc_core::LoadBalancingPolicyFactory>( grpc_core::New<grpc_core::XdsFactory>())); - grpc_channel_init_register_stage(GRPC_CLIENT_SUBCHANNEL, - GRPC_CHANNEL_INIT_BUILTIN_PRIORITY, - maybe_add_client_load_reporting_filter, - (void*)&xds_client_load_reporting_filter); } void grpc_lb_policy_xds_shutdown() {} diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.cc b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc index 3bd2653635..79b7bdbe33 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.cc +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.cc @@ -20,7 +20,7 @@ #include "pb_decode.h" #include "pb_encode.h" -#include "src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.h" +#include "src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h" #include <grpc/support/alloc.h> diff --git a/src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.h b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h index 3f096af6d6..9d08defa7e 100644 --- a/src/core/ext/filters/client_channel/lb_policy/xds/load_balancer_api.h +++ b/src/core/ext/filters/client_channel/lb_policy/xds/xds_load_balancer_api.h @@ -16,8 +16,8 @@ * */ -#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_LOAD_BALANCER_API_H -#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_LOAD_BALANCER_API_H +#ifndef GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_LOAD_BALANCER_API_H +#define GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_LOAD_BALANCER_API_H #include <grpc/support/port_platform.h> @@ -85,5 +85,5 @@ grpc_millis xds_grpclb_duration_to_millis(xds_grpclb_duration* duration_pb); /** Destroy \a initial_response */ void xds_grpclb_initial_response_destroy(xds_grpclb_initial_response* response); -#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_LOAD_BALANCER_API_H \ +#endif /* GRPC_CORE_EXT_FILTERS_CLIENT_CHANNEL_LB_POLICY_XDS_XDS_LOAD_BALANCER_API_H \ */ diff --git a/src/core/ext/transport/chttp2/transport/parsing.cc b/src/core/ext/transport/chttp2/transport/parsing.cc index f532b084c9..1ff96d3cd3 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.cc +++ b/src/core/ext/transport/chttp2/transport/parsing.cc @@ -368,6 +368,7 @@ static grpc_error* init_data_frame_parser(grpc_chttp2_transport* t) { &s->data_parser, t->incoming_frame_flags, s->id, s); } error_handler: + intptr_t unused; if (err == GRPC_ERROR_NONE) { t->incoming_stream = s; /* t->parser = grpc_chttp2_data_parser_parse;*/ @@ -375,7 +376,7 @@ error_handler: t->parser_data = &s->data_parser; t->ping_state.last_ping_sent_time = GRPC_MILLIS_INF_PAST; return GRPC_ERROR_NONE; - } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) { + } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, &unused)) { /* handle stream errors by closing the stream */ if (s != nullptr) { grpc_chttp2_mark_stream_closed(t, s, true, false, err); @@ -756,9 +757,10 @@ static grpc_error* parse_frame_slice(grpc_chttp2_transport* t, grpc_slice slice, int is_last) { grpc_chttp2_stream* s = t->incoming_stream; grpc_error* err = t->parser(t->parser_data, t, s, slice, is_last); + intptr_t unused; if (GPR_LIKELY(err == GRPC_ERROR_NONE)) { return err; - } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, nullptr)) { + } else if (grpc_error_get_int(err, GRPC_ERROR_INT_STREAM_ID, &unused)) { if (grpc_http_trace.enabled()) { const char* msg = grpc_error_string(err); gpr_log(GPR_ERROR, "%s", msg); |