grpc 1.49.1 → 1.50.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 +54 -153
- data/include/grpc/event_engine/endpoint_config.h +11 -5
- data/include/grpc/event_engine/event_engine.h +1 -1
- data/include/grpc/impl/codegen/atm_gcc_atomic.h +19 -28
- data/include/grpc/impl/codegen/atm_gcc_sync.h +0 -2
- data/include/grpc/impl/codegen/atm_windows.h +0 -2
- data/include/grpc/impl/codegen/grpc_types.h +6 -0
- data/src/core/ext/filters/channel_idle/channel_idle_filter.cc +3 -3
- data/src/core/ext/filters/client_channel/backup_poller.cc +4 -6
- data/src/core/ext/filters/client_channel/client_channel.cc +33 -22
- data/src/core/ext/filters/client_channel/client_channel.h +1 -1
- data/src/core/ext/filters/client_channel/client_channel_plugin.cc +0 -16
- data/src/core/ext/filters/client_channel/http_proxy.cc +12 -19
- data/src/core/ext/filters/client_channel/http_proxy.h +3 -2
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.cc +6 -4
- data/src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h +5 -4
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/client_load_reporting_filter.cc +0 -2
- data/src/core/ext/filters/client_channel/lb_policy/grpclb/grpclb.cc +112 -96
- data/src/core/ext/filters/client_channel/lb_policy/oob_backend_metric.cc +20 -11
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.cc +106 -108
- data/src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h +16 -0
- data/src/core/ext/filters/client_channel/lb_policy/pick_first/pick_first.cc +20 -13
- data/src/core/ext/filters/client_channel/lb_policy/priority/priority.cc +165 -257
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.cc +218 -231
- data/src/core/ext/filters/client_channel/lb_policy/ring_hash/ring_hash.h +10 -6
- data/src/core/ext/filters/client_channel/lb_policy/rls/rls.cc +389 -444
- data/src/core/ext/filters/client_channel/lb_policy/round_robin/round_robin.cc +16 -16
- data/src/core/ext/filters/client_channel/lb_policy/subchannel_list.h +8 -13
- data/src/core/ext/filters/client_channel/lb_policy/weighted_target/weighted_target.cc +84 -96
- data/src/core/ext/filters/client_channel/lb_policy/xds/cds.cc +38 -37
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_impl.cc +106 -186
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_manager.cc +106 -93
- data/src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc +170 -218
- data/src/core/ext/filters/client_channel/resolver/dns/c_ares/grpc_ares_wrapper.cc +2 -2
- data/src/core/ext/filters/client_channel/resolver/dns/native/dns_resolver.cc +1 -1
- data/src/core/ext/filters/client_channel/resolver/google_c2p/google_c2p_resolver.cc +13 -15
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.cc +84 -37
- data/src/core/ext/filters/client_channel/resolver/polling_resolver.h +11 -0
- data/src/core/ext/filters/client_channel/resolver/sockaddr/sockaddr_resolver.cc +1 -0
- data/src/core/ext/filters/client_channel/resolver/xds/xds_resolver.cc +5 -3
- data/src/core/ext/filters/client_channel/resolver_result_parsing.cc +5 -4
- data/src/core/ext/filters/client_channel/retry_filter.cc +25 -29
- data/src/core/ext/filters/client_channel/subchannel.cc +38 -33
- data/src/core/ext/filters/client_channel/subchannel.h +12 -3
- data/src/core/ext/filters/client_channel/subchannel_stream_client.cc +1 -2
- data/src/core/ext/filters/fault_injection/fault_injection_filter.cc +23 -16
- data/src/core/ext/filters/fault_injection/fault_injection_filter.h +8 -0
- data/src/core/ext/filters/http/client/http_client_filter.cc +1 -2
- data/src/core/ext/filters/http/message_compress/message_compress_filter.cc +2 -4
- data/src/core/ext/filters/http/message_compress/message_decompress_filter.cc +0 -2
- data/src/core/ext/filters/http/server/http_server_filter.cc +1 -2
- data/src/core/ext/transport/chttp2/client/chttp2_connector.cc +12 -8
- data/src/core/ext/transport/chttp2/server/chttp2_server.cc +32 -26
- data/src/core/ext/transport/chttp2/transport/bin_encoder.cc +1 -1
- data/src/core/ext/transport/chttp2/transport/chttp2_transport.cc +25 -130
- data/src/core/ext/transport/chttp2/transport/decode_huff.cc +287 -0
- data/src/core/ext/transport/chttp2/transport/decode_huff.h +1018 -0
- data/src/core/ext/transport/chttp2/transport/flow_control.cc +83 -51
- data/src/core/ext/transport/chttp2/transport/flow_control.h +11 -6
- data/src/core/ext/transport/chttp2/transport/frame_ping.cc +1 -2
- data/src/core/ext/transport/chttp2/transport/hpack_encoder.cc +2 -20
- data/src/core/ext/transport/chttp2/transport/hpack_parser.cc +28 -28
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.cc +1 -10
- data/src/core/ext/transport/chttp2/transport/hpack_parser_table.h +11 -6
- data/src/core/ext/transport/chttp2/transport/internal.h +2 -0
- data/src/core/ext/transport/chttp2/transport/parsing.cc +44 -0
- data/src/core/ext/transport/chttp2/transport/writing.cc +3 -14
- data/src/core/ext/transport/inproc/inproc_transport.cc +1 -3
- data/src/core/ext/xds/certificate_provider_store.cc +63 -3
- data/src/core/ext/xds/certificate_provider_store.h +9 -1
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.cc +5 -5
- data/src/core/ext/xds/file_watcher_certificate_provider_factory.h +1 -1
- data/src/core/ext/xds/xds_api.cc +21 -17
- data/src/core/ext/xds/xds_api.h +7 -0
- data/src/core/ext/xds/xds_bootstrap.cc +5 -537
- data/src/core/ext/xds/xds_bootstrap.h +39 -111
- data/src/core/ext/xds/xds_bootstrap_grpc.cc +370 -0
- data/src/core/ext/xds/xds_bootstrap_grpc.h +169 -0
- data/src/core/ext/xds/xds_client.cc +219 -145
- data/src/core/ext/xds/xds_client.h +19 -17
- data/src/core/ext/xds/xds_client_grpc.cc +18 -80
- data/src/core/ext/xds/xds_client_grpc.h +2 -25
- data/src/core/ext/xds/xds_client_stats.cc +4 -4
- data/src/core/ext/xds/xds_cluster.cc +87 -79
- data/src/core/ext/xds/xds_cluster.h +5 -5
- data/src/core/ext/xds/xds_cluster_specifier_plugin.cc +3 -1
- data/src/core/ext/xds/xds_common_types.cc +13 -5
- data/src/core/ext/xds/xds_endpoint.cc +8 -6
- data/src/core/ext/xds/xds_endpoint.h +3 -4
- data/src/core/ext/xds/xds_lb_policy_registry.cc +4 -2
- data/src/core/ext/xds/xds_listener.cc +25 -20
- data/src/core/ext/xds/xds_listener.h +3 -4
- data/src/core/ext/xds/xds_resource_type.h +11 -8
- data/src/core/ext/xds/xds_route_config.cc +15 -16
- data/src/core/ext/xds/xds_route_config.h +3 -3
- data/src/core/ext/xds/xds_server_config_fetcher.cc +7 -5
- data/src/core/ext/xds/xds_transport_grpc.cc +15 -7
- data/src/core/lib/backoff/backoff.cc +2 -4
- data/src/core/lib/channel/call_finalization.h +1 -3
- data/src/core/lib/channel/channel_args.h +114 -14
- data/src/core/lib/channel/channel_trace.cc +3 -4
- data/src/core/lib/channel/promise_based_filter.cc +18 -19
- data/src/core/lib/channel/status_util.cc +27 -0
- data/src/core/lib/channel/status_util.h +10 -0
- data/src/core/lib/config/core_configuration.cc +5 -1
- data/src/core/lib/config/core_configuration.h +33 -0
- data/src/core/lib/debug/stats.cc +26 -30
- data/src/core/lib/debug/stats.h +2 -12
- data/src/core/lib/debug/stats_data.cc +118 -614
- data/src/core/lib/debug/stats_data.h +67 -465
- data/src/core/lib/debug/trace.cc +0 -2
- data/src/core/lib/event_engine/channel_args_endpoint_config.cc +12 -20
- data/src/core/lib/event_engine/channel_args_endpoint_config.h +13 -7
- data/src/core/lib/event_engine/forkable.cc +1 -1
- data/src/core/lib/event_engine/poller.h +14 -12
- data/src/core/lib/event_engine/posix_engine/timer_manager.cc +53 -32
- data/src/core/lib/event_engine/posix_engine/timer_manager.h +23 -1
- data/src/core/lib/event_engine/thread_pool.cc +131 -94
- data/src/core/lib/event_engine/thread_pool.h +56 -23
- data/src/core/lib/event_engine/time_util.cc +30 -0
- data/src/core/lib/event_engine/time_util.h +32 -0
- data/src/core/lib/event_engine/utils.cc +0 -5
- data/src/core/lib/event_engine/utils.h +0 -4
- data/src/core/lib/event_engine/windows/iocp.cc +13 -7
- data/src/core/lib/event_engine/windows/iocp.h +2 -1
- data/src/core/lib/event_engine/windows/win_socket.cc +1 -1
- data/src/core/lib/experiments/config.cc +146 -0
- data/src/core/lib/experiments/config.h +43 -0
- data/src/core/lib/experiments/experiments.cc +75 -0
- data/src/core/lib/experiments/experiments.h +56 -0
- data/src/core/lib/gpr/alloc.cc +1 -9
- data/src/core/lib/gpr/log_windows.cc +0 -1
- data/src/core/lib/gpr/string_util_windows.cc +3 -30
- data/src/core/lib/gpr/sync_abseil.cc +0 -14
- data/src/core/lib/gpr/sync_posix.cc +0 -14
- data/src/core/lib/gpr/time_posix.cc +0 -6
- data/src/core/lib/gpr/time_precise.h +1 -1
- data/src/core/lib/gpr/tmpfile_windows.cc +5 -7
- data/src/core/lib/gpr/useful.h +11 -0
- data/src/core/lib/{gpr → gprpp}/env.h +25 -12
- data/src/core/lib/{gpr → gprpp}/env_linux.cc +20 -15
- data/src/core/lib/{gpr → gprpp}/env_posix.cc +11 -10
- data/src/core/lib/gprpp/env_windows.cc +56 -0
- data/src/core/lib/gprpp/fork.cc +14 -22
- data/src/core/lib/gprpp/fork.h +0 -8
- data/src/core/lib/gprpp/global_config_env.cc +7 -6
- data/src/core/lib/gprpp/notification.h +67 -0
- data/src/core/lib/gprpp/packed_table.h +40 -0
- data/src/core/lib/gprpp/ref_counted_ptr.h +20 -33
- data/src/core/lib/gprpp/sorted_pack.h +98 -0
- data/src/core/lib/gprpp/status_helper.h +6 -0
- data/src/core/lib/gprpp/table.h +9 -1
- data/src/core/lib/gprpp/tchar.cc +49 -0
- data/src/core/lib/gprpp/tchar.h +33 -0
- data/src/core/lib/gprpp/time.cc +21 -0
- data/src/core/lib/gprpp/time.h +55 -0
- data/src/core/lib/gprpp/validation_errors.cc +61 -0
- data/src/core/lib/gprpp/validation_errors.h +110 -0
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper.h +3 -3
- data/src/core/{ext/filters/client_channel → lib/handshaker}/proxy_mapper_registry.cc +14 -36
- data/src/core/lib/handshaker/proxy_mapper_registry.h +75 -0
- data/src/core/lib/iomgr/call_combiner.cc +0 -8
- data/src/core/lib/iomgr/closure.h +0 -1
- data/src/core/lib/iomgr/endpoint_pair_posix.cc +14 -10
- data/src/core/lib/iomgr/endpoint_pair_windows.cc +2 -2
- data/src/core/lib/iomgr/ev_epoll1_linux.cc +1 -38
- data/src/core/lib/iomgr/ev_poll_posix.cc +2 -17
- data/src/core/lib/iomgr/exec_ctx.cc +0 -10
- data/src/core/lib/iomgr/exec_ctx.h +7 -31
- data/src/core/lib/iomgr/iocp_windows.cc +1 -2
- data/src/core/lib/iomgr/iomgr.cc +6 -8
- data/src/core/lib/iomgr/iomgr_fwd.h +1 -0
- data/src/core/lib/iomgr/pollset.h +1 -1
- data/src/core/lib/iomgr/pollset_set.h +0 -1
- data/src/core/lib/iomgr/resolve_address.h +1 -0
- data/src/core/lib/iomgr/resolve_address_impl.h +1 -0
- data/src/core/lib/iomgr/resolve_address_posix.cc +1 -0
- data/src/core/lib/iomgr/resolve_address_windows.cc +1 -0
- data/src/core/lib/iomgr/sockaddr_utils_posix.cc +2 -1
- data/src/core/lib/iomgr/socket_utils_common_posix.cc +12 -34
- data/src/core/lib/iomgr/socket_utils_posix.cc +83 -1
- data/src/core/lib/iomgr/socket_utils_posix.h +98 -6
- data/src/core/lib/iomgr/tcp_client.cc +6 -7
- data/src/core/lib/iomgr/tcp_client.h +11 -11
- data/src/core/lib/iomgr/tcp_client_cfstream.cc +6 -6
- data/src/core/lib/iomgr/tcp_client_posix.cc +33 -29
- data/src/core/lib/iomgr/tcp_client_posix.h +12 -9
- data/src/core/lib/iomgr/tcp_client_windows.cc +6 -6
- data/src/core/lib/iomgr/tcp_posix.cc +131 -114
- data/src/core/lib/iomgr/tcp_posix.h +3 -1
- data/src/core/lib/iomgr/tcp_server.cc +5 -4
- data/src/core/lib/iomgr/tcp_server.h +9 -6
- data/src/core/lib/iomgr/tcp_server_posix.cc +17 -28
- data/src/core/lib/iomgr/tcp_server_utils_posix.h +2 -2
- data/src/core/lib/iomgr/tcp_server_utils_posix_common.cc +3 -3
- data/src/core/lib/iomgr/tcp_server_windows.cc +6 -7
- data/src/core/lib/iomgr/tcp_windows.cc +0 -1
- data/src/core/lib/iomgr/tcp_windows.h +0 -1
- data/src/core/lib/iomgr/timer_generic.cc +4 -4
- data/src/core/lib/iomgr/timer_manager.cc +1 -2
- data/src/core/lib/iomgr/wakeup_fd_eventfd.cc +0 -2
- data/src/core/lib/json/json_object_loader.cc +21 -52
- data/src/core/lib/json/json_object_loader.h +56 -76
- data/src/core/lib/json/json_util.cc +2 -1
- data/src/core/lib/load_balancing/lb_policy.h +5 -5
- data/src/core/lib/load_balancing/lb_policy_registry.cc +29 -55
- data/src/core/lib/load_balancing/lb_policy_registry.h +23 -11
- data/src/core/lib/promise/activity.h +2 -3
- data/src/core/lib/promise/context.h +1 -1
- data/src/core/lib/promise/sleep.cc +16 -4
- data/src/core/lib/promise/sleep.h +8 -2
- data/src/core/lib/resolver/resolver.h +13 -3
- data/src/core/lib/resource_quota/api.cc +9 -0
- data/src/core/lib/resource_quota/api.h +6 -0
- data/src/core/lib/resource_quota/arena.cc +1 -3
- data/src/core/lib/resource_quota/memory_quota.cc +8 -24
- data/src/core/lib/resource_quota/memory_quota.h +6 -19
- data/src/core/lib/resource_quota/periodic_update.cc +2 -3
- data/src/core/{ext/xds → lib/security/certificate_provider}/certificate_provider_factory.h +3 -3
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.cc +60 -0
- data/src/core/lib/security/certificate_provider/certificate_provider_registry.h +70 -0
- data/src/core/lib/security/credentials/channel_creds_registry_init.cc +1 -0
- data/src/core/lib/security/credentials/external/aws_external_account_credentials.cc +15 -16
- data/src/core/lib/security/credentials/external/external_account_credentials.cc +2 -1
- data/src/core/lib/security/credentials/google_default/credentials_generic.cc +5 -8
- data/src/core/lib/security/credentials/google_default/google_default_credentials.cc +6 -6
- data/src/core/lib/security/credentials/jwt/jwt_verifier.cc +3 -2
- data/src/core/lib/security/credentials/jwt/jwt_verifier.h +1 -1
- data/src/core/lib/security/credentials/oauth2/oauth2_credentials.cc +1 -2
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.cc +4 -3
- data/src/core/lib/security/credentials/tls/grpc_tls_certificate_provider.h +4 -2
- data/src/core/lib/security/credentials/tls/tls_utils.cc +3 -1
- data/src/core/lib/security/transport/client_auth_filter.cc +12 -1
- data/src/core/lib/security/transport/secure_endpoint.cc +0 -4
- data/src/core/lib/surface/call.cc +1 -11
- data/src/core/lib/surface/channel.cc +3 -2
- data/src/core/lib/surface/completion_queue.cc +16 -28
- data/src/core/lib/surface/completion_queue.h +1 -1
- data/src/core/lib/surface/completion_queue_factory.cc +5 -0
- data/src/core/lib/surface/init.cc +16 -11
- data/src/core/lib/surface/init_internally.cc +24 -0
- data/src/core/lib/surface/init_internally.h +28 -0
- data/src/core/lib/surface/server.cc +1 -7
- data/src/core/lib/surface/server.h +4 -6
- data/src/core/lib/surface/version.cc +2 -2
- data/src/core/lib/transport/bdp_estimator.cc +1 -3
- data/src/core/lib/transport/metadata_batch.cc +2 -3
- data/src/core/lib/transport/metadata_batch.h +9 -7
- data/src/core/lib/transport/parsed_metadata.h +4 -2
- data/src/core/lib/transport/status_conversion.cc +1 -3
- data/src/core/lib/transport/tcp_connect_handshaker.cc +9 -5
- data/src/core/lib/transport/transport.h +0 -1
- data/src/core/lib/transport/transport_impl.h +0 -1
- data/src/core/plugin_registry/grpc_plugin_registry.cc +23 -46
- data/src/core/plugin_registry/grpc_plugin_registry_extra.cc +13 -25
- data/src/ruby/lib/grpc/version.rb +1 -1
- data/src/ruby/spec/channel_spec.rb +5 -0
- data/src/ruby/spec/generic/server_interceptors_spec.rb +1 -1
- data/src/ruby/spec/user_agent_spec.rb +1 -1
- metadata +33 -19
- data/src/core/ext/filters/client_channel/proxy_mapper_registry.h +0 -56
- data/src/core/ext/xds/certificate_provider_registry.cc +0 -103
- data/src/core/ext/xds/certificate_provider_registry.h +0 -59
- data/src/core/lib/event_engine/promise.h +0 -78
- data/src/core/lib/gpr/env_windows.cc +0 -74
- data/src/core/lib/gpr/string_windows.h +0 -32
- data/src/core/lib/profiling/basic_timers.cc +0 -295
- data/src/core/lib/profiling/stap_timers.cc +0 -50
- data/src/core/lib/profiling/timers.h +0 -94
@@ -21,7 +21,6 @@
|
|
21
21
|
#include <algorithm>
|
22
22
|
#include <map>
|
23
23
|
#include <memory>
|
24
|
-
#include <set>
|
25
24
|
#include <string>
|
26
25
|
#include <utility>
|
27
26
|
#include <vector>
|
@@ -40,19 +39,22 @@
|
|
40
39
|
#include "src/core/ext/filters/client_channel/lb_policy/child_policy_handler.h"
|
41
40
|
#include "src/core/ext/filters/client_channel/resolver/xds/xds_resolver.h"
|
42
41
|
#include "src/core/lib/channel/channel_args.h"
|
42
|
+
#include "src/core/lib/config/core_configuration.h"
|
43
43
|
#include "src/core/lib/debug/trace.h"
|
44
44
|
#include "src/core/lib/gprpp/debug_location.h"
|
45
45
|
#include "src/core/lib/gprpp/orphanable.h"
|
46
46
|
#include "src/core/lib/gprpp/ref_counted.h"
|
47
47
|
#include "src/core/lib/gprpp/ref_counted_ptr.h"
|
48
48
|
#include "src/core/lib/gprpp/time.h"
|
49
|
+
#include "src/core/lib/gprpp/validation_errors.h"
|
49
50
|
#include "src/core/lib/gprpp/work_serializer.h"
|
50
51
|
#include "src/core/lib/iomgr/closure.h"
|
51
52
|
#include "src/core/lib/iomgr/error.h"
|
52
|
-
#include "src/core/lib/iomgr/exec_ctx.h"
|
53
53
|
#include "src/core/lib/iomgr/pollset_set.h"
|
54
54
|
#include "src/core/lib/iomgr/timer.h"
|
55
55
|
#include "src/core/lib/json/json.h"
|
56
|
+
#include "src/core/lib/json/json_args.h"
|
57
|
+
#include "src/core/lib/json/json_object_loader.h"
|
56
58
|
#include "src/core/lib/load_balancing/lb_policy.h"
|
57
59
|
#include "src/core/lib/load_balancing/lb_policy_factory.h"
|
58
60
|
#include "src/core/lib/load_balancing/lb_policy_registry.h"
|
@@ -74,18 +76,36 @@ constexpr absl::string_view kXdsClusterManager =
|
|
74
76
|
// Config for xds_cluster_manager LB policy.
|
75
77
|
class XdsClusterManagerLbConfig : public LoadBalancingPolicy::Config {
|
76
78
|
public:
|
77
|
-
|
78
|
-
|
79
|
+
struct Child {
|
80
|
+
RefCountedPtr<LoadBalancingPolicy::Config> config;
|
79
81
|
|
80
|
-
|
81
|
-
|
82
|
+
static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
|
83
|
+
void JsonPostLoad(const Json& json, const JsonArgs&,
|
84
|
+
ValidationErrors* errors);
|
85
|
+
};
|
86
|
+
|
87
|
+
XdsClusterManagerLbConfig() = default;
|
88
|
+
|
89
|
+
XdsClusterManagerLbConfig(const XdsClusterManagerLbConfig&) = delete;
|
90
|
+
XdsClusterManagerLbConfig& operator=(const XdsClusterManagerLbConfig&) =
|
91
|
+
delete;
|
92
|
+
|
93
|
+
XdsClusterManagerLbConfig(XdsClusterManagerLbConfig&& other) = delete;
|
94
|
+
XdsClusterManagerLbConfig& operator=(XdsClusterManagerLbConfig&& other) =
|
95
|
+
delete;
|
82
96
|
|
83
97
|
absl::string_view name() const override { return kXdsClusterManager; }
|
84
98
|
|
85
|
-
const
|
99
|
+
const std::map<std::string, Child>& cluster_map() const {
|
100
|
+
return cluster_map_;
|
101
|
+
}
|
102
|
+
|
103
|
+
static const JsonLoaderInterface* JsonLoader(const JsonArgs&);
|
104
|
+
void JsonPostLoad(const Json& json, const JsonArgs&,
|
105
|
+
ValidationErrors* errors);
|
86
106
|
|
87
107
|
private:
|
88
|
-
|
108
|
+
std::map<std::string, Child> cluster_map_;
|
89
109
|
};
|
90
110
|
|
91
111
|
// xds_cluster_manager LB policy.
|
@@ -95,7 +115,7 @@ class XdsClusterManagerLb : public LoadBalancingPolicy {
|
|
95
115
|
|
96
116
|
absl::string_view name() const override { return kXdsClusterManager; }
|
97
117
|
|
98
|
-
|
118
|
+
absl::Status UpdateLocked(UpdateArgs args) override;
|
99
119
|
void ExitIdleLocked() override;
|
100
120
|
void ResetBackoffLocked() override;
|
101
121
|
|
@@ -143,9 +163,10 @@ class XdsClusterManagerLb : public LoadBalancingPolicy {
|
|
143
163
|
|
144
164
|
void Orphan() override;
|
145
165
|
|
146
|
-
|
147
|
-
|
148
|
-
|
166
|
+
absl::Status UpdateLocked(
|
167
|
+
RefCountedPtr<LoadBalancingPolicy::Config> config,
|
168
|
+
const absl::StatusOr<ServerAddressList>& addresses,
|
169
|
+
const ChannelArgs& args);
|
149
170
|
void ExitIdleLocked();
|
150
171
|
void ResetBackoffLocked();
|
151
172
|
void DeactivateLocked();
|
@@ -273,8 +294,8 @@ void XdsClusterManagerLb::ResetBackoffLocked() {
|
|
273
294
|
for (auto& p : children_) p.second->ResetBackoffLocked();
|
274
295
|
}
|
275
296
|
|
276
|
-
|
277
|
-
if (shutting_down_) return;
|
297
|
+
absl::Status XdsClusterManagerLb::UpdateLocked(UpdateArgs args) {
|
298
|
+
if (shutting_down_) return absl::OkStatus();
|
278
299
|
if (GRPC_TRACE_FLAG_ENABLED(grpc_xds_cluster_manager_lb_trace)) {
|
279
300
|
gpr_log(GPR_INFO, "[xds_cluster_manager_lb %p] Received update", this);
|
280
301
|
}
|
@@ -290,18 +311,30 @@ void XdsClusterManagerLb::UpdateLocked(UpdateArgs args) {
|
|
290
311
|
}
|
291
312
|
}
|
292
313
|
// Add or update the children in the new config.
|
314
|
+
std::vector<std::string> errors;
|
293
315
|
for (const auto& p : config_->cluster_map()) {
|
294
316
|
const std::string& name = p.first;
|
295
|
-
const RefCountedPtr<LoadBalancingPolicy::Config>& config = p.second;
|
317
|
+
const RefCountedPtr<LoadBalancingPolicy::Config>& config = p.second.config;
|
296
318
|
auto& child = children_[name];
|
297
319
|
if (child == nullptr) {
|
298
320
|
child = MakeOrphanable<ClusterChild>(Ref(DEBUG_LOCATION, "ClusterChild"),
|
299
321
|
name);
|
300
322
|
}
|
301
|
-
|
323
|
+
absl::Status status =
|
324
|
+
child->UpdateLocked(config, args.addresses, args.args);
|
325
|
+
if (!status.ok()) {
|
326
|
+
errors.emplace_back(
|
327
|
+
absl::StrCat("child ", name, ": ", status.ToString()));
|
328
|
+
}
|
302
329
|
}
|
303
330
|
update_in_progress_ = false;
|
304
331
|
UpdateStateLocked();
|
332
|
+
// Return status.
|
333
|
+
if (!errors.empty()) {
|
334
|
+
return absl::UnavailableError(absl::StrCat(
|
335
|
+
"errors from children: [", absl::StrJoin(errors, "; "), "]"));
|
336
|
+
}
|
337
|
+
return absl::OkStatus();
|
305
338
|
}
|
306
339
|
|
307
340
|
void XdsClusterManagerLb::UpdateStateLocked() {
|
@@ -469,11 +502,11 @@ XdsClusterManagerLb::ClusterChild::CreateChildPolicyLocked(
|
|
469
502
|
return lb_policy;
|
470
503
|
}
|
471
504
|
|
472
|
-
|
505
|
+
absl::Status XdsClusterManagerLb::ClusterChild::UpdateLocked(
|
473
506
|
RefCountedPtr<LoadBalancingPolicy::Config> config,
|
474
507
|
const absl::StatusOr<ServerAddressList>& addresses,
|
475
508
|
const ChannelArgs& args) {
|
476
|
-
if (xds_cluster_manager_policy_->shutting_down_) return;
|
509
|
+
if (xds_cluster_manager_policy_->shutting_down_) return absl::OkStatus();
|
477
510
|
// Update child weight.
|
478
511
|
// Reactivate if needed.
|
479
512
|
if (delayed_removal_timer_callback_pending_) {
|
@@ -498,7 +531,7 @@ void XdsClusterManagerLb::ClusterChild::UpdateLocked(
|
|
498
531
|
xds_cluster_manager_policy_.get(), this, name_.c_str(),
|
499
532
|
child_policy_.get());
|
500
533
|
}
|
501
|
-
child_policy_->UpdateLocked(std::move(update_args));
|
534
|
+
return child_policy_->UpdateLocked(std::move(update_args));
|
502
535
|
}
|
503
536
|
|
504
537
|
void XdsClusterManagerLb::ClusterChild::ExitIdleLocked() {
|
@@ -516,7 +549,7 @@ void XdsClusterManagerLb::ClusterChild::DeactivateLocked() {
|
|
516
549
|
// Start a timer to delete the child.
|
517
550
|
Ref(DEBUG_LOCATION, "ClusterChild+timer").release();
|
518
551
|
grpc_timer_init(&delayed_removal_timer_,
|
519
|
-
|
552
|
+
Timestamp::Now() +
|
520
553
|
Duration::Milliseconds(
|
521
554
|
GRPC_XDS_CLUSTER_MANAGER_CHILD_RETENTION_INTERVAL_MS),
|
522
555
|
&on_delayed_removal_timer_);
|
@@ -617,6 +650,52 @@ void XdsClusterManagerLb::ClusterChild::Helper::AddTraceEvent(
|
|
617
650
|
// factory
|
618
651
|
//
|
619
652
|
|
653
|
+
const JsonLoaderInterface* XdsClusterManagerLbConfig::Child::JsonLoader(
|
654
|
+
const JsonArgs&) {
|
655
|
+
// Note: The "childPolicy" field requires custom processing, so
|
656
|
+
// it's handled in JsonPostLoad() instead.
|
657
|
+
static const auto* loader = JsonObjectLoader<Child>().Finish();
|
658
|
+
return loader;
|
659
|
+
}
|
660
|
+
|
661
|
+
void XdsClusterManagerLbConfig::Child::JsonPostLoad(const Json& json,
|
662
|
+
const JsonArgs&,
|
663
|
+
ValidationErrors* errors) {
|
664
|
+
ValidationErrors::ScopedField field(errors, ".childPolicy");
|
665
|
+
auto it = json.object_value().find("childPolicy");
|
666
|
+
if (it == json.object_value().end()) {
|
667
|
+
errors->AddError("field not present");
|
668
|
+
return;
|
669
|
+
}
|
670
|
+
auto lb_config =
|
671
|
+
CoreConfiguration::Get().lb_policy_registry().ParseLoadBalancingConfig(
|
672
|
+
it->second);
|
673
|
+
if (!lb_config.ok()) {
|
674
|
+
errors->AddError(lb_config.status().message());
|
675
|
+
return;
|
676
|
+
}
|
677
|
+
config = std::move(*lb_config);
|
678
|
+
}
|
679
|
+
|
680
|
+
const JsonLoaderInterface* XdsClusterManagerLbConfig::JsonLoader(
|
681
|
+
const JsonArgs&) {
|
682
|
+
static const auto* loader =
|
683
|
+
JsonObjectLoader<XdsClusterManagerLbConfig>()
|
684
|
+
.Field("children", &XdsClusterManagerLbConfig::cluster_map_)
|
685
|
+
.Finish();
|
686
|
+
return loader;
|
687
|
+
}
|
688
|
+
|
689
|
+
void XdsClusterManagerLbConfig::JsonPostLoad(const Json&, const JsonArgs&,
|
690
|
+
ValidationErrors* errors) {
|
691
|
+
if (cluster_map_.empty()) {
|
692
|
+
ValidationErrors::ScopedField field(errors, ".children");
|
693
|
+
if (!errors->FieldHasErrors()) {
|
694
|
+
errors->AddError("no valid children configured");
|
695
|
+
}
|
696
|
+
}
|
697
|
+
}
|
698
|
+
|
620
699
|
class XdsClusterManagerLbFactory : public LoadBalancingPolicyFactory {
|
621
700
|
public:
|
622
701
|
OrphanablePtr<LoadBalancingPolicy> CreateLoadBalancingPolicy(
|
@@ -636,83 +715,17 @@ class XdsClusterManagerLbFactory : public LoadBalancingPolicyFactory {
|
|
636
715
|
"configuration. Please use loadBalancingConfig field of service "
|
637
716
|
"config instead.");
|
638
717
|
}
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
auto it = json.object_value().find("children");
|
643
|
-
if (it == json.object_value().end()) {
|
644
|
-
errors.emplace_back("field:children error:required field not present");
|
645
|
-
} else if (it->second.type() != Json::Type::OBJECT) {
|
646
|
-
errors.emplace_back("field:children error:type should be object");
|
647
|
-
} else {
|
648
|
-
for (const auto& p : it->second.object_value()) {
|
649
|
-
const std::string& child_name = p.first;
|
650
|
-
if (child_name.empty()) {
|
651
|
-
errors.emplace_back("field:children error: name cannot be empty");
|
652
|
-
continue;
|
653
|
-
}
|
654
|
-
auto config = ParseChildConfig(p.second);
|
655
|
-
if (!config.ok()) {
|
656
|
-
errors.emplace_back(
|
657
|
-
absl::StrCat("field:children name:", child_name,
|
658
|
-
" error:", config.status().message()));
|
659
|
-
} else {
|
660
|
-
cluster_map[child_name] = std::move(*config);
|
661
|
-
clusters_to_be_used.insert(child_name);
|
662
|
-
}
|
663
|
-
}
|
664
|
-
}
|
665
|
-
if (cluster_map.empty()) {
|
666
|
-
errors.emplace_back("no valid children configured");
|
667
|
-
}
|
668
|
-
if (!errors.empty()) {
|
669
|
-
return absl::InvalidArgumentError(absl::StrCat(
|
670
|
-
"errors parsing xds_cluster_manager_experimental LB policy config: [",
|
671
|
-
absl::StrJoin(errors, "; "), "]"));
|
672
|
-
}
|
673
|
-
return MakeRefCounted<XdsClusterManagerLbConfig>(std::move(cluster_map));
|
674
|
-
}
|
675
|
-
|
676
|
-
private:
|
677
|
-
static absl::StatusOr<RefCountedPtr<LoadBalancingPolicy::Config>>
|
678
|
-
ParseChildConfig(const Json& json) {
|
679
|
-
if (json.type() != Json::Type::OBJECT) {
|
680
|
-
return absl::InvalidArgumentError("value should be of type object");
|
681
|
-
}
|
682
|
-
RefCountedPtr<LoadBalancingPolicy::Config> child_config;
|
683
|
-
std::vector<std::string> errors;
|
684
|
-
auto it = json.object_value().find("childPolicy");
|
685
|
-
if (it == json.object_value().end()) {
|
686
|
-
errors.emplace_back("did not find childPolicy");
|
687
|
-
} else {
|
688
|
-
auto config =
|
689
|
-
LoadBalancingPolicyRegistry::ParseLoadBalancingConfig(it->second);
|
690
|
-
if (!config.ok()) {
|
691
|
-
errors.emplace_back(absl::StrCat("field:childPolicy error:",
|
692
|
-
config.status().message()));
|
693
|
-
} else {
|
694
|
-
child_config = std::move(*config);
|
695
|
-
}
|
696
|
-
}
|
697
|
-
if (!errors.empty()) {
|
698
|
-
return absl::InvalidArgumentError(absl::StrJoin(errors, "; "));
|
699
|
-
}
|
700
|
-
return child_config;
|
718
|
+
return LoadRefCountedFromJson<XdsClusterManagerLbConfig>(
|
719
|
+
json, JsonArgs(),
|
720
|
+
"errors validating xds_cluster_manager LB policy config");
|
701
721
|
}
|
702
722
|
};
|
703
723
|
|
704
724
|
} // namespace
|
705
725
|
|
706
|
-
|
707
|
-
|
708
|
-
|
709
|
-
// Plugin registration
|
710
|
-
//
|
711
|
-
|
712
|
-
void grpc_lb_policy_xds_cluster_manager_init() {
|
713
|
-
grpc_core::LoadBalancingPolicyRegistry::Builder::
|
714
|
-
RegisterLoadBalancingPolicyFactory(
|
715
|
-
absl::make_unique<grpc_core::XdsClusterManagerLbFactory>());
|
726
|
+
void RegisterXdsClusterManagerLbPolicy(CoreConfiguration::Builder* builder) {
|
727
|
+
builder->lb_policy_registry()->RegisterLoadBalancingPolicyFactory(
|
728
|
+
absl::make_unique<XdsClusterManagerLbFactory>());
|
716
729
|
}
|
717
730
|
|
718
|
-
|
731
|
+
} // namespace grpc_core
|