Package io.grpc.internal
Class KeepAliveManager
- java.lang.Object
-
- io.grpc.internal.KeepAliveManager
-
public class KeepAliveManager extends java.lang.ObjectManages keepalive pings.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKeepAliveManager.ClientKeepAlivePingerDefault client sideKeepAliveManager.KeepAlivePinger.static interfaceKeepAliveManager.KeepAlivePingerprivate static classKeepAliveManager.State
-
Field Summary
Fields Modifier and Type Field Description private booleankeepAliveDuringTransportIdleprivate KeepAliveManager.KeepAlivePingerkeepAlivePingerprivate longkeepAliveTimeInNanosprivate longkeepAliveTimeoutInNanosprivate static longMIN_KEEPALIVE_TIME_NANOSprivate static longMIN_KEEPALIVE_TIMEOUT_NANOSprivate java.util.concurrent.ScheduledFuture<?>pingFutureprivate java.util.concurrent.ScheduledExecutorServiceschedulerprivate java.lang.RunnablesendPingprivate java.lang.Runnableshutdownprivate java.util.concurrent.ScheduledFuture<?>shutdownFutureprivate KeepAliveManager.Statestateprivate com.google.common.base.Stopwatchstopwatch
-
Constructor Summary
Constructors Constructor Description KeepAliveManager(KeepAliveManager.KeepAlivePinger keepAlivePinger, java.util.concurrent.ScheduledExecutorService scheduler, long keepAliveTimeInNanos, long keepAliveTimeoutInNanos, boolean keepAliveDuringTransportIdle)Creates a KeepAliverManager.KeepAliveManager(KeepAliveManager.KeepAlivePinger keepAlivePinger, java.util.concurrent.ScheduledExecutorService scheduler, com.google.common.base.Stopwatch stopwatch, long keepAliveTimeInNanos, long keepAliveTimeoutInNanos, boolean keepAliveDuringTransportIdle)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static longclampKeepAliveTimeInNanos(long keepAliveTimeInNanos)Bumps keepalive time to 10 seconds if the specified value was smaller than that.static longclampKeepAliveTimeoutInNanos(long keepAliveTimeoutInNanos)Bumps keepalive timeout to 10 milliseconds if the specified value was smaller than that.voidonDataReceived()Transport has received some data so that we can delay sending keepalives.voidonTransportActive()Transport has active streams.voidonTransportIdle()Transport has finished all streams.voidonTransportStarted()Start keepalive monitoring.voidonTransportTermination()Transport is being terminated.
-
-
-
Field Detail
-
MIN_KEEPALIVE_TIME_NANOS
private static final long MIN_KEEPALIVE_TIME_NANOS
-
MIN_KEEPALIVE_TIMEOUT_NANOS
private static final long MIN_KEEPALIVE_TIMEOUT_NANOS
-
scheduler
private final java.util.concurrent.ScheduledExecutorService scheduler
-
stopwatch
private final com.google.common.base.Stopwatch stopwatch
-
keepAlivePinger
private final KeepAliveManager.KeepAlivePinger keepAlivePinger
-
keepAliveDuringTransportIdle
private final boolean keepAliveDuringTransportIdle
-
state
private KeepAliveManager.State state
-
shutdownFuture
private java.util.concurrent.ScheduledFuture<?> shutdownFuture
-
pingFuture
private java.util.concurrent.ScheduledFuture<?> pingFuture
-
shutdown
private final java.lang.Runnable shutdown
-
sendPing
private final java.lang.Runnable sendPing
-
keepAliveTimeInNanos
private final long keepAliveTimeInNanos
-
keepAliveTimeoutInNanos
private final long keepAliveTimeoutInNanos
-
-
Constructor Detail
-
KeepAliveManager
public KeepAliveManager(KeepAliveManager.KeepAlivePinger keepAlivePinger, java.util.concurrent.ScheduledExecutorService scheduler, long keepAliveTimeInNanos, long keepAliveTimeoutInNanos, boolean keepAliveDuringTransportIdle)
Creates a KeepAliverManager.
-
KeepAliveManager
KeepAliveManager(KeepAliveManager.KeepAlivePinger keepAlivePinger, java.util.concurrent.ScheduledExecutorService scheduler, com.google.common.base.Stopwatch stopwatch, long keepAliveTimeInNanos, long keepAliveTimeoutInNanos, boolean keepAliveDuringTransportIdle)
-
-
Method Detail
-
onTransportStarted
public void onTransportStarted()
Start keepalive monitoring.
-
onDataReceived
public void onDataReceived()
Transport has received some data so that we can delay sending keepalives.
-
onTransportActive
public void onTransportActive()
Transport has active streams. Start sending keepalives if necessary.
-
onTransportIdle
public void onTransportIdle()
Transport has finished all streams.
-
onTransportTermination
public void onTransportTermination()
Transport is being terminated. We no longer need to do keepalives.
-
clampKeepAliveTimeInNanos
public static long clampKeepAliveTimeInNanos(long keepAliveTimeInNanos)
Bumps keepalive time to 10 seconds if the specified value was smaller than that.
-
clampKeepAliveTimeoutInNanos
public static long clampKeepAliveTimeoutInNanos(long keepAliveTimeoutInNanos)
Bumps keepalive timeout to 10 milliseconds if the specified value was smaller than that.
-
-