Search in sources :

Example 6 with LeastRequestConfig

use of io.grpc.xds.LeastRequestLoadBalancer.LeastRequestConfig in project grpc-java by grpc.

the class LeastRequestLoadBalancerProviderTest method parseLoadBalancingConfig_missingChoiceCount_useDefaults.

@Test
public void parseLoadBalancingConfig_missingChoiceCount_useDefaults() throws IOException {
    String lbConfig = "{}";
    ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
    assertThat(configOrError.getConfig()).isNotNull();
    LeastRequestConfig config = (LeastRequestConfig) configOrError.getConfig();
    assertThat(config.choiceCount).isEqualTo(LeastRequestLoadBalancerProvider.DEFAULT_CHOICE_COUNT);
}
Also used : LeastRequestConfig(io.grpc.xds.LeastRequestLoadBalancer.LeastRequestConfig) ConfigOrError(io.grpc.NameResolver.ConfigOrError) Test(org.junit.Test)

Example 7 with LeastRequestConfig

use of io.grpc.xds.LeastRequestLoadBalancer.LeastRequestConfig in project grpc-java by grpc.

the class LeastRequestLoadBalancerProviderTest method parseLoadBalancingConfig_choiceCountCappedAtMax.

@Test
public void parseLoadBalancingConfig_choiceCountCappedAtMax() throws IOException {
    String lbConfig = "{\"choiceCount\" : 11}";
    ConfigOrError configOrError = provider.parseLoadBalancingPolicyConfig(parseJsonObject(lbConfig));
    assertThat(configOrError.getConfig()).isNotNull();
    LeastRequestConfig config = (LeastRequestConfig) configOrError.getConfig();
    assertThat(config.choiceCount).isEqualTo(LeastRequestLoadBalancerProvider.MAX_CHOICE_COUNT);
}
Also used : LeastRequestConfig(io.grpc.xds.LeastRequestLoadBalancer.LeastRequestConfig) ConfigOrError(io.grpc.NameResolver.ConfigOrError) Test(org.junit.Test)

Aggregations

LeastRequestConfig (io.grpc.xds.LeastRequestLoadBalancer.LeastRequestConfig)7 Test (org.junit.Test)7 ConnectivityState (io.grpc.ConnectivityState)3 Subchannel (io.grpc.LoadBalancer.Subchannel)3 ConfigOrError (io.grpc.NameResolver.ConfigOrError)3 CreateSubchannelArgs (io.grpc.LoadBalancer.CreateSubchannelArgs)2 PickResult (io.grpc.LoadBalancer.PickResult)2 ClientStreamTracer (io.grpc.ClientStreamTracer)1 LoadBalancer (io.grpc.LoadBalancer)1 Metadata (io.grpc.Metadata)1 ClusterResolverConfig (io.grpc.xds.ClusterResolverLoadBalancerProvider.ClusterResolverConfig)1 DiscoveryMechanism (io.grpc.xds.ClusterResolverLoadBalancerProvider.ClusterResolverConfig.DiscoveryMechanism)1 ReadyPicker (io.grpc.xds.LeastRequestLoadBalancer.ReadyPicker)1 CdsUpdate (io.grpc.xds.XdsClient.CdsUpdate)1