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


Java GrpcUtil.IS_RESTRICTED_APPENGINE属性代码示例

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


在下文中一共展示了GrpcUtil.IS_RESTRICTED_APPENGINE属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: run

@Override
public void run() {
  String threadName = Thread.currentThread().getName();
  if (!GrpcUtil.IS_RESTRICTED_APPENGINE) {
    Thread.currentThread().setName("OkHttpClientTransport");
  }
  try {
    // Read until the underlying socket closes.
    while (frameReader.nextFrame(this)) {
      if (keepAliveManager != null) {
        keepAliveManager.onDataReceived();
      }
    }
    // frameReader.nextFrame() returns false when the underlying read encounters an IOException,
    // it may be triggered by the socket closing, in such case, the startGoAway() will do
    // nothing, otherwise, we finish all streams since it's a real IO issue.
    startGoAway(0, ErrorCode.INTERNAL_ERROR,
        Status.UNAVAILABLE.withDescription("End of stream or IOException"));
  } catch (Throwable t) {
    // TODO(madongfly): Send the exception message to the server.
    startGoAway(
        0, 
        ErrorCode.PROTOCOL_ERROR, 
        Status.UNAVAILABLE.withDescription("error in frame handler").withCause(t));
  } finally {
    try {
      frameReader.close();
    } catch (IOException ex) {
      log.log(Level.INFO, "Exception closing frame reader", ex);
    }
    listener.transportTerminated();
    if (!GrpcUtil.IS_RESTRICTED_APPENGINE) {
      // Restore the original thread name.
      Thread.currentThread().setName(threadName);
    }
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:37,代码来源:OkHttpClientTransport.java

示例2: createSocketFactory

@VisibleForTesting
@Nullable
SSLSocketFactory createSocketFactory() {
  switch (negotiationType) {
    case TLS:
      try {
        if (sslSocketFactory == null) {
          SSLContext sslContext;
          if (GrpcUtil.IS_RESTRICTED_APPENGINE) {
            // The following auth code circumvents the following AccessControlException:
            // access denied ("java.util.PropertyPermission" "javax.net.ssl.keyStore" "read")
            // Conscrypt will attempt to load the default KeyStore if a trust manager is not
            // provided, which is forbidden on AppEngine
            sslContext = SSLContext.getInstance("TLS", Platform.get().getProvider());
            TrustManagerFactory trustManagerFactory =
                TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
            trustManagerFactory.init((KeyStore) null);
            sslContext.init(
                null,
                trustManagerFactory.getTrustManagers(),
                // Use an algorithm that doesn't need /dev/urandom
                SecureRandom.getInstance("SHA1PRNG", Platform.get().getProvider()));

          } else {
            sslContext = SSLContext.getInstance("Default", Platform.get().getProvider());
          }
          sslSocketFactory = sslContext.getSocketFactory();
        }
        return sslSocketFactory;
      } catch (GeneralSecurityException gse) {
        throw new RuntimeException("TLS Provider failure", gse);
      }
    case PLAINTEXT:
      return null;
    default:
      throw new RuntimeException("Unknown negotiation type: " + negotiationType);
  }
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:38,代码来源:OkHttpChannelBuilder.java

示例3: priority

@Override
public int priority() {
  return (GrpcUtil.IS_RESTRICTED_APPENGINE || isAndroid()) ? 8 : 3;
}
 
开发者ID:grpc,项目名称:grpc-java,代码行数:4,代码来源:OkHttpChannelProvider.java


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