aboutsummaryrefslogtreecommitdiff
path: root/netty
diff options
context:
space:
mode:
authorEric Anderson <ejona@google.com>2017-09-14 11:25:59 -0700
committerEric Anderson <ejona@google.com>2017-09-14 12:15:04 -0700
commit2d711687f968444d498c3a77bcf4b61938eff699 (patch)
treeac6096dcf97caef4bcafb4e165f62f511b99d4ca /netty
parent86dec11f7bfb8fcd86fc677024c56bb83f633f59 (diff)
downloadgrpc-grpc-java-2d711687f968444d498c3a77bcf4b61938eff699.tar.gz
Revert "netty: hide ProtocolNegotiator, and expose initial ChannelHandler"
This reverts commit 332c46ff1a5f5d015502c9c22fe8297304760447. We need the protocol negotiator exposed for alternative handshake/security mechanisms.
Diffstat (limited to 'netty')
-rw-r--r--netty/src/main/java/io/grpc/netty/InternalNettyServerBuilder.java38
-rw-r--r--netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java52
-rw-r--r--netty/src/main/java/io/grpc/netty/NettyClientTransport.java116
-rw-r--r--netty/src/main/java/io/grpc/netty/NettyServer.java31
-rw-r--r--netty/src/main/java/io/grpc/netty/NettyServerBuilder.java52
-rw-r--r--netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java22
-rw-r--r--netty/src/test/java/io/grpc/netty/NettyServerTest.java2
7 files changed, 78 insertions, 235 deletions
diff --git a/netty/src/main/java/io/grpc/netty/InternalNettyServerBuilder.java b/netty/src/main/java/io/grpc/netty/InternalNettyServerBuilder.java
deleted file mode 100644
index 606a2959e..000000000
--- a/netty/src/main/java/io/grpc/netty/InternalNettyServerBuilder.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright 2016, gRPC Authors All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package io.grpc.netty;
-
-import io.grpc.Internal;
-import io.netty.channel.ChannelHandler;
-
-/**
- * Internal {@link InternalNettyServerBuilder} accessor. This is intended for usage internal to
- * the gRPC team. If you *really* think you need to use this, contact the gRPC team first.
- */
-@Internal
-public final class InternalNettyServerBuilder {
-
- /**
- * Adds an initialization handler to the Netty child at Channel initialization time. It must be
- * annotated {@link ChannelHandler.Sharable}.
- */
- public static NettyServerBuilder initHandler(NettyServerBuilder nsb, ChannelHandler initHandler) {
- return nsb.initHandler(initHandler);
- }
-
- private InternalNettyServerBuilder() {}
-}
diff --git a/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java b/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java
index 4f545237a..2fc7a3851 100644
--- a/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java
+++ b/netty/src/main/java/io/grpc/netty/NettyChannelBuilder.java
@@ -38,7 +38,6 @@ import io.grpc.internal.GrpcUtil;
import io.grpc.internal.KeepAliveManager;
import io.grpc.internal.SharedResourceHolder;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.socket.nio.NioSocketChannel;
@@ -74,7 +73,6 @@ public final class NettyChannelBuilder
@Nullable
private EventLoopGroup eventLoopGroup;
private SslContext sslContext;
- @Nullable private ChannelHandler initHandler;
private int flowControlWindow = DEFAULT_FLOW_CONTROL_WINDOW;
private int maxHeaderListSize = GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE;
private long keepAliveTimeNanos = KEEPALIVE_TIME_NANOS_DISABLED;
@@ -223,16 +221,6 @@ public final class NettyChannelBuilder
return this;
}
- final NettyChannelBuilder initHandler(ChannelHandler initHandler) {
- if (initHandler != null) {
- checkArgument(
- initHandler.getClass().isAnnotationPresent(ChannelHandler.Sharable.class),
- "initHandler must be sharable");
- }
- this.initHandler = initHandler;
- return this;
- }
-
/**
* Equivalent to using {@link #negotiationType(NegotiationType)} with {@code PLAINTEXT} or
* {@code PLAINTEXT_UPGRADE}.
@@ -334,20 +322,9 @@ public final class NettyChannelBuilder
@CheckReturnValue
@Internal
protected ClientTransportFactory buildTransportFactory() {
- return new NettyTransportFactory(
- dynamicParamsFactory,
- channelType,
- channelOptions,
- negotiationType,
- sslContext,
- initHandler,
- eventLoopGroup,
- flowControlWindow,
- maxInboundMessageSize(),
- maxHeaderListSize,
- keepAliveTimeNanos,
- keepAliveTimeoutNanos,
- keepAliveWithoutCalls);
+ return new NettyTransportFactory(dynamicParamsFactory, channelType, channelOptions,
+ negotiationType, sslContext, eventLoopGroup, flowControlWindow, maxInboundMessageSize(),
+ maxHeaderListSize, keepAliveTimeNanos, keepAliveTimeoutNanos, keepAliveWithoutCalls);
}
@Override
@@ -456,7 +433,6 @@ public final class NettyChannelBuilder
private final Class<? extends Channel> channelType;
private final Map<ChannelOption<?>, ?> channelOptions;
private final NegotiationType negotiationType;
- private final ChannelHandler initHandler;
private final EventLoopGroup group;
private final boolean usingSharedGroup;
private final int flowControlWindow;
@@ -468,20 +444,11 @@ public final class NettyChannelBuilder
private boolean closed;
- NettyTransportFactory(
- TransportCreationParamsFilterFactory transportCreationParamsFilterFactory,
- Class<? extends Channel> channelType,
- Map<ChannelOption<?>, ?> channelOptions,
- NegotiationType negotiationType,
- SslContext sslContext,
- ChannelHandler initHandler,
- EventLoopGroup group,
- int flowControlWindow,
- int maxMessageSize,
- int maxHeaderListSize,
- long keepAliveTimeNanos,
- long keepAliveTimeoutNanos,
- boolean keepAliveWithoutCalls) {
+ NettyTransportFactory(TransportCreationParamsFilterFactory transportCreationParamsFilterFactory,
+ Class<? extends Channel> channelType, Map<ChannelOption<?>, ?> channelOptions,
+ NegotiationType negotiationType, SslContext sslContext, EventLoopGroup group,
+ int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
+ long keepAliveTimeNanos, long keepAliveTimeoutNanos, boolean keepAliveWithoutCalls) {
this.channelType = channelType;
this.negotiationType = negotiationType;
this.channelOptions = new HashMap<ChannelOption<?>, Object>(channelOptions);
@@ -491,7 +458,6 @@ public final class NettyChannelBuilder
new DefaultNettyTransportCreationParamsFilterFactory(sslContext);
}
this.transportCreationParamsFilterFactory = transportCreationParamsFilterFactory;
- this.initHandler = initHandler;
this.flowControlWindow = flowControlWindow;
this.maxMessageSize = maxMessageSize;
@@ -525,7 +491,7 @@ public final class NettyChannelBuilder
};
NettyClientTransport transport = new NettyClientTransport(
dparams.getTargetServerAddress(), channelType, channelOptions, group,
- dparams.getProtocolNegotiator(), initHandler, flowControlWindow,
+ dparams.getProtocolNegotiator(), flowControlWindow,
maxMessageSize, maxHeaderListSize, keepAliveTimeNanosState.get(), keepAliveTimeoutNanos,
keepAliveWithoutCalls, dparams.getAuthority(), dparams.getUserAgent(),
tooManyPingsRunnable);
diff --git a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
index aa1651003..189b06a48 100644
--- a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
+++ b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java
@@ -36,13 +36,10 @@ import io.grpc.internal.KeepAliveManager;
import io.grpc.internal.KeepAliveManager.ClientKeepAlivePinger;
import io.grpc.internal.LogId;
import io.grpc.internal.StatsTraceContext;
-import io.grpc.netty.ProtocolNegotiator.Handler;
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.EventLoop;
import io.netty.channel.EventLoopGroup;
@@ -52,26 +49,19 @@ import io.netty.util.AsciiString;
import java.net.SocketAddress;
import java.nio.channels.ClosedChannelException;
import java.util.Map;
-import java.util.Map.Entry;
import java.util.concurrent.Executor;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.logging.Level;
-import java.util.logging.Logger;
import javax.annotation.Nullable;
/**
* A Netty-based {@link ConnectionClientTransport} implementation.
*/
class NettyClientTransport implements ConnectionClientTransport {
- private static final Logger logger = Logger.getLogger(NettyClientTransport.class.getName());
-
private final LogId logId = LogId.allocate(getClass().getName());
private final Map<ChannelOption<?>, ?> channelOptions;
private final SocketAddress address;
private final Class<? extends Channel> channelType;
private final EventLoopGroup group;
private final ProtocolNegotiator negotiator;
- private final ChannelHandler initHandler;
private final AsciiString authority;
private final AsciiString userAgent;
private final int flowControlWindow;
@@ -83,7 +73,7 @@ class NettyClientTransport implements ConnectionClientTransport {
private final boolean keepAliveWithoutCalls;
private final Runnable tooManyPingsRunnable;
- private AsciiString negotiatorScheme;
+ private ProtocolNegotiator.Handler negotiationHandler;
private NettyClientHandler handler;
// We should not send on the channel until negotiation completes. This is a hard requirement
// by SslHandler but is appropriate for HTTP/1.1 Upgrade as well.
@@ -92,26 +82,15 @@ class NettyClientTransport implements ConnectionClientTransport {
private Status statusExplainingWhyTheChannelIsNull;
/** Since not thread-safe, may only be used from event loop. */
private ClientTransportLifecycleManager lifecycleManager;
- private final AtomicBoolean notifyClosed = new AtomicBoolean();
NettyClientTransport(
- SocketAddress address,
- Class<? extends Channel> channelType,
- Map<ChannelOption<?>, ?> channelOptions,
- EventLoopGroup group,
- ProtocolNegotiator negotiator,
- @Nullable ChannelHandler initHandler,
- int flowControlWindow,
- int maxMessageSize,
- int maxHeaderListSize,
- long keepAliveTimeNanos,
- long keepAliveTimeoutNanos,
- boolean keepAliveWithoutCalls,
- String authority,
- @Nullable String userAgent,
+ SocketAddress address, Class<? extends Channel> channelType,
+ Map<ChannelOption<?>, ?> channelOptions, EventLoopGroup group,
+ ProtocolNegotiator negotiator, int flowControlWindow, int maxMessageSize,
+ int maxHeaderListSize, long keepAliveTimeNanos, long keepAliveTimeoutNanos,
+ boolean keepAliveWithoutCalls, String authority, @Nullable String userAgent,
Runnable tooManyPingsRunnable) {
this.negotiator = Preconditions.checkNotNull(negotiator, "negotiator");
- this.initHandler = initHandler;
this.address = Preconditions.checkNotNull(address, "address");
this.group = Preconditions.checkNotNull(group, "group");
this.channelType = Preconditions.checkNotNull(channelType, "channelType");
@@ -172,23 +151,8 @@ class NettyClientTransport implements ConnectionClientTransport {
return NettyClientTransport.this.statusFromFailedFuture(f);
}
},
- method, headers, channel, authority, negotiatorScheme, userAgent, statsTraceCtx);
- }
-
- private void lifecycleManagerNotifyTerminated(String reason, Throwable t) {
- lifecycleManagerNotifyTerminated(reason, Utils.statusFromThrowable(t));
- }
-
- private void lifecycleManagerNotifyTerminated(String detail, Status s) {
- if (!notifyClosed.compareAndSet(false, true)) {
- logger.log(
- Level.FINE, detail + "ignoring additional lifecycle errors", s.asRuntimeException());
- return;
- }
- if (detail != null) {
- s = s.augmentDescription(detail);
- }
- lifecycleManager.notifyTerminated(s);
+ method, headers, channel, authority, negotiationHandler.scheme(), userAgent,
+ statsTraceCtx);
}
@SuppressWarnings("unchecked")
@@ -207,6 +171,8 @@ class NettyClientTransport implements ConnectionClientTransport {
maxHeaderListSize, Ticker.systemTicker(), tooManyPingsRunnable);
NettyHandlerSettings.setAutoWindow(handler);
+ negotiationHandler = negotiator.newHandler(handler);
+
Bootstrap b = new Bootstrap();
b.group(eventLoop);
b.channel(channelType);
@@ -220,43 +186,13 @@ class NettyClientTransport implements ConnectionClientTransport {
b.option((ChannelOption<Object>) entry.getKey(), entry.getValue());
}
- final class LifecycleChannelFutureListener implements ChannelFutureListener {
- private final String reason;
-
- LifecycleChannelFutureListener(String reason) {
- this.reason = reason;
- }
-
- @Override
- public void operationComplete(ChannelFuture future) throws Exception {
- if (!future.isSuccess()) {
- lifecycleManagerNotifyTerminated(reason, future.cause());
- }
- }
- }
-
- final Handler negotiationHandler = negotiator.newHandler(handler);
- negotiatorScheme = negotiationHandler.scheme();
-
- b.handler(new ChannelInitializer<Channel>() {
- @Override
- protected void initChannel(Channel ch) throws Exception {
- if (initHandler != null) {
- ch.pipeline().addFirst(initHandler);
- }
-
- ch.pipeline().addLast(negotiationHandler);
-
- // This write will have no effect, yet it will only complete once the negotiationHandler
- // flushes any pending writes.
- ch.writeAndFlush(NettyClientHandler.NOOP_MESSAGE)
- .addListener(new LifecycleChannelFutureListener("noop write"));
- }
- });
-
+ /**
+ * We don't use a ChannelInitializer in the client bootstrap because its "initChannel" method
+ * is executed in the event loop and we need this handler to be in the pipeline immediately so
+ * that it may begin buffering writes.
+ */
+ b.handler(negotiationHandler);
ChannelFuture regFuture = b.register();
- regFuture.addListener(new LifecycleChannelFutureListener("register"));
-
channel = regFuture.channel();
if (channel == null) {
// Initialization has failed badly. All new streams should be made to fail.
@@ -274,15 +210,29 @@ class NettyClientTransport implements ConnectionClientTransport {
// could use GlobalEventExecutor (which is what regFuture would use for notifying
// listeners in this case), but avoiding on-demand thread creation in an error case seems
// a good idea and is probably clearer threading.
- lifecycleManagerNotifyTerminated(null, statusExplainingWhyTheChannelIsNull);
+ lifecycleManager.notifyTerminated(statusExplainingWhyTheChannelIsNull);
}
};
}
// Start the write queue as soon as the channel is constructed
handler.startWriteQueue(channel);
-
+ // This write will have no effect, yet it will only complete once the negotiationHandler
+ // flushes any pending writes. We need it to be staged *before* the `connect` so that
+ // the channel can't have been closed yet, removing all handlers. This write will sit in the
+ // AbstractBufferingHandler's buffer, and will either be flushed on a successful connection,
+ // or failed if the connection fails.
+ channel.writeAndFlush(NettyClientHandler.NOOP_MESSAGE).addListener(new ChannelFutureListener() {
+ @Override
+ public void operationComplete(ChannelFuture future) throws Exception {
+ if (!future.isSuccess()) {
+ // Need to notify of this failure, because NettyClientHandler may not have been added to
+ // the pipeline before the error occurred.
+ lifecycleManager.notifyTerminated(Utils.statusFromThrowable(future.cause()));
+ }
+ }
+ });
// Start the connection operation to the server.
- channel.connect(address).addListener(new LifecycleChannelFutureListener("connect"));
+ channel.connect(address);
if (keepAliveManager != null) {
keepAliveManager.onTransportStarted();
diff --git a/netty/src/main/java/io/grpc/netty/NettyServer.java b/netty/src/main/java/io/grpc/netty/NettyServer.java
index db9380300..ad66540ef 100644
--- a/netty/src/main/java/io/grpc/netty/NettyServer.java
+++ b/netty/src/main/java/io/grpc/netty/NettyServer.java
@@ -30,7 +30,6 @@ import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
-import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
@@ -53,7 +52,6 @@ class NettyServer implements InternalServer {
private final SocketAddress address;
private final Class<? extends ServerChannel> channelType;
- private final ChannelHandler initHandler;
private final ProtocolNegotiator protocolNegotiator;
private final int maxStreamsPerConnection;
private final boolean usingSharedBossGroup;
@@ -76,30 +74,19 @@ class NettyServer implements InternalServer {
private final List<ServerStreamTracer.Factory> streamTracerFactories;
NettyServer(
- SocketAddress address,
- Class<? extends ServerChannel> channelType,
- @Nullable EventLoopGroup bossGroup,
- @Nullable EventLoopGroup workerGroup,
- ProtocolNegotiator protocolNegotiator,
- @Nullable ChannelHandler initHandler,
- List<ServerStreamTracer.Factory> streamTracerFactories,
- int maxStreamsPerConnection,
- int flowControlWindow,
- int maxMessageSize,
- int maxHeaderListSize,
- long keepAliveTimeInNanos,
- long keepAliveTimeoutInNanos,
+ SocketAddress address, Class<? extends ServerChannel> channelType,
+ @Nullable EventLoopGroup bossGroup, @Nullable EventLoopGroup workerGroup,
+ ProtocolNegotiator protocolNegotiator, List<ServerStreamTracer.Factory> streamTracerFactories,
+ int maxStreamsPerConnection, int flowControlWindow, int maxMessageSize, int maxHeaderListSize,
+ long keepAliveTimeInNanos, long keepAliveTimeoutInNanos,
long maxConnectionIdleInNanos,
- long maxConnectionAgeInNanos,
- long maxConnectionAgeGraceInNanos,
- boolean permitKeepAliveWithoutCalls,
- long permitKeepAliveTimeInNanos) {
+ long maxConnectionAgeInNanos, long maxConnectionAgeGraceInNanos,
+ boolean permitKeepAliveWithoutCalls, long permitKeepAliveTimeInNanos) {
this.address = address;
this.channelType = checkNotNull(channelType, "channelType");
this.bossGroup = bossGroup;
this.workerGroup = workerGroup;
this.protocolNegotiator = checkNotNull(protocolNegotiator, "protocolNegotiator");
- this.initHandler = initHandler;
this.streamTracerFactories = checkNotNull(streamTracerFactories, "streamTracerFactories");
this.usingSharedBossGroup = bossGroup == null;
this.usingSharedWorkerGroup = workerGroup == null;
@@ -146,10 +133,6 @@ class NettyServer implements InternalServer {
@Override
public void initChannel(Channel ch) throws Exception {
- if (initHandler != null) {
- ch.pipeline().addFirst(initHandler);
- }
-
long maxConnectionAgeInNanos = NettyServer.this.maxConnectionAgeInNanos;
if (maxConnectionAgeInNanos != MAX_CONNECTION_AGE_NANOS_DISABLED) {
// apply a random jitter of +/-10% to max connection age
diff --git a/netty/src/main/java/io/grpc/netty/NettyServerBuilder.java b/netty/src/main/java/io/grpc/netty/NettyServerBuilder.java
index 88ad65d61..a2e0251eb 100644
--- a/netty/src/main/java/io/grpc/netty/NettyServerBuilder.java
+++ b/netty/src/main/java/io/grpc/netty/NettyServerBuilder.java
@@ -25,11 +25,11 @@ import static io.grpc.internal.GrpcUtil.SERVER_KEEPALIVE_TIME_NANOS_DISABLED;
import com.google.common.base.Preconditions;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.grpc.ExperimentalApi;
+import io.grpc.Internal;
import io.grpc.ServerStreamTracer;
import io.grpc.internal.AbstractServerImplBuilder;
import io.grpc.internal.GrpcUtil;
import io.grpc.internal.KeepAliveManager;
-import io.netty.channel.ChannelHandler;
import io.netty.channel.EventLoopGroup;
import io.netty.channel.ServerChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
@@ -68,7 +68,7 @@ public final class NettyServerBuilder extends AbstractServerImplBuilder<NettySer
@Nullable
private EventLoopGroup workerEventLoopGroup;
private SslContext sslContext;
- private ChannelHandler initHandler;
+ private ProtocolNegotiator protocolNegotiator;
private int maxConcurrentCallsPerConnection = Integer.MAX_VALUE;
private int flowControlWindow = DEFAULT_FLOW_CONTROL_WINDOW;
private int maxMessageSize = DEFAULT_MAX_MESSAGE_SIZE;
@@ -181,14 +181,16 @@ public final class NettyServerBuilder extends AbstractServerImplBuilder<NettySer
return this;
}
- NettyServerBuilder initHandler(ChannelHandler initHandler) {
- if (initHandler != null) {
- checkArgument(
- initHandler.getClass().isAnnotationPresent(ChannelHandler.Sharable.class),
- "initHandler must be sharable");
- }
-
- this.initHandler = initHandler;
+ /**
+ * Sets the {@link ProtocolNegotiator} to be used. If non-{@code null}, overrides the value
+ * specified in {@link #sslContext(SslContext)}.
+ *
+ * <p>Default: {@code null}.
+ */
+ @Internal
+ public final NettyServerBuilder protocolNegotiator(
+ @Nullable ProtocolNegotiator protocolNegotiator) {
+ this.protocolNegotiator = protocolNegotiator;
return this;
}
@@ -371,29 +373,19 @@ public final class NettyServerBuilder extends AbstractServerImplBuilder<NettySer
@CheckReturnValue
protected NettyServer buildTransportServer(
List<ServerStreamTracer.Factory> streamTracerFactories) {
- ProtocolNegotiator negotiator = sslContext != null
- ? ProtocolNegotiators.serverTls(sslContext)
- : ProtocolNegotiators.serverPlaintext();
+ ProtocolNegotiator negotiator = protocolNegotiator;
+ if (negotiator == null) {
+ negotiator = sslContext != null ? ProtocolNegotiators.serverTls(sslContext) :
+ ProtocolNegotiators.serverPlaintext();
+ }
return new NettyServer(
- address,
- channelType,
- bossEventLoopGroup,
- workerEventLoopGroup,
- negotiator,
- initHandler,
- streamTracerFactories,
- maxConcurrentCallsPerConnection,
- flowControlWindow,
- maxMessageSize,
- maxHeaderListSize,
- keepAliveTimeInNanos,
- keepAliveTimeoutInNanos,
+ address, channelType, bossEventLoopGroup, workerEventLoopGroup,
+ negotiator, streamTracerFactories, maxConcurrentCallsPerConnection, flowControlWindow,
+ maxMessageSize, maxHeaderListSize, keepAliveTimeInNanos, keepAliveTimeoutInNanos,
maxConnectionIdleInNanos,
- maxConnectionAgeInNanos,
- maxConnectionAgeGraceInNanos,
- permitKeepAliveWithoutCalls,
- permitKeepAliveTimeInNanos);
+ maxConnectionAgeInNanos, maxConnectionAgeGraceInNanos,
+ permitKeepAliveWithoutCalls, permitKeepAliveTimeInNanos);
}
@Override
diff --git a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java
index 6df65b159..6912e39d1 100644
--- a/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java
+++ b/netty/src/test/java/io/grpc/netty/NettyClientTransportTest.java
@@ -35,7 +35,6 @@ import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.io.ByteStreams;
-import com.google.common.truth.Truth;
import com.google.common.util.concurrent.SettableFuture;
import io.grpc.Attributes;
import io.grpc.CallOptions;
@@ -61,7 +60,6 @@ import io.grpc.internal.ServerTransport;
import io.grpc.internal.ServerTransportListener;
import io.grpc.internal.testing.TestUtils;
import io.netty.channel.ChannelConfig;
-import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelOption;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannelConfig;
@@ -169,7 +167,7 @@ public class NettyClientTransportTest {
int soLinger = 123;
channelOptions.put(ChannelOption.SO_LINGER, soLinger);
NettyClientTransport transport = new NettyClientTransport(
- address, NioSocketChannel.class, channelOptions, group, newNegotiator(), null,
+ address, NioSocketChannel.class, channelOptions, group, newNegotiator(),
DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE,
KEEPALIVE_TIME_NANOS_DISABLED, 1L, false, authority, null /* user agent */,
tooManyPingsRunnable);
@@ -266,9 +264,7 @@ public class NettyClientTransportTest {
rpc.waitForClose();
fail("expected exception");
} catch (ExecutionException ex) {
- StatusException se = (StatusException) ex.getCause();
- assertSame(failureStatus.getCode(), se.getStatus().getCode());
- Truth.assertThat(se.getStatus().getDescription()).contains(failureStatus.getDescription());
+ assertSame(failureStatus, ((StatusException) ex.getCause()).getStatus());
}
}
@@ -288,9 +284,7 @@ public class NettyClientTransportTest {
rpc.waitForClose();
fail("expected exception");
} catch (ExecutionException ex) {
- StatusException se = (StatusException) ex.getCause();
- assertSame(failureStatus.getCode(), se.getStatus().getCode());
- Truth.assertThat(se.getStatus().getDescription()).contains(failureStatus.getDescription());
+ assertSame(failureStatus, ((StatusException) ex.getCause()).getStatus());
}
}
@@ -321,9 +315,7 @@ public class NettyClientTransportTest {
rpc.waitForClose();
fail("expected exception");
} catch (ExecutionException ex) {
- StatusException se = (StatusException) ex.getCause();
- assertSame(failureStatus.getCode(), se.getStatus().getCode());
- Truth.assertThat(se.getStatus().getDescription()).contains(failureStatus.getDescription());
+ assertSame(failureStatus, ((StatusException) ex.getCause()).getStatus());
}
}
@@ -380,7 +372,7 @@ public class NettyClientTransportTest {
authority = GrpcUtil.authorityFromHostAndPort(address.getHostString(), address.getPort());
NettyClientTransport transport = new NettyClientTransport(
address, CantConstructChannel.class, new HashMap<ChannelOption<?>, Object>(), group,
- newNegotiator(), null, DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE,
+ newNegotiator(), DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE,
GrpcUtil.DEFAULT_MAX_HEADER_LIST_SIZE, KEEPALIVE_TIME_NANOS_DISABLED, 1, false, authority,
null, tooManyPingsRunnable);
transports.add(transport);
@@ -548,7 +540,7 @@ public class NettyClientTransportTest {
}
NettyClientTransport transport = new NettyClientTransport(
address, NioSocketChannel.class, new HashMap<ChannelOption<?>, Object>(), group, negotiator,
- (ChannelHandler) null, DEFAULT_WINDOW_SIZE, maxMsgSize, maxHeaderListSize,
+ DEFAULT_WINDOW_SIZE, maxMsgSize, maxHeaderListSize,
keepAliveTimeNano, keepAliveTimeoutNano,
false, authority, userAgent, tooManyPingsRunnable);
transports.add(transport);
@@ -562,7 +554,7 @@ public class NettyClientTransportTest {
private void startServer(int maxStreamsPerConnection, int maxHeaderListSize) throws IOException {
server = new NettyServer(
TestUtils.testServerAddress(0),
- NioServerSocketChannel.class, group, group, negotiator, null,
+ NioServerSocketChannel.class, group, group, negotiator,
Collections.<ServerStreamTracer.Factory>emptyList(), maxStreamsPerConnection,
DEFAULT_WINDOW_SIZE, DEFAULT_MAX_MESSAGE_SIZE, maxHeaderListSize,
DEFAULT_SERVER_KEEPALIVE_TIME_NANOS, DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS,
diff --git a/netty/src/test/java/io/grpc/netty/NettyServerTest.java b/netty/src/test/java/io/grpc/netty/NettyServerTest.java
index b6952b399..68e183d64 100644
--- a/netty/src/test/java/io/grpc/netty/NettyServerTest.java
+++ b/netty/src/test/java/io/grpc/netty/NettyServerTest.java
@@ -41,7 +41,6 @@ public class NettyServerTest {
null, // no boss group
null, // no event group
new ProtocolNegotiators.PlaintextNegotiator(),
- null, // no channel init
Collections.<ServerStreamTracer.Factory>emptyList(),
1, // ignore
1, // ignore
@@ -77,7 +76,6 @@ public class NettyServerTest {
null, // no boss group
null, // no event group
new ProtocolNegotiators.PlaintextNegotiator(),
- null, // no channel init
Collections.<ServerStreamTracer.Factory>emptyList(),
1, // ignore
1, // ignore