@ThreadSafe public abstract static class LoadBalancer.Helper extends Object
Constructor and Description |
---|
Helper() |
Modifier and Type | Method and Description |
---|---|
abstract ManagedChannel |
createOobChannel(EquivalentAddressGroup eag,
String authority)
Out-of-band channel for LoadBalancer’s own RPC needs, e.g., talking to an external
load-balancer service.
|
abstract LoadBalancer.Subchannel |
createSubchannel(EquivalentAddressGroup addrs,
Attributes attrs)
Creates a Subchannel, which is a logical connection to the given group of addresses which are
considered equivalent.
|
abstract String |
getAuthority()
Returns the authority string of the channel, which is derived from the DNS-style target name.
|
abstract NameResolver.Factory |
getNameResolverFactory()
Returns the NameResolver of the channel.
|
abstract void |
runSerialized(Runnable task)
Schedule a task to be run in the Channel Executor, which serializes the task with the
callback methods on the
LoadBalancer interface. |
void |
updateBalancingState(ConnectivityState newState,
LoadBalancer.SubchannelPicker newPicker)
Set a new state with a new picker to the channel.
|
void |
updateOobChannelAddresses(ManagedChannel channel,
EquivalentAddressGroup eag)
Updates the addresses used for connections in the
Channel . |
abstract void |
updatePicker(LoadBalancer.SubchannelPicker picker)
Deprecated.
Please migrate ALL usages to
updateBalancingState(io.grpc.ConnectivityState, io.grpc.LoadBalancer.SubchannelPicker) |
void |
updateSubchannelAddresses(LoadBalancer.Subchannel subchannel,
EquivalentAddressGroup addrs)
Replaces the existing addresses used with
subchannel . |
public abstract LoadBalancer.Subchannel createSubchannel(EquivalentAddressGroup addrs, Attributes attrs)
attrs
are custom attributes associated with this
Subchannel, and can be accessed later through Subchannel.getAttributes()
.
The LoadBalancer is responsible for closing unused Subchannels, and closing all
Subchannels within LoadBalancer.shutdown()
.
public void updateSubchannelAddresses(LoadBalancer.Subchannel subchannel, EquivalentAddressGroup addrs)
subchannel
. This method is superior to
createSubchannel(io.grpc.EquivalentAddressGroup, io.grpc.Attributes)
when the new and old addresses overlap, since the subchannel can
continue using an existing connection.IllegalArgumentException
- if subchannel
was not returned from createSubchannel(io.grpc.EquivalentAddressGroup, io.grpc.Attributes)
public abstract ManagedChannel createOobChannel(EquivalentAddressGroup eag, String authority)
The LoadBalancer is responsible for closing unused OOB channels, and closing all OOB
channels within LoadBalancer.shutdown()
.
public void updateOobChannelAddresses(ManagedChannel channel, EquivalentAddressGroup eag)
Channel
. This is supperior to
createOobChannel(io.grpc.EquivalentAddressGroup, java.lang.String)
when the old and new addresses overlap, since the channel can
continue using an existing connection.IllegalArgumentException
- if channel
was not returned from createOobChannel(io.grpc.EquivalentAddressGroup, java.lang.String)
@Deprecated public abstract void updatePicker(LoadBalancer.SubchannelPicker picker)
updateBalancingState(io.grpc.ConnectivityState, io.grpc.LoadBalancer.SubchannelPicker)
When a new picker is provided via updatePicker()
, the channel will apply the
picker on all buffered RPCs, by calling LoadBalancer.SubchannelPicker.pickSubchannel(
LoadBalancer.PickSubchannelArgs)
.
The channel will hold the picker and use it for all RPCs, until updatePicker()
is
called again and a new picker replaces the old one. If updatePicker()
has never been
called, the channel will buffer all RPCs until a picker is provided.
Using this method implies that this load balancer doesn't support channel state, and the application will get exception when trying to get the channel state.
public void updateBalancingState(@Nonnull ConnectivityState newState, @Nonnull LoadBalancer.SubchannelPicker newPicker)
When a new picker is provided via updateBalancingState()
, the channel will apply
the picker on all buffered RPCs, by calling LoadBalancer.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. If updateBalancingState()
has never been called, the channel will buffer all RPCs until a
picker is provided.
The passed state will be the channel's new state. The SHUTDOWN state should not be passed and its behavior is undefined.
public abstract void runSerialized(Runnable task)
LoadBalancer
interface.public abstract NameResolver.Factory getNameResolverFactory()
public abstract String getAuthority()