Class ForeignExceptionDispatcher
java.lang.Object
org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher
- All Implemented Interfaces:
ForeignExceptionListener,ForeignExceptionSnare
@Private
public class ForeignExceptionDispatcher
extends Object
implements ForeignExceptionListener, ForeignExceptionSnare
The dispatcher acts as the state holding entity for foreign error handling. The first exception
received by the dispatcher get passed directly to the listeners. Subsequent exceptions are
dropped.
If there are multiple dispatchers that are all in the same foreign exception monitoring group, ideally all these monitors are "peers" -- any error on one dispatcher should get propagated to all others (via rpc, or some other mechanism). Due to racing error conditions the exact reason for failure may be different on different peers, but the fact that they are in error state should eventually hold on all.
This is thread-safe and must be because this is expected to be used to propagate exceptions from foreign threads.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate ForeignExceptionprotected final List<ForeignExceptionListener>private static final org.slf4j.Loggerprotected final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(ForeignExceptionListener errorable) Listen for failures to a given process.private voidSends an exception to all listeners.Get the value of the captured exception.getName()booleanNon-exceptional form ofForeignExceptionSnare.rethrowException().voidReceive a ForeignException.voidRethrow an exception currently held by theForeignExceptionSnare.
-
Field Details
-
LOG
-
name
-
listeners
-
exception
-
-
Constructor Details
-
ForeignExceptionDispatcher
-
ForeignExceptionDispatcher
public ForeignExceptionDispatcher()
-
-
Method Details
-
getName
-
receive
Description copied from interface:ForeignExceptionListenerReceive a ForeignException.Implementers must ensure that this method is thread-safe.
- Specified by:
receivein interfaceForeignExceptionListener- Parameters:
e- exception causing the error. Implementations must accept and handle null here.
-
rethrowException
Description copied from interface:ForeignExceptionSnareRethrow an exception currently held by theForeignExceptionSnare. If there is no exception this is a no-op all exceptions from remote sources are procedure exceptions- Specified by:
rethrowExceptionin interfaceForeignExceptionSnare- Throws:
ForeignException
-
hasException
Description copied from interface:ForeignExceptionSnareNon-exceptional form ofForeignExceptionSnare.rethrowException(). Checks to see if any process to which the exception checkers is bound has created an error that would cause a failure.- Specified by:
hasExceptionin interfaceForeignExceptionSnare- Returns:
- true if there has been an error,false otherwise
-
getException
Description copied from interface:ForeignExceptionSnareGet the value of the captured exception.- Specified by:
getExceptionin interfaceForeignExceptionSnare- Returns:
- the captured foreign exception or null if no exception captured.
-
dispatch
Sends an exception to all listeners.- Parameters:
e-ForeignExceptioncontaining the cause. Can be null.
-
addListener
Listen for failures to a given process. This method should only be used during initialization and not added to after exceptions are accepted.- Parameters:
errorable- listener for the errors. may be null.
-