org.apache.hadoop.hbase.errorhandling
Class ForeignException

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.io.IOException
              extended by org.apache.hadoop.hbase.errorhandling.ForeignException
All Implemented Interfaces:
Serializable

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class ForeignException
extends IOException

A ForeignException is an exception from another thread or process.

ForeignExceptions are sent to 'remote' peers to signal an abort in the face of failures. When serialized for transmission we encode using Protobufs to ensure version compatibility.

Foreign exceptions contain a Throwable as its cause. This can be a "regular" exception generated locally or a ProxyThrowable that is a representation of the original exception created on original 'remote' source. These ProxyThrowables have their their stacks traces and messages overridden to reflect the original 'remote' exception. The only way these ProxyThrowables are generated are by this class's deserialize(byte[]) method.

See Also:
Serialized Form

Constructor Summary
ForeignException(String source, String msg)
          Create a new ForeignException that can be serialized.
ForeignException(String source, Throwable cause)
          Create a new ForeignException that can be serialized.
 
Method Summary
static ForeignException deserialize(byte[] bytes)
          Takes a series of bytes and tries to generate an ForeignException instance for it.
 String getSource()
           
 boolean isRemote()
          The cause of a ForeignException can be an exception that was generated on a local in process thread, or a thread from a 'remote' separate process.
static byte[] serialize(String source, Throwable t)
          Converts a ForeignException to an array of bytes.
 String toString()
           
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ForeignException

public ForeignException(String source,
                        Throwable cause)
Create a new ForeignException that can be serialized. It is assumed that this came form a local source.

Parameters:
source -
cause -

ForeignException

public ForeignException(String source,
                        String msg)
Create a new ForeignException that can be serialized. It is assumed that this is locally generated.

Parameters:
source -
msg -
Method Detail

getSource

public String getSource()

isRemote

public boolean isRemote()
The cause of a ForeignException can be an exception that was generated on a local in process thread, or a thread from a 'remote' separate process. If the cause is a ProxyThrowable, we know it came from deserialization which usually means it came from not only another thread, but also from a remote thread.

Returns:
true if went through deserialization, false if locally generated

toString

public String toString()
Overrides:
toString in class Throwable

serialize

public static byte[] serialize(String source,
                               Throwable t)
Converts a ForeignException to an array of bytes.

Parameters:
source - the name of the external exception source
t - the "local" external exception (local)
Returns:
protobuf serialized version of ForeignException

deserialize

public static ForeignException deserialize(byte[] bytes)
                                    throws com.google.protobuf.InvalidProtocolBufferException
Takes a series of bytes and tries to generate an ForeignException instance for it.

Parameters:
bytes -
Returns:
the ForeignExcpetion instance
Throws:
com.google.protobuf.InvalidProtocolBufferException - if there was deserialization problem this is thrown.


Copyright © 2007-2016 The Apache Software Foundation. All Rights Reserved.