Channel that provides lifecycle management.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public abstract boolean | Returns: whether the channel is terminated, as would be done byisTerminated().Waits for the channel to become terminated, giving up if the timeout is reached. |
| public void | enterIdle()
Invoking this method moves the channel into the IDLE state and triggers tear-down of the channel's name resolver and load balancer, while still allowing on-going RPCs on the channel to continue. |
| public ConnectivityState | getState(boolean
if requestConnection)true, the channel will try to make a connection if it is
currently IDLEGets the current connectivity state. |
| public abstract boolean | |
| public abstract boolean | |
| public void | notifyWhenStateChanged(ConnectivityState
the assumed current state, typically just returned by source, Runnable getStatethe one-off callback callback)Registers a one-off callback that will be run if the connectivity state of the channel diverges
from the given |
| public void | resetConnectBackoff()
For subchannels that are in TRANSIENT_FAILURE state, short-circuit the backoff timer and make them reconnect immediately. |
| public abstract ManagedChannel | Returns: thisInitiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled. |
| public abstract ManagedChannel | Returns: thisInitiates a forceful shutdown in which preexisting and new calls are cancelled. |
| ManagedChannel | back to summary |
|---|---|
| public ManagedChannel() | |
| awaitTermination | back to summary |
|---|---|
| public abstract boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException Waits for the channel to become terminated, giving up if the timeout is reached.
| |
| enterIdle | back to summary |
|---|---|
| public void enterIdle() Invoking this method moves the channel into the IDLE state and triggers tear-down of the channel's name resolver and load balancer, while still allowing on-going RPCs on the channel to continue. New RPCs on the channel will trigger creation of a new connection. This is primarily intended for Android users when a device is transitioning from a cellular to a wifi connection. The OS will issue a notification that a new network (wifi) has been made the default, but for approximately 30 seconds the device will maintain both the cellular and wifi connections. Apps may invoke this method to ensure that new RPCs are created using the new default wifi network, rather than the soon-to-be-disconnected cellular network. No-op if not supported by implementation.
| |
| getState | back to summary |
|---|---|
| public ConnectivityState getState(boolean requestConnection) Gets the current connectivity state. Note the result may soon become outdated. Note that the core library did not provide an implementation of this method until v1.6.1.
| |
| isShutdown | back to summary |
|---|---|
| public abstract boolean isShutdown() Returns whether the channel is shutdown. Shutdown channels immediately cancel any new calls, but may still have some calls being processed.
| |
| isTerminated | back to summary |
|---|---|
| public abstract boolean isTerminated() Returns whether the channel is terminated. Terminated channels have no running calls and relevant resources released (like TCP connections).
| |
| notifyWhenStateChanged | back to summary |
|---|---|
| public void notifyWhenStateChanged(ConnectivityState source, Runnable callback) Registers a one-off callback that will be run if the connectivity state of the channel diverges
from the given There is an inherent race between the notification to Note that the core library did not provide an implementation of this method until v1.6.1.
| |
| resetConnectBackoff | back to summary |
|---|---|
| public void resetConnectBackoff() For subchannels that are in TRANSIENT_FAILURE state, short-circuit the backoff timer and make
them reconnect immediately. May also attempt to invoke This is primarily intended for Android users, where the network may experience frequent temporary drops. Rather than waiting for gRPC's name resolution and reconnect timers to elapse before reconnecting, the app may use this method as a mechanism to notify gRPC that the network is now available and a reconnection attempt may occur immediately. No-op if not supported by the implementation.
| |
| shutdown | back to summary |
|---|---|
| public abstract ManagedChannel shutdown() Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.
| |
| shutdownNow | back to summary |
|---|---|
| public abstract ManagedChannel shutdownNow() Initiates a forceful shutdown in which preexisting and new calls are cancelled. Although
forceful, the shutdown process is still not instantaneous;
| |