16
16
17
17
#include < grpc/support/port_platform.h>
18
18
19
+ #include < stddef.h>
20
+ #include < stdint.h>
21
+
19
22
#include < algorithm>
20
23
#include < map>
21
24
#include < memory>
22
25
#include < set>
23
26
#include < string>
24
- #include < type_traits>
25
27
#include < utility>
26
28
#include < vector>
27
29
30
+ #include " absl/functional/function_ref.h"
28
31
#include " absl/status/status.h"
29
32
#include " absl/status/statusor.h"
30
33
#include " absl/strings/str_cat.h"
34
+ #include " absl/strings/str_join.h"
31
35
#include " absl/strings/string_view.h"
32
36
#include " absl/types/optional.h"
33
37
#include " absl/types/variant.h"
34
38
35
- #include < grpc/grpc_security.h>
36
39
#include < grpc/impl/connectivity_state.h>
37
40
#include < grpc/support/json.h>
38
41
#include < grpc/support/log.h>
41
44
#include " src/core/ext/filters/client_channel/lb_policy/outlier_detection/outlier_detection.h"
42
45
#include " src/core/ext/filters/client_channel/lb_policy/xds/xds_channel_args.h"
43
46
#include " src/core/ext/filters/client_channel/resolver/xds/xds_config.h"
44
- #include " src/core/ext/xds/certificate_provider_store .h"
47
+ #include " src/core/ext/xds/xds_client_stats .h"
45
48
#include " src/core/ext/xds/xds_cluster.h"
46
- #include " src/core/ext/xds/xds_common_types .h"
49
+ #include " src/core/ext/xds/xds_endpoint .h"
47
50
#include " src/core/ext/xds/xds_health_status.h"
48
51
#include " src/core/lib/channel/channel_args.h"
49
52
#include " src/core/lib/config/core_configuration.h"
50
53
#include " src/core/lib/debug/trace.h"
51
- #include " src/core/lib/gprpp/debug_location.h"
52
- #include " src/core/lib/gprpp/match.h"
54
+ #include " src/core/lib/gprpp/no_destruct.h"
53
55
#include " src/core/lib/gprpp/orphanable.h"
54
56
#include " src/core/lib/gprpp/ref_counted_ptr.h"
57
+ #include " src/core/lib/gprpp/ref_counted_string.h"
55
58
#include " src/core/lib/gprpp/time.h"
56
- #include " src/core/lib/gprpp/unique_type_name.h"
57
- #include " src/core/lib/gprpp/work_serializer.h"
58
59
#include " src/core/lib/iomgr/pollset_set.h"
60
+ #include " src/core/lib/iomgr/resolved_address.h"
59
61
#include " src/core/lib/json/json.h"
60
62
#include " src/core/lib/json/json_args.h"
61
63
#include " src/core/lib/json/json_object_loader.h"
64
66
#include " src/core/lib/load_balancing/lb_policy.h"
65
67
#include " src/core/lib/load_balancing/lb_policy_factory.h"
66
68
#include " src/core/lib/load_balancing/lb_policy_registry.h"
69
+ #include " src/core/lib/resolver/endpoint_addresses.h"
67
70
68
71
namespace grpc_core {
69
72
@@ -263,8 +266,7 @@ absl::Status CdsLb::UpdateLocked(UpdateArgs args) {
263
266
if (!child_config.ok ()) {
264
267
// Should never happen.
265
268
absl::Status status = absl::InternalError (
266
- absl::StrCat (cluster_name_,
267
- " : error parsing child policy config: " ,
269
+ absl::StrCat (cluster_name_, " : error parsing child policy config: " ,
268
270
child_config.status ().message ()));
269
271
ReportTransientFailure (status);
270
272
return status;
@@ -276,10 +278,8 @@ absl::Status CdsLb::UpdateLocked(UpdateArgs args) {
276
278
lb_args.args = args.args ;
277
279
lb_args.channel_control_helper = std::make_unique<Helper>(Ref ());
278
280
child_policy_ =
279
- CoreConfiguration::Get ()
280
- .lb_policy_registry ()
281
- .CreateLoadBalancingPolicy ((*child_config)->name (),
282
- std::move (lb_args));
281
+ CoreConfiguration::Get ().lb_policy_registry ().CreateLoadBalancingPolicy (
282
+ (*child_config)->name (), std::move (lb_args));
283
283
if (child_policy_ == nullptr ) {
284
284
// Should never happen.
285
285
absl::Status status = absl::UnavailableError (
@@ -390,7 +390,7 @@ std::vector<CdsLb::ChildNameState> CdsLb::ComputeChildNames(
390
390
if (!child_number.has_value ()) {
391
391
for (child_number = new_numbers.next_available_child_number ;
392
392
mappings.child_locality_map .find (*child_number) !=
393
- mappings.child_locality_map .end ();
393
+ mappings.child_locality_map .end ();
394
394
++(*child_number)) {
395
395
}
396
396
new_numbers.next_available_child_number = *child_number + 1 ;
@@ -498,41 +498,40 @@ Json CdsLb::CreateChildPolicyConfig(
498
498
if (outlier_detection_update.success_rate_ejection .has_value ()) {
499
499
outlier_detection_config[" successRateEjection" ] = Json::FromObject ({
500
500
{" stdevFactor" ,
501
- Json::FromNumber (
502
- outlier_detection_update.success_rate_ejection
503
- ->stdev_factor )},
501
+ Json::FromNumber (outlier_detection_update.success_rate_ejection
502
+ ->stdev_factor )},
504
503
{" enforcementPercentage" ,
505
504
Json::FromNumber (outlier_detection_update.success_rate_ejection
506
505
->enforcement_percentage )},
507
506
{" minimumHosts" ,
508
- Json::FromNumber (
509
- outlier_detection_update.success_rate_ejection
510
- ->minimum_hosts )},
511
- {" requestVolume" ,
512
- Json::FromNumber (
513
- outlier_detection_update.success_rate_ejection
514
- ->request_volume )},
515
- });
516
- }
517
- if (outlier_detection_update.failure_percentage_ejection .has_value ()) {
518
- outlier_detection_config[" failurePercentageEjection" ] = Json::FromObject ({
519
- {" threshold" ,
520
- Json::FromNumber (outlier_detection_update
521
- .failure_percentage_ejection ->threshold )},
522
- {" enforcementPercentage" ,
523
- Json::FromNumber (
524
- outlier_detection_update.failure_percentage_ejection
525
- ->enforcement_percentage )},
526
- {" minimumHosts" ,
527
- Json::FromNumber (outlier_detection_update
528
- .failure_percentage_ejection
507
+ Json::FromNumber (outlier_detection_update.success_rate_ejection
529
508
->minimum_hosts )},
530
509
{" requestVolume" ,
531
- Json::FromNumber (outlier_detection_update
532
- .failure_percentage_ejection
510
+ Json::FromNumber (outlier_detection_update.success_rate_ejection
533
511
->request_volume )},
534
512
});
535
513
}
514
+ if (outlier_detection_update.failure_percentage_ejection .has_value ()) {
515
+ outlier_detection_config[" failurePercentageEjection" ] =
516
+ Json::FromObject ({
517
+ {" threshold" ,
518
+ Json::FromNumber (
519
+ outlier_detection_update.failure_percentage_ejection
520
+ ->threshold )},
521
+ {" enforcementPercentage" ,
522
+ Json::FromNumber (
523
+ outlier_detection_update.failure_percentage_ejection
524
+ ->enforcement_percentage )},
525
+ {" minimumHosts" ,
526
+ Json::FromNumber (
527
+ outlier_detection_update.failure_percentage_ejection
528
+ ->minimum_hosts )},
529
+ {" requestVolume" ,
530
+ Json::FromNumber (
531
+ outlier_detection_update.failure_percentage_ejection
532
+ ->request_volume )},
533
+ });
534
+ }
536
535
}
537
536
outlier_detection_config[" childPolicy" ] =
538
537
Json::FromArray ({Json::FromObject ({
@@ -566,8 +565,8 @@ Json CdsLb::CreateChildPolicyConfig(
566
565
})},
567
566
})});
568
567
if (GRPC_TRACE_FLAG_ENABLED (grpc_cds_lb_trace)) {
569
- gpr_log (GPR_INFO, " [cdslb %p] generated config for child policy: %s" ,
570
- this , JsonDump (json, /* indent=*/ 1 ).c_str ());
568
+ gpr_log (GPR_INFO, " [cdslb %p] generated config for child policy: %s" , this ,
569
+ JsonDump (json, /* indent=*/ 1 ).c_str ());
571
570
}
572
571
return json;
573
572
}
@@ -579,10 +578,9 @@ class PriorityEndpointIterator : public EndpointAddressesIterator {
579
578
std::shared_ptr<const XdsEndpointResource> endpoints;
580
579
std::vector<size_t /* child_number*/ > priority_child_numbers;
581
580
582
- ClusterEntry (
583
- std::string cluster,
584
- std::shared_ptr<const XdsEndpointResource> resource,
585
- std::vector<size_t > child_numbers)
581
+ ClusterEntry (std::string cluster,
582
+ std::shared_ptr<const XdsEndpointResource> resource,
583
+ std::vector<size_t > child_numbers)
586
584
: cluster_name(std::move(cluster)),
587
585
endpoints (std::move(resource)),
588
586
priority_child_numbers(std::move(child_numbers)) {}
0 commit comments