Class ForwardingLoadBalancerHelper
- Direct Known Subclasses:
CachingRlsLbClient.RlsLbHelper, ChildLoadBalancerHelper, HealthCheckingLoadBalancerFactory.HelperImpl, HealthProducerHelper, LbPolicyConfiguration.ChildPolicyWrapper.ChildPolicyReportingHelper, MultiChildLoadBalancer.ChildLbState.ChildLbStateHelper, OutlierDetectionLoadBalancer.ChildHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateOobChannel(EquivalentAddressGroup eag, String authority) Out-of-band channel for LoadBalancer’s own RPC needs, e.g., talking to an external load-balancer service.createOobChannel(List<EquivalentAddressGroup> eag, String authority) Accept a list of EAG for multiple authorities: https://github.com/grpc/grpc-java/issues/4618createResolvingOobChannel(String target) Creates an out-of-band channel for LoadBalancer's own RPC needs, e.g., talking to an external load-balancer service, that is specified by a target string.Deprecated.createResolvingOobChannelBuilder(String target, ChannelCredentials creds) Creates an out-of-band channel builder for LoadBalancer's own RPC needs, e.g., talking to an external load-balancer service, that is specified by a target string and credentials.Creates a Subchannel, which is a logical connection to the given group of addresses which are considered equivalent.protected abstract LoadBalancer.Helperdelegate()Returns the underlying helper.Returns the authority string of the channel, which is derived from the DNS-style target name.Returns the ChannelCredentials used to construct the channel, without bearer tokens.Returns theChannelLoggerfor the Channel served by this LoadBalancer.Returns the target string of the channel, guaranteed to include its scheme.Returns theMetricRecorderthat the channel uses to record metrics.Returns theNameResolver.Argsthat the Channel uses to createNameResolvers.Returns theNameResolverRegistrythat the Channel uses to look forNameResolvers.Returns aScheduledExecutorServicefor scheduling delayed tasks.Returns aSynchronizationContextthat runs tasks in the same Synchronization Context as that the callback methods on theLoadBalancerinterface are run in.Returns the UNSAFE ChannelCredentials used to construct the channel, including bearer tokens.voidDeprecated.voidCallNameResolver.refresh()on the channel's resolver.toString()voidupdateBalancingState(ConnectivityState newState, LoadBalancer.SubchannelPicker newPicker) Set a new state with a new picker to the channel.voidupdateOobChannelAddresses(ManagedChannel channel, EquivalentAddressGroup eag) Updates the addresses used for connections in theChannelthat was created byLoadBalancer.Helper.createOobChannel(EquivalentAddressGroup, String).voidupdateOobChannelAddresses(ManagedChannel channel, List<EquivalentAddressGroup> eag) Updates the addresses with a new EAG list.
-
Constructor Details
-
ForwardingLoadBalancerHelper
public ForwardingLoadBalancerHelper()
-
-
Method Details
-
delegate
Returns the underlying helper. -
createSubchannel
Description copied from class:LoadBalancer.HelperCreates a Subchannel, which is a logical connection to the given group of addresses which are considered equivalent. Theattrsare custom attributes associated with this Subchannel, and can be accessed later throughSubchannel.getAttributes().The LoadBalancer is responsible for closing unused Subchannels, and closing all Subchannels within
LoadBalancer.shutdown().It must be called from
the Synchronization Context- Overrides:
createSubchannelin classLoadBalancer.Helper- Returns:
- Must return a valid Subchannel object, may not return null.
-
createOobChannel
Description copied from class:LoadBalancer.HelperOut-of-band channel for LoadBalancer’s own RPC needs, e.g., talking to an external load-balancer service.The LoadBalancer is responsible for closing unused OOB channels, and closing all OOB channels within
LoadBalancer.shutdown().- Specified by:
createOobChannelin classLoadBalancer.Helper
-
createOobChannel
Description copied from class:LoadBalancer.HelperAccept a list of EAG for multiple authorities: https://github.com/grpc/grpc-java/issues/4618- Overrides:
createOobChannelin classLoadBalancer.Helper
-
updateOobChannelAddresses
Description copied from class:LoadBalancer.HelperUpdates the addresses used for connections in theChannelthat was created byLoadBalancer.Helper.createOobChannel(EquivalentAddressGroup, String). This is superior toLoadBalancer.Helper.createOobChannel(EquivalentAddressGroup, String)when the old and new addresses overlap, since the channel can continue using an existing connection.- Overrides:
updateOobChannelAddressesin classLoadBalancer.Helper
-
updateOobChannelAddresses
Description copied from class:LoadBalancer.HelperUpdates the addresses with a new EAG list. Connection is continued when old and new addresses overlap.- Overrides:
updateOobChannelAddressesin classLoadBalancer.Helper
-
createResolvingOobChannelBuilder
Deprecated.Description copied from class:LoadBalancer.HelperCreates an out-of-band channel builder for LoadBalancer's own RPC needs, e.g., talking to an external load-balancer service, that is specified by a target string. See the documentation onManagedChannelBuilder.forTarget(String)for the format of a target string.The target string will be resolved by a
NameResolvercreated according to the target string.The returned oob-channel builder defaults to use the same authority and ChannelCredentials (without bearer tokens) as the parent channel's for authentication. This is different from
LoadBalancer.Helper.createResolvingOobChannelBuilder(String, ChannelCredentials).The LoadBalancer is responsible for closing unused OOB channels, and closing all OOB channels within
LoadBalancer.shutdown().- Overrides:
createResolvingOobChannelBuilderin classLoadBalancer.Helper
-
createResolvingOobChannelBuilder
public ManagedChannelBuilder<?> createResolvingOobChannelBuilder(String target, ChannelCredentials creds) Description copied from class:LoadBalancer.HelperCreates an out-of-band channel builder for LoadBalancer's own RPC needs, e.g., talking to an external load-balancer service, that is specified by a target string and credentials. See the documentation onGrpc.newChannelBuilder(String, ChannelCredentials)for the format of a target string.The target string will be resolved by a
NameResolvercreated according to the target string.The LoadBalancer is responsible for closing unused OOB channels, and closing all OOB channels within
LoadBalancer.shutdown().- Overrides:
createResolvingOobChannelBuilderin classLoadBalancer.Helper
-
createResolvingOobChannel
Description copied from class:LoadBalancer.HelperCreates an out-of-band channel for LoadBalancer's own RPC needs, e.g., talking to an external load-balancer service, that is specified by a target string. See the documentation onManagedChannelBuilder.forTarget(String)for the format of a target string.The target string will be resolved by a
NameResolvercreated according to the target string.The LoadBalancer is responsible for closing unused OOB channels, and closing all OOB channels within
LoadBalancer.shutdown().- Overrides:
createResolvingOobChannelin classLoadBalancer.Helper
-
updateBalancingState
public void updateBalancingState(ConnectivityState newState, LoadBalancer.SubchannelPicker newPicker) Description copied from class:LoadBalancer.HelperSet a new state with a new picker to the channel.When a new picker is provided via
updateBalancingState(), the channel will apply the picker on all buffered RPCs, by callingLoadBalancer.SubchannelPicker.pickSubchannel(LoadBalancer.PickSubchannelArgs).The channel will hold the picker and use it for all RPCs, until
updateBalancingState()is called again and a new picker replaces the old one. IfupdateBalancingState()has never been called, the channel will buffer all RPCs until a picker is provided.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.
The passed state will be the channel's new state. The SHUTDOWN state should not be passed and its behavior is undefined.
- Specified by:
updateBalancingStatein classLoadBalancer.Helper
-
refreshNameResolution
public void refreshNameResolution()Description copied from class:LoadBalancer.HelperCallNameResolver.refresh()on the channel's resolver.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:
refreshNameResolutionin classLoadBalancer.Helper
-
ignoreRefreshNameResolutionCheck
Deprecated.Description copied from class:LoadBalancer.HelperHistorically the channel automatically refreshes name resolution if any subchannel connection is broken. It's transitioning to let load balancers make the decision. To avoid silent breakages, the channel checks ifLoadBalancer.Helper.refreshNameResolution()is called by the load balancer. If not, it will do it and log a warning. This will be removed in the future and load balancers are completely responsible for triggering the refresh. See #8088 for the background.This should rarely be used, but sometimes the address for the subchannel wasn't provided by the name resolver and a refresh needs to be directed somewhere else instead. Then you can call this method to disable the short-tem check for detecting LoadBalancers that need to be updated for the new expected behavior.
- Overrides:
ignoreRefreshNameResolutionCheckin classLoadBalancer.Helper
-
getAuthority
Description copied from class:LoadBalancer.HelperReturns the authority string of the channel, which is derived from the DNS-style target name. If overridden by a load balancer,LoadBalancer.Helper.getUnsafeChannelCredentials()must also be overridden to callLoadBalancer.Helper.getChannelCredentials()or provide appropriate credentials.- Specified by:
getAuthorityin classLoadBalancer.Helper
-
getChannelTarget
Description copied from class:LoadBalancer.HelperReturns the target string of the channel, guaranteed to include its scheme.- Overrides:
getChannelTargetin classLoadBalancer.Helper
-
getChannelCredentials
Description copied from class:LoadBalancer.HelperReturns the ChannelCredentials used to construct the channel, without bearer tokens.- Overrides:
getChannelCredentialsin classLoadBalancer.Helper
-
getUnsafeChannelCredentials
Description copied from class:LoadBalancer.HelperReturns the UNSAFE ChannelCredentials used to construct the channel, including bearer tokens. Load balancers should generally have no use for these credentials and use of them is heavily discouraged. These must be used very carefully to avoid sending bearer tokens to untrusted servers as the server could then impersonate the client. Generally it is only safe to use these credentials when communicating with the backend.- Overrides:
getUnsafeChannelCredentialsin classLoadBalancer.Helper
-
getSynchronizationContext
Description copied from class:LoadBalancer.HelperReturns aSynchronizationContextthat runs tasks in the same Synchronization Context as that the callback methods on theLoadBalancerinterface are run in.Pro-tip: in order to call
SynchronizationContext.schedule(Runnable, long, TimeUnit, ScheduledExecutorService), you need to provide aScheduledExecutorService.LoadBalancer.Helper.getScheduledExecutorService()is provided for your convenience.- Overrides:
getSynchronizationContextin classLoadBalancer.Helper
-
getScheduledExecutorService
Description copied from class:LoadBalancer.HelperReturns aScheduledExecutorServicefor scheduling delayed tasks.This service is a shared resource and is only meant for quick tasks. DO NOT block or run time-consuming tasks.
The returned service doesn't support
shutdown()andshutdownNow(). They will throw if called.- Overrides:
getScheduledExecutorServicein classLoadBalancer.Helper
-
getChannelLogger
Description copied from class:LoadBalancer.HelperReturns theChannelLoggerfor the Channel served by this LoadBalancer.- Overrides:
getChannelLoggerin classLoadBalancer.Helper
-
getNameResolverArgs
Description copied from class:LoadBalancer.HelperReturns theNameResolver.Argsthat the Channel uses to createNameResolvers.- Overrides:
getNameResolverArgsin classLoadBalancer.Helper
-
getNameResolverRegistry
Description copied from class:LoadBalancer.HelperReturns theNameResolverRegistrythat the Channel uses to look forNameResolvers.- Overrides:
getNameResolverRegistryin classLoadBalancer.Helper
-
getMetricRecorder
Description copied from class:LoadBalancer.HelperReturns theMetricRecorderthat the channel uses to record metrics.- Overrides:
getMetricRecorderin classLoadBalancer.Helper
-
toString
-