• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

grpc / grpc-java / #20015

13 Oct 2025 07:57AM UTC coverage: 88.57% (+0.02%) from 88.552%
#20015

push

github

web-flow
xds: ORCA to LRS propagation changes (#12203)

Implements gRFC A85 (https://github.com/grpc/proposal/pull/454).

34925 of 39432 relevant lines covered (88.57%)

0.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.52
/../xds/src/main/java/io/grpc/xds/ClusterImplLoadBalancerProvider.java
1
/*
2
 * Copyright 2020 The gRPC Authors
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16

17
package io.grpc.xds;
18

19
import static com.google.common.base.Preconditions.checkNotNull;
20

21
import com.google.common.base.MoreObjects;
22
import com.google.common.collect.ImmutableMap;
23
import com.google.protobuf.Struct;
24
import io.grpc.CallOptions;
25
import io.grpc.Internal;
26
import io.grpc.LoadBalancer;
27
import io.grpc.LoadBalancer.Helper;
28
import io.grpc.LoadBalancerProvider;
29
import io.grpc.LoadBalancerRegistry;
30
import io.grpc.NameResolver.ConfigOrError;
31
import io.grpc.Status;
32
import io.grpc.xds.Endpoints.DropOverload;
33
import io.grpc.xds.EnvoyServerProtoData.UpstreamTlsContext;
34
import io.grpc.xds.client.BackendMetricPropagation;
35
import io.grpc.xds.client.Bootstrapper.ServerInfo;
36
import java.util.ArrayList;
37
import java.util.Collections;
38
import java.util.List;
39
import java.util.Map;
40
import java.util.function.Consumer;
41
import javax.annotation.Nullable;
42

43
/**
44
 * The provider for the cluster_impl load balancing policy. This class should not be directly
45
 * referenced in code.  The policy should be accessed through
46
 * {@link LoadBalancerRegistry#getProvider} with the name "cluster_impl_experimental".
47
 */
48
@Internal
49
public final class ClusterImplLoadBalancerProvider extends LoadBalancerProvider {
1✔
50
  /**
51
   * Consumer of filter metadata from the cluster used by the call. Consumer may not modify map.
52
   */
53
  public static final CallOptions.Key<Consumer<Map<String, Struct>>> FILTER_METADATA_CONSUMER =
1✔
54
      CallOptions.Key.createWithDefault("io.grpc.xds.internalFilterMetadataConsumer", (m) -> { });
1✔
55

56
  @Override
57
  public boolean isAvailable() {
58
    return true;
1✔
59
  }
60

61
  @Override
62
  public int getPriority() {
63
    return 5;
1✔
64
  }
65

66
  @Override
67
  public String getPolicyName() {
68
    return XdsLbPolicies.CLUSTER_IMPL_POLICY_NAME;
1✔
69
  }
70

71
  @Override
72
  public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawLoadBalancingPolicyConfig) {
73
    return ConfigOrError.fromError(
×
74
        Status.INTERNAL.withDescription(getPolicyName() + " cannot be used from service config"));
×
75
  }
76

77
  @Override
78
  public LoadBalancer newLoadBalancer(Helper helper) {
79
    return new ClusterImplLoadBalancer(helper);
1✔
80
  }
81

82
  static final class ClusterImplConfig {
83
    // Name of the cluster.
84
    final String cluster;
85
    // Resource name used in discovering endpoints via EDS. Only valid for EDS clusters.
86
    @Nullable
87
    final String edsServiceName;
88
    // Load report server info. Null if load reporting is disabled.
89
    @Nullable
90
    final ServerInfo lrsServerInfo;
91
    // Cluster-level max concurrent request threshold. Null if not specified.
92
    @Nullable
93
    final Long maxConcurrentRequests;
94
    // TLS context for connections to endpoints.
95
    @Nullable
96
    final UpstreamTlsContext tlsContext;
97
    // Drop configurations.
98
    final List<DropOverload> dropCategories;
99
    // Provides the direct child policy and its config.
100
    final Object childConfig;
101
    final Map<String, Struct> filterMetadata;
102
    @Nullable
103
    final BackendMetricPropagation backendMetricPropagation;
104

105
    ClusterImplConfig(String cluster, @Nullable String edsServiceName,
106
        @Nullable ServerInfo lrsServerInfo, @Nullable Long maxConcurrentRequests,
107
        List<DropOverload> dropCategories, Object childConfig,
108
        @Nullable UpstreamTlsContext tlsContext, Map<String, Struct> filterMetadata,
109
        @Nullable BackendMetricPropagation backendMetricPropagation) {
1✔
110
      this.cluster = checkNotNull(cluster, "cluster");
1✔
111
      this.edsServiceName = edsServiceName;
1✔
112
      this.lrsServerInfo = lrsServerInfo;
1✔
113
      this.maxConcurrentRequests = maxConcurrentRequests;
1✔
114
      this.tlsContext = tlsContext;
1✔
115
      this.filterMetadata = ImmutableMap.copyOf(filterMetadata);
1✔
116
      this.dropCategories = Collections.unmodifiableList(
1✔
117
          new ArrayList<>(checkNotNull(dropCategories, "dropCategories")));
1✔
118
      this.childConfig = checkNotNull(childConfig, "childConfig");
1✔
119
      this.backendMetricPropagation = backendMetricPropagation;
1✔
120
    }
1✔
121

122
    @Override
123
    public String toString() {
124
      return MoreObjects.toStringHelper(this)
×
125
          .add("cluster", cluster)
×
126
          .add("edsServiceName", edsServiceName)
×
127
          .add("lrsServerInfo", lrsServerInfo)
×
128
          .add("maxConcurrentRequests", maxConcurrentRequests)
×
129
          // Exclude tlsContext as its string representation is cumbersome.
130
          .add("dropCategories", dropCategories)
×
131
          .add("childConfig", childConfig)
×
132
          .toString();
×
133
    }
134
  }
135
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc