org.apache.hadoop.hbase.errorhandling
Class ForeignExceptionDispatcher

java.lang.Object
  extended by org.apache.hadoop.hbase.errorhandling.ForeignExceptionDispatcher
All Implemented Interfaces:
ForeignExceptionListener, ForeignExceptionSnare

@InterfaceAudience.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
protected  List<ForeignExceptionListener> listeners
           
static org.apache.commons.logging.Log LOG
           
protected  String name
           
 
Constructor Summary
ForeignExceptionDispatcher()
           
ForeignExceptionDispatcher(String name)
           
 
Method Summary
 void addListener(ForeignExceptionListener errorable)
          Listen for failures to a given process.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final org.apache.commons.logging.Log LOG

name

protected final String name

listeners

protected final List<ForeignExceptionListener> listeners
Constructor Detail

ForeignExceptionDispatcher

public ForeignExceptionDispatcher(String name)

ForeignExceptionDispatcher

public ForeignExceptionDispatcher()
Method Detail

getName

public String getName()

receive

public void receive(ForeignException e)
Description copied from interface: ForeignExceptionListener
Receive a ForeignException.

Implementers must ensure that this method is thread-safe.

Specified by:
receive in interface ForeignExceptionListener
Parameters:
e - exception causing the error. Implementations must accept and handle null here.

rethrowException

public void rethrowException()
                      throws ForeignException
Description copied from interface: ForeignExceptionSnare
Rethrow an exception currently held by the ForeignExceptionSnare. If there is no exception this is a no-op

Specified by:
rethrowException in interface ForeignExceptionSnare
Throws:
ForeignException - all exceptions from remote sources are procedure exceptions

hasException

public boolean hasException()
Description copied from interface: ForeignExceptionSnare
Non-exceptional form of ForeignExceptionSnare.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 interface ForeignExceptionSnare
Returns:
true if there has been an error,false otherwise

getException

public ForeignException getException()
Description copied from interface: ForeignExceptionSnare
Get the value of the captured exception.

Specified by:
getException in interface ForeignExceptionSnare
Returns:
the captured foreign exception or null if no exception captured.

addListener

public void addListener(ForeignExceptionListener errorable)
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.


Copyright © 2007–2015 The Apache Software Foundation. All rights reserved.