com.netflix.client
Class AbstractLoadBalancerAwareClient<S extends com.netflix.client.ClientRequest,T extends com.netflix.client.IResponse>

java.lang.Object
  extended by com.netflix.loadbalancer.LoadBalancerContext
      extended by com.netflix.loadbalancer.LoadBalancerExecutor
          extended by com.netflix.client.AbstractLoadBalancerAwareClient<S,T>
All Implemented Interfaces:
com.netflix.client.IClient<S,T>, com.netflix.client.IClientConfigAware

public abstract class AbstractLoadBalancerAwareClient<S extends com.netflix.client.ClientRequest,T extends com.netflix.client.IResponse>
extends LoadBalancerExecutor
implements com.netflix.client.IClient<S,T>, com.netflix.client.IClientConfigAware

Abstract class that provides the integration of client with load balancers.


Field Summary
 
Fields inherited from class com.netflix.loadbalancer.LoadBalancerContext
clientName, defaultRetryHandler, maxAutoRetries, maxAutoRetriesNextServer, okToRetryOnAllOperations, vipAddresses
 
Constructor Summary
AbstractLoadBalancerAwareClient(ILoadBalancer lb)
           
AbstractLoadBalancerAwareClient(ILoadBalancer lb, com.netflix.client.config.IClientConfig clientConfig)
          Delegate to LoadBalancerContext.initWithNiwsConfig(IClientConfig)
 
Method Summary
protected  T executeOnSingleServer(S request, com.netflix.client.config.IClientConfig requestConfig)
          Execute the request on single server after the final URI is calculated.
 T executeWithLoadBalancer(S request)
           
 T executeWithLoadBalancer(S request, com.netflix.client.config.IClientConfig requestConfig)
          This method should be used when the caller wants to dispatch the request to a server chosen by the load balancer, instead of specifying the server in the request's URI.
abstract  com.netflix.client.RequestSpecificRetryHandler getRequestSpecificRetryHandler(S request, com.netflix.client.config.IClientConfig requestConfig)
           
protected  boolean isCircuitBreakerException(java.lang.Throwable e)
          Deprecated. 
protected  boolean isRetriable(S request)
          Deprecated. 
protected  boolean isRetriableException(java.lang.Throwable e)
          Deprecated. 
 
Methods inherited from class com.netflix.loadbalancer.LoadBalancerExecutor
create, create, create, create, execute, execute, retryWithSameServer
 
Methods inherited from class com.netflix.loadbalancer.LoadBalancerContext
deriveHostAndPortFromVipAddress, deriveSchemeAndPortFromPartialUri, generateNIWSException, getClientName, getDeepestCause, getDefaultPortFromScheme, getExecuteTracer, getLoadBalancer, getMaxAutoRetries, getMaxAutoRetriesNextServer, getNumberRetriesOnSameServer, getRetriesNextServer, getRetryHandler, getServerFromLoadBalancer, getServerStats, handleSameServerRetry, initWithNiwsConfig, isOkToRetryOnAllOperations, noteError, noteOpenConnection, noteRequestCompletion, noteRequestCompletion, noteResponse, reconstructURIWithServer, setLoadBalancer, setMaxAutoRetries, setMaxAutoRetriesNextServer, setOkToRetryOnAllOperations, setRetryHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.netflix.client.IClient
execute
 
Methods inherited from interface com.netflix.client.IClientConfigAware
initWithNiwsConfig
 

Constructor Detail

AbstractLoadBalancerAwareClient

public AbstractLoadBalancerAwareClient(ILoadBalancer lb)

AbstractLoadBalancerAwareClient

public AbstractLoadBalancerAwareClient(ILoadBalancer lb,
                                       com.netflix.client.config.IClientConfig clientConfig)
Delegate to LoadBalancerContext.initWithNiwsConfig(IClientConfig)

Parameters:
clientConfig -
Method Detail

isCircuitBreakerException

@Deprecated
protected boolean isCircuitBreakerException(java.lang.Throwable e)
Deprecated. 

Determine if an exception should contribute to circuit breaker trip. If such exceptions happen consecutively on a server, it will be deemed as circuit breaker tripped and enter into a time out when it will be skipped by the AvailabilityFilteringRule, which is the default rule for load balancers.


isRetriableException

@Deprecated
protected boolean isRetriableException(java.lang.Throwable e)
Deprecated. 

Determine if operation can be retried if an exception is thrown. For example, connect timeout related exceptions are typically retriable.


executeOnSingleServer

protected T executeOnSingleServer(S request,
                                  com.netflix.client.config.IClientConfig requestConfig)
                                                                throws com.netflix.client.ClientException
Execute the request on single server after the final URI is calculated. This method takes care of retries and update server stats.

Throws:
com.netflix.client.ClientException

executeWithLoadBalancer

public T executeWithLoadBalancer(S request)
                                                               throws com.netflix.client.ClientException
Throws:
com.netflix.client.ClientException

executeWithLoadBalancer

public T executeWithLoadBalancer(S request,
                                 com.netflix.client.config.IClientConfig requestConfig)
                                                               throws com.netflix.client.ClientException
This method should be used when the caller wants to dispatch the request to a server chosen by the load balancer, instead of specifying the server in the request's URI. It calculates the final URI by calling LoadBalancerContext.reconstructURIWithServer(com.netflix.loadbalancer.Server, java.net.URI) and then calls executeWithLoadBalancer(ClientRequest, com.netflix.client.config.IClientConfig).

Parameters:
request - request to be dispatched to a server chosen by the load balancer. The URI can be a partial URI which does not contain the host name or the protocol.
Throws:
com.netflix.client.ClientException

getRequestSpecificRetryHandler

public abstract com.netflix.client.RequestSpecificRetryHandler getRequestSpecificRetryHandler(S request,
                                                                                              com.netflix.client.config.IClientConfig requestConfig)

isRetriable

@Deprecated
protected boolean isRetriable(S request)
Deprecated.