Package io.grpc.internal
Class ConnectivityStateManager
- java.lang.Object
-
- io.grpc.internal.ConnectivityStateManager
-
@NotThreadSafe final class ConnectivityStateManager extends java.lang.Object
Manages connectivity states of the channel. Used forManagedChannel.getState(boolean)
to read the current state of the channel, forManagedChannel.notifyWhenStateChanged(io.grpc.ConnectivityState, java.lang.Runnable)
to add listeners to state change events, and forLoadBalancer.Helper#updateBalancingState
to update the state and run thegotoState(io.grpc.ConnectivityState)
s.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
ConnectivityStateManager.Listener
-
Field Summary
Fields Modifier and Type Field Description private java.util.ArrayList<ConnectivityStateManager.Listener>
listeners
private ConnectivityState
state
-
Constructor Summary
Constructors Constructor Description ConnectivityStateManager()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) ConnectivityState
getState()
Gets the current connectivity state of the channel.(package private) void
gotoState(ConnectivityState newState)
Connectivity state is changed to the specified value.(package private) void
notifyWhenStateChanged(java.lang.Runnable callback, java.util.concurrent.Executor executor, ConnectivityState source)
Adds a listener for state change event.
-
-
-
Field Detail
-
listeners
private java.util.ArrayList<ConnectivityStateManager.Listener> listeners
-
state
private volatile ConnectivityState state
-
-
Method Detail
-
notifyWhenStateChanged
void notifyWhenStateChanged(java.lang.Runnable callback, java.util.concurrent.Executor executor, ConnectivityState source)
Adds a listener for state change event.The
executor
must be one that can run RPC call listeners.
-
gotoState
void gotoState(@Nonnull ConnectivityState newState)
Connectivity state is changed to the specified value. Will trigger some notifications that have been registered earlier byManagedChannel.notifyWhenStateChanged(io.grpc.ConnectivityState, java.lang.Runnable)
.
-
getState
ConnectivityState getState()
Gets the current connectivity state of the channel. This method is threadsafe.
-
-