Class ForwardingSubchannel
- java.lang.Object
-
- io.grpc.LoadBalancer.Subchannel
-
- io.grpc.util.ForwardingSubchannel
-
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1771") public abstract class ForwardingSubchannel extends LoadBalancer.Subchannel
-
-
Constructor Summary
Constructors Constructor Description ForwardingSubchannel()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description ChannelasChannel()(Internal use only) returns aChannelthat is backed by this Subchannel.protected abstract LoadBalancer.Subchanneldelegate()Returns the underlying Subchannel.List<EquivalentAddressGroup>getAllAddresses()Returns the addresses that this Subchannel is bound to.AttributesgetAttributes()The same attributes passed toHelper.createSubchannel().ChannelLoggergetChannelLogger()Returns aChannelLoggerfor this Subchannel.AttributesgetConnectedAddressAttributes()(Internal use only) returns attributes of the address subchannel is connected to.ObjectgetInternalSubchannel()(Internal use only) returns an object that represents the underlying subchannel that is used by the Channel for sending RPCs when thisLoadBalancer.Subchannelis picked.voidrequestConnection()Asks the Subchannel to create a connection (aka transport), if there isn't an active one.voidshutdown()Shuts down the Subchannel.voidstart(LoadBalancer.SubchannelStateListener listener)Starts the Subchannel.StringtoString()voidupdateAddresses(List<EquivalentAddressGroup> addrs)Replaces the existing addresses used with thisSubchannel.-
Methods inherited from class io.grpc.LoadBalancer.Subchannel
getAddresses
-
-
-
-
Method Detail
-
delegate
protected abstract LoadBalancer.Subchannel delegate()
Returns the underlying Subchannel.
-
start
public void start(LoadBalancer.SubchannelStateListener listener)
Description copied from class:LoadBalancer.SubchannelStarts 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:
startin classLoadBalancer.Subchannel- Parameters:
listener- receives state updates for this Subchannel.
-
shutdown
public void shutdown()
Description copied from class:LoadBalancer.SubchannelShuts 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:
shutdownin classLoadBalancer.Subchannel
-
requestConnection
public void requestConnection()
Description copied from class:LoadBalancer.SubchannelAsks 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:
requestConnectionin classLoadBalancer.Subchannel
-
getAllAddresses
public List<EquivalentAddressGroup> getAllAddresses()
Description copied from class:LoadBalancer.SubchannelReturns 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:
getAllAddressesin classLoadBalancer.Subchannel
-
getAttributes
public Attributes getAttributes()
Description copied from class:LoadBalancer.SubchannelThe same attributes passed toHelper.createSubchannel(). LoadBalancer can use it to attach additional information here, e.g., the shard this Subchannel belongs to.- Specified by:
getAttributesin classLoadBalancer.Subchannel
-
asChannel
public Channel asChannel()
Description copied from class:LoadBalancer.Subchannel(Internal use only) returns aChannelthat 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-readyRPCs. 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
READYstate (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:
asChannelin classLoadBalancer.Subchannel
- It can issue RPCs only if the Subchannel is
-
getChannelLogger
public ChannelLogger getChannelLogger()
Description copied from class:LoadBalancer.SubchannelReturns aChannelLoggerfor this Subchannel.- Overrides:
getChannelLoggerin classLoadBalancer.Subchannel
-
getInternalSubchannel
public Object 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.Subchannelis 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:
getInternalSubchannelin classLoadBalancer.Subchannel
-
updateAddresses
public void updateAddresses(List<EquivalentAddressGroup> addrs)
Description copied from class:LoadBalancer.SubchannelReplaces 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:
updateAddressesin classLoadBalancer.Subchannel
-
getConnectedAddressAttributes
public Attributes 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:
getConnectedAddressAttributesin classLoadBalancer.Subchannel
-
-