Skip to content

Commit

Permalink
Logging use of alpn-boot vs. tcnative jar.
Browse files Browse the repository at this point in the history
  • Loading branch information
sduskis committed Oct 12, 2015
1 parent 995ea41 commit b8dbdf6
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import io.grpc.netty.NettyChannelBuilder;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.handler.ssl.OpenSsl;
import io.netty.handler.ssl.SslContext;
import io.netty.handler.ssl.SslContextBuilder;

Expand Down Expand Up @@ -120,21 +121,16 @@ public class BigtableSession implements AutoCloseable {
performWarmup();
}

private static SslContextBuilder createGrpcSslBuilder() {
SslContextBuilder sslBuilder = GrpcSslContexts.forClient();
sslBuilder.ciphers(null);
return sslBuilder;
}

private static synchronized SslContextBuilder getSslBuilder() {
private synchronized static SslContext createSslContext() throws SSLException {
if (sslBuilder == null) {
sslBuilder = createGrpcSslBuilder();
sslBuilder = GrpcSslContexts.forClient().ciphers(null);
if (OpenSsl.isAvailable()) {
LOG.info("gRPC is using the OpenSSL provider (tcnactive jar)");
} else {
LOG.info("gRPC is using the JDK provder (alpn-boot jar)");
}
}
return sslBuilder;
}

private static SslContext createSslContext() throws SSLException {
return getSslBuilder().build();
return sslBuilder.build();
}

private static void performWarmup() {
Expand All @@ -146,12 +142,14 @@ public void run() {
// The first invocation of createSslContext() is expensive.
// Create a throw away object in order to speed up the creation of the first
// BigtableConnection which uses SslContexts under the covers.
try {
Class.forName("org.eclipse.jetty.alpn.ALPN");
} catch (ClassNotFoundException e1) {
LOG.warn(
"Could not asynchronously create the ssl context, since ALPN is not installed.");
return;
if (!OpenSsl.isAvailable()) {
try {
Class.forName("org.eclipse.jetty.alpn.ALPN");
} catch (ClassNotFoundException e1) {
LOG.warn(
"Could not asynchronously create the ssl context, since ALPN is not installed.");
return;
}
}
try {
// We create multiple channels via refreshing and pooling channel implementation.
Expand Down

0 comments on commit b8dbdf6

Please sign in to comment.