use of io.grpc.rls.LbPolicyConfiguration.ChildLoadBalancingPolicy in project grpc-java by grpc.
the class LbPolicyConfigurationTest method childLoadBalancingPolicy_effectiveChildPolicy.
@Test
public void childLoadBalancingPolicy_effectiveChildPolicy() {
LoadBalancerProvider mockProvider = mock(LoadBalancerProvider.class);
ChildLoadBalancingPolicy childLbPolicy = new ChildLoadBalancingPolicy("targetFieldName", ImmutableMap.<String, Object>of("foo", "bar"), mockProvider);
assertThat(childLbPolicy.getEffectiveChildPolicy("target")).containsExactly("foo", "bar", "targetFieldName", "target");
assertThat(childLbPolicy.getEffectiveLbProvider()).isEqualTo(mockProvider);
}
use of io.grpc.rls.LbPolicyConfiguration.ChildLoadBalancingPolicy in project grpc-java by grpc.
the class RlsLoadBalancerProvider method parseLoadBalancingPolicyConfig.
@Override
public ConfigOrError parseLoadBalancingPolicyConfig(Map<String, ?> rawLoadBalancingConfigPolicy) {
try {
RouteLookupConfig routeLookupConfig = new RouteLookupConfigConverter().convert(JsonUtil.getObject(rawLoadBalancingConfigPolicy, "routeLookupConfig"));
Map<String, ?> routeLookupChannelServiceConfig = JsonUtil.getObject(rawLoadBalancingConfigPolicy, "routeLookupChannelServiceConfig");
ChildLoadBalancingPolicy lbPolicy = ChildLoadBalancingPolicy.create(JsonUtil.getString(rawLoadBalancingConfigPolicy, "childPolicyConfigTargetFieldName"), JsonUtil.checkObjectList(checkNotNull(JsonUtil.getList(rawLoadBalancingConfigPolicy, "childPolicy"))));
return ConfigOrError.fromConfig(new LbPolicyConfiguration(routeLookupConfig, routeLookupChannelServiceConfig, lbPolicy));
} catch (Exception e) {
return ConfigOrError.fromError(Status.INVALID_ARGUMENT.withDescription("can't parse config: " + e.getMessage()).withCause(e));
}
}
Aggregations