本文整理汇总了Java中io.grpc.LoadBalancer.PickResult.withNoResult方法的典型用法代码示例。如果您正苦于以下问题:Java PickResult.withNoResult方法的具体用法?Java PickResult.withNoResult怎么用?Java PickResult.withNoResult使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类io.grpc.LoadBalancer.PickResult
的用法示例。
在下文中一共展示了PickResult.withNoResult方法的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));
}
示例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();
}
示例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();
}
示例4: pickResult_withNoResult
import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
@Test
public void pickResult_withNoResult() {
PickResult result = PickResult.withNoResult();
assertThat(result.getSubchannel()).isNull();
assertThat(result.getStatus()).isSameAs(Status.OK);
assertThat(result.getStreamTracerFactory()).isNull();
assertThat(result.isDrop()).isFalse();
}
示例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);
}
示例6: picked
import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
@Override
public PickResult picked(Metadata headers) {
return PickResult.withNoResult();
}