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


Java PickResult.withSubchannel方法代码示例

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


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

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

示例5: pickResult_withSubchannelAndTracer

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

示例6: 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

示例7: BackendEntry

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
/**
 * Creates a BackendEntry whose usage will be reported to load recorder.
 */
BackendEntry(Subchannel subchannel, GrpclbClientLoadRecorder loadRecorder, String token) {
  this.result = PickResult.withSubchannel(subchannel, loadRecorder);
  this.loadRecorder = checkNotNull(loadRecorder, "loadRecorder");
  this.token = checkNotNull(token, "token");
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:9,代码来源:GrpclbState.java

示例8: setSubchannel

import io.grpc.LoadBalancer.PickResult; //导入方法依赖的package包/类
void setSubchannel(final InternalSubchannel subchannel) {
  log.log(Level.FINE, "[{0}] Created with [{1}]", new Object[] {this, subchannel});
  this.subchannel = subchannel;
  subchannelImpl = new AbstractSubchannel() {
      @Override
      public void shutdown() {
        subchannel.shutdown(Status.UNAVAILABLE.withDescription("OobChannel is shutdown"));
      }

      @Override
      ClientTransport obtainActiveTransport() {
        return subchannel.obtainActiveTransport();
      }

      @Override
      public void requestConnection() {
        subchannel.obtainActiveTransport();
      }

      @Override
      public EquivalentAddressGroup getAddresses() {
        return subchannel.getAddressGroup();
      }

      @Override
      public Attributes getAttributes() {
        return Attributes.EMPTY;
      }

      @Override
      public ListenableFuture<ChannelStats> getStats() {
        SettableFuture<ChannelStats> ret = SettableFuture.create();
        ChannelStats.Builder builder = new ChannelStats.Builder();
        subchannelCallsTracer.updateBuilder(builder);
        builder.setTarget(authority).setState(subchannel.getState());
        ret.set(builder.build());
        return ret;
      }
  };

  subchannelPicker = new SubchannelPicker() {
      final PickResult result = PickResult.withSubchannel(subchannelImpl);

      @Override
      public PickResult pickSubchannel(PickSubchannelArgs args) {
        return result;
      }
    };
  delayedTransport.reprocess(subchannelPicker);
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:51,代码来源:OobChannel.java


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