Package io.grpc.internal
Class OobChannel
- java.lang.Object
-
- io.grpc.Channel
-
- io.grpc.ManagedChannel
-
- io.grpc.internal.OobChannel
-
- All Implemented Interfaces:
InternalInstrumented<InternalChannelz.ChannelStats>
,InternalWithLogId
@ThreadSafe final class OobChannel extends ManagedChannel implements InternalInstrumented<InternalChannelz.ChannelStats>
A ManagedChannel backed by a singleInternalSubchannel
and used forLoadBalancer
to its own RPC needs.
-
-
Field Summary
Fields Modifier and Type Field Description private java.lang.String
authority
private CallTracer
channelCallsTracer
private ChannelTracer
channelTracer
private InternalChannelz
channelz
private java.util.concurrent.ScheduledExecutorService
deadlineCancellationExecutor
private DelayedClientTransport
delayedTransport
private java.util.concurrent.Executor
executor
private ObjectPool<? extends java.util.concurrent.Executor>
executorPool
private static java.util.logging.Logger
log
private InternalLogId
logId
private boolean
shutdown
private InternalSubchannel
subchannel
private AbstractSubchannel
subchannelImpl
private LoadBalancer.SubchannelPicker
subchannelPicker
private java.util.concurrent.CountDownLatch
terminatedLatch
private TimeProvider
timeProvider
private ClientCallImpl.ClientStreamProvider
transportProvider
-
Constructor Summary
Constructors Constructor Description OobChannel(java.lang.String authority, ObjectPool<? extends java.util.concurrent.Executor> executorPool, java.util.concurrent.ScheduledExecutorService deadlineCancellationExecutor, SynchronizationContext syncContext, CallTracer callsTracer, ChannelTracer channelTracer, InternalChannelz channelz, TimeProvider timeProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
authority()
The authority of the destination this channel connects to.boolean
awaitTermination(long time, java.util.concurrent.TimeUnit unit)
Waits for the channel to become terminated, giving up if the timeout is reached.(package private) InternalSubchannel
getInternalSubchannel()
InternalLogId
getLogId()
Returns an ID that is primarily used in debug logs.ConnectivityState
getState(boolean requestConnectionIgnored)
Gets the current connectivity state.com.google.common.util.concurrent.ListenableFuture<InternalChannelz.ChannelStats>
getStats()
Returns the stats object.(package private) LoadBalancer.Subchannel
getSubchannel()
(package private) void
handleSubchannelStateChange(ConnectivityStateInfo newState)
(package private) void
handleSubchannelTerminated()
boolean
isShutdown()
Returns whether the channel is shutdown.boolean
isTerminated()
Returns whether the channel is terminated.<RequestT,ResponseT>
ClientCall<RequestT,ResponseT>newCall(MethodDescriptor<RequestT,ResponseT> methodDescriptor, CallOptions callOptions)
Create aClientCall
to the remote operation specified by the givenMethodDescriptor
.void
resetConnectBackoff()
For subchannels that are in TRANSIENT_FAILURE state, short-circuit the backoff timer and make them reconnect immediately.(package private) void
setSubchannel(InternalSubchannel subchannel)
ManagedChannel
shutdown()
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.ManagedChannel
shutdownNow()
Initiates a forceful shutdown in which preexisting and new calls are cancelled.java.lang.String
toString()
(package private) void
updateAddresses(java.util.List<EquivalentAddressGroup> eag)
-
Methods inherited from class io.grpc.ManagedChannel
enterIdle, notifyWhenStateChanged
-
-
-
-
Field Detail
-
log
private static final java.util.logging.Logger log
-
subchannel
private InternalSubchannel subchannel
-
subchannelImpl
private AbstractSubchannel subchannelImpl
-
subchannelPicker
private LoadBalancer.SubchannelPicker subchannelPicker
-
logId
private final InternalLogId logId
-
authority
private final java.lang.String authority
-
delayedTransport
private final DelayedClientTransport delayedTransport
-
channelz
private final InternalChannelz channelz
-
executorPool
private final ObjectPool<? extends java.util.concurrent.Executor> executorPool
-
executor
private final java.util.concurrent.Executor executor
-
deadlineCancellationExecutor
private final java.util.concurrent.ScheduledExecutorService deadlineCancellationExecutor
-
terminatedLatch
private final java.util.concurrent.CountDownLatch terminatedLatch
-
shutdown
private volatile boolean shutdown
-
channelCallsTracer
private final CallTracer channelCallsTracer
-
channelTracer
private final ChannelTracer channelTracer
-
timeProvider
private final TimeProvider timeProvider
-
transportProvider
private final ClientCallImpl.ClientStreamProvider transportProvider
-
-
Constructor Detail
-
OobChannel
OobChannel(java.lang.String authority, ObjectPool<? extends java.util.concurrent.Executor> executorPool, java.util.concurrent.ScheduledExecutorService deadlineCancellationExecutor, SynchronizationContext syncContext, CallTracer callsTracer, ChannelTracer channelTracer, InternalChannelz channelz, TimeProvider timeProvider)
-
-
Method Detail
-
setSubchannel
void setSubchannel(InternalSubchannel subchannel)
-
updateAddresses
void updateAddresses(java.util.List<EquivalentAddressGroup> eag)
-
newCall
public <RequestT,ResponseT> ClientCall<RequestT,ResponseT> newCall(MethodDescriptor<RequestT,ResponseT> methodDescriptor, CallOptions callOptions)
Description copied from class:Channel
Create aClientCall
to the remote operation specified by the givenMethodDescriptor
. The returnedClientCall
does not trigger any remote behavior untilClientCall.start(ClientCall.Listener, Metadata)
is invoked.- Specified by:
newCall
in classChannel
- Parameters:
methodDescriptor
- describes the name and parameter types of the operation to call.callOptions
- runtime options to be applied to this call.- Returns:
- a
ClientCall
bound to the specified method.
-
authority
public java.lang.String authority()
Description copied from class:Channel
The authority of the destination this channel connects to. Typically this is in the formathost:port
.
-
isTerminated
public boolean isTerminated()
Description copied from class:ManagedChannel
Returns whether the channel is terminated. Terminated channels have no running calls and relevant resources released (like TCP connections).- Specified by:
isTerminated
in classManagedChannel
- See Also:
ManagedChannel.isShutdown()
-
awaitTermination
public boolean awaitTermination(long time, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException
Description copied from class:ManagedChannel
Waits for the channel to become terminated, giving up if the timeout is reached.- Specified by:
awaitTermination
in classManagedChannel
- Returns:
- whether the channel is terminated, as would be done by
ManagedChannel.isTerminated()
. - Throws:
java.lang.InterruptedException
-
getState
public ConnectivityState getState(boolean requestConnectionIgnored)
Description copied from class:ManagedChannel
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.
- Overrides:
getState
in classManagedChannel
- Parameters:
requestConnectionIgnored
- iftrue
, the channel will try to make a connection if it is currently IDLE
-
shutdown
public ManagedChannel shutdown()
Description copied from class:ManagedChannel
Initiates an orderly shutdown in which preexisting calls continue but new calls are immediately cancelled.- Specified by:
shutdown
in classManagedChannel
- Returns:
- this
-
isShutdown
public boolean isShutdown()
Description copied from class:ManagedChannel
Returns whether the channel is shutdown. Shutdown channels immediately cancel any new calls, but may still have some calls being processed.- Specified by:
isShutdown
in classManagedChannel
- See Also:
ManagedChannel.shutdown()
,ManagedChannel.isTerminated()
-
shutdownNow
public ManagedChannel shutdownNow()
Description copied from class:ManagedChannel
Initiates a forceful shutdown in which preexisting and new calls are cancelled. Although forceful, the shutdown process is still not instantaneous;ManagedChannel.isTerminated()
will likely returnfalse
immediately after this method returns.- Specified by:
shutdownNow
in classManagedChannel
- Returns:
- this
-
handleSubchannelStateChange
void handleSubchannelStateChange(ConnectivityStateInfo newState)
-
handleSubchannelTerminated
void handleSubchannelTerminated()
-
getSubchannel
LoadBalancer.Subchannel getSubchannel()
-
getInternalSubchannel
InternalSubchannel getInternalSubchannel()
-
getStats
public com.google.common.util.concurrent.ListenableFuture<InternalChannelz.ChannelStats> getStats()
Description copied from interface:InternalInstrumented
Returns the stats object.- Specified by:
getStats
in interfaceInternalInstrumented<InternalChannelz.ChannelStats>
-
getLogId
public InternalLogId getLogId()
Description copied from interface:InternalWithLogId
Returns an ID that is primarily used in debug logs. It usually contains the class name and a numeric ID that is unique among the instances.The subclasses of this interface usually want to include the log ID in their
Object.toString()
results.- Specified by:
getLogId
in interfaceInternalWithLogId
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
resetConnectBackoff
public void resetConnectBackoff()
Description copied from class:ManagedChannel
For subchannels that are in TRANSIENT_FAILURE state, short-circuit the backoff timer and make them reconnect immediately. May also attempt to invokeNameResolver.refresh()
.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.
- Overrides:
resetConnectBackoff
in classManagedChannel
-
-