@InterfaceAudience.Private public class ForeignExceptionDispatcher extends Object implements ForeignExceptionListener, ForeignExceptionSnare
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.
Modifier and Type | Field and Description |
---|---|
private ForeignException |
exception |
protected List<ForeignExceptionListener> |
listeners |
private static org.slf4j.Logger |
LOG |
protected String |
name |
Constructor and Description |
---|
ForeignExceptionDispatcher() |
ForeignExceptionDispatcher(String name) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ForeignExceptionListener errorable)
Listen for failures to a given process.
|
private void |
dispatch(ForeignException e)
Sends an exception to all listeners.
|
ForeignException |
getException()
Get the value of the captured exception.
|
String |
getName() |
boolean |
hasException()
Non-exceptional form of
ForeignExceptionSnare.rethrowException() . |
void |
receive(ForeignException e)
Receive a ForeignException.
|
void |
rethrowException()
Rethrow an exception currently held by the
ForeignExceptionSnare . |
private static final org.slf4j.Logger LOG
protected final List<ForeignExceptionListener> listeners
private ForeignException exception
public ForeignExceptionDispatcher(String name)
public ForeignExceptionDispatcher()
public void receive(ForeignException e)
ForeignExceptionListener
Implementers must ensure that this method is thread-safe.
receive
in interface ForeignExceptionListener
e
- exception causing the error. Implementations must accept and handle null here.public void rethrowException() throws ForeignException
ForeignExceptionSnare
ForeignExceptionSnare
. If there is
no exception this is a no-oprethrowException
in interface ForeignExceptionSnare
ForeignException
- all exceptions from remote sources are procedure exceptionspublic boolean hasException()
ForeignExceptionSnare
ForeignExceptionSnare.rethrowException()
. Checks to see if any
process to which the exception checkers is bound has created an error that
would cause a failure.hasException
in interface ForeignExceptionSnare
public ForeignException getException()
ForeignExceptionSnare
getException
in interface ForeignExceptionSnare
private void dispatch(ForeignException e)
e
- ForeignException
containing the cause. Can be null.public void addListener(ForeignExceptionListener errorable)
errorable
- listener for the errors. may be null.Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.