com.netflix.loadbalancer
Class CompositePredicate

java.lang.Object
  extended by com.netflix.loadbalancer.AbstractServerPredicate
      extended by com.netflix.loadbalancer.CompositePredicate
All Implemented Interfaces:
com.google.common.base.Predicate<PredicateKey>

public class CompositePredicate
extends AbstractServerPredicate

A predicate that is composed from one or more predicates in "AND" relationship. It also has the functionality of "fallback" to one of more different predicates. If the primary predicate yield too few filtered servers from the getEligibleServers(List, Object) API, it will try the fallback predicates one by one, until the number of filtered servers exceeds certain number threshold or percentage threshold.


Nested Class Summary
static class CompositePredicate.Builder
           
 
Field Summary
 
Fields inherited from class com.netflix.loadbalancer.AbstractServerPredicate
rule
 
Constructor Summary
CompositePredicate()
           
 
Method Summary
 boolean apply(PredicateKey input)
           
 java.util.List<Server> getEligibleServers(java.util.List<Server> servers, java.lang.Object loadBalancerKey)
          Get the filtered servers from primary predicate, and if the number of the filtered servers are not enough, trying the fallback predicates
static CompositePredicate.Builder withPredicate(AbstractServerPredicate primaryPredicate)
           
static CompositePredicate.Builder withPredicates(AbstractServerPredicate... primaryPredicates)
           
 
Methods inherited from class com.netflix.loadbalancer.AbstractServerPredicate
alwaysTrue, chooseRandomlyAfterFiltering, chooseRandomlyAfterFiltering, chooseRoundRobinAfterFiltering, chooseRoundRobinAfterFiltering, getEligibleServers, getLBStats, getServerOnlyPredicate, ofKeyPredicate, ofServerPredicate, setLoadBalancerStats
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.common.base.Predicate
equals
 

Constructor Detail

CompositePredicate

public CompositePredicate()
Method Detail

apply

public boolean apply(@Nullable
                     PredicateKey input)

withPredicates

public static CompositePredicate.Builder withPredicates(AbstractServerPredicate... primaryPredicates)

withPredicate

public static CompositePredicate.Builder withPredicate(AbstractServerPredicate primaryPredicate)

getEligibleServers

public java.util.List<Server> getEligibleServers(java.util.List<Server> servers,
                                                 java.lang.Object loadBalancerKey)
Get the filtered servers from primary predicate, and if the number of the filtered servers are not enough, trying the fallback predicates

Overrides:
getEligibleServers in class AbstractServerPredicate