io.grpc.internal.PickFirstLoadBalancerProvider Java Examples

The following examples show how to use io.grpc.internal.PickFirstLoadBalancerProvider. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoadBalancerRegistryTest.java    From grpc-nebula-java with Apache License 2.0 6 votes vote down vote up
@Test
public void stockProviders() {
  LoadBalancerRegistry defaultRegistry = LoadBalancerRegistry.getDefaultRegistry();
  assertThat(defaultRegistry.providers()).hasSize(3);

  LoadBalancerProvider pickFirst = defaultRegistry.getProvider("pick_first");
  assertThat(pickFirst).isInstanceOf(PickFirstLoadBalancerProvider.class);
  assertThat(pickFirst.getPriority()).isEqualTo(5);

  LoadBalancerProvider roundRobin = defaultRegistry.getProvider("round_robin");
  assertThat(roundRobin.getClass().getName()).isEqualTo(
      "io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider");
  assertThat(roundRobin.getPriority()).isEqualTo(5);

  LoadBalancerProvider grpclb = defaultRegistry.getProvider("grpclb");
  assertThat(grpclb).isInstanceOf(GrpclbLoadBalancerProvider.class);
  assertThat(grpclb.getPriority()).isEqualTo(5);
}
 
Example #2
Source File: LoadBalancerRegistryTest.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
@Test
public void stockProviders() {
  LoadBalancerRegistry defaultRegistry = LoadBalancerRegistry.getDefaultRegistry();
  assertThat(defaultRegistry.providers()).hasSize(3);

  LoadBalancerProvider pickFirst = defaultRegistry.getProvider("pick_first");
  assertThat(pickFirst).isInstanceOf(PickFirstLoadBalancerProvider.class);
  assertThat(pickFirst.getPriority()).isEqualTo(5);

  LoadBalancerProvider roundRobin = defaultRegistry.getProvider("round_robin");
  assertThat(roundRobin.getClass().getName()).isEqualTo(
      "io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider");
  assertThat(roundRobin.getPriority()).isEqualTo(5);

  LoadBalancerProvider grpclb = defaultRegistry.getProvider("grpclb");
  assertThat(grpclb).isInstanceOf(GrpclbLoadBalancerProvider.class);
  assertThat(grpclb.getPriority()).isEqualTo(5);
}
 
Example #3
Source File: LoadBalancerRegistryTest.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Test
public void getClassesViaHardcoded_classesPresent() throws Exception {
  List<Class<?>> classes = LoadBalancerRegistry.getHardCodedClasses();
  assertThat(classes).hasSize(2);
  assertThat(classes.get(0)).isEqualTo(PickFirstLoadBalancerProvider.class);
  assertThat(classes.get(1).getName()).isEqualTo(
      "io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider");
}
 
Example #4
Source File: GrpcServerProcessor.java    From quarkus with Apache License 2.0 5 votes vote down vote up
@BuildStep
public void configureNativeExecutable(CombinedIndexBuildItem combinedIndex,
        BuildProducer<ReflectiveClassBuildItem> reflectiveClass,
        BuildProducer<ExtensionSslNativeSupportBuildItem> extensionSslNativeSupport) {

    // we force the usage of the reflection invoker.
    Collection<ClassInfo> messages = combinedIndex.getIndex()
            .getAllKnownSubclasses(GrpcDotNames.GENERATED_MESSAGE_V3);
    for (ClassInfo message : messages) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, true, message.name().toString()));
    }
    Collection<ClassInfo> builders = combinedIndex.getIndex().getAllKnownSubclasses(GrpcDotNames.MESSAGE_BUILDER);
    for (ClassInfo builder : builders) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, true, builder.name().toString()));
    }

    Collection<ClassInfo> lbs = combinedIndex.getIndex().getAllKnownSubclasses(GrpcDotNames.LOAD_BALANCER_PROVIDER);
    for (ClassInfo lb : lbs) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false, lb.name().toString()));
    }

    Collection<ClassInfo> nrs = combinedIndex.getIndex().getAllKnownSubclasses(GrpcDotNames.NAME_RESOLVER_PROVIDER);
    for (ClassInfo nr : nrs) {
        reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false, nr.name().toString()));
    }

    // Built-In providers:
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false, DnsNameResolverProvider.class));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false, PickFirstLoadBalancerProvider.class));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false,
            "io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider"));
    reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, false, NettyChannelProvider.class));

    extensionSslNativeSupport.produce(new ExtensionSslNativeSupportBuildItem(GRPC_SERVER));
}
 
Example #5
Source File: LoadBalancerRegistryTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Test
public void getClassesViaHardcoded_classesPresent() throws Exception {
  List<Class<?>> classes = LoadBalancerRegistry.getHardCodedClasses();
  assertThat(classes).hasSize(2);
  assertThat(classes.get(0)).isEqualTo(PickFirstLoadBalancerProvider.class);
  assertThat(classes.get(1).getName()).isEqualTo(
      "io.grpc.util.SecretRoundRobinLoadBalancerProvider$Provider");
}