@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1771") public abstract class ForwardingSubchannel extends LoadBalancer.Subchannel
Constructor and Description |
---|
ForwardingSubchannel() |
Modifier and Type | Method and Description |
---|---|
Channel |
asChannel()
(Internal use only) returns a
Channel that is backed by this Subchannel. |
protected abstract LoadBalancer.Subchannel |
delegate()
Returns the underlying Subchannel.
|
List<EquivalentAddressGroup> |
getAllAddresses()
Returns the addresses that this Subchannel is bound to.
|
Attributes |
getAttributes()
The same attributes passed to
Helper.createSubchannel() . |
ChannelLogger |
getChannelLogger()
Returns a
ChannelLogger for this Subchannel. |
Object |
getInternalSubchannel()
(Internal use only) returns an object that represents the underlying subchannel that is used
by the Channel for sending RPCs when this
LoadBalancer.Subchannel is picked. |
void |
requestConnection()
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.
|
String |
toString() |
void |
updateAddresses(List<EquivalentAddressGroup> addrs)
Replaces the existing addresses used with this
Subchannel . |
getAddresses
protected abstract LoadBalancer.Subchannel delegate()
public void start(LoadBalancer.SubchannelStateListener listener)
LoadBalancer.Subchannel
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.
start
in class LoadBalancer.Subchannel
listener
- receives state updates for this Subchannel.public void shutdown()
LoadBalancer.Subchannel
picker
, 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.
shutdown
in class LoadBalancer.Subchannel
public void requestConnection()
LoadBalancer.Subchannel
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.
requestConnection
in class LoadBalancer.Subchannel
public List<EquivalentAddressGroup> getAllAddresses()
LoadBalancer.Subchannel
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.
getAllAddresses
in class LoadBalancer.Subchannel
public Attributes getAttributes()
LoadBalancer.Subchannel
Helper.createSubchannel()
.
LoadBalancer can use it to attach additional information here, e.g., the shard this
Subchannel belongs to.getAttributes
in class LoadBalancer.Subchannel
public Channel asChannel()
LoadBalancer.Subchannel
Channel
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:
READY
. If Channel.newCall(io.grpc.MethodDescriptor<RequestT, ResponseT>, io.grpc.CallOptions)
is called when the Subchannel is not READY
, the RPC will fail
immediately.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 through LoadBalancer.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.
asChannel
in class LoadBalancer.Subchannel
public ChannelLogger getChannelLogger()
LoadBalancer.Subchannel
ChannelLogger
for this Subchannel.getChannelLogger
in class LoadBalancer.Subchannel
public Object getInternalSubchannel()
LoadBalancer.Subchannel
LoadBalancer.Subchannel
is picked. This is an opaque
object that is both provided and consumed by the Channel. Its type is not
Subchannel
.
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.
getInternalSubchannel
in class LoadBalancer.Subchannel
public void updateAddresses(List<EquivalentAddressGroup> addrs)
LoadBalancer.Subchannel
Subchannel
. 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.
updateAddresses
in class LoadBalancer.Subchannel