mirror of https://github.com/grpc/grpc-java.git
xsd: Fix some lint errors. (#9159)
This commit is contained in:
parent
8f1dab0470
commit
f68be9f87c
|
|
@ -57,7 +57,7 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
class LoadBalancerConfigFactory {
|
class LoadBalancerConfigFactory {
|
||||||
|
|
||||||
private static XdsLogger logger = XdsLogger.withLogId(
|
private static final XdsLogger logger = XdsLogger.withLogId(
|
||||||
InternalLogId.allocate("xds-client-lbconfig-factory", null));
|
InternalLogId.allocate("xds-client-lbconfig-factory", null));
|
||||||
|
|
||||||
static final String ROUND_ROBIN_FIELD_NAME = "round_robin";
|
static final String ROUND_ROBIN_FIELD_NAME = "round_robin";
|
||||||
|
|
@ -87,7 +87,7 @@ class LoadBalancerConfigFactory {
|
||||||
return LoadBalancingPolicyConverter.convertToServiceConfig(cluster.getLoadBalancingPolicy(),
|
return LoadBalancingPolicyConverter.convertToServiceConfig(cluster.getLoadBalancingPolicy(),
|
||||||
0);
|
0);
|
||||||
} catch (MaxRecursionReachedException e) {
|
} catch (MaxRecursionReachedException e) {
|
||||||
throw new ResourceInvalidException("Maximum LB config recursion depth reached");
|
throw new ResourceInvalidException("Maximum LB config recursion depth reached", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return LegacyLoadBalancingPolicyConverter.convertToServiceConfig(cluster, enableLeastRequest);
|
return LegacyLoadBalancingPolicyConverter.convertToServiceConfig(cluster, enableLeastRequest);
|
||||||
|
|
@ -195,7 +195,7 @@ class LoadBalancerConfigFactory {
|
||||||
* Converts a ring_hash {@link Any} configuration to service config format.
|
* Converts a ring_hash {@link Any} configuration to service config format.
|
||||||
*/
|
*/
|
||||||
private static ImmutableMap<String, ?> convertRingHashConfig(RingHash ringHash)
|
private static ImmutableMap<String, ?> convertRingHashConfig(RingHash ringHash)
|
||||||
throws InvalidProtocolBufferException, ResourceInvalidException {
|
throws ResourceInvalidException {
|
||||||
// The hash function needs to be validated here as it is not exposed in the returned
|
// The hash function needs to be validated here as it is not exposed in the returned
|
||||||
// configuration for later validation.
|
// configuration for later validation.
|
||||||
if (RingHash.HashFunction.XX_HASH != ringHash.getHashFunction()) {
|
if (RingHash.HashFunction.XX_HASH != ringHash.getHashFunction()) {
|
||||||
|
|
@ -212,7 +212,7 @@ class LoadBalancerConfigFactory {
|
||||||
* Converts a wrr_locality {@link Any} configuration to service config format.
|
* Converts a wrr_locality {@link Any} configuration to service config format.
|
||||||
*/
|
*/
|
||||||
private static ImmutableMap<String, ?> convertWrrLocalityConfig(WrrLocality wrrLocality,
|
private static ImmutableMap<String, ?> convertWrrLocalityConfig(WrrLocality wrrLocality,
|
||||||
int recursionDepth) throws InvalidProtocolBufferException, ResourceInvalidException,
|
int recursionDepth) throws ResourceInvalidException,
|
||||||
MaxRecursionReachedException {
|
MaxRecursionReachedException {
|
||||||
return buildWrrLocalityConfig(
|
return buildWrrLocalityConfig(
|
||||||
convertToServiceConfig(wrrLocality.getEndpointPickingPolicy(), recursionDepth + 1));
|
convertToServiceConfig(wrrLocality.getEndpointPickingPolicy(), recursionDepth + 1));
|
||||||
|
|
@ -230,7 +230,7 @@ class LoadBalancerConfigFactory {
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private static ImmutableMap<String, ?> convertCustomConfig(TypedStruct configTypedStruct)
|
private static ImmutableMap<String, ?> convertCustomConfig(TypedStruct configTypedStruct)
|
||||||
throws InvalidProtocolBufferException, ResourceInvalidException {
|
throws ResourceInvalidException {
|
||||||
Object rawJsonConfig = null;
|
Object rawJsonConfig = null;
|
||||||
try {
|
try {
|
||||||
rawJsonConfig = JsonParser.parse(JsonFormat.printer().print(configTypedStruct.getValue()));
|
rawJsonConfig = JsonParser.parse(JsonFormat.printer().print(configTypedStruct.getValue()));
|
||||||
|
|
|
||||||
|
|
@ -312,10 +312,9 @@ public class ClusterResolverLoadBalancerTest {
|
||||||
assertThat(wrrLocalityConfig.childPolicy.getProvider().getPolicyName()).isEqualTo(
|
assertThat(wrrLocalityConfig.childPolicy.getProvider().getPolicyName()).isEqualTo(
|
||||||
"least_request_experimental");
|
"least_request_experimental");
|
||||||
|
|
||||||
Map<Locality, Integer> localityWeights = childBalancer.attributes.get(
|
assertThat(
|
||||||
InternalXdsAttributes.ATTR_LOCALITY_WEIGHTS);
|
childBalancer.attributes.get(InternalXdsAttributes.ATTR_LOCALITY_WEIGHTS)).containsEntry(
|
||||||
assertThat(localityWeights).containsKey(locality1);
|
locality1, 100);
|
||||||
assertThat(localityWeights.get(locality1)).isEqualTo(100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
@ -412,12 +411,9 @@ public class ClusterResolverLoadBalancerTest {
|
||||||
|
|
||||||
Map<Locality, Integer> localityWeights = childBalancer.attributes.get(
|
Map<Locality, Integer> localityWeights = childBalancer.attributes.get(
|
||||||
InternalXdsAttributes.ATTR_LOCALITY_WEIGHTS);
|
InternalXdsAttributes.ATTR_LOCALITY_WEIGHTS);
|
||||||
assertThat(localityWeights).containsKey(locality1);
|
assertThat(localityWeights).containsEntry(locality1, 70);
|
||||||
assertThat(localityWeights.get(locality1)).isEqualTo(70);
|
assertThat(localityWeights).containsEntry(locality2, 10);
|
||||||
assertThat(localityWeights).containsKey(locality2);
|
assertThat(localityWeights).containsEntry(locality3, 20);
|
||||||
assertThat(localityWeights.get(locality2)).isEqualTo(10);
|
|
||||||
assertThat(localityWeights).containsKey(locality3);
|
|
||||||
assertThat(localityWeights.get(locality3)).isEqualTo(20);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ public class LoadBalancerConfigFactoryTest {
|
||||||
|
|
||||||
private static final Policy ROUND_ROBIN_POLICY = Policy.newBuilder().setTypedExtensionConfig(
|
private static final Policy ROUND_ROBIN_POLICY = Policy.newBuilder().setTypedExtensionConfig(
|
||||||
TypedExtensionConfig.newBuilder().setTypedConfig(
|
TypedExtensionConfig.newBuilder().setTypedConfig(
|
||||||
Any.pack(RoundRobin.newBuilder().build()))).build();
|
Any.pack(RoundRobin.getDefaultInstance()))).build();
|
||||||
|
|
||||||
private static final long RING_HASH_MIN_RING_SIZE = 1;
|
private static final long RING_HASH_MIN_RING_SIZE = 1;
|
||||||
private static final long RING_HASH_MAX_RING_SIZE = 2;
|
private static final long RING_HASH_MAX_RING_SIZE = 2;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue