@InterfaceAudience.Private class PreemptiveFastFailInterceptor extends RetryingCallerInterceptor
RetryingCallerInterceptor
class that implements the preemptive fast fail
feature.
The motivation is as follows :
In case where a large number of clients try and talk to a particular region server in hbase, if
the region server goes down due to network problems, we might end up in a scenario where
the clients would go into a state where they all start to retry.
This behavior will set off many of the threads in pretty much the same path and they all would be
sleeping giving rise to a state where the client either needs to create more threads to send new
requests to other hbase machines or block because the client cannot create anymore threads.
In most cases the clients might prefer to have a bound on the number of threads that are created
in order to send requests to hbase. This would mostly result in the client thread starvation.
To circumvent this problem, the approach that is being taken here under is to let 1 of the many
threads who are trying to contact the regionserver with connection problems and let the other
threads get a PreemptiveFastFailException
so that they can move on and take other
requests.
This would give the client more flexibility on the kind of action he would want to take in cases
where the regionserver is down. He can either discard the requests and send a nack upstream
faster or have an application level retry or buffer the requests up so as to send them down to
hbase later.Modifier and Type | Field and Description |
---|---|
protected long |
failureMapCleanupIntervalMilliSec |
private long |
fastFailClearingTimeMilliSec |
protected long |
fastFailThresholdMilliSec |
protected long |
lastFailureMapCleanupTimeMilliSec |
private static org.apache.commons.logging.Log |
LOG |
protected ConcurrentMap<ServerName,FailureInfo> |
repeatedFailuresMap |
private ThreadLocal<org.apache.commons.lang.mutable.MutableBoolean> |
threadRetryingInFastFailMode |
Constructor and Description |
---|
PreemptiveFastFailInterceptor(org.apache.hadoop.conf.Configuration conf) |
Modifier and Type | Method and Description |
---|---|
RetryingCallerInterceptorContext |
createEmptyContext()
This returns the context object for the current call.
|
private boolean |
currentThreadInFastFailMode()
Checks to see if the current thread is already in FastFail mode for *some*
server.
|
void |
handleFailure(FastFailInterceptorContext context,
Throwable t) |
void |
handleFailure(RetryingCallerInterceptorContext context,
Throwable t)
Call this function in case we caught a failure during retries.
|
private void |
handleFailureToServer(ServerName serverName,
Throwable t)
Handles failures encountered when communicating with a server.
|
void |
handleThrowable(Throwable t1,
ServerName serverName,
org.apache.commons.lang.mutable.MutableBoolean couldNotCommunicateWithServer) |
private boolean |
inFastFailMode(ServerName server)
Checks to see if we are in the Fast fail mode for requests to the server.
|
void |
intercept(FastFailInterceptorContext context) |
void |
intercept(RetryingCallerInterceptorContext context)
Call this function alongside the actual call done on the callable.
|
private boolean |
isConnectionException(Throwable e)
Check if the exception is something that indicates that we cannot
contact/communicate with the server.
|
protected boolean |
isServerInFailureMap(ServerName serverName) |
protected void |
occasionallyCleanupFailureInformation()
Occasionally cleans up unused information in repeatedFailuresMap.
|
protected boolean |
shouldRetryInspiteOfFastFail(FailureInfo fInfo)
Check to see if the client should try to connnect to the server, inspite of
knowing that it is in the fast fail mode.
|
String |
toString() |
private Throwable |
translateException(Throwable t) |
void |
updateFailureInfo(FastFailInterceptorContext context) |
void |
updateFailureInfo(RetryingCallerInterceptorContext context)
Call this function to update at the end of the retry.
|
private void |
updateFailureInfoForServer(ServerName server,
FailureInfo fInfo,
boolean didTry,
boolean couldNotCommunicate,
boolean retryDespiteFastFailMode)
This function updates the Failure info for a particular server after the
attempt to
|
private static final org.apache.commons.logging.Log LOG
protected final long fastFailThresholdMilliSec
protected final ConcurrentMap<ServerName,FailureInfo> repeatedFailuresMap
protected final long failureMapCleanupIntervalMilliSec
protected volatile long lastFailureMapCleanupTimeMilliSec
private long fastFailClearingTimeMilliSec
private final ThreadLocal<org.apache.commons.lang.mutable.MutableBoolean> threadRetryingInFastFailMode
public PreemptiveFastFailInterceptor(org.apache.hadoop.conf.Configuration conf)
public void intercept(FastFailInterceptorContext context) throws PreemptiveFastFailException
PreemptiveFastFailException
public void handleFailure(FastFailInterceptorContext context, Throwable t) throws IOException
IOException
public void updateFailureInfo(FastFailInterceptorContext context)
private void handleFailureToServer(ServerName serverName, Throwable t)
serverName
- t
- - the throwable to be handled.PreemptiveFastFailException
public void handleThrowable(Throwable t1, ServerName serverName, org.apache.commons.lang.mutable.MutableBoolean couldNotCommunicateWithServer) throws IOException
IOException
private Throwable translateException(Throwable t) throws IOException
IOException
private boolean isConnectionException(Throwable e)
e
- protected void occasionallyCleanupFailureInformation()
private boolean inFastFailMode(ServerName server)
server
- private boolean currentThreadInFastFailMode()
protected boolean shouldRetryInspiteOfFastFail(FailureInfo fInfo)
fInfo
- private void updateFailureInfoForServer(ServerName server, FailureInfo fInfo, boolean didTry, boolean couldNotCommunicate, boolean retryDespiteFastFailMode)
server
- fInfo
- couldNotCommunicate
- retryDespiteFastFailMode
- public void intercept(RetryingCallerInterceptorContext context) throws PreemptiveFastFailException
RetryingCallerInterceptor
intercept
in class RetryingCallerInterceptor
PreemptiveFastFailException
public void handleFailure(RetryingCallerInterceptorContext context, Throwable t) throws IOException
RetryingCallerInterceptor
handleFailure
in class RetryingCallerInterceptor
context
- : The context object that we obtained previously.t
- : The exception that we caught in this particular tryIOException
public void updateFailureInfo(RetryingCallerInterceptorContext context)
RetryingCallerInterceptor
updateFailureInfo
in class RetryingCallerInterceptor
public RetryingCallerInterceptorContext createEmptyContext()
RetryingCallerInterceptor
createEmptyContext
in class RetryingCallerInterceptor
protected boolean isServerInFailureMap(ServerName serverName)
public String toString()
toString
in class RetryingCallerInterceptor
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.