Skip to content

Commit 08e7e9d

Browse files
authored
netty: extract default permit keepalive time to GrpcUtil constant (grpc#12754)
A simple change that makes the permit keepalive time value a constant.
1 parent ce9bc06 commit 08e7e9d

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

core/src/main/java/io/grpc/internal/GrpcUtil.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ public byte[] parseAsciiString(byte[] serialized) {
241241
*/
242242
public static final long DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS = TimeUnit.SECONDS.toNanos(20L);
243243

244+
/**
245+
* The default minimum time between client keepalive pings permitted by server.
246+
*/
247+
public static final long DEFAULT_SERVER_PERMIT_KEEPALIVE_TIME_NANOS
248+
= TimeUnit.MINUTES.toNanos(5L);
249+
244250
/**
245251
* The magic keepalive time value that disables keepalive.
246252
*/

netty/src/main/java/io/grpc/netty/NettyServerBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import static io.grpc.internal.GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE;
2323
import static io.grpc.internal.GrpcUtil.DEFAULT_SERVER_KEEPALIVE_TIMEOUT_NANOS;
2424
import static io.grpc.internal.GrpcUtil.DEFAULT_SERVER_KEEPALIVE_TIME_NANOS;
25+
import static io.grpc.internal.GrpcUtil.DEFAULT_SERVER_PERMIT_KEEPALIVE_TIME_NANOS;
2526
import static io.grpc.internal.GrpcUtil.SERVER_KEEPALIVE_TIME_NANOS_DISABLED;
2627

2728
import com.google.common.annotations.VisibleForTesting;
@@ -113,7 +114,7 @@ public final class NettyServerBuilder extends ForwardingServerBuilder<NettyServe
113114
private long maxConnectionAgeInNanos = MAX_CONNECTION_AGE_NANOS_DISABLED;
114115
private long maxConnectionAgeGraceInNanos = MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE;
115116
private boolean permitKeepAliveWithoutCalls;
116-
private long permitKeepAliveTimeInNanos = TimeUnit.MINUTES.toNanos(5);
117+
private long permitKeepAliveTimeInNanos = DEFAULT_SERVER_PERMIT_KEEPALIVE_TIME_NANOS;
117118
private int maxRstCount;
118119
private long maxRstPeriodNanos;
119120
private Attributes eagAttributes = Attributes.EMPTY;

okhttp/src/main/java/io/grpc/okhttp/OkHttpServerBuilder.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import static com.google.common.base.Preconditions.checkArgument;
2020
import static io.grpc.internal.CertificateUtils.createTrustManager;
21+
import static io.grpc.internal.GrpcUtil.DEFAULT_SERVER_PERMIT_KEEPALIVE_TIME_NANOS;
2122

2223
import com.google.common.base.Preconditions;
2324
import com.google.errorprone.annotations.CanIgnoreReturnValue;
@@ -137,7 +138,7 @@ public InternalServer buildClientTransportServers(
137138
int maxInboundMessageSize = GrpcUtil.DEFAULT_MAX_MESSAGE_SIZE;
138139
long maxConnectionIdleInNanos = MAX_CONNECTION_IDLE_NANOS_DISABLED;
139140
boolean permitKeepAliveWithoutCalls;
140-
long permitKeepAliveTimeInNanos = TimeUnit.MINUTES.toNanos(5);
141+
long permitKeepAliveTimeInNanos = DEFAULT_SERVER_PERMIT_KEEPALIVE_TIME_NANOS;
141142
long maxConnectionAgeInNanos = MAX_CONNECTION_AGE_NANOS_DISABLED;
142143
long maxConnectionAgeGraceInNanos = MAX_CONNECTION_AGE_GRACE_NANOS_INFINITE;
143144
int maxConcurrentCallsPerConnection = MAX_CONCURRENT_STREAMS;

0 commit comments

Comments
 (0)