io.grpc.netty.InternalNettyChannelBuilder Java Examples

The following examples show how to use io.grpc.netty.InternalNettyChannelBuilder. 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: AltsChannelBuilder.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
@Override
public ManagedChannel build() {
  if (!CheckGcpEnvironment.isOnGcp()) {
    if (enableUntrustedAlts) {
      logger.log(
          Level.WARNING,
          "Untrusted ALTS mode is enabled and we cannot guarantee the trustworthiness of the "
              + "ALTS handshaker service");
    } else {
      Status status =
          Status.INTERNAL.withDescription("ALTS is only allowed to run on Google Cloud Platform");
      delegate().intercept(new FailingClientInterceptor(status));
    }
  }
  InternalNettyChannelBuilder.setProtocolNegotiatorFactory(
      delegate(),
      new ClientAltsProtocolNegotiatorFactory(
          targetServiceAccountsBuilder.build(), handshakerChannelPool));

  return delegate().build();
}
 
Example #2
Source File: ComputeEngineChannelBuilder.java    From grpc-java with Apache License 2.0 6 votes vote down vote up
private ComputeEngineChannelBuilder(String target) {
  delegate = NettyChannelBuilder.forTarget(target);
  SslContext sslContext;
  try {
    sslContext = GrpcSslContexts.forClient().build();
  } catch (SSLException e) {
    throw new RuntimeException(e);
  }
  InternalNettyChannelBuilder.setProtocolNegotiatorFactory(
      delegate(),
      new GoogleDefaultProtocolNegotiatorFactory(
          /* targetServiceAccounts= */ ImmutableList.<String>of(),
          SharedResourcePool.forResource(HandshakerServiceChannel.SHARED_HANDSHAKER_CHANNEL),
          sslContext));
  CallCredentials credentials = MoreCallCredentials.from(ComputeEngineCredentials.create());
  Status status = Status.OK;
  if (!CheckGcpEnvironment.isOnGcp()) {
    status =
        Status.INTERNAL.withDescription(
            "Compute Engine Credentials can only be used on Google Cloud Platform");
  }
  delegate().intercept(new CallCredentialsInterceptor(credentials, status));
}
 
Example #3
Source File: AltsChannelBuilder.java    From grpc-nebula-java with Apache License 2.0 5 votes vote down vote up
private AltsChannelBuilder(String target) {
  delegate =
      NettyChannelBuilder.forTarget(target)
          .keepAliveTime(20, TimeUnit.SECONDS)
          .keepAliveTimeout(10, TimeUnit.SECONDS)
          .keepAliveWithoutCalls(true);
  InternalNettyChannelBuilder.setProtocolNegotiatorFactory(
      delegate(), new ProtocolNegotiatorFactory());
}
 
Example #4
Source File: NettyFlowControlTest.java    From grpc-java with Apache License 2.0 5 votes vote down vote up
/**
 * Resets client/server and their flow control windows.
 */
private void createAndStartChannel(int clientFlowControlWindow) {
  NettyChannelBuilder channelBuilder =
      NettyChannelBuilder
          .forAddress(new InetSocketAddress("localhost", proxyPort))
          .initialFlowControlWindow(clientFlowControlWindow)
          .negotiationType(NegotiationType.PLAINTEXT);
  InternalNettyChannelBuilder.setProtocolNegotiatorFactory(channelBuilder, capturingPnFactory);
  channel = channelBuilder.build();
}
 
Example #5
Source File: GoogleDefaultChannelBuilder.java    From grpc-nebula-java with Apache License 2.0 4 votes vote down vote up
private GoogleDefaultChannelBuilder(String target) {
  delegate = NettyChannelBuilder.forTarget(target);
  InternalNettyChannelBuilder.setProtocolNegotiatorFactory(
      delegate(), new ProtocolNegotiatorFactory());
}
 
Example #6
Source File: DefaultChannelFactory.java    From pinpoint with Apache License 2.0 4 votes vote down vote up
private void setupInternal(NettyChannelBuilder channelBuilder) {
    InternalNettyChannelBuilder.setStatsEnabled(channelBuilder, false);
    InternalNettyChannelBuilder.setTracingEnabled(channelBuilder, false);
    InternalNettyChannelBuilder.setStatsRecordStartedRpcs(channelBuilder, false);
}
 
Example #7
Source File: XdsChannelBuilder.java    From grpc-java with Apache License 2.0 4 votes vote down vote up
@Override
public ManagedChannel build() {
  InternalNettyChannelBuilder.setProtocolNegotiatorFactory(
      delegate, SdsProtocolNegotiators.clientProtocolNegotiatorFactory());
  return delegate.build();
}