com.twitter.common.net.loadbalancing
Class MarkDeadStrategyWithHostCheck.LiveHostChecker<S>

java.lang.Object
  extended by com.twitter.common.net.loadbalancing.MarkDeadStrategyWithHostCheck.LiveHostChecker<S>
All Implemented Interfaces:
Predicate<S>
Enclosing class:
MarkDeadStrategyWithHostCheck<S>

protected static class MarkDeadStrategyWithHostCheck.LiveHostChecker<S>
extends Object
implements Predicate<S>

LiveHostChecker implements Filter to determine whether a host is alive based on the result of the most recent connection attempt to that host. It keeps a map of backend -> last connection result, which gets updated every time someone tries to add to connection result.


Constructor Summary
protected MarkDeadStrategyWithHostCheck.LiveHostChecker()
           
 
Method Summary
 void addConnectResult(S backend, LoadBalancingStrategy.ConnectionResult result)
          Adds the connection result of this backend to the last connection result map.
 boolean apply(S backend)
          Checks if the last connection result for this backend and returns true if it was ConnectionResult#SUCCESS otherwise returns false.
 
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

MarkDeadStrategyWithHostCheck.LiveHostChecker

protected MarkDeadStrategyWithHostCheck.LiveHostChecker()
Method Detail

addConnectResult

public void addConnectResult(S backend,
                             LoadBalancingStrategy.ConnectionResult result)
Adds the connection result of this backend to the last connection result map.

Parameters:
backend - typically the socket address of the backend.
result - result of what happened when the client tried to connect to this backend.

apply

public boolean apply(S backend)
Checks if the last connection result for this backend and returns true if it was ConnectionResult#SUCCESS otherwise returns false.

Specified by:
apply in interface Predicate<S>
Parameters:
backend - typically the socket address of the backend.