core,grpclb: use better generics on service config

This commit is contained in:
Carl Mastrangelo 2019-03-08 14:11:13 -08:00 committed by GitHub
parent cbec70ab93
commit e5e01b5169
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
22 changed files with 162 additions and 167 deletions

View File

@ -109,7 +109,7 @@ public abstract class LoadBalancer {
* <p>{@link NameResolver}s should not produce this attribute. * <p>{@link NameResolver}s should not produce this attribute.
*/ */
@NameResolver.ResolutionResultAttr @NameResolver.ResolutionResultAttr
public static final Attributes.Key<Map<String, Object>> ATTR_LOAD_BALANCING_CONFIG = public static final Attributes.Key<Map<String, ?>> ATTR_LOAD_BALANCING_CONFIG =
Attributes.Key.create("io.grpc.LoadBalancer.loadBalancingConfig"); Attributes.Key.create("io.grpc.LoadBalancer.loadBalancingConfig");
/** /**

View File

@ -106,7 +106,7 @@ public final class AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factor
"Unexpected ATTR_LOAD_BALANCING_CONFIG from upstream: " "Unexpected ATTR_LOAD_BALANCING_CONFIG from upstream: "
+ attributes.get(ATTR_LOAD_BALANCING_CONFIG)); + attributes.get(ATTR_LOAD_BALANCING_CONFIG));
} }
Map<String, Object> configMap = attributes.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG); Map<String, ?> configMap = attributes.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG);
PolicySelection selection; PolicySelection selection;
try { try {
selection = decideLoadBalancerProvider(servers, configMap); selection = decideLoadBalancerProvider(servers, configMap);
@ -202,7 +202,7 @@ public final class AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factor
*/ */
@VisibleForTesting @VisibleForTesting
PolicySelection decideLoadBalancerProvider( PolicySelection decideLoadBalancerProvider(
List<EquivalentAddressGroup> servers, @Nullable Map<String, Object> config) List<EquivalentAddressGroup> servers, @Nullable Map<String, ?> config)
throws PolicyException { throws PolicyException {
// Check for balancer addresses // Check for balancer addresses
boolean haveBalancerAddress = false; boolean haveBalancerAddress = false;
@ -217,7 +217,7 @@ public final class AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factor
List<LbConfig> lbConfigs = null; List<LbConfig> lbConfigs = null;
if (config != null) { if (config != null) {
List<Map<String, Object>> rawLbConfigs = List<Map<String, ?>> rawLbConfigs =
ServiceConfigUtil.getLoadBalancingConfigsFromServiceConfig(config); ServiceConfigUtil.getLoadBalancingConfigsFromServiceConfig(config);
lbConfigs = ServiceConfigUtil.unwrapLoadBalancingConfigList(rawLbConfigs); lbConfigs = ServiceConfigUtil.unwrapLoadBalancingConfigList(rawLbConfigs);
} }
@ -304,11 +304,11 @@ public final class AutoConfiguredLoadBalancerFactory extends LoadBalancer.Factor
static final class PolicySelection { static final class PolicySelection {
final LoadBalancerProvider provider; final LoadBalancerProvider provider;
final List<EquivalentAddressGroup> serverList; final List<EquivalentAddressGroup> serverList;
@Nullable final Map<String, Object> config; @Nullable final Map<String, ?> config;
PolicySelection( PolicySelection(
LoadBalancerProvider provider, List<EquivalentAddressGroup> serverList, LoadBalancerProvider provider, List<EquivalentAddressGroup> serverList,
@Nullable Map<String, Object> config) { @Nullable Map<String, ?> config) {
this.provider = checkNotNull(provider, "provider"); this.provider = checkNotNull(provider, "provider");
this.serverList = Collections.unmodifiableList(checkNotNull(serverList, "serverList")); this.serverList = Collections.unmodifiableList(checkNotNull(serverList, "serverList"));
this.config = config; this.config = config;

View File

@ -285,10 +285,9 @@ final class DnsNameResolver extends NameResolver {
Attributes.Builder attrs = Attributes.newBuilder(); Attributes.Builder attrs = Attributes.newBuilder();
if (!resolutionResults.txtRecords.isEmpty()) { if (!resolutionResults.txtRecords.isEmpty()) {
Map<String, Object> serviceConfig = null; Map<String, ?> serviceConfig = null;
try { try {
for (Map<String, Object> possibleConfig : for (Map<String, ?> possibleConfig : parseTxtResults(resolutionResults.txtRecords)) {
parseTxtResults(resolutionResults.txtRecords)) {
try { try {
serviceConfig = serviceConfig =
maybeChooseServiceConfig(possibleConfig, random, getLocalHostname()); maybeChooseServiceConfig(possibleConfig, random, getLocalHostname());
@ -406,23 +405,23 @@ final class DnsNameResolver extends NameResolver {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@VisibleForTesting @VisibleForTesting
static List<Map<String, Object>> parseTxtResults(List<String> txtRecords) { static List<Map<String, ?>> parseTxtResults(List<String> txtRecords) {
List<Map<String, Object>> serviceConfigs = new ArrayList<>(); List<Map<String, ?>> serviceConfigs = new ArrayList<>();
for (String txtRecord : txtRecords) { for (String txtRecord : txtRecords) {
if (txtRecord.startsWith(SERVICE_CONFIG_PREFIX)) { if (txtRecord.startsWith(SERVICE_CONFIG_PREFIX)) {
List<Map<String, Object>> choices; List<Map<String, ?>> choices;
try { try {
Object rawChoices = JsonParser.parse(txtRecord.substring(SERVICE_CONFIG_PREFIX.length())); Object rawChoices = JsonParser.parse(txtRecord.substring(SERVICE_CONFIG_PREFIX.length()));
if (!(rawChoices instanceof List)) { if (!(rawChoices instanceof List)) {
throw new IOException("wrong type " + rawChoices); throw new IOException("wrong type " + rawChoices);
} }
List<Object> listChoices = (List<Object>) rawChoices; List<?> listChoices = (List<?>) rawChoices;
for (Object obj : listChoices) { for (Object obj : listChoices) {
if (!(obj instanceof Map)) { if (!(obj instanceof Map)) {
throw new IOException("wrong element type " + rawChoices); throw new IOException("wrong element type " + rawChoices);
} }
} }
choices = (List<Map<String, Object>>) (List<?>) listChoices; choices = (List<Map<String, ?>>) listChoices;
} catch (IOException e) { } catch (IOException e) {
logger.log(Level.WARNING, "Bad service config: " + txtRecord, e); logger.log(Level.WARNING, "Bad service config: " + txtRecord, e);
continue; continue;
@ -436,8 +435,7 @@ final class DnsNameResolver extends NameResolver {
} }
@Nullable @Nullable
private static final Double getPercentageFromChoice( private static final Double getPercentageFromChoice(Map<String, ?> serviceConfigChoice) {
Map<String, Object> serviceConfigChoice) {
if (!serviceConfigChoice.containsKey(SERVICE_CONFIG_CHOICE_PERCENTAGE_KEY)) { if (!serviceConfigChoice.containsKey(SERVICE_CONFIG_CHOICE_PERCENTAGE_KEY)) {
return null; return null;
} }
@ -446,7 +444,7 @@ final class DnsNameResolver extends NameResolver {
@Nullable @Nullable
private static final List<String> getClientLanguagesFromChoice( private static final List<String> getClientLanguagesFromChoice(
Map<String, Object> serviceConfigChoice) { Map<String, ?> serviceConfigChoice) {
if (!serviceConfigChoice.containsKey(SERVICE_CONFIG_CHOICE_CLIENT_LANGUAGE_KEY)) { if (!serviceConfigChoice.containsKey(SERVICE_CONFIG_CHOICE_CLIENT_LANGUAGE_KEY)) {
return null; return null;
} }
@ -455,8 +453,7 @@ final class DnsNameResolver extends NameResolver {
} }
@Nullable @Nullable
private static final List<String> getHostnamesFromChoice( private static final List<String> getHostnamesFromChoice(Map<String, ?> serviceConfigChoice) {
Map<String, Object> serviceConfigChoice) {
if (!serviceConfigChoice.containsKey(SERVICE_CONFIG_CHOICE_CLIENT_HOSTNAME_KEY)) { if (!serviceConfigChoice.containsKey(SERVICE_CONFIG_CHOICE_CLIENT_HOSTNAME_KEY)) {
return null; return null;
} }
@ -499,8 +496,8 @@ final class DnsNameResolver extends NameResolver {
*/ */
@Nullable @Nullable
@VisibleForTesting @VisibleForTesting
static Map<String, Object> maybeChooseServiceConfig( static Map<String, ?> maybeChooseServiceConfig(
Map<String, Object> choice, Random random, String hostname) { Map<String, ?> choice, Random random, String hostname) {
for (Entry<String, ?> entry : choice.entrySet()) { for (Entry<String, ?> entry : choice.entrySet()) {
Verify.verify(SERVICE_CONFIG_CHOICE_KEYS.contains(entry.getKey()), "Bad key: %s", entry); Verify.verify(SERVICE_CONFIG_CHOICE_KEYS.contains(entry.getKey()), "Bad key: %s", entry);
} }

View File

@ -31,7 +31,7 @@ public final class GrpcAttributes {
* Attribute key for service config. * Attribute key for service config.
*/ */
@NameResolver.ResolutionResultAttr @NameResolver.ResolutionResultAttr
public static final Attributes.Key<Map<String, Object>> NAME_RESOLVER_SERVICE_CONFIG = public static final Attributes.Key<Map<String, ?>> NAME_RESOLVER_SERVICE_CONFIG =
Attributes.Key.create("service-config"); Attributes.Key.create("service-config");
/** /**

View File

@ -40,7 +40,7 @@ public final class JsonParser {
private JsonParser() {} private JsonParser() {}
/** /**
* Parses a json string, returning either a {@code Map<String, Object>}, {@code List<Object>}, * Parses a json string, returning either a {@code Map<String, ?>}, {@code List<Object>},
* {@code String}, {@code Double}, {@code Boolean}, or {@code null}. * {@code String}, {@code Double}, {@code Boolean}, or {@code null}.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@ -77,7 +77,7 @@ public final class JsonParser {
} }
} }
private static Map<String, Object> parseJsonObject(JsonReader jr) throws IOException { private static Map<String, ?> parseJsonObject(JsonReader jr) throws IOException {
jr.beginObject(); jr.beginObject();
Map<String, Object> obj = new LinkedHashMap<>(); Map<String, Object> obj = new LinkedHashMap<>();
while (jr.hasNext()) { while (jr.hasNext()) {
@ -90,7 +90,7 @@ public final class JsonParser {
return Collections.unmodifiableMap(obj); return Collections.unmodifiableMap(obj);
} }
private static List<Object> parseJsonArray(JsonReader jr) throws IOException { private static List<?> parseJsonArray(JsonReader jr) throws IOException {
jr.beginArray(); jr.beginArray();
List<Object> array = new ArrayList<>(); List<Object> array = new ArrayList<>();
while (jr.hasNext()) { while (jr.hasNext()) {

View File

@ -237,7 +237,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
@CheckForNull @CheckForNull
private Boolean haveBackends; // a flag for doing channel tracing when flipped private Boolean haveBackends; // a flag for doing channel tracing when flipped
@Nullable @Nullable
private Map<String, Object> lastServiceConfig; // used for channel tracing when value changed private Map<String, ?> lastServiceConfig; // used for channel tracing when value changed
// One instance per channel. // One instance per channel.
private final ChannelBufferMeter channelBufferUsed = new ChannelBufferMeter(); private final ChannelBufferMeter channelBufferUsed = new ChannelBufferMeter();
@ -1296,8 +1296,7 @@ final class ManagedChannelImpl extends ManagedChannel implements
channelLogger.log(ChannelLogLevel.INFO, "Address resolved: {0}", servers); channelLogger.log(ChannelLogLevel.INFO, "Address resolved: {0}", servers);
haveBackends = true; haveBackends = true;
} }
final Map<String, Object> serviceConfig = final Map<String, ?> serviceConfig = config.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG);
config.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG);
if (serviceConfig != null && !serviceConfig.equals(lastServiceConfig)) { if (serviceConfig != null && !serviceConfig.equals(lastServiceConfig)) {
channelLogger.log(ChannelLogLevel.INFO, "Service config changed"); channelLogger.log(ChannelLogLevel.INFO, "Service config changed");
lastServiceConfig = serviceConfig; lastServiceConfig = serviceConfig;

View File

@ -73,14 +73,14 @@ final class ServiceConfigInterceptor implements ClientInterceptor {
this.maxHedgedAttemptsLimit = maxHedgedAttemptsLimit; this.maxHedgedAttemptsLimit = maxHedgedAttemptsLimit;
} }
void handleUpdate(@Nonnull Map<String, Object> serviceConfig) { void handleUpdate(@Nonnull Map<String, ?> serviceConfig) {
Map<String, MethodInfo> newServiceMethodConfigs = new HashMap<>(); Map<String, MethodInfo> newServiceMethodConfigs = new HashMap<>();
Map<String, MethodInfo> newServiceConfigs = new HashMap<>(); Map<String, MethodInfo> newServiceConfigs = new HashMap<>();
// Try and do as much validation here before we swap out the existing configuration. In case // Try and do as much validation here before we swap out the existing configuration. In case
// the input is invalid, we don't want to lose the existing configuration. // the input is invalid, we don't want to lose the existing configuration.
List<Map<String, Object>> methodConfigs = List<Map<String, ?>> methodConfigs =
ServiceConfigUtil.getMethodConfigFromServiceConfig(serviceConfig); ServiceConfigUtil.getMethodConfigFromServiceConfig(serviceConfig);
if (methodConfigs == null) { if (methodConfigs == null) {
logger.log(Level.FINE, "No method configs found, skipping"); logger.log(Level.FINE, "No method configs found, skipping");
@ -88,16 +88,16 @@ final class ServiceConfigInterceptor implements ClientInterceptor {
return; return;
} }
for (Map<String, Object> methodConfig : methodConfigs) { for (Map<String, ?> methodConfig : methodConfigs) {
MethodInfo info = new MethodInfo( MethodInfo info = new MethodInfo(
methodConfig, retryEnabled, maxRetryAttemptsLimit, maxHedgedAttemptsLimit); methodConfig, retryEnabled, maxRetryAttemptsLimit, maxHedgedAttemptsLimit);
List<Map<String, Object>> nameList = List<Map<String, ?>> nameList =
ServiceConfigUtil.getNameListFromMethodConfig(methodConfig); ServiceConfigUtil.getNameListFromMethodConfig(methodConfig);
checkArgument( checkArgument(
nameList != null && !nameList.isEmpty(), "no names in method config %s", methodConfig); nameList != null && !nameList.isEmpty(), "no names in method config %s", methodConfig);
for (Map<String, Object> name : nameList) { for (Map<String, ?> name : nameList) {
String serviceName = ServiceConfigUtil.getServiceFromName(name); String serviceName = ServiceConfigUtil.getServiceFromName(name);
checkArgument(!Strings.isNullOrEmpty(serviceName), "missing service name"); checkArgument(!Strings.isNullOrEmpty(serviceName), "missing service name");
String methodName = ServiceConfigUtil.getMethodFromName(name); String methodName = ServiceConfigUtil.getMethodFromName(name);
@ -141,7 +141,7 @@ final class ServiceConfigInterceptor implements ClientInterceptor {
* @param retryEnabled when false, the argument maxRetryAttemptsLimit will have no effect. * @param retryEnabled when false, the argument maxRetryAttemptsLimit will have no effect.
*/ */
MethodInfo( MethodInfo(
Map<String, Object> methodConfig, boolean retryEnabled, int maxRetryAttemptsLimit, Map<String, ?> methodConfig, boolean retryEnabled, int maxRetryAttemptsLimit,
int maxHedgedAttemptsLimit) { int maxHedgedAttemptsLimit) {
timeoutNanos = ServiceConfigUtil.getTimeoutFromMethodConfig(methodConfig); timeoutNanos = ServiceConfigUtil.getTimeoutFromMethodConfig(methodConfig);
waitForReady = ServiceConfigUtil.getWaitForReadyFromMethodConfig(methodConfig); waitForReady = ServiceConfigUtil.getWaitForReadyFromMethodConfig(methodConfig);
@ -160,12 +160,12 @@ final class ServiceConfigInterceptor implements ClientInterceptor {
"maxOutboundMessageSize %s exceeds bounds", maxOutboundMessageSize); "maxOutboundMessageSize %s exceeds bounds", maxOutboundMessageSize);
} }
Map<String, Object> retryPolicyMap = Map<String, ?> retryPolicyMap =
retryEnabled ? ServiceConfigUtil.getRetryPolicyFromMethodConfig(methodConfig) : null; retryEnabled ? ServiceConfigUtil.getRetryPolicyFromMethodConfig(methodConfig) : null;
retryPolicy = retryPolicyMap == null retryPolicy = retryPolicyMap == null
? RetryPolicy.DEFAULT : retryPolicy(retryPolicyMap, maxRetryAttemptsLimit); ? RetryPolicy.DEFAULT : retryPolicy(retryPolicyMap, maxRetryAttemptsLimit);
Map<String, Object> hedgingPolicyMap = Map<String, ?> hedgingPolicyMap =
retryEnabled ? ServiceConfigUtil.getHedgingPolicyFromMethodConfig(methodConfig) : null; retryEnabled ? ServiceConfigUtil.getHedgingPolicyFromMethodConfig(methodConfig) : null;
hedgingPolicy = hedgingPolicyMap == null hedgingPolicy = hedgingPolicyMap == null
? HedgingPolicy.DEFAULT : hedgingPolicy(hedgingPolicyMap, maxHedgedAttemptsLimit); ? HedgingPolicy.DEFAULT : hedgingPolicy(hedgingPolicyMap, maxHedgedAttemptsLimit);
@ -201,7 +201,7 @@ final class ServiceConfigInterceptor implements ClientInterceptor {
.toString(); .toString();
} }
private static RetryPolicy retryPolicy(Map<String, Object> retryPolicy, int maxAttemptsLimit) { private static RetryPolicy retryPolicy(Map<String, ?> retryPolicy, int maxAttemptsLimit) {
int maxAttempts = checkNotNull( int maxAttempts = checkNotNull(
ServiceConfigUtil.getMaxAttemptsFromRetryPolicy(retryPolicy), ServiceConfigUtil.getMaxAttemptsFromRetryPolicy(retryPolicy),
"maxAttempts cannot be empty"); "maxAttempts cannot be empty");
@ -249,7 +249,7 @@ final class ServiceConfigInterceptor implements ClientInterceptor {
} }
private static HedgingPolicy hedgingPolicy( private static HedgingPolicy hedgingPolicy(
Map<String, Object> hedgingPolicy, int maxAttemptsLimit) { Map<String, ?> hedgingPolicy, int maxAttemptsLimit) {
int maxAttempts = checkNotNull( int maxAttempts = checkNotNull(
ServiceConfigUtil.getMaxAttemptsFromHedgingPolicy(hedgingPolicy), ServiceConfigUtil.getMaxAttemptsFromHedgingPolicy(hedgingPolicy),
"maxAttempts cannot be empty"); "maxAttempts cannot be empty");

View File

@ -74,7 +74,7 @@ public final class ServiceConfigUtil {
* Fetch the health-checked service name from service config. {@code null} if can't find one. * Fetch the health-checked service name from service config. {@code null} if can't find one.
*/ */
@Nullable @Nullable
public static String getHealthCheckedServiceName(@Nullable Map<String, Object> serviceConfig) { public static String getHealthCheckedServiceName(@Nullable Map<String, ?> serviceConfig) {
String healthCheckKey = "healthCheckConfig"; String healthCheckKey = "healthCheckConfig";
String serviceNameKey = "serviceName"; String serviceNameKey = "serviceName";
if (serviceConfig == null || !serviceConfig.containsKey(healthCheckKey)) { if (serviceConfig == null || !serviceConfig.containsKey(healthCheckKey)) {
@ -89,7 +89,7 @@ public final class ServiceConfigUtil {
} }
} }
*/ */
Map<String, Object> healthCheck = getObject(serviceConfig, healthCheckKey); Map<String, ?> healthCheck = getObject(serviceConfig, healthCheckKey);
if (!healthCheck.containsKey(serviceNameKey)) { if (!healthCheck.containsKey(serviceNameKey)) {
return null; return null;
} }
@ -97,7 +97,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Throttle getThrottlePolicy(@Nullable Map<String, Object> serviceConfig) { static Throttle getThrottlePolicy(@Nullable Map<String, ?> serviceConfig) {
String retryThrottlingKey = "retryThrottling"; String retryThrottlingKey = "retryThrottling";
if (serviceConfig == null || !serviceConfig.containsKey(retryThrottlingKey)) { if (serviceConfig == null || !serviceConfig.containsKey(retryThrottlingKey)) {
return null; return null;
@ -122,7 +122,7 @@ public final class ServiceConfigUtil {
} }
*/ */
Map<String, Object> throttling = getObject(serviceConfig, retryThrottlingKey); Map<String, ?> throttling = getObject(serviceConfig, retryThrottlingKey);
float maxTokens = getDouble(throttling, "maxTokens").floatValue(); float maxTokens = getDouble(throttling, "maxTokens").floatValue();
float tokenRatio = getDouble(throttling, "tokenRatio").floatValue(); float tokenRatio = getDouble(throttling, "tokenRatio").floatValue();
@ -132,7 +132,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Integer getMaxAttemptsFromRetryPolicy(Map<String, Object> retryPolicy) { static Integer getMaxAttemptsFromRetryPolicy(Map<String, ?> retryPolicy) {
if (!retryPolicy.containsKey(RETRY_POLICY_MAX_ATTEMPTS_KEY)) { if (!retryPolicy.containsKey(RETRY_POLICY_MAX_ATTEMPTS_KEY)) {
return null; return null;
} }
@ -140,7 +140,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Long getInitialBackoffNanosFromRetryPolicy(Map<String, Object> retryPolicy) { static Long getInitialBackoffNanosFromRetryPolicy(Map<String, ?> retryPolicy) {
if (!retryPolicy.containsKey(RETRY_POLICY_INITIAL_BACKOFF_KEY)) { if (!retryPolicy.containsKey(RETRY_POLICY_INITIAL_BACKOFF_KEY)) {
return null; return null;
} }
@ -153,7 +153,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Long getMaxBackoffNanosFromRetryPolicy(Map<String, Object> retryPolicy) { static Long getMaxBackoffNanosFromRetryPolicy(Map<String, ?> retryPolicy) {
if (!retryPolicy.containsKey(RETRY_POLICY_MAX_BACKOFF_KEY)) { if (!retryPolicy.containsKey(RETRY_POLICY_MAX_BACKOFF_KEY)) {
return null; return null;
} }
@ -166,7 +166,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Double getBackoffMultiplierFromRetryPolicy(Map<String, Object> retryPolicy) { static Double getBackoffMultiplierFromRetryPolicy(Map<String, ?> retryPolicy) {
if (!retryPolicy.containsKey(RETRY_POLICY_BACKOFF_MULTIPLIER_KEY)) { if (!retryPolicy.containsKey(RETRY_POLICY_BACKOFF_MULTIPLIER_KEY)) {
return null; return null;
} }
@ -174,7 +174,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static List<String> getRetryableStatusCodesFromRetryPolicy(Map<String, Object> retryPolicy) { static List<String> getRetryableStatusCodesFromRetryPolicy(Map<String, ?> retryPolicy) {
if (!retryPolicy.containsKey(RETRY_POLICY_RETRYABLE_STATUS_CODES_KEY)) { if (!retryPolicy.containsKey(RETRY_POLICY_RETRYABLE_STATUS_CODES_KEY)) {
return null; return null;
} }
@ -182,7 +182,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Integer getMaxAttemptsFromHedgingPolicy(Map<String, Object> hedgingPolicy) { static Integer getMaxAttemptsFromHedgingPolicy(Map<String, ?> hedgingPolicy) {
if (!hedgingPolicy.containsKey(HEDGING_POLICY_MAX_ATTEMPTS_KEY)) { if (!hedgingPolicy.containsKey(HEDGING_POLICY_MAX_ATTEMPTS_KEY)) {
return null; return null;
} }
@ -190,7 +190,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Long getHedgingDelayNanosFromHedgingPolicy(Map<String, Object> hedgingPolicy) { static Long getHedgingDelayNanosFromHedgingPolicy(Map<String, ?> hedgingPolicy) {
if (!hedgingPolicy.containsKey(HEDGING_POLICY_HEDGING_DELAY_KEY)) { if (!hedgingPolicy.containsKey(HEDGING_POLICY_HEDGING_DELAY_KEY)) {
return null; return null;
} }
@ -203,7 +203,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static List<String> getNonFatalStatusCodesFromHedgingPolicy(Map<String, Object> hedgingPolicy) { static List<String> getNonFatalStatusCodesFromHedgingPolicy(Map<String, ?> hedgingPolicy) {
if (!hedgingPolicy.containsKey(HEDGING_POLICY_NON_FATAL_STATUS_CODES_KEY)) { if (!hedgingPolicy.containsKey(HEDGING_POLICY_NON_FATAL_STATUS_CODES_KEY)) {
return null; return null;
} }
@ -211,7 +211,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static String getServiceFromName(Map<String, Object> name) { static String getServiceFromName(Map<String, ?> name) {
if (!name.containsKey(NAME_SERVICE_KEY)) { if (!name.containsKey(NAME_SERVICE_KEY)) {
return null; return null;
} }
@ -219,7 +219,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static String getMethodFromName(Map<String, Object> name) { static String getMethodFromName(Map<String, ?> name) {
if (!name.containsKey(NAME_METHOD_KEY)) { if (!name.containsKey(NAME_METHOD_KEY)) {
return null; return null;
} }
@ -227,7 +227,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Map<String, Object> getRetryPolicyFromMethodConfig(Map<String, Object> methodConfig) { static Map<String, ?> getRetryPolicyFromMethodConfig(Map<String, ?> methodConfig) {
if (!methodConfig.containsKey(METHOD_CONFIG_RETRY_POLICY_KEY)) { if (!methodConfig.containsKey(METHOD_CONFIG_RETRY_POLICY_KEY)) {
return null; return null;
} }
@ -235,7 +235,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Map<String, Object> getHedgingPolicyFromMethodConfig(Map<String, Object> methodConfig) { static Map<String, ?> getHedgingPolicyFromMethodConfig(Map<String, ?> methodConfig) {
if (!methodConfig.containsKey(METHOD_CONFIG_HEDGING_POLICY_KEY)) { if (!methodConfig.containsKey(METHOD_CONFIG_HEDGING_POLICY_KEY)) {
return null; return null;
} }
@ -243,7 +243,8 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static List<Map<String, Object>> getNameListFromMethodConfig(Map<String, Object> methodConfig) { static List<Map<String, ?>> getNameListFromMethodConfig(
Map<String, ?> methodConfig) {
if (!methodConfig.containsKey(METHOD_CONFIG_NAME_KEY)) { if (!methodConfig.containsKey(METHOD_CONFIG_NAME_KEY)) {
return null; return null;
} }
@ -256,7 +257,7 @@ public final class ServiceConfigUtil {
* @return duration nanoseconds, or {@code null} if it isn't present. * @return duration nanoseconds, or {@code null} if it isn't present.
*/ */
@Nullable @Nullable
static Long getTimeoutFromMethodConfig(Map<String, Object> methodConfig) { static Long getTimeoutFromMethodConfig(Map<String, ?> methodConfig) {
if (!methodConfig.containsKey(METHOD_CONFIG_TIMEOUT_KEY)) { if (!methodConfig.containsKey(METHOD_CONFIG_TIMEOUT_KEY)) {
return null; return null;
} }
@ -269,7 +270,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Boolean getWaitForReadyFromMethodConfig(Map<String, Object> methodConfig) { static Boolean getWaitForReadyFromMethodConfig(Map<String, ?> methodConfig) {
if (!methodConfig.containsKey(METHOD_CONFIG_WAIT_FOR_READY_KEY)) { if (!methodConfig.containsKey(METHOD_CONFIG_WAIT_FOR_READY_KEY)) {
return null; return null;
} }
@ -277,7 +278,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Integer getMaxRequestMessageBytesFromMethodConfig(Map<String, Object> methodConfig) { static Integer getMaxRequestMessageBytesFromMethodConfig(Map<String, ?> methodConfig) {
if (!methodConfig.containsKey(METHOD_CONFIG_MAX_REQUEST_MESSAGE_BYTES_KEY)) { if (!methodConfig.containsKey(METHOD_CONFIG_MAX_REQUEST_MESSAGE_BYTES_KEY)) {
return null; return null;
} }
@ -285,7 +286,7 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static Integer getMaxResponseMessageBytesFromMethodConfig(Map<String, Object> methodConfig) { static Integer getMaxResponseMessageBytesFromMethodConfig(Map<String, ?> methodConfig) {
if (!methodConfig.containsKey(METHOD_CONFIG_MAX_RESPONSE_MESSAGE_BYTES_KEY)) { if (!methodConfig.containsKey(METHOD_CONFIG_MAX_RESPONSE_MESSAGE_BYTES_KEY)) {
return null; return null;
} }
@ -293,8 +294,8 @@ public final class ServiceConfigUtil {
} }
@Nullable @Nullable
static List<Map<String, Object>> getMethodConfigFromServiceConfig( static List<Map<String, ?>> getMethodConfigFromServiceConfig(
Map<String, Object> serviceConfig) { Map<String, ?> serviceConfig) {
if (!serviceConfig.containsKey(SERVICE_CONFIG_METHOD_CONFIG_KEY)) { if (!serviceConfig.containsKey(SERVICE_CONFIG_METHOD_CONFIG_KEY)) {
return null; return null;
} }
@ -306,8 +307,8 @@ public final class ServiceConfigUtil {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@VisibleForTesting @VisibleForTesting
public static List<Map<String, Object>> getLoadBalancingConfigsFromServiceConfig( public static List<Map<String, ?>> getLoadBalancingConfigsFromServiceConfig(
Map<String, Object> serviceConfig) { Map<String, ?> serviceConfig) {
/* schema as follows /* schema as follows
{ {
"loadBalancingConfig": { "loadBalancingConfig": {
@ -325,11 +326,11 @@ public final class ServiceConfigUtil {
"loadBalancingPolicy": "ROUND_ROBIN" // The deprecated policy key "loadBalancingPolicy": "ROUND_ROBIN" // The deprecated policy key
} }
*/ */
List<Map<String, Object>> lbConfigs = new ArrayList<>(); List<Map<String, ?>> lbConfigs = new ArrayList<>();
if (serviceConfig.containsKey(SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY)) { if (serviceConfig.containsKey(SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY)) {
List<Object> configs = getList(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY); List<?> configs = getList(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_CONFIG_KEY);
for (Object config : configs) { for (Object config : configs) {
lbConfigs.add((Map<String, Object>) config); lbConfigs.add((Map<String, ?>) config);
} }
} }
if (lbConfigs.isEmpty()) { if (lbConfigs.isEmpty()) {
@ -338,7 +339,7 @@ public final class ServiceConfigUtil {
String policy = getString(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_POLICY_KEY); String policy = getString(serviceConfig, SERVICE_CONFIG_LOAD_BALANCING_POLICY_KEY);
// Convert the policy to a config, so that the caller can handle them in the same way. // Convert the policy to a config, so that the caller can handle them in the same way.
policy = policy.toLowerCase(Locale.ROOT); policy = policy.toLowerCase(Locale.ROOT);
Map<String, Object> fakeConfig = Map<String, ?> fakeConfig =
Collections.singletonMap(policy, (Object) Collections.emptyMap()); Collections.singletonMap(policy, (Object) Collections.emptyMap());
lbConfigs.add(fakeConfig); lbConfigs.add(fakeConfig);
} }
@ -353,9 +354,9 @@ public final class ServiceConfigUtil {
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static LbConfig unwrapLoadBalancingConfig(Object lbConfig) { public static LbConfig unwrapLoadBalancingConfig(Object lbConfig) {
Map<String, Object> map; Map<String, ?> map;
try { try {
map = (Map<String, Object>) lbConfig; map = (Map<String, ?>) lbConfig;
} catch (ClassCastException e) { } catch (ClassCastException e) {
ClassCastException ex = new ClassCastException("Invalid type. Config=" + lbConfig); ClassCastException ex = new ClassCastException("Invalid type. Config=" + lbConfig);
ex.initCause(e); ex.initCause(e);
@ -366,10 +367,10 @@ public final class ServiceConfigUtil {
"There are " + map.size() + " fields in a LoadBalancingConfig object. Exactly one" "There are " + map.size() + " fields in a LoadBalancingConfig object. Exactly one"
+ " is expected. Config=" + lbConfig); + " is expected. Config=" + lbConfig);
} }
Map.Entry<String, Object> entry = map.entrySet().iterator().next(); Map.Entry<String, ?> entry = map.entrySet().iterator().next();
Map<String, Object> configValue; Map<String, ?> configValue;
try { try {
configValue = (Map<String, Object>) entry.getValue(); configValue = (Map<String, ?>) entry.getValue();
} catch (ClassCastException e) { } catch (ClassCastException e) {
ClassCastException ex = ClassCastException ex =
new ClassCastException("Invalid value type. value=" + entry.getValue()); new ClassCastException("Invalid value type. value=" + entry.getValue());
@ -403,7 +404,7 @@ public final class ServiceConfigUtil {
* Extracts the loadbalancer name from xds loadbalancer config. * Extracts the loadbalancer name from xds loadbalancer config.
*/ */
public static String getBalancerNameFromXdsConfig(LbConfig xdsConfig) { public static String getBalancerNameFromXdsConfig(LbConfig xdsConfig) {
Map<String, Object> map = xdsConfig.getRawConfigValue(); Map<String, ?> map = xdsConfig.getRawConfigValue();
return getString(map, XDS_CONFIG_BALANCER_NAME_KEY); return getString(map, XDS_CONFIG_BALANCER_NAME_KEY);
} }
@ -412,7 +413,7 @@ public final class ServiceConfigUtil {
*/ */
@Nullable @Nullable
public static List<LbConfig> getChildPolicyFromXdsConfig(LbConfig xdsConfig) { public static List<LbConfig> getChildPolicyFromXdsConfig(LbConfig xdsConfig) {
Map<String, Object> map = xdsConfig.getRawConfigValue(); Map<String, ?> map = xdsConfig.getRawConfigValue();
Object rawChildPolicies = map.get(XDS_CONFIG_CHILD_POLICY_KEY); Object rawChildPolicies = map.get(XDS_CONFIG_CHILD_POLICY_KEY);
if (rawChildPolicies != null) { if (rawChildPolicies != null) {
return unwrapLoadBalancingConfigList(rawChildPolicies); return unwrapLoadBalancingConfigList(rawChildPolicies);
@ -425,7 +426,7 @@ public final class ServiceConfigUtil {
*/ */
@Nullable @Nullable
public static List<LbConfig> getFallbackPolicyFromXdsConfig(LbConfig xdsConfig) { public static List<LbConfig> getFallbackPolicyFromXdsConfig(LbConfig xdsConfig) {
Map<String, Object> map = xdsConfig.getRawConfigValue(); Map<String, ?> map = xdsConfig.getRawConfigValue();
Object rawFallbackPolicies = map.get(XDS_CONFIG_FALLBACK_POLICY_KEY); Object rawFallbackPolicies = map.get(XDS_CONFIG_FALLBACK_POLICY_KEY);
if (rawFallbackPolicies != null) { if (rawFallbackPolicies != null) {
return unwrapLoadBalancingConfigList(rawFallbackPolicies); return unwrapLoadBalancingConfigList(rawFallbackPolicies);
@ -438,7 +439,7 @@ public final class ServiceConfigUtil {
*/ */
@Nullable @Nullable
public static String getStickinessMetadataKeyFromServiceConfig( public static String getStickinessMetadataKeyFromServiceConfig(
Map<String, Object> serviceConfig) { Map<String, ?> serviceConfig) {
if (!serviceConfig.containsKey(SERVICE_CONFIG_STICKINESS_METADATA_KEY)) { if (!serviceConfig.containsKey(SERVICE_CONFIG_STICKINESS_METADATA_KEY)) {
return null; return null;
} }
@ -449,11 +450,11 @@ public final class ServiceConfigUtil {
* Gets a list from an object for the given key. * Gets a list from an object for the given key.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static List<Object> getList(Map<String, Object> obj, String key) { static List<?> getList(Map<String, ?> obj, String key) {
assert obj.containsKey(key); assert obj.containsKey(key);
Object value = checkNotNull(obj.get(key), "no such key %s", key); Object value = checkNotNull(obj.get(key), "no such key %s", key);
if (value instanceof List) { if (value instanceof List) {
return (List<Object>) value; return (List<?>) value;
} }
throw new ClassCastException( throw new ClassCastException(
String.format("value %s for key %s in %s is not List", value, key, obj)); String.format("value %s for key %s in %s is not List", value, key, obj));
@ -463,11 +464,11 @@ public final class ServiceConfigUtil {
* Gets an object from an object for the given key. * Gets an object from an object for the given key.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static Map<String, Object> getObject(Map<String, Object> obj, String key) { static Map<String, ?> getObject(Map<String, ?> obj, String key) {
assert obj.containsKey(key); assert obj.containsKey(key);
Object value = checkNotNull(obj.get(key), "no such key %s", key); Object value = checkNotNull(obj.get(key), "no such key %s", key);
if (value instanceof Map) { if (value instanceof Map) {
return (Map<String, Object>) value; return (Map<String, ?>) value;
} }
throw new ClassCastException( throw new ClassCastException(
String.format("value %s for key %s in %s is not object", value, key, obj)); String.format("value %s for key %s in %s is not object", value, key, obj));
@ -477,7 +478,7 @@ public final class ServiceConfigUtil {
* Gets a double from an object for the given key. * Gets a double from an object for the given key.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static Double getDouble(Map<String, Object> obj, String key) { static Double getDouble(Map<String, ?> obj, String key) {
assert obj.containsKey(key); assert obj.containsKey(key);
Object value = checkNotNull(obj.get(key), "no such key %s", key); Object value = checkNotNull(obj.get(key), "no such key %s", key);
if (value instanceof Double) { if (value instanceof Double) {
@ -491,7 +492,7 @@ public final class ServiceConfigUtil {
* Gets a string from an object for the given key. * Gets a string from an object for the given key.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static String getString(Map<String, Object> obj, String key) { static String getString(Map<String, ?> obj, String key) {
assert obj.containsKey(key); assert obj.containsKey(key);
Object value = checkNotNull(obj.get(key), "no such key %s", key); Object value = checkNotNull(obj.get(key), "no such key %s", key);
if (value instanceof String) { if (value instanceof String) {
@ -505,7 +506,7 @@ public final class ServiceConfigUtil {
* Gets a string from an object for the given index. * Gets a string from an object for the given index.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static String getString(List<Object> list, int i) { static String getString(List<?> list, int i) {
assert i >= 0 && i < list.size(); assert i >= 0 && i < list.size();
Object value = checkNotNull(list.get(i), "idx %s in %s is null", i, list); Object value = checkNotNull(list.get(i), "idx %s in %s is null", i, list);
if (value instanceof String) { if (value instanceof String) {
@ -518,7 +519,7 @@ public final class ServiceConfigUtil {
/** /**
* Gets a boolean from an object for the given key. * Gets a boolean from an object for the given key.
*/ */
static Boolean getBoolean(Map<String, Object> obj, String key) { static Boolean getBoolean(Map<String, ?> obj, String key) {
assert obj.containsKey(key); assert obj.containsKey(key);
Object value = checkNotNull(obj.get(key), "no such key %s", key); Object value = checkNotNull(obj.get(key), "no such key %s", key);
if (value instanceof Boolean) { if (value instanceof Boolean) {
@ -529,25 +530,25 @@ public final class ServiceConfigUtil {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static List<Map<String, Object>> checkObjectList(List<Object> rawList) { private static List<Map<String, ?>> checkObjectList(List<?> rawList) {
for (int i = 0; i < rawList.size(); i++) { for (int i = 0; i < rawList.size(); i++) {
if (!(rawList.get(i) instanceof Map)) { if (!(rawList.get(i) instanceof Map)) {
throw new ClassCastException( throw new ClassCastException(
String.format("value %s for idx %d in %s is not object", rawList.get(i), i, rawList)); String.format("value %s for idx %d in %s is not object", rawList.get(i), i, rawList));
} }
} }
return (List<Map<String, Object>>) (List<?>) rawList; return (List<Map<String, ?>>) rawList;
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
static List<String> checkStringList(List<Object> rawList) { static List<String> checkStringList(List<?> rawList) {
for (int i = 0; i < rawList.size(); i++) { for (int i = 0; i < rawList.size(); i++) {
if (!(rawList.get(i) instanceof String)) { if (!(rawList.get(i) instanceof String)) {
throw new ClassCastException( throw new ClassCastException(
String.format("value %s for idx %d in %s is not string", rawList.get(i), i, rawList)); String.format("value %s for idx %d in %s is not string", rawList.get(i), i, rawList));
} }
} }
return (List<String>) (List<?>) rawList; return (List<String>) rawList;
} }
/** /**
@ -687,9 +688,9 @@ public final class ServiceConfigUtil {
*/ */
public static final class LbConfig { public static final class LbConfig {
private final String policyName; private final String policyName;
private final Map<String, Object> rawConfigValue; private final Map<String, ?> rawConfigValue;
public LbConfig(String policyName, Map<String, Object> rawConfigValue) { public LbConfig(String policyName, Map<String, ?> rawConfigValue) {
this.policyName = checkNotNull(policyName, "policyName"); this.policyName = checkNotNull(policyName, "policyName");
this.rawConfigValue = checkNotNull(rawConfigValue, "rawConfigValue"); this.rawConfigValue = checkNotNull(rawConfigValue, "rawConfigValue");
} }
@ -698,7 +699,7 @@ public final class ServiceConfigUtil {
return policyName; return policyName;
} }
public Map<String, Object> getRawConfigValue() { public Map<String, ?> getRawConfigValue() {
return rawConfigValue; return rawConfigValue;
} }

View File

@ -94,8 +94,7 @@ final class RoundRobinLoadBalancer extends LoadBalancer {
Set<EquivalentAddressGroup> addedAddrs = setsDifference(latestAddrs, currentAddrs); Set<EquivalentAddressGroup> addedAddrs = setsDifference(latestAddrs, currentAddrs);
Set<EquivalentAddressGroup> removedAddrs = setsDifference(currentAddrs, latestAddrs); Set<EquivalentAddressGroup> removedAddrs = setsDifference(currentAddrs, latestAddrs);
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig = attributes.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG);
attributes.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG);
if (serviceConfig != null) { if (serviceConfig != null) {
String stickinessMetadataKey = String stickinessMetadataKey =
ServiceConfigUtil.getStickinessMetadataKeyFromServiceConfig(serviceConfig); ServiceConfigUtil.getStickinessMetadataKeyFromServiceConfig(serviceConfig);

View File

@ -191,7 +191,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
@Test @Test
public void handleResolvedAddressGroups_shutsDownOldBalancer() { public void handleResolvedAddressGroups_shutsDownOldBalancer() {
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("loadBalancingPolicy", "round_robin"); serviceConfig.put("loadBalancingPolicy", "round_robin");
Attributes serviceConfigAttrs = Attributes serviceConfigAttrs =
Attributes.newBuilder() Attributes.newBuilder()
@ -237,7 +237,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
@Test @Test
public void handleResolvedAddressGroups_propagateLbConfigToDelegate() throws Exception { public void handleResolvedAddressGroups_propagateLbConfigToDelegate() throws Exception {
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"high\" } } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"high\" } } ] }");
Attributes serviceConfigAttrs = Attributes serviceConfigAttrs =
Attributes.newBuilder() Attributes.newBuilder()
@ -310,7 +310,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(helper); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(helper);
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"high\" } } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"test_lb\": { \"setting1\": \"high\" } } ] }");
lb.handleResolvedAddressGroups( lb.handleResolvedAddressGroups(
Collections.<EquivalentAddressGroup>emptyList(), Collections.<EquivalentAddressGroup>emptyList(),
@ -333,7 +333,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(helper); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(helper);
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"test_lb2\": { \"setting1\": \"high\" } } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"test_lb2\": { \"setting1\": \"high\" } } ] }");
lb.handleResolvedAddressGroups( lb.handleResolvedAddressGroups(
Collections.<EquivalentAddressGroup>emptyList(), Collections.<EquivalentAddressGroup>emptyList(),
@ -345,7 +345,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
ArgumentCaptor<Attributes> attrsCaptor = ArgumentCaptor.forClass(null); ArgumentCaptor<Attributes> attrsCaptor = ArgumentCaptor.forClass(null);
verify(testLbBalancer2).handleResolvedAddressGroups( verify(testLbBalancer2).handleResolvedAddressGroups(
eq(Collections.<EquivalentAddressGroup>emptyList()), attrsCaptor.capture()); eq(Collections.<EquivalentAddressGroup>emptyList()), attrsCaptor.capture());
Map<String, Object> lbConfig = Map<String, ?> lbConfig =
attrsCaptor.getValue().get(LoadBalancer.ATTR_LOAD_BALANCING_CONFIG); attrsCaptor.getValue().get(LoadBalancer.ATTR_LOAD_BALANCING_CONFIG);
assertThat(lbConfig).isEqualTo(Collections.<String, Object>singletonMap("setting1", "high")); assertThat(lbConfig).isEqualTo(Collections.<String, Object>singletonMap("setting1", "high"));
assertThat(attrsCaptor.getValue().get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG)) assertThat(attrsCaptor.getValue().get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG))
@ -357,7 +357,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
throws Exception { throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = null; Map<String, ?> serviceConfig = null;
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){}));
PolicySelection selection = lb.decideLoadBalancerProvider(servers, serviceConfig); PolicySelection selection = lb.decideLoadBalancerProvider(servers, serviceConfig);
@ -374,7 +374,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) new AutoConfiguredLoadBalancerFactory("test_lb") (AutoConfiguredLoadBalancer) new AutoConfiguredLoadBalancerFactory("test_lb")
.newLoadBalancer(new TestHelper()); .newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = null; Map<String, ?> serviceConfig = null;
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){}));
PolicySelection selection = lb.decideLoadBalancerProvider(servers, serviceConfig); PolicySelection selection = lb.decideLoadBalancerProvider(servers, serviceConfig);
@ -389,7 +389,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_oneBalancer_noServiceConfig_grpclb() throws Exception { public void decideLoadBalancerProvider_oneBalancer_noServiceConfig_grpclb() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = null; Map<String, ?> serviceConfig = null;
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList( Collections.singletonList(
new EquivalentAddressGroup( new EquivalentAddressGroup(
@ -407,7 +407,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_serviceConfigLbPolicy() throws Exception { public void decideLoadBalancerProvider_serviceConfigLbPolicy() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("loadBalancingPolicy", "round_robin"); serviceConfig.put("loadBalancingPolicy", "round_robin");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Arrays.asList( Arrays.asList(
@ -431,7 +431,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_serviceConfigLbConfig() throws Exception { public void decideLoadBalancerProvider_serviceConfigLbConfig() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"round_robin\": {} } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"round_robin\": {} } ] }");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Arrays.asList( Arrays.asList(
@ -454,7 +454,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_grpclbConfigPropagated() throws Exception { public void decideLoadBalancerProvider_grpclbConfigPropagated() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig( parseConfig(
"{\"loadBalancingConfig\": [" "{\"loadBalancingConfig\": ["
+ "{\"grpclb\": {\"childPolicy\": [ {\"pick_first\": {} } ] } }" + "{\"grpclb\": {\"childPolicy\": [ {\"pick_first\": {} } ] } }"
@ -477,7 +477,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_policyUnavailButGrpclbAddressPresent() throws Exception { public void decideLoadBalancerProvider_policyUnavailButGrpclbAddressPresent() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig( parseConfig(
"{\"loadBalancingConfig\": [" "{\"loadBalancingConfig\": ["
+ "{\"unavail\": {} }" + "{\"unavail\": {} }"
@ -506,7 +506,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) new AutoConfiguredLoadBalancerFactory( (AutoConfiguredLoadBalancer) new AutoConfiguredLoadBalancerFactory(
registry, GrpcUtil.DEFAULT_LB_POLICY).newLoadBalancer(new TestHelper()); registry, GrpcUtil.DEFAULT_LB_POLICY).newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"grpclb\": {} } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"grpclb\": {} } ] }");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Arrays.asList( Arrays.asList(
@ -541,7 +541,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) new AutoConfiguredLoadBalancerFactory( (AutoConfiguredLoadBalancer) new AutoConfiguredLoadBalancerFactory(
registry, GrpcUtil.DEFAULT_LB_POLICY).newLoadBalancer(new TestHelper()); registry, GrpcUtil.DEFAULT_LB_POLICY).newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"grpclb\": {} } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"grpclb\": {} } ] }");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList( Collections.singletonList(
@ -562,7 +562,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_serviceConfigLbPolicyOverridesDefault() throws Exception { public void decideLoadBalancerProvider_serviceConfigLbPolicyOverridesDefault() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("loadBalancingPolicy", "round_robin"); serviceConfig.put("loadBalancingPolicy", "round_robin");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){}));
@ -578,7 +578,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_serviceConfigLbConfigOverridesDefault() throws Exception { public void decideLoadBalancerProvider_serviceConfigLbConfigOverridesDefault() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"round_robin\": {\"setting1\": \"high\"} } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"round_robin\": {\"setting1\": \"high\"} } ] }");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){}));
@ -595,7 +595,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_serviceConfigLbPolicyFailsOnUnknown() { public void decideLoadBalancerProvider_serviceConfigLbPolicyFailsOnUnknown() {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("loadBalancingPolicy", "MAGIC_BALANCER"); serviceConfig.put("loadBalancingPolicy", "MAGIC_BALANCER");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){}));
@ -612,7 +612,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_serviceConfigLbConfigFailsOnUnknown() throws Exception { public void decideLoadBalancerProvider_serviceConfigLbConfigFailsOnUnknown() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig("{\"loadBalancingConfig\": [ {\"magic_balancer\": {} } ] }"); parseConfig("{\"loadBalancingConfig\": [ {\"magic_balancer\": {} } ] }");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){})); Collections.singletonList(new EquivalentAddressGroup(new SocketAddress(){}));
@ -629,7 +629,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
public void decideLoadBalancerProvider_serviceConfigLbConfigSkipUnknown() throws Exception { public void decideLoadBalancerProvider_serviceConfigLbConfigSkipUnknown() throws Exception {
AutoConfiguredLoadBalancer lb = AutoConfiguredLoadBalancer lb =
(AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper()); (AutoConfiguredLoadBalancer) lbf.newLoadBalancer(new TestHelper());
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
parseConfig( parseConfig(
"{\"loadBalancingConfig\": [ {\"magic_balancer\": {} }, {\"round_robin\": {} } ] }"); "{\"loadBalancingConfig\": [ {\"magic_balancer\": {} }, {\"round_robin\": {} } ] }");
List<EquivalentAddressGroup> servers = List<EquivalentAddressGroup> servers =
@ -705,7 +705,7 @@ public class AutoConfiguredLoadBalancerFactoryTest {
verifyNoMoreInteractions(channelLogger); verifyNoMoreInteractions(channelLogger);
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("loadBalancingPolicy", "round_robin"); serviceConfig.put("loadBalancingPolicy", "round_robin");
lb.handleResolvedAddressGroups(servers, lb.handleResolvedAddressGroups(servers,
Attributes.newBuilder() Attributes.newBuilder()
@ -778,8 +778,8 @@ public class AutoConfiguredLoadBalancerFactoryTest {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static Map<String, Object> parseConfig(String json) throws Exception { private static Map<String, ?> parseConfig(String json) throws Exception {
return (Map<String, Object>) JsonParser.parse(json); return (Map<String, ?>) JsonParser.parse(json);
} }
private static class TestLoadBalancer extends ForwardingLoadBalancer { private static class TestLoadBalancer extends ForwardingLoadBalancer {

View File

@ -93,7 +93,7 @@ public class DnsNameResolverTest {
@Rule public final MockitoRule mocks = MockitoJUnit.rule(); @Rule public final MockitoRule mocks = MockitoJUnit.rule();
@Rule public final ExpectedException thrown = ExpectedException.none(); @Rule public final ExpectedException thrown = ExpectedException.none();
private final Map<String, Object> serviceConfig = new LinkedHashMap<>(); private final Map<String, ?> serviceConfig = new LinkedHashMap<>();
private static final int DEFAULT_PORT = 887; private static final int DEFAULT_PORT = 887;
private final SynchronizationContext syncContext = new SynchronizationContext( private final SynchronizationContext syncContext = new SynchronizationContext(
@ -656,7 +656,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_clientLanguageMatchesJava() { public void maybeChooseServiceConfig_clientLanguageMatchesJava() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> langs = new ArrayList<>(); List<String> langs = new ArrayList<>();
langs.add("java"); langs.add("java");
choice.put("clientLanguage", langs); choice.put("clientLanguage", langs);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -667,7 +667,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_clientLanguageDoesntMatchGo() { public void maybeChooseServiceConfig_clientLanguageDoesntMatchGo() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> langs = new ArrayList<>(); List<String> langs = new ArrayList<>();
langs.add("go"); langs.add("go");
choice.put("clientLanguage", langs); choice.put("clientLanguage", langs);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -678,7 +678,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_clientLanguageCaseInsensitive() { public void maybeChooseServiceConfig_clientLanguageCaseInsensitive() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> langs = new ArrayList<>(); List<String> langs = new ArrayList<>();
langs.add("JAVA"); langs.add("JAVA");
choice.put("clientLanguage", langs); choice.put("clientLanguage", langs);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -689,7 +689,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_clientLanguageMatchesEmtpy() { public void maybeChooseServiceConfig_clientLanguageMatchesEmtpy() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> langs = new ArrayList<>(); List<String> langs = new ArrayList<>();
choice.put("clientLanguage", langs); choice.put("clientLanguage", langs);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -699,7 +699,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_clientLanguageMatchesMulti() { public void maybeChooseServiceConfig_clientLanguageMatchesMulti() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> langs = new ArrayList<>(); List<String> langs = new ArrayList<>();
langs.add("go"); langs.add("go");
langs.add("java"); langs.add("java");
choice.put("clientLanguage", langs); choice.put("clientLanguage", langs);
@ -825,7 +825,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_hostnameMatches() { public void maybeChooseServiceConfig_hostnameMatches() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> hosts = new ArrayList<>(); List<String> hosts = new ArrayList<>();
hosts.add("localhost"); hosts.add("localhost");
choice.put("clientHostname", hosts); choice.put("clientHostname", hosts);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -836,7 +836,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_hostnameDoesntMatch() { public void maybeChooseServiceConfig_hostnameDoesntMatch() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> hosts = new ArrayList<>(); List<String> hosts = new ArrayList<>();
hosts.add("localhorse"); hosts.add("localhorse");
choice.put("clientHostname", hosts); choice.put("clientHostname", hosts);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -847,7 +847,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_clientLanguageCaseSensitive() { public void maybeChooseServiceConfig_clientLanguageCaseSensitive() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> hosts = new ArrayList<>(); List<String> hosts = new ArrayList<>();
hosts.add("LOCALHOST"); hosts.add("LOCALHOST");
choice.put("clientHostname", hosts); choice.put("clientHostname", hosts);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -858,7 +858,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_hostnameMatchesEmtpy() { public void maybeChooseServiceConfig_hostnameMatchesEmtpy() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> hosts = new ArrayList<>(); List<String> hosts = new ArrayList<>();
choice.put("clientHostname", hosts); choice.put("clientHostname", hosts);
choice.put("serviceConfig", serviceConfig); choice.put("serviceConfig", serviceConfig);
@ -868,7 +868,7 @@ public class DnsNameResolverTest {
@Test @Test
public void maybeChooseServiceConfig_hostnameMatchesMulti() { public void maybeChooseServiceConfig_hostnameMatchesMulti() {
Map<String, Object> choice = new LinkedHashMap<>(); Map<String, Object> choice = new LinkedHashMap<>();
List<Object> hosts = new ArrayList<>(); List<String> hosts = new ArrayList<>();
hosts.add("localhorse"); hosts.add("localhorse");
hosts.add("localhost"); hosts.add("localhost");
choice.put("clientHostname", hosts); choice.put("clientHostname", hosts);
@ -883,7 +883,7 @@ public class DnsNameResolverTest {
txtRecords.add("some_record"); txtRecords.add("some_record");
txtRecords.add("_grpc_config=[]"); txtRecords.add("_grpc_config=[]");
List<Map<String, Object>> results = DnsNameResolver.parseTxtResults(txtRecords); List<? extends Map<String, ?>> results = DnsNameResolver.parseTxtResults(txtRecords);
assertThat(results).isEmpty(); assertThat(results).isEmpty();
} }
@ -898,7 +898,7 @@ public class DnsNameResolverTest {
txtRecords.add("some_record"); txtRecords.add("some_record");
txtRecords.add("grpc_config={}"); txtRecords.add("grpc_config={}");
List<Map<String, Object>> results = DnsNameResolver.parseTxtResults(txtRecords); List<? extends Map<String, ?>> results = DnsNameResolver.parseTxtResults(txtRecords);
assertThat(results).isEmpty(); assertThat(results).isEmpty();
} finally { } finally {
@ -916,7 +916,7 @@ public class DnsNameResolverTest {
txtRecords.add("some_record"); txtRecords.add("some_record");
txtRecords.add("grpc_config=[\"bogus\"]"); txtRecords.add("grpc_config=[\"bogus\"]");
List<Map<String, Object>> results = DnsNameResolver.parseTxtResults(txtRecords); List<? extends Map<String, ?>> results = DnsNameResolver.parseTxtResults(txtRecords);
assertThat(results).isEmpty(); assertThat(results).isEmpty();
} finally { } finally {
@ -936,7 +936,7 @@ public class DnsNameResolverTest {
txtRecords.add("grpc_config=[{}, {}]"); // 2 records txtRecords.add("grpc_config=[{}, {}]"); // 2 records
txtRecords.add("grpc_config=[{\"\":{}}]"); // 1 record txtRecords.add("grpc_config=[{\"\":{}}]"); // 1 record
List<Map<String, Object>> results = DnsNameResolver.parseTxtResults(txtRecords); List<? extends Map<String, ?>> results = DnsNameResolver.parseTxtResults(txtRecords);
assertThat(results).hasSize(2 + 1); assertThat(results).hasSize(2 + 1);
} finally { } finally {

View File

@ -57,7 +57,7 @@ public class HedgingPolicyTest {
assertTrue(serviceConfigObj instanceof Map); assertTrue(serviceConfigObj instanceof Map);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> serviceConfig = (Map<String, Object>) serviceConfigObj; Map<String, ?> serviceConfig = (Map<String, ?>) serviceConfigObj;
ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor( ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor(
/* retryEnabled = */ true, /* maxRetryAttemptsLimit = */ 3, /* retryEnabled = */ true, /* maxRetryAttemptsLimit = */ 3,
@ -129,7 +129,7 @@ public class HedgingPolicyTest {
assertTrue(serviceConfigObj instanceof Map); assertTrue(serviceConfigObj instanceof Map);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> serviceConfig = (Map<String, Object>) serviceConfigObj; Map<String, ?> serviceConfig = (Map<String, ?>) serviceConfigObj;
ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor( ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor(
/* retryEnabled = */ false, /* maxRetryAttemptsLimit = */ 3, /* retryEnabled = */ false, /* maxRetryAttemptsLimit = */ 3,

View File

@ -889,9 +889,9 @@ public class ManagedChannelImplTest {
ArgumentCaptor<Attributes> attrsCaptor = ArgumentCaptor.forClass(null); ArgumentCaptor<Attributes> attrsCaptor = ArgumentCaptor.forClass(null);
verify(mockLoadBalancer).handleResolvedAddressGroups( verify(mockLoadBalancer).handleResolvedAddressGroups(
eq(ImmutableList.<EquivalentAddressGroup>of()), attrsCaptor.capture()); eq(ImmutableList.<EquivalentAddressGroup>of()), attrsCaptor.capture());
Map<String, Object> lbConfig = Map<String, ?> lbConfig =
attrsCaptor.getValue().get(LoadBalancer.ATTR_LOAD_BALANCING_CONFIG); attrsCaptor.getValue().get(LoadBalancer.ATTR_LOAD_BALANCING_CONFIG);
assertEquals(ImmutableMap.<String, Object>of("setting1", "high"), lbConfig); assertEquals(ImmutableMap.<String, String>of("setting1", "high"), lbConfig);
assertSame( assertSame(
serviceConfig, attrsCaptor.getValue().get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG)); serviceConfig, attrsCaptor.getValue().get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG));
} }

View File

@ -60,7 +60,7 @@ public class RetryPolicyTest {
assertTrue(serviceConfigObj instanceof Map); assertTrue(serviceConfigObj instanceof Map);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> serviceConfig = (Map<String, Object>) serviceConfigObj; Map<String, ?> serviceConfig = (Map<String, ?>) serviceConfigObj;
ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor( ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor(
/* retryEnabled = */ true, /* maxRetryAttemptsLimit = */ 4, /* retryEnabled = */ true, /* maxRetryAttemptsLimit = */ 4,
@ -138,7 +138,7 @@ public class RetryPolicyTest {
assertTrue(serviceConfigObj instanceof Map); assertTrue(serviceConfigObj instanceof Map);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> serviceConfig = (Map<String, Object>) serviceConfigObj; Map<String, ?> serviceConfig = (Map<String, ?>) serviceConfigObj;
ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor( ServiceConfigInterceptor serviceConfigInterceptor = new ServiceConfigInterceptor(
/* retryEnabled = */ false, /* maxRetryAttemptsLimit = */ 4, /* retryEnabled = */ false, /* maxRetryAttemptsLimit = */ 4,
@ -175,7 +175,7 @@ public class RetryPolicyTest {
assertTrue(serviceConfigObj instanceof Map); assertTrue(serviceConfigObj instanceof Map);
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> serviceConfig = (Map<String, Object>) serviceConfigObj; Map<String, ?> serviceConfig = (Map<String, ?>) serviceConfigObj;
Throttle throttle = ServiceConfigUtil.getThrottlePolicy(serviceConfig); Throttle throttle = ServiceConfigUtil.getThrottlePolicy(serviceConfig);
assertEquals(new Throttle(10f, 0.1f), throttle); assertEquals(new Throttle(10f, 0.1f), throttle);

View File

@ -470,7 +470,7 @@ public class RoundRobinLoadBalancerTest {
@Test @Test
public void stickinessEnabled_withStickyHeader() { public void stickinessEnabled_withStickyHeader() {
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("stickinessMetadataKey", "my-sticky-key"); serviceConfig.put("stickinessMetadataKey", "my-sticky-key");
Attributes attributes = Attributes.newBuilder() Attributes attributes = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build();
@ -500,7 +500,7 @@ public class RoundRobinLoadBalancerTest {
@Test @Test
public void stickinessEnabled_withDifferentStickyHeaders() { public void stickinessEnabled_withDifferentStickyHeaders() {
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("stickinessMetadataKey", "my-sticky-key"); serviceConfig.put("stickinessMetadataKey", "my-sticky-key");
Attributes attributes = Attributes.newBuilder() Attributes attributes = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build();
@ -545,7 +545,7 @@ public class RoundRobinLoadBalancerTest {
@Test @Test
public void stickiness_goToTransientFailure_pick_backToReady() { public void stickiness_goToTransientFailure_pick_backToReady() {
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("stickinessMetadataKey", "my-sticky-key"); serviceConfig.put("stickinessMetadataKey", "my-sticky-key");
Attributes attributes = Attributes.newBuilder() Attributes attributes = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build();
@ -593,7 +593,7 @@ public class RoundRobinLoadBalancerTest {
@Test @Test
public void stickiness_goToTransientFailure_backToReady_pick() { public void stickiness_goToTransientFailure_backToReady_pick() {
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("stickinessMetadataKey", "my-sticky-key"); serviceConfig.put("stickinessMetadataKey", "my-sticky-key");
Attributes attributes = Attributes.newBuilder() Attributes attributes = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build();
@ -647,7 +647,7 @@ public class RoundRobinLoadBalancerTest {
@Test @Test
public void stickiness_oneSubchannelShutdown() { public void stickiness_oneSubchannelShutdown() {
Map<String, Object> serviceConfig = new HashMap<>(); Map<String, String> serviceConfig = new HashMap<>();
serviceConfig.put("stickinessMetadataKey", "my-sticky-key"); serviceConfig.put("stickinessMetadataKey", "my-sticky-key");
Attributes attributes = Attributes.newBuilder() Attributes attributes = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig).build();
@ -703,14 +703,14 @@ public class RoundRobinLoadBalancerTest {
@Test @Test
public void stickiness_resolveTwice_metadataKeyChanged() { public void stickiness_resolveTwice_metadataKeyChanged() {
Map<String, Object> serviceConfig1 = new HashMap<>(); Map<String, String> serviceConfig1 = new HashMap<>();
serviceConfig1.put("stickinessMetadataKey", "my-sticky-key1"); serviceConfig1.put("stickinessMetadataKey", "my-sticky-key1");
Attributes attributes1 = Attributes.newBuilder() Attributes attributes1 = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig1).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig1).build();
loadBalancer.handleResolvedAddressGroups(servers, attributes1); loadBalancer.handleResolvedAddressGroups(servers, attributes1);
Map<String, ?> stickinessMap1 = loadBalancer.getStickinessMapForTest(); Map<String, ?> stickinessMap1 = loadBalancer.getStickinessMapForTest();
Map<String, Object> serviceConfig2 = new HashMap<>(); Map<String, String> serviceConfig2 = new HashMap<>();
serviceConfig2.put("stickinessMetadataKey", "my-sticky-key2"); serviceConfig2.put("stickinessMetadataKey", "my-sticky-key2");
Attributes attributes2 = Attributes.newBuilder() Attributes attributes2 = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig2).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig2).build();
@ -722,7 +722,7 @@ public class RoundRobinLoadBalancerTest {
@Test @Test
public void stickiness_resolveTwice_metadataKeyUnChanged() { public void stickiness_resolveTwice_metadataKeyUnChanged() {
Map<String, Object> serviceConfig1 = new HashMap<>(); Map<String, String> serviceConfig1 = new HashMap<>();
serviceConfig1.put("stickinessMetadataKey", "my-sticky-key1"); serviceConfig1.put("stickinessMetadataKey", "my-sticky-key1");
Attributes attributes1 = Attributes.newBuilder() Attributes attributes1 = Attributes.newBuilder()
.set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig1).build(); .set(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG, serviceConfig1).build();

View File

@ -100,7 +100,7 @@ class GrpclbLoadBalancer extends LoadBalancer {
newLbAddressGroups = Collections.unmodifiableList(newLbAddressGroups); newLbAddressGroups = Collections.unmodifiableList(newLbAddressGroups);
newBackendServers = Collections.unmodifiableList(newBackendServers); newBackendServers = Collections.unmodifiableList(newBackendServers);
Map<String, Object> rawLbConfigValue = attributes.get(ATTR_LOAD_BALANCING_CONFIG); Map<String, ?> rawLbConfigValue = attributes.get(ATTR_LOAD_BALANCING_CONFIG);
Mode newMode = retrieveModeFromLbConfig(rawLbConfigValue, helper.getChannelLogger()); Mode newMode = retrieveModeFromLbConfig(rawLbConfigValue, helper.getChannelLogger());
if (!mode.equals(newMode)) { if (!mode.equals(newMode)) {
mode = newMode; mode = newMode;
@ -112,7 +112,7 @@ class GrpclbLoadBalancer extends LoadBalancer {
@VisibleForTesting @VisibleForTesting
static Mode retrieveModeFromLbConfig( static Mode retrieveModeFromLbConfig(
@Nullable Map<String, Object> rawLbConfigValue, ChannelLogger channelLogger) { @Nullable Map<String, ?> rawLbConfigValue, ChannelLogger channelLogger) {
try { try {
if (rawLbConfigValue == null) { if (rawLbConfigValue == null) {
return DEFAULT_MODE; return DEFAULT_MODE;

View File

@ -2167,8 +2167,8 @@ public class GrpclbLoadBalancerTest {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private static Map<String, Object> parseJsonObject(String json) throws Exception { private static Map<String, ?> parseJsonObject(String json) throws Exception {
return (Map<String, Object>) JsonParser.parse(json); return (Map<String, ?>) JsonParser.parse(json);
} }
private static class ServerEntry { private static class ServerEntry {

View File

@ -169,7 +169,7 @@ final class HealthCheckingLoadBalancerFactory extends Factory {
@Override @Override
public void handleResolvedAddressGroups( public void handleResolvedAddressGroups(
List<EquivalentAddressGroup> servers, Attributes attributes) { List<EquivalentAddressGroup> servers, Attributes attributes) {
Map<String, Object> serviceConfig = Map<String, ?> serviceConfig =
attributes.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG); attributes.get(GrpcAttributes.NAME_RESOLVER_SERVICE_CONFIG);
String serviceName = ServiceConfigUtil.getHealthCheckedServiceName(serviceConfig); String serviceName = ServiceConfigUtil.getHealthCheckedServiceName(serviceConfig);
helper.setHealthCheckedService(serviceName); helper.setHealthCheckedService(serviceName);

View File

@ -935,8 +935,7 @@ public class HealthCheckingLoadBalancerFactoryTest {
@Test @Test
public void getHealthCheckedServiceName_noHealthCheckConfig() { public void getHealthCheckedServiceName_noHealthCheckConfig() {
assertThat(ServiceConfigUtil.getHealthCheckedServiceName(new HashMap<String, Object>())) assertThat(ServiceConfigUtil.getHealthCheckedServiceName(new HashMap<String, Void>())).isNull();
.isNull();
} }
@Test @Test

View File

@ -52,7 +52,7 @@ final class XdsLoadBalancer extends LoadBalancer {
Attributes.Key.create("io.grpc.xds.XdsLoadBalancer.stateInfo"); Attributes.Key.create("io.grpc.xds.XdsLoadBalancer.stateInfo");
private static final LbConfig DEFAULT_FALLBACK_POLICY = private static final LbConfig DEFAULT_FALLBACK_POLICY =
new LbConfig("round_robin", ImmutableMap.<String, Object>of()); new LbConfig("round_robin", ImmutableMap.<String, Void>of());
private final SubchannelStore subchannelStore; private final SubchannelStore subchannelStore;
private final Helper helper; private final Helper helper;
@ -89,7 +89,7 @@ final class XdsLoadBalancer extends LoadBalancer {
@Override @Override
public void handleResolvedAddressGroups( public void handleResolvedAddressGroups(
List<EquivalentAddressGroup> servers, Attributes attributes) { List<EquivalentAddressGroup> servers, Attributes attributes) {
Map<String, Object> newRawLbConfig = checkNotNull( Map<String, ?> newRawLbConfig = checkNotNull(
attributes.get(ATTR_LOAD_BALANCING_CONFIG), "ATTR_LOAD_BALANCING_CONFIG not available"); attributes.get(ATTR_LOAD_BALANCING_CONFIG), "ATTR_LOAD_BALANCING_CONFIG not available");
LbConfig newLbConfig = ServiceConfigUtil.unwrapLoadBalancingConfig(newRawLbConfig); LbConfig newLbConfig = ServiceConfigUtil.unwrapLoadBalancingConfig(newRawLbConfig);
fallbackPolicy = selectFallbackPolicy(newLbConfig, lbRegistry); fallbackPolicy = selectFallbackPolicy(newLbConfig, lbRegistry);

View File

@ -106,7 +106,7 @@ public class FallbackManagerTest {
doReturn(fakeClock.getScheduledExecutorService()).when(helper).getScheduledExecutorService(); doReturn(fakeClock.getScheduledExecutorService()).when(helper).getScheduledExecutorService();
doReturn(channelLogger).when(helper).getChannelLogger(); doReturn(channelLogger).when(helper).getChannelLogger();
fallbackManager = new FallbackManager(helper, new SubchannelStoreImpl(), lbRegistry); fallbackManager = new FallbackManager(helper, new SubchannelStoreImpl(), lbRegistry);
fallbackPolicy = new LbConfig("test_policy", new HashMap<String, Object>()); fallbackPolicy = new LbConfig("test_policy", new HashMap<String, Void>());
lbRegistry.register(fakeLbProvider); lbRegistry.register(fakeLbProvider);
} }

View File

@ -311,7 +311,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build(); Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -328,7 +328,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig2 = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig2 = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build(); attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -352,7 +352,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build(); Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -366,7 +366,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig2 = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig2 = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build(); attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -388,7 +388,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build(); Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -404,7 +404,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig2 = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig2 = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build(); attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -426,7 +426,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build(); Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -442,7 +442,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig2 = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig2 = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build(); attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -463,7 +463,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build(); Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -477,7 +477,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig2 = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig2 = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build(); attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig2).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);
@ -588,7 +588,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"supported_1\" : { \"supported_1_option\" : \"yes\"}}]" + "\"fallbackPolicy\" : [{\"supported_1\" : { \"supported_1_option\" : \"yes\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
return Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build(); return Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build();
} }
@ -600,7 +600,7 @@ public class XdsLoadBalancerTest {
+ "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]" + "\"fallbackPolicy\" : [{\"unsupported\" : {}}, {\"supported_1\" : {\"key\" : \"val\"}}]"
+ "}}"; + "}}";
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Map<String, Object> lbConfig = (Map<String, Object>) JsonParser.parse(lbConfigRaw); Map<String, ?> lbConfig = (Map<String, ?>) JsonParser.parse(lbConfigRaw);
Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build(); Attributes attrs = Attributes.newBuilder().set(ATTR_LOAD_BALANCING_CONFIG, lbConfig).build();
lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs); lb.handleResolvedAddressGroups(Collections.<EquivalentAddressGroup>emptyList(), attrs);