mirror of https://github.com/grpc/grpc-java.git
core,xds: remove deprecated rawConfig field from PolicySelection
This commit is contained in:
parent
bc8c758a3c
commit
d5668b9ee1
|
|
@ -21,7 +21,6 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.common.base.MoreObjects;
|
||||
import io.grpc.Attributes;
|
||||
import io.grpc.ChannelLogger;
|
||||
import io.grpc.ChannelLogger.ChannelLogLevel;
|
||||
import io.grpc.ConnectivityState;
|
||||
import io.grpc.ConnectivityStateInfo;
|
||||
|
|
@ -126,7 +125,7 @@ public final class AutoConfiguredLoadBalancerFactory {
|
|||
return Status.OK;
|
||||
}
|
||||
policySelection =
|
||||
new PolicySelection(defaultProvider, /* rawConfig= */ null, /* config= */ null);
|
||||
new PolicySelection(defaultProvider, /* config= */ null);
|
||||
}
|
||||
|
||||
if (delegateProvider == null
|
||||
|
|
@ -227,7 +226,7 @@ public final class AutoConfiguredLoadBalancerFactory {
|
|||
* @return the parsed {@link PolicySelection}, or {@code null} if no selection could be made.
|
||||
*/
|
||||
@Nullable
|
||||
ConfigOrError parseLoadBalancerPolicy(Map<String, ?> serviceConfig, ChannelLogger channelLogger) {
|
||||
ConfigOrError parseLoadBalancerPolicy(Map<String, ?> serviceConfig) {
|
||||
try {
|
||||
List<LbConfig> loadBalancerConfigs = null;
|
||||
if (serviceConfig != null) {
|
||||
|
|
|
|||
|
|
@ -612,8 +612,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
|
|||
retryEnabled,
|
||||
builder.maxRetryAttempts,
|
||||
builder.maxHedgedAttempts,
|
||||
loadBalancerFactory,
|
||||
channelLogger);
|
||||
loadBalancerFactory);
|
||||
this.nameResolverArgs =
|
||||
NameResolver.Args.newBuilder()
|
||||
.setDefaultPort(builder.getDefaultPort())
|
||||
|
|
@ -2146,20 +2145,17 @@ final class ManagedChannelImpl extends ManagedChannel implements
|
|||
private final int maxRetryAttemptsLimit;
|
||||
private final int maxHedgedAttemptsLimit;
|
||||
private final AutoConfiguredLoadBalancerFactory autoLoadBalancerFactory;
|
||||
private final ChannelLogger channelLogger;
|
||||
|
||||
ScParser(
|
||||
boolean retryEnabled,
|
||||
int maxRetryAttemptsLimit,
|
||||
int maxHedgedAttemptsLimit,
|
||||
AutoConfiguredLoadBalancerFactory autoLoadBalancerFactory,
|
||||
ChannelLogger channelLogger) {
|
||||
AutoConfiguredLoadBalancerFactory autoLoadBalancerFactory) {
|
||||
this.retryEnabled = retryEnabled;
|
||||
this.maxRetryAttemptsLimit = maxRetryAttemptsLimit;
|
||||
this.maxHedgedAttemptsLimit = maxHedgedAttemptsLimit;
|
||||
this.autoLoadBalancerFactory =
|
||||
checkNotNull(autoLoadBalancerFactory, "autoLoadBalancerFactory");
|
||||
this.channelLogger = checkNotNull(channelLogger, "channelLogger");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -2167,7 +2163,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
|
|||
try {
|
||||
Object loadBalancingPolicySelection;
|
||||
ConfigOrError choiceFromLoadBalancer =
|
||||
autoLoadBalancerFactory.parseLoadBalancerPolicy(rawServiceConfig, channelLogger);
|
||||
autoLoadBalancerFactory.parseLoadBalancerPolicy(rawServiceConfig);
|
||||
if (choiceFromLoadBalancer == null) {
|
||||
loadBalancingPolicySelection = null;
|
||||
} else if (choiceFromLoadBalancer.getError() != null) {
|
||||
|
|
|
|||
|
|
@ -352,8 +352,8 @@ public final class ServiceConfigUtil {
|
|||
if (parsedLbPolicyConfig.getError() != null) {
|
||||
return parsedLbPolicyConfig;
|
||||
}
|
||||
return ConfigOrError.fromConfig(new PolicySelection(
|
||||
provider, lbConfig.rawConfigValue, parsedLbPolicyConfig.getConfig()));
|
||||
return ConfigOrError.fromConfig(
|
||||
new PolicySelection(provider, parsedLbPolicyConfig.getConfig()));
|
||||
}
|
||||
}
|
||||
return ConfigOrError.fromError(
|
||||
|
|
@ -408,20 +408,14 @@ public final class ServiceConfigUtil {
|
|||
|
||||
public static final class PolicySelection {
|
||||
final LoadBalancerProvider provider;
|
||||
@Deprecated
|
||||
@Nullable
|
||||
final Map<String, ?> rawConfig;
|
||||
@Nullable
|
||||
final Object config;
|
||||
|
||||
/** Constructs a PolicySelection with selected LB provider, a copy of raw config and the deeply
|
||||
* parsed LB config. */
|
||||
/** Constructs a PolicySelection with selected LB provider and the deeply parsed LB config. */
|
||||
public PolicySelection(
|
||||
LoadBalancerProvider provider,
|
||||
@Nullable Map<String, ?> rawConfig,
|
||||
@Nullable Object config) {
|
||||
this.provider = checkNotNull(provider, "provider");
|
||||
this.rawConfig = rawConfig;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
|
|
@ -444,20 +438,18 @@ public final class ServiceConfigUtil {
|
|||
}
|
||||
PolicySelection that = (PolicySelection) o;
|
||||
return Objects.equal(provider, that.provider)
|
||||
&& Objects.equal(rawConfig, that.rawConfig)
|
||||
&& Objects.equal(config, that.config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hashCode(provider, rawConfig, config);
|
||||
return Objects.hashCode(provider, config);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return MoreObjects.toStringHelper(this)
|
||||
.add("provider", provider)
|
||||
.add("rawConfig", rawConfig)
|
||||
.add("config", config)
|
||||
.toString();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,7 +199,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
public void handleResolvedAddressGroups_shutsDownOldBalancer() throws Exception {
|
||||
Map<String, ?> serviceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"round_robin\": { } } ] }");
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
|
||||
final List<EquivalentAddressGroup> servers =
|
||||
Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){}));
|
||||
|
|
@ -243,7 +243,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
public void handleResolvedAddressGroups_propagateLbConfigToDelegate() throws Exception {
|
||||
Map<String, ?> rawServiceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"high\" } } ] }");
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig, channelLogger);
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig);
|
||||
assertThat(lbConfigs.getConfig()).isNotNull();
|
||||
|
||||
final List<EquivalentAddressGroup> servers =
|
||||
|
|
@ -272,7 +272,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
|
||||
rawServiceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"low\" } } ] }");
|
||||
lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig, channelLogger);
|
||||
lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig);
|
||||
|
||||
handleResult = lb.tryHandleResolvedAddresses(
|
||||
ResolvedAddresses.newBuilder()
|
||||
|
|
@ -297,7 +297,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
public void handleResolvedAddressGroups_propagateAddrsToDelegate() throws Exception {
|
||||
Map<String, ?> rawServiceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"high\" } } ] }");
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig, channelLogger);
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig);
|
||||
assertThat(lbConfigs.getConfig()).isNotNull();
|
||||
|
||||
Helper helper = new TestHelper();
|
||||
|
|
@ -340,7 +340,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
|
||||
Map<String, ?> serviceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"high\" } } ] }");
|
||||
ConfigOrError lbConfig = lbf.parseLoadBalancerPolicy(serviceConfig, helper.getChannelLogger());
|
||||
ConfigOrError lbConfig = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
Status handleResult = lb.tryHandleResolvedAddresses(
|
||||
ResolvedAddresses.newBuilder()
|
||||
.setAddresses(Collections.<EquivalentAddressGroup>emptyList())
|
||||
|
|
@ -362,7 +362,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
Map<String, ?> rawServiceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb2\": { \"setting1\": \"high\" } } ] }");
|
||||
ConfigOrError lbConfigs =
|
||||
lbf.parseLoadBalancerPolicy(rawServiceConfig, helper.getChannelLogger());
|
||||
lbf.parseLoadBalancerPolicy(rawServiceConfig);
|
||||
Status handleResult = lb.tryHandleResolvedAddresses(
|
||||
ResolvedAddresses.newBuilder()
|
||||
.setAddresses(Collections.<EquivalentAddressGroup>emptyList())
|
||||
|
|
@ -384,7 +384,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
public void handleResolvedAddressGroups_useSelectedLbPolicy() throws Exception {
|
||||
Map<String, ?> rawServiceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [{\"round_robin\": {}}]}");
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig, channelLogger);
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(rawServiceConfig);
|
||||
assertThat(lbConfigs.getConfig()).isNotNull();
|
||||
assertThat(((PolicySelection) lbConfigs.getConfig()).provider.getClass().getName())
|
||||
.isEqualTo("io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider");
|
||||
|
|
@ -471,7 +471,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
nextParsedConfigOrError.set(testLbParsedConfig);
|
||||
Map<String, ?> serviceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { } } ] }");
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError lbConfigs = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
handleResult = lb.tryHandleResolvedAddresses(
|
||||
ResolvedAddresses.newBuilder()
|
||||
.setAddresses(servers)
|
||||
|
|
@ -494,7 +494,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
testLbParsedConfig = ConfigOrError.fromConfig("bar");
|
||||
nextParsedConfigOrError.set(testLbParsedConfig);
|
||||
serviceConfig = parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { } } ] }");
|
||||
lbConfigs = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
lbConfigs = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
handleResult = lb.tryHandleResolvedAddresses(
|
||||
ResolvedAddresses.newBuilder()
|
||||
.setAddresses(servers)
|
||||
|
|
@ -512,7 +512,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
public void parseLoadBalancerConfig_failedOnUnknown() throws Exception {
|
||||
Map<String, ?> serviceConfig =
|
||||
parseConfig("{\"loadBalancingConfig\": [ {\"magic_balancer\": {} } ] }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed.getError()).isNotNull();
|
||||
assertThat(parsed.getError().getDescription())
|
||||
.isEqualTo("None of [magic_balancer] specified by Service Config are available.");
|
||||
|
|
@ -522,7 +522,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
public void parseLoadBalancerPolicy_failedOnUnknown() throws Exception {
|
||||
Map<String, ?> serviceConfig =
|
||||
parseConfig("{\"loadBalancingPolicy\": \"magic_balancer\"}");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed.getError()).isNotNull();
|
||||
assertThat(parsed.getError().getDescription())
|
||||
.isEqualTo("None of [magic_balancer] specified by Service Config are available.");
|
||||
|
|
@ -535,7 +535,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
"{\"loadBalancingConfig\": ["
|
||||
+ "{\"round_robin\": {}},"
|
||||
+ "{\"test_lb\": {} } ] }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed).isNotNull();
|
||||
assertThat(parsed.getError()).isNull();
|
||||
assertThat(parsed.getConfig()).isInstanceOf(PolicySelection.class);
|
||||
|
|
@ -549,7 +549,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
parseConfig(
|
||||
"{\"loadBalancingConfig\": [{\"round_robin\": {} } ],"
|
||||
+ "\"loadBalancingPolicy\": \"pick_first\" }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed).isNotNull();
|
||||
assertThat(parsed.getError()).isNull();
|
||||
assertThat(parsed.getConfig()).isInstanceOf(PolicySelection.class);
|
||||
|
|
@ -564,7 +564,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
parseConfig(
|
||||
"{\"loadBalancingConfig\": [{\"magic_balancer\": {} } ],"
|
||||
+ "\"loadBalancingPolicy\": \"round_robin\" }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed.getError()).isNotNull();
|
||||
assertThat(parsed.getError().getDescription())
|
||||
.isEqualTo("None of [magic_balancer] specified by Service Config are available.");
|
||||
|
|
@ -580,7 +580,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
"{\"loadBalancingConfig\": ["
|
||||
+ "{\"test_lb\": {}},"
|
||||
+ "{\"round_robin\": {} } ] }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed).isNotNull();
|
||||
assertThat(parsed.getConfig()).isNull();
|
||||
assertThat(parsed.getError()).isEqualTo(Status.UNKNOWN);
|
||||
|
|
@ -596,7 +596,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
"{\"loadBalancingConfig\": ["
|
||||
+ "{\"round_robin\": {}},"
|
||||
+ "{\"test_lb\": {} } ] }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed).isNotNull();
|
||||
assertThat(parsed.getConfig()).isNotNull();
|
||||
assertThat(((PolicySelection) parsed.getConfig()).config).isNotNull();
|
||||
|
|
@ -608,7 +608,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
parseConfig("{\"loadBalancingConfig\": [ "
|
||||
+ "{\"magic_balancer\": {} },"
|
||||
+ "{\"round_robin\": {}} ] }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(serviceConfig);
|
||||
assertThat(parsed).isNotNull();
|
||||
assertThat(parsed.getConfig()).isNotNull();
|
||||
assertThat(((PolicySelection) parsed.getConfig()).config).isNotNull();
|
||||
|
|
@ -621,7 +621,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
|
|||
"{\"loadBalancingConfig\": ["
|
||||
+ "{\"grpclb\": {\"childPolicy\": [ {\"pick_first\": {} } ] } }"
|
||||
+ "] }");
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(rawServiceConfig, channelLogger);
|
||||
ConfigOrError parsed = lbf.parseLoadBalancerPolicy(rawServiceConfig);
|
||||
assertThat(parsed).isNotNull();
|
||||
assertThat(parsed.getConfig()).isNotNull();
|
||||
PolicySelection policySelection = (PolicySelection) parsed.getConfig();
|
||||
|
|
|
|||
|
|
@ -1163,7 +1163,6 @@ public class ManagedChannelImplTest {
|
|||
rawServiceConfig,
|
||||
new PolicySelection(
|
||||
mockLoadBalancerProvider,
|
||||
parseConfig(rawLbConfig),
|
||||
parsedLbConfig));
|
||||
nameResolverFactory.nextConfigOrError.set(ConfigOrError.fromConfig(parsedServiceConfig));
|
||||
channelBuilder.nameResolverFactory(nameResolverFactory);
|
||||
|
|
@ -2951,7 +2950,7 @@ public class ManagedChannelImplTest {
|
|||
ManagedChannelServiceConfig mcsc1 = createManagedChannelServiceConfig(
|
||||
ImmutableMap.<String, Object>of(),
|
||||
new PolicySelection(
|
||||
mockLoadBalancerProvider, ImmutableMap.of("foo", "bar"), null));
|
||||
mockLoadBalancerProvider, null));
|
||||
ResolutionResult resolutionResult1 = ResolutionResult.newBuilder()
|
||||
.setAddresses(Collections.singletonList(
|
||||
new EquivalentAddressGroup(
|
||||
|
|
@ -3608,7 +3607,7 @@ public class ManagedChannelImplTest {
|
|||
Object fakeLbConfig = new Object();
|
||||
PolicySelection lbConfigs =
|
||||
new PolicySelection(
|
||||
mockLoadBalancerProvider, rawServiceConfig, fakeLbConfig);
|
||||
mockLoadBalancerProvider, fakeLbConfig);
|
||||
mockLoadBalancerProvider.parseLoadBalancingPolicyConfig(rawServiceConfig);
|
||||
ManagedChannelServiceConfig managedChannelServiceConfig =
|
||||
createManagedChannelServiceConfig(rawServiceConfig, lbConfigs);
|
||||
|
|
@ -3766,8 +3765,7 @@ public class ManagedChannelImplTest {
|
|||
retryEnabled,
|
||||
maxRetryAttemptsLimit,
|
||||
maxHedgedAttemptsLimit,
|
||||
autoConfiguredLoadBalancerFactory,
|
||||
mock(ChannelLogger.class));
|
||||
autoConfiguredLoadBalancerFactory);
|
||||
|
||||
ConfigOrError coe = parser.parseServiceConfig(ImmutableMap.<String, Object>of());
|
||||
|
||||
|
|
@ -3789,8 +3787,7 @@ public class ManagedChannelImplTest {
|
|||
retryEnabled,
|
||||
maxRetryAttemptsLimit,
|
||||
maxHedgedAttemptsLimit,
|
||||
autoConfiguredLoadBalancerFactory,
|
||||
mock(ChannelLogger.class));
|
||||
autoConfiguredLoadBalancerFactory);
|
||||
|
||||
ConfigOrError coe =
|
||||
parser.parseServiceConfig(ImmutableMap.<String, Object>of("methodConfig", "bogus"));
|
||||
|
|
@ -3813,8 +3810,7 @@ public class ManagedChannelImplTest {
|
|||
retryEnabled,
|
||||
maxRetryAttemptsLimit,
|
||||
maxHedgedAttemptsLimit,
|
||||
autoConfiguredLoadBalancerFactory,
|
||||
mock(ChannelLogger.class));
|
||||
autoConfiguredLoadBalancerFactory);
|
||||
|
||||
ConfigOrError coe =
|
||||
parser.parseServiceConfig(ImmutableMap.of("loadBalancingConfig", ImmutableList.of()));
|
||||
|
|
|
|||
|
|
@ -210,8 +210,8 @@ final class CdsLoadBalancer extends LoadBalancer {
|
|||
/* clusterName = */ newUpdate.getClusterName(),
|
||||
/* edsServiceName = */ newUpdate.getEdsServiceName(),
|
||||
/* lrsServerName = */ newUpdate.getLrsServerName(),
|
||||
new PolicySelection(localityPickingPolicyProvider, null, null /* by EDS policy */),
|
||||
new PolicySelection(endpointPickingPolicyProvider, null, null));
|
||||
new PolicySelection(localityPickingPolicyProvider, null /* by EDS policy */),
|
||||
new PolicySelection(endpointPickingPolicyProvider, null));
|
||||
if (isXdsSecurityEnabled()) {
|
||||
updateSslContextProviderSupplier(newUpdate.getUpstreamTlsContext());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -390,7 +390,7 @@ final class EdsLoadBalancer2 extends LoadBalancer {
|
|||
generateWeightedTargetLbConfig(cluster, edsServiceName, lrsServerName,
|
||||
endpointPickingPolicy, lbRegistry, prioritizedLocalityWeights.get(priority));
|
||||
PolicySelection childPolicySelection =
|
||||
new PolicySelection(localityPickingPolicy.getProvider(), null, childConfig);
|
||||
new PolicySelection(localityPickingPolicy.getProvider(), childConfig);
|
||||
String childName = priorityName(priority);
|
||||
childPolicies.put(childName, childPolicySelection);
|
||||
priorities.add(childName);
|
||||
|
|
@ -413,7 +413,7 @@ final class EdsLoadBalancer2 extends LoadBalancer {
|
|||
LrsConfig childConfig =
|
||||
new LrsConfig(cluster, edsServiceName, lrsServerName, locality, endpointPickingPolicy);
|
||||
LoadBalancerProvider childPolicyProvider = lbRegistry.getProvider(LRS_POLICY_NAME);
|
||||
childPolicy = new PolicySelection(childPolicyProvider, null, childConfig);
|
||||
childPolicy = new PolicySelection(childPolicyProvider, childConfig);
|
||||
} else {
|
||||
childPolicy = endpointPickingPolicy;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ import io.grpc.internal.JsonParser;
|
|||
import io.grpc.internal.ServiceConfigUtil.PolicySelection;
|
||||
import io.grpc.xds.ClusterManagerLoadBalancerProvider.ClusterManagerConfig;
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -132,9 +131,9 @@ public class ClusterManagerLoadBalancerProviderTest {
|
|||
.containsExactly(
|
||||
"child1",
|
||||
new PolicySelection(
|
||||
lbProviderFoo, Collections.singletonMap("config_name", "config_value"), fooConfig),
|
||||
lbProviderFoo, fooConfig),
|
||||
"child2",
|
||||
new PolicySelection(lbProviderBar, Collections.<String, Object>emptyMap(), barConfig));
|
||||
new PolicySelection(lbProviderBar, barConfig));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ public class ClusterManagerLoadBalancerTest {
|
|||
String childPolicyName = childPolicies.get(name);
|
||||
Object childConfig = lbConfigInventory.get(name);
|
||||
PolicySelection policy =
|
||||
new PolicySelection(new FakeLoadBalancerProvider(childPolicyName), null, childConfig);
|
||||
new PolicySelection(new FakeLoadBalancerProvider(childPolicyName), childConfig);
|
||||
childPolicySelections.put(name, policy);
|
||||
}
|
||||
return new ClusterManagerConfig(childPolicySelections);
|
||||
|
|
|
|||
|
|
@ -105,9 +105,9 @@ public class EdsLoadBalancer2Test {
|
|||
private final FakeClock fakeClock = new FakeClock();
|
||||
private final LoadBalancerRegistry registry = new LoadBalancerRegistry();
|
||||
private final PolicySelection roundRobin =
|
||||
new PolicySelection(new FakeLoadBalancerProvider("round_robin"), null, null);
|
||||
new PolicySelection(new FakeLoadBalancerProvider("round_robin"), null);
|
||||
private final PolicySelection weightedTarget =
|
||||
new PolicySelection(new FakeLoadBalancerProvider(WEIGHTED_TARGET_POLICY_NAME), null, null);
|
||||
new PolicySelection(new FakeLoadBalancerProvider(WEIGHTED_TARGET_POLICY_NAME), null);
|
||||
private final List<FakeLoadBalancer> downstreamBalancers = new ArrayList<>();
|
||||
private final FakeXdsClient xdsClient = new FakeXdsClient();
|
||||
private final ObjectPool<XdsClient> xdsClientPool = new ObjectPool<XdsClient>() {
|
||||
|
|
@ -480,7 +480,7 @@ public class EdsLoadBalancer2Test {
|
|||
assertThat(leafBalancer.name).isEqualTo("round_robin");
|
||||
FakeLoadBalancerProvider fakePickFirstProvider = new FakeLoadBalancerProvider("pick_first");
|
||||
PolicySelection fakePickFirstSelection =
|
||||
new PolicySelection(fakePickFirstProvider, null, null);
|
||||
new PolicySelection(fakePickFirstProvider, null);
|
||||
loadBalancer.handleResolvedAddresses(ResolvedAddresses.newBuilder()
|
||||
.setAddresses(Collections.<EquivalentAddressGroup>emptyList())
|
||||
.setAttributes(
|
||||
|
|
@ -633,9 +633,9 @@ public class EdsLoadBalancer2Test {
|
|||
registry.deregister(registry.getProvider(LRS_POLICY_NAME));
|
||||
registry.register(new LrsLoadBalancerProvider());
|
||||
PolicySelection weightedTargetSelection =
|
||||
new PolicySelection(new WeightedTargetLoadBalancerProvider(), null, null);
|
||||
new PolicySelection(new WeightedTargetLoadBalancerProvider(), null);
|
||||
PolicySelection fakeLeafPolicySelection =
|
||||
new PolicySelection(fakeLeafPolicyProvider, null, null);
|
||||
new PolicySelection(fakeLeafPolicyProvider, null);
|
||||
loadBalancer.handleResolvedAddresses(
|
||||
ResolvedAddresses.newBuilder()
|
||||
.setAddresses(Collections.<EquivalentAddressGroup>emptyList())
|
||||
|
|
|
|||
|
|
@ -144,9 +144,9 @@ public class EdsLoadBalancerTest {
|
|||
};
|
||||
|
||||
private final PolicySelection fakeLocalityPickingPolicy =
|
||||
new PolicySelection(mock(LoadBalancerProvider.class), null, null);
|
||||
new PolicySelection(mock(LoadBalancerProvider.class), null);
|
||||
private final PolicySelection fakeEndpointPickingPolicy =
|
||||
new PolicySelection(mock(LoadBalancerProvider.class), null, new Object());
|
||||
new PolicySelection(mock(LoadBalancerProvider.class), new Object());
|
||||
|
||||
@Mock
|
||||
private Helper helper;
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public class LrsLoadBalancerTest {
|
|||
private void deliverResolvedAddresses(
|
||||
List<EquivalentAddressGroup> addresses, String childPolicy) {
|
||||
PolicySelection childPolicyConfig =
|
||||
new PolicySelection(new FakeLoadBalancerProvider(childPolicy), null, null);
|
||||
new PolicySelection(new FakeLoadBalancerProvider(childPolicy), null);
|
||||
LrsConfig config =
|
||||
new LrsConfig(
|
||||
CLUSTER_NAME, EDS_SERVICE_NAME, LRS_SERVER_NAME, TEST_LOCALITY, childPolicyConfig);
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class PriorityLoadBalancerProviderTest {
|
|||
@Test
|
||||
public void priorityLbConfig_emptyPriorities() {
|
||||
Map<String, PolicySelection> childConfigs =
|
||||
ImmutableMap.of("p0", new PolicySelection(mock(LoadBalancerProvider.class), null, null));
|
||||
ImmutableMap.of("p0", new PolicySelection(mock(LoadBalancerProvider.class), null));
|
||||
List<String> priorities = ImmutableList.of();
|
||||
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
|
@ -51,7 +51,7 @@ public class PriorityLoadBalancerProviderTest {
|
|||
@Test
|
||||
public void priorityLbConfig_missingChildConfig() {
|
||||
Map<String, PolicySelection> childConfigs =
|
||||
ImmutableMap.of("p1", new PolicySelection(mock(LoadBalancerProvider.class), null, null));
|
||||
ImmutableMap.of("p1", new PolicySelection(mock(LoadBalancerProvider.class), null));
|
||||
List<String> priorities = ImmutableList.of("p0", "p1");
|
||||
|
||||
thrown.expect(IllegalArgumentException.class);
|
||||
|
|
|
|||
|
|
@ -137,11 +137,11 @@ public class PriorityLoadBalancerTest {
|
|||
Attributes attributes =
|
||||
Attributes.newBuilder().set(Attributes.Key.create("fakeKey"), "fakeValue").build();
|
||||
Object fooConfig0 = new Object();
|
||||
PolicySelection fooPolicy0 = new PolicySelection(fooLbProvider, null, fooConfig0);
|
||||
PolicySelection fooPolicy0 = new PolicySelection(fooLbProvider, fooConfig0);
|
||||
Object barConfig0 = new Object();
|
||||
PolicySelection barPolicy0 = new PolicySelection(barLbProvider, null, barConfig0);
|
||||
PolicySelection barPolicy0 = new PolicySelection(barLbProvider, barConfig0);
|
||||
Object fooConfig1 = new Object();
|
||||
PolicySelection fooPolicy1 = new PolicySelection(fooLbProvider, null, fooConfig1);
|
||||
PolicySelection fooPolicy1 = new PolicySelection(fooLbProvider, fooConfig1);
|
||||
PriorityLbConfig priorityLbConfig =
|
||||
new PriorityLbConfig(
|
||||
ImmutableMap.of("p0", fooPolicy0, "p1", barPolicy0, "p2", fooPolicy1),
|
||||
|
|
@ -190,7 +190,7 @@ public class PriorityLoadBalancerTest {
|
|||
newEag = AddressFilter.setPathFilter(newEag, ImmutableList.of("p1"));
|
||||
List<EquivalentAddressGroup> newAddresses = ImmutableList.of(newEag);
|
||||
Object newBarConfig = new Object();
|
||||
PolicySelection newBarPolicy = new PolicySelection(barLbProvider, null, newBarConfig);
|
||||
PolicySelection newBarPolicy = new PolicySelection(barLbProvider, newBarConfig);
|
||||
PriorityLbConfig newPriorityLbConfig =
|
||||
new PriorityLbConfig(ImmutableMap.of("p1", newBarPolicy), ImmutableList.of("p1"));
|
||||
priorityLb.handleResolvedAddresses(
|
||||
|
|
@ -217,9 +217,9 @@ public class PriorityLoadBalancerTest {
|
|||
@Test
|
||||
public void handleNameResolutionError() {
|
||||
Object fooConfig0 = new Object();
|
||||
PolicySelection fooPolicy0 = new PolicySelection(fooLbProvider, null, fooConfig0);
|
||||
PolicySelection fooPolicy0 = new PolicySelection(fooLbProvider, fooConfig0);
|
||||
Object fooConfig1 = new Object();
|
||||
PolicySelection fooPolicy1 = new PolicySelection(fooLbProvider, null, fooConfig1);
|
||||
PolicySelection fooPolicy1 = new PolicySelection(fooLbProvider, fooConfig1);
|
||||
|
||||
PriorityLbConfig priorityLbConfig =
|
||||
new PriorityLbConfig(ImmutableMap.of("p0", fooPolicy0), ImmutableList.of("p0"));
|
||||
|
|
@ -253,10 +253,10 @@ public class PriorityLoadBalancerTest {
|
|||
|
||||
@Test
|
||||
public void typicalPriorityFailOverFlow() {
|
||||
PolicySelection policy0 = new PolicySelection(fooLbProvider, null, new Object());
|
||||
PolicySelection policy1 = new PolicySelection(fooLbProvider, null, new Object());
|
||||
PolicySelection policy2 = new PolicySelection(fooLbProvider, null, new Object());
|
||||
PolicySelection policy3 = new PolicySelection(fooLbProvider, null, new Object());
|
||||
PolicySelection policy0 = new PolicySelection(fooLbProvider, new Object());
|
||||
PolicySelection policy1 = new PolicySelection(fooLbProvider, new Object());
|
||||
PolicySelection policy2 = new PolicySelection(fooLbProvider, new Object());
|
||||
PolicySelection policy3 = new PolicySelection(fooLbProvider, new Object());
|
||||
PriorityLbConfig priorityLbConfig =
|
||||
new PriorityLbConfig(
|
||||
ImmutableMap.of("p0", policy0, "p1", policy1, "p2", policy2, "p3", policy3),
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import io.grpc.internal.JsonParser;
|
|||
import io.grpc.internal.ServiceConfigUtil.PolicySelection;
|
||||
import io.grpc.xds.WeightedTargetLoadBalancerProvider.WeightedPolicySelection;
|
||||
import io.grpc.xds.WeightedTargetLoadBalancerProvider.WeightedTargetConfig;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
|
@ -129,11 +128,11 @@ public class WeightedTargetLoadBalancerProviderTest {
|
|||
"target_1",
|
||||
new WeightedPolicySelection(
|
||||
10,
|
||||
new PolicySelection(lbProviderFoo, new HashMap<String, Object>(), fooConfig)),
|
||||
new PolicySelection(lbProviderFoo, fooConfig)),
|
||||
"target_2",
|
||||
new WeightedPolicySelection(
|
||||
20,
|
||||
new PolicySelection(lbProviderBar, new HashMap<String, Object>(), barConfig)))));
|
||||
new PolicySelection(lbProviderBar, barConfig)))));
|
||||
assertThat(parsedConfig).isEqualTo(expectedConfig);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,13 +133,13 @@ public class WeightedTargetLoadBalancerTest {
|
|||
};
|
||||
|
||||
private final WeightedPolicySelection weightedLbConfig0 = new WeightedPolicySelection(
|
||||
weights[0], new PolicySelection(fooLbProvider, null, configs[0]));
|
||||
weights[0], new PolicySelection(fooLbProvider, configs[0]));
|
||||
private final WeightedPolicySelection weightedLbConfig1 = new WeightedPolicySelection(
|
||||
weights[1], new PolicySelection(barLbProvider, null, configs[1]));
|
||||
weights[1], new PolicySelection(barLbProvider, configs[1]));
|
||||
private final WeightedPolicySelection weightedLbConfig2 = new WeightedPolicySelection(
|
||||
weights[2], new PolicySelection(barLbProvider, null, configs[2]));
|
||||
weights[2], new PolicySelection(barLbProvider, configs[2]));
|
||||
private final WeightedPolicySelection weightedLbConfig3 = new WeightedPolicySelection(
|
||||
weights[3], new PolicySelection(fooLbProvider, null, configs[3]));
|
||||
weights[3], new PolicySelection(fooLbProvider, configs[3]));
|
||||
|
||||
@Mock
|
||||
private Helper helper;
|
||||
|
|
@ -220,16 +220,16 @@ public class WeightedTargetLoadBalancerTest {
|
|||
Map<String, WeightedPolicySelection> newTargets = ImmutableMap.of(
|
||||
"target1",
|
||||
new WeightedPolicySelection(
|
||||
newWeights[0], new PolicySelection(barLbProvider, null, newConfigs[0])),
|
||||
newWeights[0], new PolicySelection(barLbProvider, newConfigs[0])),
|
||||
"target2",
|
||||
new WeightedPolicySelection(
|
||||
newWeights[1], new PolicySelection(barLbProvider, null, newConfigs[1])),
|
||||
newWeights[1], new PolicySelection(barLbProvider, newConfigs[1])),
|
||||
"target3",
|
||||
new WeightedPolicySelection(
|
||||
newWeights[2], new PolicySelection(fooLbProvider, null, newConfigs[2])),
|
||||
newWeights[2], new PolicySelection(fooLbProvider, newConfigs[2])),
|
||||
"target4",
|
||||
new WeightedPolicySelection(
|
||||
newWeights[3], new PolicySelection(fooLbProvider, null, newConfigs[3])));
|
||||
newWeights[3], new PolicySelection(fooLbProvider, newConfigs[3])));
|
||||
weightedTargetLb.handleResolvedAddresses(
|
||||
ResolvedAddresses.newBuilder()
|
||||
.setAddresses(ImmutableList.<EquivalentAddressGroup>of())
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ import io.grpc.xds.XdsRoutingLoadBalancerProvider.Route;
|
|||
import io.grpc.xds.XdsRoutingLoadBalancerProvider.XdsRoutingConfig;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.junit.Test;
|
||||
|
|
@ -224,9 +223,9 @@ public class XdsRoutingLoadBalancerProviderTest {
|
|||
assertThat(configActions).hasSize(2);
|
||||
assertThat(configActions).containsExactly(
|
||||
"action_foo",
|
||||
new PolicySelection(lbProviderFoo, new HashMap<String, Object>(), fooConfig),
|
||||
new PolicySelection(lbProviderFoo, fooConfig),
|
||||
"action_bar",
|
||||
new PolicySelection(
|
||||
lbProviderBar, new HashMap<String, Object>(), barConfig));
|
||||
lbProviderBar, barConfig));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ public class XdsRoutingLoadBalancerTest {
|
|||
String childPolicyName = childPolicies.get(route);
|
||||
Object childConfig = lbConfigInventory.get(childActionName);
|
||||
PolicySelection policy =
|
||||
new PolicySelection(new FakeLoadBalancerProvider(childPolicyName), null, childConfig);
|
||||
new PolicySelection(new FakeLoadBalancerProvider(childPolicyName), childConfig);
|
||||
childPolicySelections.put(childActionName, policy);
|
||||
routeList.add(route);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue