當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。