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
Modifier and TypeFieldDescriptionprivate ForeignException
protected final List<ForeignExceptionListener>
private static final org.slf4j.Logger
protected final String
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(ForeignExceptionListener errorable) Listen for failures to a given process.private void
Sends an exception to all listeners.Get the value of the captured exception.getName()
boolean
Non-exceptional form ofForeignExceptionSnare.rethrowException()
.void
Receive a ForeignException.void
Rethrow 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:ForeignExceptionListener
Receive a ForeignException.Implementers must ensure that this method is thread-safe.
- Specified by:
receive
in interfaceForeignExceptionListener
- Parameters:
e
- exception causing the error. Implementations must accept and handle null here.
-
rethrowException
Description copied from interface:ForeignExceptionSnare
Rethrow 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:
rethrowException
in interfaceForeignExceptionSnare
- Throws:
ForeignException
-
hasException
Description copied from interface:ForeignExceptionSnare
Non-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:
hasException
in interfaceForeignExceptionSnare
- Returns:
- true if there has been an error,false otherwise
-
getException
Description copied from interface:ForeignExceptionSnare
Get the value of the captured exception.- Specified by:
getException
in interfaceForeignExceptionSnare
- Returns:
- the captured foreign exception or null if no exception captured.
-
dispatch
Sends an exception to all listeners.- Parameters:
e
-ForeignException
containing 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.
-