com.netflix.loadbalancer
Class ServerListSubsetFilter<T extends Server>

java.lang.Object
  extended by com.netflix.loadbalancer.AbstractServerListFilter<T>
      extended by com.netflix.loadbalancer.ZoneAffinityServerListFilter<T>
          extended by 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.


Constructor Summary
ServerListSubsetFilter()
           
 
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 com.netflix.loadbalancer.ZoneAffinityServerListFilter
toString
 
Methods inherited from class com.netflix.loadbalancer.AbstractServerListFilter
getLoadBalancerStats, setLoadBalancerStats
 
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
 

Constructor Detail

ServerListSubsetFilter

public ServerListSubsetFilter()
Method Detail

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:

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>