grpc 1.25.0 → 1.26.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grpc might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Makefile +782 -291
- data/include/grpc/impl/codegen/grpc_types.h +4 -0
- data/include/grpc/impl/codegen/port_platform.h +7 -0
- data/include/grpc/support/alloc.h +0 -16
- data/src/core/ext/filters/client_channel/backend_metric.cc +2 -2
- data/src/core/ext/filters/client_channel/backup_poller.cc +1 -1
- data/src/core/ext/filters/client_channel/channel_connectivity.cc +2 -2
- data/src/core/ext/filters/client_channel/client_channel.cc +95 -88
- data/src/core/ext/filters/client_channel/client_channel_channelz.cc +7 -7
- data/src/core/ext/filters/client_channel/client_channel_channelz.h +4 -2
- data/src/core/ext/filters/client_channel/client_channel_factory.cc +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +3 -3
- data/src/core/ext/filters/client_channel/connector.h +40 -45
- data/src/core/ext/filters/client_channel/global_subchannel_pool.cc +10 -10
- data/src/core/ext/filters/client_channel/health/health_check_client.cc +16 -13
- data/src/core/ext/filters/client_channel/http_connect_handshaker.cc +66 -37
- data/src/core/ext/filters/client_channel/http_proxy.cc +107 -116
- data/src/core/ext/filters/client_channel/http_proxy.h +5 -1
- data/src/core/ext/filters/client_channel/lb_policy.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy.h +9 -5
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +10 -8
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +18 -19
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.cc +4 -3
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb_client_stats.h +4 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/load_balancer_api.cc +1 -1
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +3 -3
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +6 -9
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +368 -0
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds.cc +157 -77
- data/src/core/ext/filters/client_channel/lb_policy_registry.cc +5 -5
- data/src/core/ext/filters/client_channel/lb_policy_registry.h +1 -1
- data/src/core/ext/filters/client_channel/local_subchannel_pool.cc +8 -8
- data/src/core/ext/filters/client_channel/proxy_mapper.h +14 -34
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.cc +46 -79
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +23 -17
- data/src/core/ext/filters/client_channel/resolver.cc +2 -1
- data/src/core/ext/filters/client_channel/resolver.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/dns_resolver_ares.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver.h +1 -1
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_libuv.cc +13 -10
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_posix.cc +3 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_ev_driver_windows.cc +9 -8
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +17 -16
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.h +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper_fallback.cc +4 -4
- data/src/core/ext/filters/client_channel/resolver/fake/fake_resolver.cc +9 -9
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver_factory.h +3 -3
- data/src/core/ext/filters/client_channel/resolver_registry.cc +14 -12
- data/src/core/ext/filters/client_channel/resolver_registry.h +6 -4
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +6 -6
- data/src/core/ext/filters/client_channel/resolver_result_parsing.h +6 -6
- data/src/core/ext/filters/client_channel/resolving_lb_policy.cc +5 -5
- data/src/core/ext/filters/client_channel/resolving_lb_policy.h +3 -3
- data/src/core/ext/filters/client_channel/service_config.cc +15 -14
- data/src/core/ext/filters/client_channel/service_config.h +14 -19
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -36
- data/src/core/ext/filters/client_channel/subchannel.h +11 -12
- data/src/core/ext/filters/client_channel/subchannel_interface.h +1 -1
- data/src/core/ext/filters/client_channel/xds/xds_api.cc +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_api.h +19 -9
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.cc +3 -3
- data/src/core/ext/filters/client_channel/xds/xds_bootstrap.h +6 -5
- data/src/core/ext/filters/client_channel/xds/xds_client.cc +58 -31
- data/src/core/ext/filters/client_channel/xds/xds_client.h +20 -15
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.cc +5 -3
- data/src/core/ext/filters/client_channel/xds/xds_client_stats.h +18 -15
- data/src/core/ext/filters/client_idle/client_idle_filter.cc +10 -10
- data/src/core/ext/filters/deadline/deadline_filter.cc +15 -13
- data/src/core/ext/filters/http/client/http_client_filter.cc +12 -12
- data/src/core/ext/filters/http/client_authority_filter.cc +3 -3
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +13 -7
- data/src/core/ext/filters/http/server/http_server_filter.cc +14 -13
- data/src/core/ext/filters/max_age/max_age_filter.cc +16 -14
- data/src/core/ext/filters/message_size/message_size_filter.cc +10 -8
- data/src/core/ext/filters/message_size/message_size_filter.h +1 -1
- data/src/core/ext/filters/workarounds/workaround_cronet_compression_filter.cc +9 -8
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +141 -174
- data/src/core/ext/transport/chttp2/client/chttp2_connector.h +31 -1
- data/src/core/ext/transport/chttp2/client/insecure/channel_create.cc +7 -6
- data/src/core/ext/transport/chttp2/client/secure/secure_channel_create.cc +14 -12
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +8 -5
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +46 -38
- data/src/core/ext/transport/chttp2/transport/context_list.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/flow_control.h +0 -5
- data/src/core/ext/transport/chttp2/transport/frame_data.cc +6 -7
- data/src/core/ext/transport/chttp2/transport/frame_goaway.cc +2 -2
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/frame_settings.cc +4 -3
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +5 -5
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +11 -8
- data/src/core/ext/transport/chttp2/transport/internal.h +3 -3
- data/src/core/ext/transport/chttp2/transport/parsing.cc +4 -4
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -2
- data/src/core/ext/transport/inproc/inproc_transport.cc +65 -41
- data/src/core/ext/upb-generated/envoy/api/v2/auth/cert.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.c +141 -70
- data/src/core/ext/upb-generated/envoy/api/v2/cds.upb.h +352 -118
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/circuit_breaker.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/filter.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.c +8 -4
- data/src/core/ext/upb-generated/envoy/api/v2/cluster/outlier_detection.upb.h +65 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/address.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.c +16 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/base.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.c +12 -5
- data/src/core/ext/upb-generated/envoy/api/v2/core/config_source.upb.h +34 -0
- data/src/core/ext/upb-generated/envoy/api/v2/core/grpc_service.upb.c +1 -2
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.c +13 -12
- data/src/core/ext/upb-generated/envoy/api/v2/core/health_check.upb.h +28 -24
- data/src/core/ext/upb-generated/envoy/api/v2/core/http_uri.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.c +5 -4
- data/src/core/ext/upb-generated/envoy/api/v2/core/protocol.upb.h +13 -0
- data/src/core/ext/upb-generated/envoy/api/v2/discovery.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.c +23 -23
- data/src/core/ext/upb-generated/envoy/api/v2/eds.upb.h +48 -44
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/endpoint.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/api/v2/endpoint/load_report.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/http.upb.c +16 -0
- data/src/core/ext/upb-generated/envoy/type/http.upb.h +36 -0
- data/src/core/ext/upb-generated/envoy/type/percent.upb.c +0 -1
- data/src/core/ext/upb-generated/envoy/type/range.upb.c +0 -1
- data/src/core/lib/avl/avl.cc +1 -1
- data/src/core/lib/channel/channel_stack.cc +1 -1
- data/src/core/lib/channel/channel_stack.h +16 -4
- data/src/core/lib/channel/channel_trace.cc +4 -4
- data/src/core/lib/channel/channelz.cc +46 -46
- data/src/core/lib/channel/channelz.h +37 -35
- data/src/core/lib/channel/channelz_registry.cc +2 -2
- data/src/core/lib/channel/channelz_registry.h +1 -1
- data/src/core/lib/channel/connected_channel.cc +3 -2
- data/src/core/lib/channel/handshaker.cc +1 -1
- data/src/core/lib/channel/handshaker_registry.cc +5 -5
- data/src/core/lib/channel/handshaker_registry.h +3 -3
- data/src/core/lib/compression/message_compress.cc +3 -2
- data/src/core/lib/compression/stream_compression_identity.cc +5 -7
- data/src/core/lib/gpr/alloc.cc +4 -29
- data/src/core/lib/gpr/cpu_linux.cc +1 -1
- data/src/core/lib/gprpp/fork.cc +4 -4
- data/src/core/lib/gprpp/global_config_env.cc +7 -7
- data/src/core/lib/gprpp/global_config_env.h +2 -2
- data/src/core/lib/gprpp/host_port.cc +8 -8
- data/src/core/lib/gprpp/host_port.h +3 -3
- data/src/core/lib/gprpp/inlined_vector.h +13 -0
- data/src/core/lib/gprpp/map.h +2 -9
- data/src/core/lib/gprpp/memory.h +12 -98
- data/src/core/lib/gprpp/orphanable.h +3 -3
- data/src/core/lib/gprpp/ref_counted.h +3 -3
- data/src/core/lib/gprpp/ref_counted_ptr.h +1 -1
- data/src/core/lib/gprpp/string_view.h +45 -23
- data/src/core/lib/gprpp/thd.h +1 -1
- data/src/core/lib/gprpp/thd_posix.cc +6 -5
- data/src/core/lib/gprpp/thd_windows.cc +3 -3
- data/src/core/lib/http/httpcli.cc +1 -1
- data/src/core/lib/http/httpcli_security_connector.cc +3 -3
- data/src/core/lib/iomgr/buffer_list.cc +10 -5
- data/src/core/lib/iomgr/call_combiner.cc +7 -6
- data/src/core/lib/iomgr/call_combiner.h +4 -3
- data/src/core/lib/iomgr/cfstream_handle.cc +2 -2
- data/src/core/lib/iomgr/closure.h +33 -135
- data/src/core/lib/iomgr/combiner.cc +10 -17
- data/src/core/lib/iomgr/combiner.h +0 -2
- data/src/core/lib/iomgr/endpoint_cfstream.cc +2 -2
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +1 -1
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +3 -2
- data/src/core/lib/iomgr/ev_epollex_linux.cc +23 -13
- data/src/core/lib/iomgr/ev_poll_posix.cc +30 -17
- data/src/core/lib/iomgr/exec_ctx.cc +52 -5
- data/src/core/lib/iomgr/exec_ctx.h +6 -2
- data/src/core/lib/iomgr/executor.cc +16 -37
- data/src/core/lib/iomgr/executor.h +4 -7
- data/src/core/lib/iomgr/executor/threadpool.cc +4 -4
- data/src/core/lib/iomgr/iomgr_custom.cc +1 -1
- data/src/core/lib/iomgr/lockfree_event.cc +9 -8
- data/src/core/lib/iomgr/logical_thread.cc +103 -0
- data/src/core/lib/iomgr/logical_thread.h +52 -0
- data/src/core/lib/iomgr/pollset_custom.cc +5 -5
- data/src/core/lib/iomgr/pollset_set_custom.cc +9 -9
- data/src/core/lib/iomgr/pollset_windows.cc +16 -2
- data/src/core/lib/iomgr/port.h +3 -0
- data/src/core/lib/iomgr/resolve_address_custom.cc +4 -4
- data/src/core/lib/iomgr/resolve_address_posix.cc +8 -9
- data/src/core/lib/iomgr/resolve_address_windows.cc +4 -6
- data/src/core/lib/iomgr/resource_quota.cc +26 -21
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +11 -0
- data/src/core/lib/iomgr/socket_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_custom.cc +2 -2
- data/src/core/lib/iomgr/tcp_client_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_client_windows.cc +2 -2
- data/src/core/lib/iomgr/tcp_custom.cc +10 -9
- data/src/core/lib/iomgr/tcp_posix.cc +19 -15
- data/src/core/lib/iomgr/tcp_server_custom.cc +3 -2
- data/src/core/lib/iomgr/tcp_server_posix.cc +5 -4
- data/src/core/lib/iomgr/tcp_server_windows.cc +5 -3
- data/src/core/lib/iomgr/tcp_windows.cc +16 -13
- data/src/core/lib/iomgr/timer_custom.cc +4 -3
- data/src/core/lib/iomgr/timer_generic.cc +11 -9
- data/src/core/lib/iomgr/udp_server.cc +16 -13
- data/src/core/lib/security/credentials/alts/alts_credentials.cc +8 -5
- data/src/core/lib/security/credentials/alts/check_gcp_environment_windows.cc +45 -57
- data/src/core/lib/security/credentials/composite/composite_credentials.cc +7 -6
- data/src/core/lib/security/credentials/credentials.cc +8 -8
- data/src/core/lib/security/credentials/credentials.h +5 -5
- data/src/core/lib/security/credentials/fake/fake_credentials.cc +5 -5
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +1 -1
- data/src/core/lib/security/credentials/iam/iam_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_credentials.cc +4 -4
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +2 -2
- data/src/core/lib/security/credentials/local/local_credentials.cc +3 -3
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +13 -11
- data/src/core/lib/security/credentials/plugin/plugin_credentials.cc +6 -5
- data/src/core/lib/security/credentials/ssl/ssl_credentials.cc +4 -4
- data/src/core/lib/security/credentials/tls/grpc_tls_credentials_options.cc +5 -5
- data/src/core/lib/security/credentials/tls/spiffe_credentials.cc +2 -2
- data/src/core/lib/security/security_connector/alts/alts_security_connector.cc +28 -22
- data/src/core/lib/security/security_connector/alts/alts_security_connector.h +5 -0
- data/src/core/lib/security/security_connector/fake/fake_security_connector.cc +10 -10
- data/src/core/lib/security/security_connector/load_system_roots_linux.cc +2 -1
- data/src/core/lib/security/security_connector/local/local_security_connector.cc +8 -8
- data/src/core/lib/security/security_connector/security_connector.h +1 -1
- data/src/core/lib/security/security_connector/ssl/ssl_security_connector.cc +9 -9
- data/src/core/lib/security/security_connector/ssl_utils.cc +5 -4
- data/src/core/lib/security/security_connector/tls/spiffe_security_connector.cc +14 -15
- data/src/core/lib/security/transport/client_auth_filter.cc +4 -3
- data/src/core/lib/security/transport/secure_endpoint.cc +9 -8
- data/src/core/lib/security/transport/security_handshaker.cc +67 -23
- data/src/core/lib/security/transport/server_auth_filter.cc +6 -5
- data/src/core/lib/security/transport/target_authority_table.h +1 -1
- data/src/core/lib/slice/b64.cc +3 -4
- data/src/core/lib/slice/b64.h +1 -2
- data/src/core/lib/slice/slice.cc +8 -13
- data/src/core/lib/surface/call.cc +19 -19
- data/src/core/lib/surface/call.h +6 -7
- data/src/core/lib/surface/call_log_batch.cc +1 -2
- data/src/core/lib/surface/channel.cc +17 -18
- data/src/core/lib/surface/channel.h +4 -19
- data/src/core/lib/surface/channel_ping.cc +1 -1
- data/src/core/lib/surface/completion_queue.cc +21 -22
- data/src/core/lib/surface/completion_queue_factory.cc +1 -1
- data/src/core/lib/surface/init.cc +1 -1
- data/src/core/lib/surface/init_secure.cc +2 -2
- data/src/core/lib/surface/lame_client.cc +10 -12
- data/src/core/lib/surface/server.cc +24 -18
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/byte_stream.cc +2 -2
- data/src/core/lib/transport/byte_stream.h +2 -1
- data/src/core/lib/transport/connectivity_state.cc +4 -4
- data/src/core/lib/transport/connectivity_state.h +2 -2
- data/src/core/lib/transport/metadata.cc +8 -10
- data/src/core/lib/transport/metadata.h +5 -8
- data/src/core/lib/transport/metadata_batch.cc +6 -0
- data/src/core/lib/transport/static_metadata.cc +2 -4
- data/src/core/lib/transport/status_metadata.cc +7 -0
- data/src/core/lib/transport/status_metadata.h +18 -0
- data/src/core/lib/transport/transport.cc +9 -7
- data/src/core/plugin_registry/grpc_plugin_registry.cc +4 -0
- data/src/core/tsi/alts/handshaker/alts_handshaker_client.cc +292 -43
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.cc +197 -46
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker.h +4 -2
- data/src/core/tsi/alts/handshaker/alts_tsi_handshaker_private.h +5 -0
- data/src/core/tsi/ssl/session_cache/ssl_session.h +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_boringssl.cc +1 -1
- data/src/core/tsi/ssl/session_cache/ssl_session_cache.cc +4 -4
- data/src/core/tsi/ssl/session_cache/ssl_session_openssl.cc +1 -1
- data/src/core/tsi/ssl_transport_security.cc +2 -1
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.c +0 -4
- data/src/ruby/ext/grpc/rb_grpc_imports.generated.h +0 -6
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/third_party/upb/upb/decode.c +1 -0
- metadata +34 -32
- data/src/core/ext/filters/client_channel/connector.cc +0 -41
- data/src/core/ext/filters/client_channel/proxy_mapper.cc +0 -48
- data/src/core/lib/gprpp/set.h +0 -33
@@ -77,9 +77,14 @@ constexpr char kXds[] = "xds_experimental";
|
|
77
77
|
class ParsedXdsConfig : public LoadBalancingPolicy::Config {
|
78
78
|
public:
|
79
79
|
ParsedXdsConfig(RefCountedPtr<LoadBalancingPolicy::Config> child_policy,
|
80
|
-
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy
|
80
|
+
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy,
|
81
|
+
grpc_core::UniquePtr<char> eds_service_name,
|
82
|
+
grpc_core::UniquePtr<char> lrs_load_reporting_server_name)
|
81
83
|
: child_policy_(std::move(child_policy)),
|
82
|
-
fallback_policy_(std::move(fallback_policy))
|
84
|
+
fallback_policy_(std::move(fallback_policy)),
|
85
|
+
eds_service_name_(std::move(eds_service_name)),
|
86
|
+
lrs_load_reporting_server_name_(
|
87
|
+
std::move(lrs_load_reporting_server_name)) {}
|
83
88
|
|
84
89
|
const char* name() const override { return kXds; }
|
85
90
|
|
@@ -91,9 +96,17 @@ class ParsedXdsConfig : public LoadBalancingPolicy::Config {
|
|
91
96
|
return fallback_policy_;
|
92
97
|
}
|
93
98
|
|
99
|
+
const char* eds_service_name() const { return eds_service_name_.get(); };
|
100
|
+
|
101
|
+
const char* lrs_load_reporting_server_name() const {
|
102
|
+
return lrs_load_reporting_server_name_.get();
|
103
|
+
};
|
104
|
+
|
94
105
|
private:
|
95
106
|
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_;
|
96
107
|
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy_;
|
108
|
+
grpc_core::UniquePtr<char> eds_service_name_;
|
109
|
+
grpc_core::UniquePtr<char> lrs_load_reporting_server_name_;
|
97
110
|
};
|
98
111
|
|
99
112
|
class XdsLb : public LoadBalancingPolicy {
|
@@ -110,36 +123,39 @@ class XdsLb : public LoadBalancingPolicy {
|
|
110
123
|
|
111
124
|
// We need this wrapper for the following reasons:
|
112
125
|
// 1. To process per-locality load reporting.
|
113
|
-
// 2. Since pickers are
|
114
|
-
//
|
115
|
-
|
126
|
+
// 2. Since pickers are std::unique_ptrs we use this RefCounted wrapper to
|
127
|
+
// control
|
128
|
+
// references to it by the xds picker and the locality.
|
129
|
+
class EndpointPickerWrapper : public RefCounted<EndpointPickerWrapper> {
|
116
130
|
public:
|
117
|
-
|
118
|
-
|
131
|
+
EndpointPickerWrapper(
|
132
|
+
std::unique_ptr<SubchannelPicker> picker,
|
133
|
+
RefCountedPtr<XdsClientStats::LocalityStats> locality_stats)
|
119
134
|
: picker_(std::move(picker)),
|
120
135
|
locality_stats_(std::move(locality_stats)) {
|
121
136
|
locality_stats_->RefByPicker();
|
122
137
|
}
|
123
|
-
~
|
138
|
+
~EndpointPickerWrapper() { locality_stats_->UnrefByPicker(); }
|
124
139
|
|
125
140
|
PickResult Pick(PickArgs args);
|
126
141
|
|
127
142
|
private:
|
128
|
-
|
143
|
+
std::unique_ptr<SubchannelPicker> picker_;
|
129
144
|
RefCountedPtr<XdsClientStats::LocalityStats> locality_stats_;
|
130
145
|
};
|
131
146
|
|
132
147
|
// The picker will use a stateless weighting algorithm to pick the locality to
|
133
148
|
// use for each request.
|
134
|
-
class
|
149
|
+
class LocalityPicker : public SubchannelPicker {
|
135
150
|
public:
|
136
151
|
// Maintains a weighted list of pickers from each locality that is in ready
|
137
152
|
// state. The first element in the pair represents the end of a range
|
138
153
|
// proportional to the locality's weight. The start of the range is the
|
139
154
|
// previous value in the vector and is 0 for the first element.
|
140
155
|
using PickerList =
|
141
|
-
InlinedVector<std::pair<uint32_t, RefCountedPtr<
|
142
|
-
|
156
|
+
InlinedVector<std::pair<uint32_t, RefCountedPtr<EndpointPickerWrapper>>,
|
157
|
+
1>;
|
158
|
+
LocalityPicker(RefCountedPtr<XdsLb> xds_policy, PickerList pickers)
|
143
159
|
: xds_policy_(std::move(xds_policy)),
|
144
160
|
pickers_(std::move(pickers)),
|
145
161
|
drop_config_(xds_policy_->drop_config_) {}
|
@@ -165,7 +181,7 @@ class XdsLb : public LoadBalancingPolicy {
|
|
165
181
|
RefCountedPtr<SubchannelInterface> CreateSubchannel(
|
166
182
|
const grpc_channel_args& args) override;
|
167
183
|
void UpdateState(grpc_connectivity_state state,
|
168
|
-
|
184
|
+
std::unique_ptr<SubchannelPicker> picker) override;
|
169
185
|
void RequestReresolution() override;
|
170
186
|
void AddTraceEvent(TraceSeverity severity, StringView message) override;
|
171
187
|
|
@@ -204,7 +220,7 @@ class XdsLb : public LoadBalancingPolicy {
|
|
204
220
|
return connectivity_state_;
|
205
221
|
}
|
206
222
|
uint32_t weight() const { return weight_; }
|
207
|
-
RefCountedPtr<
|
223
|
+
RefCountedPtr<EndpointPickerWrapper> picker_wrapper() const {
|
208
224
|
return picker_wrapper_;
|
209
225
|
}
|
210
226
|
|
@@ -223,7 +239,7 @@ class XdsLb : public LoadBalancingPolicy {
|
|
223
239
|
RefCountedPtr<SubchannelInterface> CreateSubchannel(
|
224
240
|
const grpc_channel_args& args) override;
|
225
241
|
void UpdateState(grpc_connectivity_state state,
|
226
|
-
|
242
|
+
std::unique_ptr<SubchannelPicker> picker) override;
|
227
243
|
// This is a no-op, because we get the addresses from the xds
|
228
244
|
// client, which is a watch-based API.
|
229
245
|
void RequestReresolution() override {}
|
@@ -256,7 +272,7 @@ class XdsLb : public LoadBalancingPolicy {
|
|
256
272
|
RefCountedPtr<XdsLocalityName> name_;
|
257
273
|
OrphanablePtr<LoadBalancingPolicy> child_policy_;
|
258
274
|
OrphanablePtr<LoadBalancingPolicy> pending_child_policy_;
|
259
|
-
RefCountedPtr<
|
275
|
+
RefCountedPtr<EndpointPickerWrapper> picker_wrapper_;
|
260
276
|
grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE;
|
261
277
|
uint32_t weight_;
|
262
278
|
|
@@ -312,8 +328,8 @@ class XdsLb : public LoadBalancingPolicy {
|
|
312
328
|
|
313
329
|
RefCountedPtr<XdsLb> xds_policy_;
|
314
330
|
|
315
|
-
|
316
|
-
|
331
|
+
std::map<RefCountedPtr<XdsLocalityName>, OrphanablePtr<Locality>,
|
332
|
+
XdsLocalityName::Less>
|
317
333
|
localities_;
|
318
334
|
const uint32_t priority_;
|
319
335
|
grpc_connectivity_state connectivity_state_ = GRPC_CHANNEL_IDLE;
|
@@ -377,16 +393,24 @@ class XdsLb : public LoadBalancingPolicy {
|
|
377
393
|
const char* name, const grpc_channel_args* args);
|
378
394
|
void MaybeExitFallbackMode();
|
379
395
|
|
396
|
+
const char* eds_service_name() const {
|
397
|
+
if (config_ != nullptr && config_->eds_service_name() != nullptr) {
|
398
|
+
return config_->eds_service_name();
|
399
|
+
}
|
400
|
+
return server_name_.get();
|
401
|
+
}
|
402
|
+
|
380
403
|
XdsClient* xds_client() const {
|
381
404
|
return xds_client_from_channel_ != nullptr ? xds_client_from_channel_.get()
|
382
405
|
: xds_client_.get();
|
383
406
|
}
|
384
407
|
|
385
|
-
//
|
386
|
-
|
408
|
+
// Server name from target URI.
|
409
|
+
grpc_core::UniquePtr<char> server_name_;
|
387
410
|
|
388
|
-
// Current channel args from the resolver.
|
411
|
+
// Current channel args and config from the resolver.
|
389
412
|
const grpc_channel_args* args_ = nullptr;
|
413
|
+
RefCountedPtr<ParsedXdsConfig> config_;
|
390
414
|
|
391
415
|
// Internal state.
|
392
416
|
bool shutting_down_ = false;
|
@@ -418,14 +442,10 @@ class XdsLb : public LoadBalancingPolicy {
|
|
418
442
|
grpc_timer lb_fallback_timer_;
|
419
443
|
grpc_closure lb_on_fallback_;
|
420
444
|
|
421
|
-
// The policy to use for the fallback backends.
|
422
|
-
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy_config_;
|
423
445
|
// Non-null iff we are in fallback mode.
|
424
446
|
OrphanablePtr<LoadBalancingPolicy> fallback_policy_;
|
425
447
|
OrphanablePtr<LoadBalancingPolicy> pending_fallback_policy_;
|
426
448
|
|
427
|
-
// The policy to use for the backends.
|
428
|
-
RefCountedPtr<LoadBalancingPolicy::Config> child_policy_config_;
|
429
449
|
const grpc_millis locality_retention_interval_ms_;
|
430
450
|
const grpc_millis locality_map_failover_timeout_ms_;
|
431
451
|
// A list of locality maps indexed by priority.
|
@@ -441,10 +461,10 @@ class XdsLb : public LoadBalancingPolicy {
|
|
441
461
|
};
|
442
462
|
|
443
463
|
//
|
444
|
-
// XdsLb::
|
464
|
+
// XdsLb::EndpointPickerWrapper
|
445
465
|
//
|
446
466
|
|
447
|
-
LoadBalancingPolicy::PickResult XdsLb::
|
467
|
+
LoadBalancingPolicy::PickResult XdsLb::EndpointPickerWrapper::Pick(
|
448
468
|
LoadBalancingPolicy::PickArgs args) {
|
449
469
|
// Forward the pick to the picker returned from the child policy.
|
450
470
|
PickResult result = picker_->Pick(args);
|
@@ -460,8 +480,8 @@ LoadBalancingPolicy::PickResult XdsLb::PickerWrapper::Pick(
|
|
460
480
|
result.recv_trailing_metadata_ready =
|
461
481
|
// Note: This callback does not run in either the control plane
|
462
482
|
// combiner or in the data plane mutex.
|
463
|
-
[locality_stats](grpc_error* error, MetadataInterface* metadata
|
464
|
-
CallState* call_state) {
|
483
|
+
[locality_stats](grpc_error* error, MetadataInterface* /*metadata*/,
|
484
|
+
CallState* /*call_state*/) {
|
465
485
|
const bool call_failed = error != GRPC_ERROR_NONE;
|
466
486
|
locality_stats->AddCallFinished(call_failed);
|
467
487
|
locality_stats->Unref(DEBUG_LOCATION, "LocalityStats+call");
|
@@ -470,12 +490,12 @@ LoadBalancingPolicy::PickResult XdsLb::PickerWrapper::Pick(
|
|
470
490
|
}
|
471
491
|
|
472
492
|
//
|
473
|
-
// XdsLb::
|
493
|
+
// XdsLb::LocalityPicker
|
474
494
|
//
|
475
495
|
|
476
|
-
XdsLb::PickResult XdsLb::
|
496
|
+
XdsLb::PickResult XdsLb::LocalityPicker::Pick(PickArgs args) {
|
477
497
|
// Handle drop.
|
478
|
-
const UniquePtr<char>* drop_category;
|
498
|
+
const grpc_core::UniquePtr<char>* drop_category;
|
479
499
|
if (drop_config_->ShouldDrop(&drop_category)) {
|
480
500
|
xds_policy_->client_stats_.AddCallDropped(*drop_category);
|
481
501
|
PickResult result;
|
@@ -489,8 +509,8 @@ XdsLb::PickResult XdsLb::Picker::Pick(PickArgs args) {
|
|
489
509
|
return PickFromLocality(key, args);
|
490
510
|
}
|
491
511
|
|
492
|
-
XdsLb::PickResult XdsLb::
|
493
|
-
|
512
|
+
XdsLb::PickResult XdsLb::LocalityPicker::PickFromLocality(const uint32_t key,
|
513
|
+
PickArgs args) {
|
494
514
|
size_t mid = 0;
|
495
515
|
size_t start_index = 0;
|
496
516
|
size_t end_index = pickers_.size() - 1;
|
@@ -534,8 +554,8 @@ RefCountedPtr<SubchannelInterface> XdsLb::FallbackHelper::CreateSubchannel(
|
|
534
554
|
return parent_->channel_control_helper()->CreateSubchannel(args);
|
535
555
|
}
|
536
556
|
|
537
|
-
void XdsLb::FallbackHelper::UpdateState(
|
538
|
-
|
557
|
+
void XdsLb::FallbackHelper::UpdateState(
|
558
|
+
grpc_connectivity_state state, std::unique_ptr<SubchannelPicker> picker) {
|
539
559
|
if (parent_->shutting_down_) return;
|
540
560
|
// If this request is from the pending fallback policy, ignore it until
|
541
561
|
// it reports READY, at which point we swap it into place.
|
@@ -686,11 +706,11 @@ XdsLb::XdsLb(Args args)
|
|
686
706
|
GPR_ASSERT(server_uri != nullptr);
|
687
707
|
grpc_uri* uri = grpc_uri_parse(server_uri, true);
|
688
708
|
GPR_ASSERT(uri->path[0] != '\0');
|
689
|
-
server_name_
|
709
|
+
server_name_.reset(
|
710
|
+
gpr_strdup(uri->path[0] == '/' ? uri->path + 1 : uri->path));
|
690
711
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) {
|
691
|
-
gpr_log(GPR_INFO,
|
692
|
-
|
693
|
-
server_name_);
|
712
|
+
gpr_log(GPR_INFO, "[xdslb %p] server name from channel: %s", this,
|
713
|
+
server_name_.get());
|
694
714
|
}
|
695
715
|
grpc_uri_destroy(uri);
|
696
716
|
}
|
@@ -699,7 +719,6 @@ XdsLb::~XdsLb() {
|
|
699
719
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_lb_xds_trace)) {
|
700
720
|
gpr_log(GPR_INFO, "[xdslb %p] destroying xds LB policy", this);
|
701
721
|
}
|
702
|
-
gpr_free((void*)server_name_);
|
703
722
|
grpc_channel_args_destroy(args_);
|
704
723
|
}
|
705
724
|
|
@@ -722,9 +741,13 @@ void XdsLb::ShutdownLocked() {
|
|
722
741
|
pending_fallback_policy_.reset();
|
723
742
|
// Cancel the endpoint watch here instead of in our dtor, because the
|
724
743
|
// watcher holds a ref to us.
|
725
|
-
xds_client()->CancelEndpointDataWatch(StringView(
|
744
|
+
xds_client()->CancelEndpointDataWatch(StringView(eds_service_name()),
|
726
745
|
endpoint_watcher_);
|
727
|
-
|
746
|
+
if (config_->lrs_load_reporting_server_name() != nullptr) {
|
747
|
+
xds_client()->RemoveClientStats(
|
748
|
+
StringView(config_->lrs_load_reporting_server_name()),
|
749
|
+
StringView(eds_service_name()), &client_stats_);
|
750
|
+
}
|
728
751
|
xds_client_from_channel_.reset();
|
729
752
|
xds_client_.reset();
|
730
753
|
}
|
@@ -753,9 +776,9 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
|
|
753
776
|
}
|
754
777
|
const bool is_initial_update = args_ == nullptr;
|
755
778
|
// Update config.
|
756
|
-
|
757
|
-
|
758
|
-
|
779
|
+
const char* old_eds_service_name = eds_service_name();
|
780
|
+
auto old_config = std::move(config_);
|
781
|
+
config_ = std::move(args.config);
|
759
782
|
// Update fallback address list.
|
760
783
|
fallback_backend_addresses_ = std::move(args.addresses);
|
761
784
|
// Update args.
|
@@ -772,7 +795,7 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
|
|
772
795
|
if (xds_client_from_channel_ == nullptr) {
|
773
796
|
grpc_error* error = GRPC_ERROR_NONE;
|
774
797
|
xds_client_ = MakeOrphanable<XdsClient>(
|
775
|
-
combiner(), interested_parties(), StringView(
|
798
|
+
combiner(), interested_parties(), StringView(eds_service_name()),
|
776
799
|
nullptr /* service config watcher */, *args_, &error);
|
777
800
|
// TODO(roth): If we decide that we care about fallback mode, add
|
778
801
|
// proper error handling here.
|
@@ -782,11 +805,6 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
|
|
782
805
|
xds_client_.get());
|
783
806
|
}
|
784
807
|
}
|
785
|
-
auto watcher = MakeUnique<EndpointWatcher>(Ref());
|
786
|
-
endpoint_watcher_ = watcher.get();
|
787
|
-
xds_client()->WatchEndpointData(StringView(server_name_),
|
788
|
-
std::move(watcher));
|
789
|
-
xds_client()->AddClientStats(StringView(server_name_), &client_stats_);
|
790
808
|
// Start fallback-at-startup checks.
|
791
809
|
grpc_millis deadline = ExecCtx::Get()->Now() + lb_fallback_timeout_ms_;
|
792
810
|
Ref(DEBUG_LOCATION, "on_fallback_timer").release(); // Held by closure
|
@@ -795,6 +813,42 @@ void XdsLb::UpdateLocked(UpdateArgs args) {
|
|
795
813
|
fallback_at_startup_checks_pending_ = true;
|
796
814
|
grpc_timer_init(&lb_fallback_timer_, deadline, &lb_on_fallback_);
|
797
815
|
}
|
816
|
+
// Update endpoint watcher if needed.
|
817
|
+
if (is_initial_update ||
|
818
|
+
strcmp(old_eds_service_name, eds_service_name()) != 0) {
|
819
|
+
if (!is_initial_update) {
|
820
|
+
xds_client()->CancelEndpointDataWatch(StringView(old_eds_service_name),
|
821
|
+
endpoint_watcher_);
|
822
|
+
}
|
823
|
+
auto watcher = MakeUnique<EndpointWatcher>(Ref());
|
824
|
+
endpoint_watcher_ = watcher.get();
|
825
|
+
xds_client()->WatchEndpointData(StringView(eds_service_name()),
|
826
|
+
std::move(watcher));
|
827
|
+
}
|
828
|
+
// Update load reporting if needed.
|
829
|
+
// TODO(roth): Ideally, we should not collect any stats if load reporting
|
830
|
+
// is disabled, which would require changing this code to recreate
|
831
|
+
// all of the pickers whenever load reporting is enabled or disabled
|
832
|
+
// here.
|
833
|
+
if (is_initial_update ||
|
834
|
+
(config_->lrs_load_reporting_server_name() == nullptr) !=
|
835
|
+
(old_config->lrs_load_reporting_server_name() == nullptr) ||
|
836
|
+
(config_->lrs_load_reporting_server_name() != nullptr &&
|
837
|
+
old_config->lrs_load_reporting_server_name() != nullptr &&
|
838
|
+
strcmp(config_->lrs_load_reporting_server_name(),
|
839
|
+
old_config->lrs_load_reporting_server_name()) != 0)) {
|
840
|
+
if (old_config != nullptr &&
|
841
|
+
old_config->lrs_load_reporting_server_name() != nullptr) {
|
842
|
+
xds_client()->RemoveClientStats(
|
843
|
+
StringView(old_config->lrs_load_reporting_server_name()),
|
844
|
+
StringView(old_eds_service_name), &client_stats_);
|
845
|
+
}
|
846
|
+
if (config_->lrs_load_reporting_server_name() != nullptr) {
|
847
|
+
xds_client()->AddClientStats(
|
848
|
+
StringView(config_->lrs_load_reporting_server_name()),
|
849
|
+
StringView(eds_service_name()), &client_stats_);
|
850
|
+
}
|
851
|
+
}
|
798
852
|
}
|
799
853
|
|
800
854
|
//
|
@@ -839,9 +893,7 @@ void XdsLb::UpdateFallbackPolicyLocked() {
|
|
839
893
|
// Construct update args.
|
840
894
|
UpdateArgs update_args;
|
841
895
|
update_args.addresses = fallback_backend_addresses_;
|
842
|
-
update_args.config =
|
843
|
-
? nullptr
|
844
|
-
: fallback_policy_config_->Ref();
|
896
|
+
update_args.config = config_->fallback_policy();
|
845
897
|
update_args.args = grpc_channel_args_copy(args_);
|
846
898
|
// If the child policy name changes, we need to create a new child
|
847
899
|
// policy. When this happens, we leave child_policy_ as-is and store
|
@@ -892,9 +944,9 @@ void XdsLb::UpdateFallbackPolicyLocked() {
|
|
892
944
|
// that was there before, which will be immediately shut down)
|
893
945
|
// and will later be swapped into child_policy_ by the helper
|
894
946
|
// when the new child transitions into state READY.
|
895
|
-
const char* fallback_policy_name =
|
947
|
+
const char* fallback_policy_name = update_args.config == nullptr
|
896
948
|
? "round_robin"
|
897
|
-
:
|
949
|
+
: update_args.config->name();
|
898
950
|
const bool create_policy =
|
899
951
|
// case 1
|
900
952
|
fallback_policy_ == nullptr ||
|
@@ -941,12 +993,12 @@ void XdsLb::UpdateFallbackPolicyLocked() {
|
|
941
993
|
OrphanablePtr<LoadBalancingPolicy> XdsLb::CreateFallbackPolicyLocked(
|
942
994
|
const char* name, const grpc_channel_args* args) {
|
943
995
|
FallbackHelper* helper =
|
944
|
-
|
996
|
+
new FallbackHelper(Ref(DEBUG_LOCATION, "FallbackHelper"));
|
945
997
|
LoadBalancingPolicy::Args lb_policy_args;
|
946
998
|
lb_policy_args.combiner = combiner();
|
947
999
|
lb_policy_args.args = args;
|
948
1000
|
lb_policy_args.channel_control_helper =
|
949
|
-
|
1001
|
+
std::unique_ptr<ChannelControlHelper>(helper);
|
950
1002
|
OrphanablePtr<LoadBalancingPolicy> lb_policy =
|
951
1003
|
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
|
952
1004
|
name, std::move(lb_policy_args));
|
@@ -1030,7 +1082,7 @@ void XdsLb::PriorityList::UpdateXdsPickerLocked() {
|
|
1030
1082
|
void XdsLb::PriorityList::MaybeCreateLocalityMapLocked(uint32_t priority) {
|
1031
1083
|
// Exhausted priorities in the update.
|
1032
1084
|
if (!priority_list_update().Contains(priority)) return;
|
1033
|
-
auto new_locality_map =
|
1085
|
+
auto new_locality_map = new LocalityMap(
|
1034
1086
|
xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+LocalityMap"), priority);
|
1035
1087
|
priorities_.emplace_back(OrphanablePtr<LocalityMap>(new_locality_map));
|
1036
1088
|
new_locality_map->UpdateLocked(*priority_list_update().Find(priority));
|
@@ -1175,7 +1227,7 @@ void XdsLb::PriorityList::LocalityMap::UpdateXdsPickerLocked() {
|
|
1175
1227
|
// that are ready. Each locality is represented by a portion of the range
|
1176
1228
|
// proportional to its weight, such that the total range is the sum of the
|
1177
1229
|
// weights of all localities.
|
1178
|
-
|
1230
|
+
LocalityPicker::PickerList picker_list;
|
1179
1231
|
uint32_t end = 0;
|
1180
1232
|
for (const auto& p : localities_) {
|
1181
1233
|
const auto& locality_name = p.first;
|
@@ -1187,9 +1239,9 @@ void XdsLb::PriorityList::LocalityMap::UpdateXdsPickerLocked() {
|
|
1187
1239
|
picker_list.push_back(std::make_pair(end, locality->picker_wrapper()));
|
1188
1240
|
}
|
1189
1241
|
xds_policy()->channel_control_helper()->UpdateState(
|
1190
|
-
GRPC_CHANNEL_READY,
|
1191
|
-
|
1192
|
-
|
1242
|
+
GRPC_CHANNEL_READY, MakeUnique<LocalityPicker>(
|
1243
|
+
xds_policy_->Ref(DEBUG_LOCATION, "XdsLb+Picker"),
|
1244
|
+
std::move(picker_list)));
|
1193
1245
|
}
|
1194
1246
|
|
1195
1247
|
OrphanablePtr<XdsLb::PriorityList::LocalityMap::Locality>
|
@@ -1449,12 +1501,12 @@ XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyArgsLocked(
|
|
1449
1501
|
OrphanablePtr<LoadBalancingPolicy>
|
1450
1502
|
XdsLb::PriorityList::LocalityMap::Locality::CreateChildPolicyLocked(
|
1451
1503
|
const char* name, const grpc_channel_args* args) {
|
1452
|
-
Helper* helper =
|
1504
|
+
Helper* helper = new Helper(this->Ref(DEBUG_LOCATION, "Helper"));
|
1453
1505
|
LoadBalancingPolicy::Args lb_policy_args;
|
1454
1506
|
lb_policy_args.combiner = xds_policy()->combiner();
|
1455
1507
|
lb_policy_args.args = args;
|
1456
1508
|
lb_policy_args.channel_control_helper =
|
1457
|
-
|
1509
|
+
std::unique_ptr<ChannelControlHelper>(helper);
|
1458
1510
|
OrphanablePtr<LoadBalancingPolicy> lb_policy =
|
1459
1511
|
LoadBalancingPolicyRegistry::CreateLoadBalancingPolicy(
|
1460
1512
|
name, std::move(lb_policy_args));
|
@@ -1490,9 +1542,7 @@ void XdsLb::PriorityList::LocalityMap::Locality::UpdateLocked(
|
|
1490
1542
|
// Construct update args.
|
1491
1543
|
UpdateArgs update_args;
|
1492
1544
|
update_args.addresses = std::move(serverlist);
|
1493
|
-
update_args.config = xds_policy()->
|
1494
|
-
? nullptr
|
1495
|
-
: xds_policy()->child_policy_config_->Ref();
|
1545
|
+
update_args.config = xds_policy()->config_->child_policy();
|
1496
1546
|
update_args.args = CreateChildPolicyArgsLocked(xds_policy()->args_);
|
1497
1547
|
// If the child policy name changes, we need to create a new child
|
1498
1548
|
// policy. When this happens, we leave child_policy_ as-is and store
|
@@ -1545,10 +1595,9 @@ void XdsLb::PriorityList::LocalityMap::Locality::UpdateLocked(
|
|
1545
1595
|
// when the new child transitions into state READY.
|
1546
1596
|
// TODO(juanlishen): If the child policy is not configured via service config,
|
1547
1597
|
// use whatever algorithm is specified by the balancer.
|
1548
|
-
const char* child_policy_name =
|
1549
|
-
|
1550
|
-
|
1551
|
-
: xds_policy()->child_policy_config_->name();
|
1598
|
+
const char* child_policy_name = update_args.config == nullptr
|
1599
|
+
? "round_robin"
|
1600
|
+
: update_args.config->name();
|
1552
1601
|
const bool create_policy =
|
1553
1602
|
// case 1
|
1554
1603
|
child_policy_ == nullptr ||
|
@@ -1693,7 +1742,7 @@ XdsLb::PriorityList::LocalityMap::Locality::Helper::CreateSubchannel(
|
|
1693
1742
|
}
|
1694
1743
|
|
1695
1744
|
void XdsLb::PriorityList::LocalityMap::Locality::Helper::UpdateState(
|
1696
|
-
grpc_connectivity_state state,
|
1745
|
+
grpc_connectivity_state state, std::unique_ptr<SubchannelPicker> picker) {
|
1697
1746
|
if (locality_->xds_policy()->shutting_down_) return;
|
1698
1747
|
// If this request is from the pending child policy, ignore it until
|
1699
1748
|
// it reports READY, at which point we swap it into place.
|
@@ -1715,7 +1764,11 @@ void XdsLb::PriorityList::LocalityMap::Locality::Helper::UpdateState(
|
|
1715
1764
|
return;
|
1716
1765
|
}
|
1717
1766
|
// Cache the picker and its state in the locality.
|
1718
|
-
|
1767
|
+
// TODO(roth): If load reporting is not configured, we should ideally
|
1768
|
+
// pass a null LocalityStats ref to the EndpointPickerWrapper and have it
|
1769
|
+
// not collect any stats, since they're not going to be used. This would
|
1770
|
+
// require recreating all of the pickers whenever we get a config update.
|
1771
|
+
locality_->picker_wrapper_ = MakeRefCounted<EndpointPickerWrapper>(
|
1719
1772
|
std::move(picker),
|
1720
1773
|
locality_->xds_policy()->client_stats_.FindLocalityStats(
|
1721
1774
|
locality_->name_));
|
@@ -1762,6 +1815,8 @@ class XdsFactory : public LoadBalancingPolicyFactory {
|
|
1762
1815
|
InlinedVector<grpc_error*, 3> error_list;
|
1763
1816
|
RefCountedPtr<LoadBalancingPolicy::Config> child_policy;
|
1764
1817
|
RefCountedPtr<LoadBalancingPolicy::Config> fallback_policy;
|
1818
|
+
const char* eds_service_name = nullptr;
|
1819
|
+
const char* lrs_load_reporting_server_name = nullptr;
|
1765
1820
|
for (const grpc_json* field = json->child; field != nullptr;
|
1766
1821
|
field = field->next) {
|
1767
1822
|
if (field->key == nullptr) continue;
|
@@ -1789,11 +1844,36 @@ class XdsFactory : public LoadBalancingPolicyFactory {
|
|
1789
1844
|
GPR_DEBUG_ASSERT(parse_error != GRPC_ERROR_NONE);
|
1790
1845
|
error_list.push_back(parse_error);
|
1791
1846
|
}
|
1847
|
+
} else if (strcmp(field->key, "edsServiceName") == 0) {
|
1848
|
+
if (eds_service_name != nullptr) {
|
1849
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1850
|
+
"field:edsServiceName error:Duplicate entry"));
|
1851
|
+
}
|
1852
|
+
if (field->type != GRPC_JSON_STRING) {
|
1853
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1854
|
+
"field:edsServiceName error:type should be string"));
|
1855
|
+
continue;
|
1856
|
+
}
|
1857
|
+
eds_service_name = field->value;
|
1858
|
+
} else if (strcmp(field->key, "lrsLoadReportingServerName") == 0) {
|
1859
|
+
if (lrs_load_reporting_server_name != nullptr) {
|
1860
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1861
|
+
"field:lrsLoadReportingServerName error:Duplicate entry"));
|
1862
|
+
}
|
1863
|
+
if (field->type != GRPC_JSON_STRING) {
|
1864
|
+
error_list.push_back(GRPC_ERROR_CREATE_FROM_STATIC_STRING(
|
1865
|
+
"field:lrsLoadReportingServerName error:type should be string"));
|
1866
|
+
continue;
|
1867
|
+
}
|
1868
|
+
lrs_load_reporting_server_name = field->value;
|
1792
1869
|
}
|
1793
1870
|
}
|
1794
1871
|
if (error_list.empty()) {
|
1795
|
-
return
|
1796
|
-
std::move(child_policy), std::move(fallback_policy)
|
1872
|
+
return MakeRefCounted<ParsedXdsConfig>(
|
1873
|
+
std::move(child_policy), std::move(fallback_policy),
|
1874
|
+
grpc_core::UniquePtr<char>(gpr_strdup(eds_service_name)),
|
1875
|
+
grpc_core::UniquePtr<char>(
|
1876
|
+
gpr_strdup(lrs_load_reporting_server_name)));
|
1797
1877
|
} else {
|
1798
1878
|
*error = GRPC_ERROR_CREATE_FROM_VECTOR("Xds Parser", &error_list);
|
1799
1879
|
return nullptr;
|