Package io.grpc.util
Class HealthProducerHelper
- java.lang.Object
-
- io.grpc.LoadBalancer.Helper
-
- io.grpc.util.ForwardingLoadBalancerHelper
-
- io.grpc.util.HealthProducerHelper
-
@Internal public final class HealthProducerHelper extends ForwardingLoadBalancerHelper
A newLoadBalancer.Helperused by health producer systems to build health notification chain, viaLoadBalancer.CreateSubchannelArgs. The leaf health consumer is pick first. Each health producer uses this helper. The health producers should make state listener a pass-through and manipulate theLoadBalancer.CreateSubchannelArgsfor health notifications. The helper detects health listener parent. The root health producer in the chain will fan out the subchannel state change to both state listener and health listener.Example usage:
class HealthProducerLB { private final LoadBalancer.Helper helper; public HealthProducer(Helper helper) { this.helper = new MyHelper(HealthCheckUtil.HealthCheckHelper(helper)); } class MyHelper implements LoadBalancer.Helper { public void createSubchannel(CreateSubchannelArgs args) { SubchannelStateListener originalListener = args.getAttributes(HEALTH_CHECK_CONSUMER_LISTENER); if (hcListener != null) { // Implement a health listener that producers health check information. SubchannelStateListener myListener = MyHealthListener(originalListener); args = args.toBuilder.setOption(HEALTH_CHECK_CONSUMER_LISTENER, myListener); } return super.createSubchannel(args); } } }
-
-
Constructor Summary
Constructors Constructor Description HealthProducerHelper(LoadBalancer.Helper helper)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LoadBalancer.SubchannelcreateSubchannel(LoadBalancer.CreateSubchannelArgs args)Creates a Subchannel, which is a logical connection to the given group of addresses which are considered equivalent.protected LoadBalancer.Helperdelegate()Returns the underlying helper.-
Methods inherited from class io.grpc.util.ForwardingLoadBalancerHelper
createOobChannel, createOobChannel, createResolvingOobChannel, createResolvingOobChannelBuilder, createResolvingOobChannelBuilder, getAuthority, getChannelCredentials, getChannelLogger, getChannelTarget, getMetricRecorder, getNameResolverArgs, getNameResolverRegistry, getScheduledExecutorService, getSynchronizationContext, getUnsafeChannelCredentials, ignoreRefreshNameResolutionCheck, refreshNameResolution, toString, updateBalancingState, updateOobChannelAddresses, updateOobChannelAddresses
-
-
-
-
Constructor Detail
-
HealthProducerHelper
public HealthProducerHelper(LoadBalancer.Helper helper)
-
-
Method Detail
-
createSubchannel
public LoadBalancer.Subchannel createSubchannel(LoadBalancer.CreateSubchannelArgs args)
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 classForwardingLoadBalancerHelper- Returns:
- Must return a valid Subchannel object, may not return null.
-
delegate
protected LoadBalancer.Helper delegate()
Description copied from class:ForwardingLoadBalancerHelperReturns the underlying helper.- Specified by:
delegatein classForwardingLoadBalancerHelper
-
-