org.apache.hadoop.hbase.errorhandling
Interface ForeignExceptionSnare

All Known Implementing Classes:
CopyRecoveredEditsTask, DisabledTableSnapshotHandler, EnabledTableSnapshotHandler, ForeignExceptionDispatcher, ReferenceRegionHFilesTask, ReferenceServerWALsTask, SnapshotTask, TableInfoCopyTask, TakeSnapshotHandler

@InterfaceAudience.Public
@InterfaceStability.Evolving
public interface ForeignExceptionSnare

This is an interface for a cooperative exception throwing mechanism. Implementations are containers that holds an exception from a separate thread. This can be used to receive exceptions from 'foreign' threads or from separate 'foreign' processes.

To use, one would pass an implementation of this object to a long running method and periodically check by calling rethrowException(). If any foreign exceptions have been received, the calling thread is then responsible for handling the rethrown exception.

One could use the boolean hasException() to determine if there is an exceptoin as well.

NOTE: This is very similar to the InterruptedException/interrupt/interrupted pattern. There, the notification state is bound to a Thread. Using this, applications receive Exceptions in the snare. The snare is referenced and checked by multiple threads which enables exception notification in all the involved threads/processes.


Method Summary
 ForeignException getException()
          Get the value of the captured exception.
 boolean hasException()
          Non-exceptional form of rethrowException().
 void rethrowException()
          Rethrow an exception currently held by the ForeignExceptionSnare.
 

Method Detail

rethrowException

void rethrowException()
                      throws ForeignException
Rethrow an exception currently held by the ForeignExceptionSnare. If there is no exception this is a no-op

Throws:
ForeignException - all exceptions from remote sources are procedure exceptions

hasException

boolean hasException()
Non-exceptional form of rethrowException(). Checks to see if any process to which the exception checkers is bound has created an error that would cause a failure.

Returns:
true if there has been an error,false otherwise

getException

ForeignException getException()
Get the value of the captured exception.

Returns:
the captured foreign exception or null if no exception captured.


Copyright © 2014 The Apache Software Foundation. All Rights Reserved.