当前位置: 首页>>代码示例>>Java>>正文


Java PickFirstBalancerFactory类代码示例

本文整理汇总了Java中io.grpc.PickFirstBalancerFactory的典型用法代码示例。如果您正苦于以下问题:Java PickFirstBalancerFactory类的具体用法?Java PickFirstBalancerFactory怎么用?Java PickFirstBalancerFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PickFirstBalancerFactory类属于io.grpc包,在下文中一共展示了PickFirstBalancerFactory类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testPickFirstBalancerFactory

import io.grpc.PickFirstBalancerFactory; //导入依赖的package包/类
@Test
public void testPickFirstBalancerFactory() throws Exception {
  try (Client client = Client.builder()
          .endpoints(TestConstants.endpoints)
          .loadBalancerFactory(PickFirstBalancerFactory.getInstance())
          .build();

       KV kv = client.getKVClient()) {
    PutResponse response;
    long lastMemberId = 0;

    for (int i = 0; i < TestConstants.endpoints.length * 2; i++) {
      response = kv.put(TestUtil.randomByteSequence(), TestUtil.randomByteSequence()).get();

      if (i == 0) {
        lastMemberId = response.getHeader().getMemberId();
      }

      assertThat(response.getHeader().getMemberId()).isEqualTo(lastMemberId);
    }
  }
}
 
开发者ID:coreos,项目名称:jetcd,代码行数:23,代码来源:LoadBalancerTest.java

示例2: newLoadBalancer

import io.grpc.PickFirstBalancerFactory; //导入依赖的package包/类
@Override
public LoadBalancer newLoadBalancer(LoadBalancer.Helper helper) {
  return new GrpclbLoadBalancer(
      helper, PickFirstBalancerFactory.getInstance(),
      RoundRobinLoadBalancerFactory.getInstance(),
      // TODO(zhangkun83): balancer sends load reporting RPCs from it, which also involves
      // channelExecutor thus may also run other tasks queued in the channelExecutor.  If such
      // load should not be on the shared scheduled executor, we should use a combination of the
      // scheduled executor and the default app executor.
      SharedResourcePool.forResource(GrpcUtil.TIMER_SERVICE),
      TIME_PROVIDER);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:13,代码来源:GrpclbLoadBalancerFactory.java


注:本文中的io.grpc.PickFirstBalancerFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。