|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.netflix.client.AbstractLoadBalancerAwareClient<S,T>
public abstract class AbstractLoadBalancerAwareClient<S extends ClientRequest,T extends IResponse>
Abstract class that provides the integration of client with load balancers.
Constructor Summary | |
---|---|
AbstractLoadBalancerAwareClient()
|
|
AbstractLoadBalancerAwareClient(IClientConfig clientConfig)
Delegate to initWithNiwsConfig(IClientConfig) |
Method Summary | |
---|---|
protected S |
computeFinalUriWithLoadBalancer(S original)
Compute the final URI from a partial URI in the request. |
protected com.netflix.util.Pair<java.lang.String,java.lang.Integer> |
deriveHostAndPortFromVipAddress(java.lang.String vipAddress)
Derive the host and port from virtual address if virtual address is indeed contains the actual host and port of the server. |
protected abstract com.netflix.util.Pair<java.lang.String,java.lang.Integer> |
deriveSchemeAndPortFromPartialUri(S task)
Derive scheme and port from a partial URI. |
protected T |
executeOnSingleServer(S request)
Execute the request on single server after the final URI is calculated. |
T |
executeWithLoadBalancer(S request)
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. |
java.lang.String |
getClientName()
|
protected abstract int |
getDefaultPort()
Get the default port which is protocol specific if port is missing in the request URI. |
ILoadBalancer |
getLoadBalancer()
|
void |
initWithNiwsConfig(IClientConfig clientConfig)
Set necessary parameters from client configuration and register with Servo monitors. |
protected abstract boolean |
isCircuitBreakerException(java.lang.Exception e)
Determine if an exception should contribute to circuit breaker trip. |
protected abstract boolean |
isRetriableException(java.lang.Exception e)
Determine if operation can be retried if an exception is thrown. |
protected void |
noteOpenConnection(ServerStats serverStats,
S task)
Called just before IClient.execute(ClientRequest) call. |
protected void |
noteRequestCompletion(ServerStats stats,
S task,
IResponse response,
java.lang.Exception e,
long responseTime)
This is called after a response is received or an exception is thrown from the IClient.execute(ClientRequest)
to update related stats. |
protected void |
noteResponseReceived(ServerStats stats,
T task,
IResponse response)
This method is called after a response (either success or not) is received to update certain stats. |
void |
setLoadBalancer(ILoadBalancer lb)
|
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 |
Constructor Detail |
---|
public AbstractLoadBalancerAwareClient()
public AbstractLoadBalancerAwareClient(IClientConfig clientConfig)
initWithNiwsConfig(IClientConfig)
clientConfig
- Method Detail |
---|
public void initWithNiwsConfig(IClientConfig clientConfig)
initWithNiwsConfig
in interface IClientConfigAware
public final java.lang.String getClientName()
public ILoadBalancer getLoadBalancer()
public void setLoadBalancer(ILoadBalancer lb)
protected abstract boolean isCircuitBreakerException(java.lang.Exception e)
AvailabilityFilteringRule
, which is the default rule for load balancers.
protected abstract boolean isRetriableException(java.lang.Exception e)
protected T executeOnSingleServer(S request) throws ClientException
ClientException
protected void noteRequestCompletion(ServerStats stats, S task, IResponse response, java.lang.Exception e, long responseTime)
IClient.execute(ClientRequest)
to update related stats.
protected void noteResponseReceived(ServerStats stats, T task, IResponse response)
protected void noteOpenConnection(ServerStats serverStats, S task)
IClient.execute(ClientRequest)
call.
public T executeWithLoadBalancer(S request) throws ClientException
computeFinalUriWithLoadBalancer(ClientRequest)
and then calls IClient.execute(ClientRequest)
.
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.
ClientException
protected abstract com.netflix.util.Pair<java.lang.String,java.lang.Integer> deriveSchemeAndPortFromPartialUri(S task)
computeFinalUriWithLoadBalancer(ClientRequest)
to get the complete executable URI.
protected abstract int getDefaultPort()
protected com.netflix.util.Pair<java.lang.String,java.lang.Integer> deriveHostAndPortFromVipAddress(java.lang.String vipAddress) throws java.net.URISyntaxException, ClientException
computeFinalUriWithLoadBalancer(ClientRequest)
if there is no load balancer available and the request URI is incomplete. Sub classes can override this method
to be more accurate or throws ClientException if it does not want to support virtual address to be the
same as physical server address.
The virtual address is used by certain load balancers to filter the servers of the same function to form the server pool.
java.net.URISyntaxException
ClientException
protected S computeFinalUriWithLoadBalancer(S original) throws ClientException
original
- Original URI passed from caller
ClientException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |