Java Code Examples for io.grpc.ConnectivityState#IDLE

The following examples show how to use io.grpc.ConnectivityState#IDLE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TripleClientTransport.java    From sofa-rpc with Apache License 2.0 6 votes vote down vote up
protected boolean channelAvailable(ManagedChannel channel) {
    if (channel == null) {
        return false;
    }
    ConnectivityState state = channel.getState(false);
    if (ConnectivityState.READY == state) {
        return true;
    }
    if (ConnectivityState.SHUTDOWN == state || ConnectivityState.TRANSIENT_FAILURE == state) {
        return false;
    }
    if (ConnectivityState.IDLE == state || ConnectivityState.CONNECTING == state) {
        return true;
    }
    return false;
}
 
Example 2
Source File: OobChannel.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectivityState getState(boolean requestConnectionIgnored) {
  if (subchannel == null) {
    return ConnectivityState.IDLE;
  }
  return subchannel.getState();
}
 
Example 3
Source File: GrpcClient.java    From sofa-jraft with Apache License 2.0 5 votes vote down vote up
private boolean checkChannel(final Endpoint endpoint) {
    final ManagedChannel ch = this.managedChannelPool.get(endpoint);
    if (ch == null) {
        return false;
    }
    final ConnectivityState st = ch.getState(true);
    return st == ConnectivityState.CONNECTING || st == ConnectivityState.READY || st == ConnectivityState.IDLE;
}
 
Example 4
Source File: MilvusGrpcClient.java    From milvus-sdk-java with Apache License 2.0 5 votes vote down vote up
private boolean channelIsReadyOrIdle() {
  if (channel == null) {
    return false;
  }
  ConnectivityState connectivityState = channel.getState(false);
  return connectivityState == ConnectivityState.READY
      || connectivityState
          == ConnectivityState.IDLE; // Since a new RPC would take the channel out of idle mode
}
 
Example 5
Source File: SubchannelStateManagerImpl.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectivityState getAggregatedState() {
  if (stateMultiset.contains(ConnectivityState.READY)) {
    return ConnectivityState.READY;
  } else if (stateMultiset.contains(ConnectivityState.CONNECTING)) {
    return ConnectivityState.CONNECTING;
  } else if (stateMultiset.contains(ConnectivityState.IDLE)) {
    return ConnectivityState.IDLE;
  } else if (stateMultiset.contains(ConnectivityState.TRANSIENT_FAILURE)) {
    return ConnectivityState.TRANSIENT_FAILURE;
  }
  // empty or shutdown
  return ConnectivityState.IDLE;
}
 
Example 6
Source File: OobChannel.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
@Override
public ConnectivityState getState(boolean requestConnectionIgnored) {
  if (subchannel == null) {
    return ConnectivityState.IDLE;
  }
  return subchannel.getState();
}