Package io.grpc.internal
Class KeepAliveEnforcer
java.lang.Object
io.grpc.internal.KeepAliveEnforcer
Monitors the client's PING usage to make sure the rate is permitted.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
(package private) static interface
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final long
private boolean
static final long
private long
static final int
private final long
private final boolean
private int
private final KeepAliveEnforcer.Ticker
-
Constructor Summary
ConstructorsConstructorDescriptionKeepAliveEnforcer
(boolean permitWithoutCalls, long minTime, TimeUnit unit) KeepAliveEnforcer
(boolean permitWithoutCalls, long minTime, TimeUnit unit, KeepAliveEnforcer.Ticker ticker) -
Method Summary
Modifier and TypeMethodDescriptionprivate static long
compareNanos
(long time1, long time2) Positive when time1 is greater; negative when time2 is greater; 0 when equal.void
There are outstanding RPCs on the transport.void
There are no outstanding RPCs on the transport.boolean
Returnsfalse
when client is misbehaving and should be disconnected.void
Reset any counters because PINGs are allowed in response to something sent.
-
Field Details
-
MAX_PING_STRIKES
public static final int MAX_PING_STRIKES- See Also:
-
IMPLICIT_PERMIT_TIME_NANOS
public static final long IMPLICIT_PERMIT_TIME_NANOS -
permitWithoutCalls
private final boolean permitWithoutCalls -
minTimeNanos
private final long minTimeNanos -
ticker
-
epoch
private final long epoch -
lastValidPingTime
private long lastValidPingTime -
hasOutstandingCalls
private boolean hasOutstandingCalls -
pingStrikes
private int pingStrikes
-
-
Constructor Details
-
KeepAliveEnforcer
-
KeepAliveEnforcer
KeepAliveEnforcer(boolean permitWithoutCalls, long minTime, TimeUnit unit, KeepAliveEnforcer.Ticker ticker)
-
-
Method Details
-
pingAcceptable
Returnsfalse
when client is misbehaving and should be disconnected. -
resetCounters
public void resetCounters()Reset any counters because PINGs are allowed in response to something sent. Typically called when sending HEADERS and DATA frames. -
onTransportActive
public void onTransportActive()There are outstanding RPCs on the transport. -
onTransportIdle
public void onTransportIdle()There are no outstanding RPCs on the transport. -
compareNanos
private static long compareNanos(long time1, long time2) Positive when time1 is greater; negative when time2 is greater; 0 when equal. It is important to use something like this instead of directly comparing nano times. SeeSystem.nanoTime()
.
-