com.netflix.loadbalancer
Class ServerListSubsetFilter<T extends Server>
java.lang.Object
com.netflix.loadbalancer.AbstractServerListFilter<T>
com.netflix.loadbalancer.ZoneAffinityServerListFilter<T>
com.netflix.loadbalancer.ServerListSubsetFilter<T>
- Type Parameters:
T -
- All Implemented Interfaces:
- com.netflix.client.IClientConfigAware, ServerListFilter<T>, java.util.Comparator<T>
public class ServerListSubsetFilter<T extends Server>
- extends ZoneAffinityServerListFilter<T>
- implements com.netflix.client.IClientConfigAware, java.util.Comparator<T>
A server list filter that limits the number of the servers used by the load balancer to be the subset of all servers.
This is useful if the server farm is large (e.g., in the hundreds) and making use of every one of them
and keeping the connections in http client's connection pool is unnecessary. It also has the capability of eviction
of relatively unhealthy servers by comparing the total network failures and concurrent connections.
|
Method Summary |
int |
compare(T server1,
T server2)
Function to sort the list by server health condition, with
unhealthy servers before healthy servers. |
java.util.List<T> |
getFilteredListOfServers(java.util.List<T> servers)
Given all the servers, keep only a stable subset of servers to use. |
void |
initWithNiwsConfig(com.netflix.client.config.IClientConfig clientConfig)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
equals |
ServerListSubsetFilter
public ServerListSubsetFilter()
initWithNiwsConfig
public void initWithNiwsConfig(com.netflix.client.config.IClientConfig clientConfig)
- Specified by:
initWithNiwsConfig in interface com.netflix.client.IClientConfigAware- Overrides:
initWithNiwsConfig in class ZoneAffinityServerListFilter<T extends Server>
getFilteredListOfServers
public java.util.List<T> getFilteredListOfServers(java.util.List<T> servers)
- Given all the servers, keep only a stable subset of servers to use. This method
keeps the current list of subset in use and keep returning the same list, with exceptions
to relatively unhealthy servers, which are defined as the following:
- Servers with their concurrent connection count exceeding the client configuration for
<clientName>.<nameSpace>.ServerListSubsetFilter.eliminationConnectionThresold (default is 0)
- Servers with their failure count exceeding the client configuration for
<clientName>.<nameSpace>.ServerListSubsetFilter.eliminationFailureThresold (default is 0)
- If the servers evicted above is less than the forced eviction percentage as defined by client configuration
<clientName>.<nameSpace>.ServerListSubsetFilter.forceEliminatePercent (default is 10%, or 0.1), the
remaining servers will be sorted by their health status and servers will worst health status will be
forced evicted.
After the elimination, new servers will be randomly chosen from all servers pool to keep the
number of the subset unchanged.
- Specified by:
getFilteredListOfServers in interface ServerListFilter<T extends Server>- Overrides:
getFilteredListOfServers in class ZoneAffinityServerListFilter<T extends Server>
compare
public int compare(T server1,
T server2)
- Function to sort the list by server health condition, with
unhealthy servers before healthy servers. The servers are first sorted by
failures count, and then concurrent connection count.
- Specified by:
compare in interface java.util.Comparator<T extends Server>