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


Java PickResult.withError方法代码示例

本文整理汇总了Java中io.grpc.LoadBalancer.PickResult.withError方法的典型用法代码示例。如果您正苦于以下问题:Java PickResult.withError方法的具体用法?Java PickResult.withError怎么用?Java PickResult.withError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在io.grpc.LoadBalancer.PickResult的用法示例。


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

示例1: handleSubchannelState

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
@Override
public void handleSubchannelState(Subchannel subchannel, ConnectivityStateInfo stateInfo) {
  ConnectivityState currentState = stateInfo.getState();
  if (subchannel != this.subchannel || currentState == SHUTDOWN) {
    return;
  }

  PickResult pickResult;
  switch (currentState) {
    case CONNECTING:
      pickResult = PickResult.withNoResult();
      break;
    case READY:
    case IDLE:
      pickResult = PickResult.withSubchannel(subchannel);
      break;
    case TRANSIENT_FAILURE:
      pickResult = PickResult.withError(stateInfo.getStatus());
      break;
    default:
      throw new IllegalArgumentException("Unsupported state:" + currentState);
  }

  helper.updateBalancingState(currentState, new Picker(pickResult));
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:26,代码来源:PickFirstBalancerFactory.java

示例2: pickSubchannel

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
@Override
public PickResult pickSubchannel(PickSubchannelArgs args) {
  Map<String, Object> affinity =
      args.getCallOptions().getOption(GrpcCallOptions.CALLOPTIONS_CUSTOME_KEY);
  GrpcURL refUrl = (GrpcURL) affinity.get(GrpcCallOptions.GRPC_REF_URL);
  if (size > 0) {
    Subchannel subchannel = nextSubchannel(refUrl);
    affinity.put(GrpcCallOptions.GRPC_NAMERESOVER_ATTRIBUTES, nameResovleCache);
    return PickResult.withSubchannel(subchannel);
  }
  if (status != null) {
    return PickResult.withError(status);
  }
  return PickResult.withNoResult();
}
 
开发者ID:venus-boot,项目名称:saluki,代码行数:16,代码来源:GrpcRoutePicker.java

示例3: pickSubchannel

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
@Override
public PickResult pickSubchannel(PickSubchannelArgs args) {
  if (list.size() > 0) {
    return PickResult.withSubchannel(nextSubchannel());
  }

  if (status != null) {
    return PickResult.withError(status);
  }

  return PickResult.withNoResult();
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:13,代码来源:RoundRobinLoadBalancerFactory.java

示例4: pickResult_withError

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
@Test
public void pickResult_withError() {
  PickResult result = PickResult.withError(status);
  assertThat(result.getSubchannel()).isNull();
  assertThat(result.getStatus()).isSameAs(status);
  assertThat(result.getStreamTracerFactory()).isNull();
  assertThat(result.isDrop()).isFalse();
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:9,代码来源:LoadBalancerTest.java

示例5: pickResult_equals

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
@Test
public void pickResult_equals() {
  PickResult sc1 = PickResult.withSubchannel(subchannel);
  PickResult sc2 = PickResult.withSubchannel(subchannel);
  PickResult sc3 = PickResult.withSubchannel(subchannel, tracerFactory);
  PickResult sc4 = PickResult.withSubchannel(subchannel2);
  PickResult nr = PickResult.withNoResult();
  PickResult error1 = PickResult.withError(status);
  PickResult error2 = PickResult.withError(status2);
  PickResult error3 = PickResult.withError(status2);
  PickResult drop1 = PickResult.withDrop(status);
  PickResult drop2 = PickResult.withDrop(status);
  PickResult drop3 = PickResult.withDrop(status2);

  assertThat(sc1).isNotEqualTo(nr);
  assertThat(sc1).isNotEqualTo(error1);
  assertThat(sc1).isNotEqualTo(drop1);
  assertThat(sc1).isEqualTo(sc2);
  assertThat(sc1).isNotEqualTo(sc3);
  assertThat(sc1).isNotEqualTo(sc4);

  assertThat(error1).isNotEqualTo(error2);
  assertThat(error2).isEqualTo(error3);

  assertThat(drop1).isEqualTo(drop2);
  assertThat(drop1).isNotEqualTo(drop3);

  assertThat(error1.getStatus()).isEqualTo(drop1.getStatus());
  assertThat(error1).isNotEqualTo(drop1);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:31,代码来源:LoadBalancerTest.java

示例6: ErrorEntry

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
ErrorEntry(Status status) {
  result = PickResult.withError(status);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:4,代码来源:GrpclbState.java


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