T - the transport type to balance@ExperimentalApi @ThreadSafe public abstract class LoadBalancer<T> extends Object
NameResolver and provides the
channel a usable transport when asked.
Note to implementations: all methods are expected to return quickly. Any work that may block should be done asynchronously.
| Modifier and Type | Class and Description |
|---|---|
static class |
LoadBalancer.Factory |
| Constructor and Description |
|---|
LoadBalancer() |
| Modifier and Type | Method and Description |
|---|---|
void |
handleNameResolutionError(Status error)
Handles an error from the name resolution system.
|
void |
handleResolvedAddresses(List<ResolvedServerInfo> servers,
Attributes config)
Handles newly resolved addresses and service config from name resolution system.
|
void |
handleTransportReady(EquivalentAddressGroup addressGroup)
Called when a transport is fully connected and ready to accept traffic.
|
void |
handleTransportShutdown(EquivalentAddressGroup addressGroup,
Status s)
Called when a transport is shutting down.
|
abstract T |
pickTransport(Attributes affinity)
Pick a transport that Channel will use for next RPC.
|
void |
shutdown()
Shuts down this
LoadBalancer. |
public abstract T pickTransport(Attributes affinity)
If called after shutdown() has been called, this method will return
a transport that would fail all requests.
affinity - for affinity-based routingpublic void shutdown()
LoadBalancer.public void handleResolvedAddresses(List<ResolvedServerInfo> servers, Attributes config)
Implementations should not modify the given servers.
servers - the resolved server addresses. Never empty.config - extra configuration data from naming system.public void handleNameResolutionError(Status error)
error - a non-OK statuspublic void handleTransportReady(EquivalentAddressGroup addressGroup)
public void handleTransportShutdown(EquivalentAddressGroup addressGroup, Status s)