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