Class ManagedChannelImpl.SubchannelImpl
- Enclosing class:
ManagedChannelImpl
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) List
<EquivalentAddressGroup> (package private) final LoadBalancer.CreateSubchannelArgs
(package private) SynchronizationContext.ScheduledHandle
(package private) boolean
(package private) boolean
(package private) InternalSubchannel
(package private) final ChannelLoggerImpl
(package private) final InternalLogId
(package private) final ChannelTracer
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(Internal use only) returns aChannel
that is backed by this Subchannel.Returns the addresses that this Subchannel is bound to.The same attributes passed toHelper.createSubchannel()
.Returns aChannelLogger
for this Subchannel.(Internal use only) returns attributes of the address subchannel is connected to.(package private) InternalInstrumented
<InternalChannelz.ChannelStats> Returns the InternalSubchannel as anInstrumented<T>
for the sole purpose of channelz unit tests.(Internal use only) returns an object that represents the underlying subchannel that is used by the Channel for sending RPCs when thisLoadBalancer.Subchannel
is picked.void
Asks the Subchannel to create a connection (aka transport), if there isn't an active one.void
shutdown()
Shuts down the Subchannel.void
start
(LoadBalancer.SubchannelStateListener listener) Starts the Subchannel.private List
<EquivalentAddressGroup> toString()
void
Replaces the existing addresses used with thisSubchannel
.Methods inherited from class io.grpc.LoadBalancer.Subchannel
getAddresses
-
Field Details
-
args
-
subchannelLogId
-
subchannelLogger
-
subchannelTracer
-
addressGroups
List<EquivalentAddressGroup> addressGroups -
subchannel
InternalSubchannel subchannel -
started
boolean started -
shutdown
boolean shutdown -
delayedShutdownTask
SynchronizationContext.ScheduledHandle delayedShutdownTask
-
-
Constructor Details
-
SubchannelImpl
SubchannelImpl(LoadBalancer.CreateSubchannelArgs args)
-
-
Method Details
-
start
Description copied from class:LoadBalancer.Subchannel
Starts the Subchannel. Can only be called once.Must be called prior to any other method on this class, except for
LoadBalancer.Subchannel.shutdown()
which may be called at any time.Must be called from the
Synchronization Context
, otherwise it may throw. See #5015 for more discussions.- Overrides:
start
in classLoadBalancer.Subchannel
- Parameters:
listener
- receives state updates for this Subchannel.
-
getInstrumentedInternalSubchannel
InternalInstrumented<InternalChannelz.ChannelStats> getInstrumentedInternalSubchannel()Description copied from class:AbstractSubchannel
Returns the InternalSubchannel as anInstrumented<T>
for the sole purpose of channelz unit tests.- Specified by:
getInstrumentedInternalSubchannel
in classAbstractSubchannel
-
shutdown
public void shutdown()Description copied from class:LoadBalancer.Subchannel
Shuts down the Subchannel. After this method is called, this Subchannel should no longer be returned by the latestpicker
, and can be safely discarded.Calling it on an already shut-down Subchannel has no effect.
It should be called from the Synchronization Context. Currently will log a warning if violated. It will become an exception eventually. See #5015 for the background.
- Specified by:
shutdown
in classLoadBalancer.Subchannel
-
requestConnection
public void requestConnection()Description copied from class:LoadBalancer.Subchannel
Asks the Subchannel to create a connection (aka transport), if there isn't an active one.It should be called from the Synchronization Context. Currently will log a warning if violated. It will become an exception eventually. See #5015 for the background.
- Specified by:
requestConnection
in classLoadBalancer.Subchannel
-
getAllAddresses
Description copied from class:LoadBalancer.Subchannel
Returns the addresses that this Subchannel is bound to. The returned list will not be empty.It should be called from the Synchronization Context. Currently will log a warning if violated. It will become an exception eventually. See #5015 for the background.
- Overrides:
getAllAddresses
in classLoadBalancer.Subchannel
-
getAttributes
Description copied from class:LoadBalancer.Subchannel
The same attributes passed toHelper.createSubchannel()
. LoadBalancer can use it to attach additional information here, e.g., the shard this Subchannel belongs to.- Specified by:
getAttributes
in classLoadBalancer.Subchannel
-
toString
-
asChannel
Description copied from class:LoadBalancer.Subchannel
(Internal use only) returns aChannel
that is backed by this Subchannel. This allows a LoadBalancer to issue its own RPCs for auxiliary purposes, such as health-checking, on already-established connections. This channel has certain restrictions:- It can issue RPCs only if the Subchannel is
READY
. IfChannel.newCall(io.grpc.MethodDescriptor<RequestT, ResponseT>, io.grpc.CallOptions)
is called when the Subchannel is notREADY
, the RPC will fail immediately. - It doesn't support
wait-for-ready
RPCs. Such RPCs will fail immediately.
RPCs made on this Channel is not counted when determining ManagedChannel's
idle mode
. In other words, they won't prevent ManagedChannel from entering idle mode.Warning: RPCs made on this channel will prevent a shut-down transport from terminating. If you make long-running RPCs, you need to make sure they will finish in time after the Subchannel has transitioned away from
READY
state (notified throughLoadBalancer.handleSubchannelState(io.grpc.LoadBalancer.Subchannel, io.grpc.ConnectivityStateInfo)
).Warning: this is INTERNAL API, is not supposed to be used by external users, and may change without notice. If you think you must use it, please file an issue.
- Overrides:
asChannel
in classLoadBalancer.Subchannel
- It can issue RPCs only if the Subchannel is
-
getInternalSubchannel
Description copied from class:LoadBalancer.Subchannel
(Internal use only) returns an object that represents the underlying subchannel that is used by the Channel for sending RPCs when thisLoadBalancer.Subchannel
is picked. This is an opaque object that is both provided and consumed by the Channel. Its type is notSubchannel
.Warning: this is INTERNAL API, is not supposed to be used by external users, and may change without notice. If you think you must use it, please file an issue and we can consider removing its "internal" status.
- Overrides:
getInternalSubchannel
in classLoadBalancer.Subchannel
-
getChannelLogger
Description copied from class:LoadBalancer.Subchannel
Returns aChannelLogger
for this Subchannel.- Overrides:
getChannelLogger
in classLoadBalancer.Subchannel
-
updateAddresses
Description copied from class:LoadBalancer.Subchannel
Replaces the existing addresses used with thisSubchannel
. If the new and old addresses overlap, the Subchannel can continue using an existing connection.It must be called from the Synchronization Context or will throw.
- Overrides:
updateAddresses
in classLoadBalancer.Subchannel
-
getConnectedAddressAttributes
Description copied from class:LoadBalancer.Subchannel
(Internal use only) returns attributes of the address subchannel is connected to.Warning: this is INTERNAL API, is not supposed to be used by external users, and may change without notice. If you think you must use it, please file an issue and we can consider removing its "internal" status.
- Overrides:
getConnectedAddressAttributes
in classLoadBalancer.Subchannel
-
stripOverrideAuthorityAttributes
private List<EquivalentAddressGroup> stripOverrideAuthorityAttributes(List<EquivalentAddressGroup> eags)
-