@InterfaceAudience.Public @InterfaceStability.Evolving public class ForeignException extends IOException
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.
Modifier and Type | Class and Description |
---|---|
private static class |
ForeignException.ProxyThrowable
This is a Proxy Throwable that contains the information of the original remote exception
|
Modifier and Type | Field and Description |
---|---|
private String |
source
Name of the throwable's source such as a host or thread name.
|
Constructor and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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.
|
private static StackTraceElement[] |
toStackTrace(List<org.apache.hadoop.hbase.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage> traceList)
Unwind a serialized array of
ErrorHandlingProtos.StackTraceElementMessage s to a
StackTraceElement s. |
private static List<org.apache.hadoop.hbase.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage> |
toStackTraceElementMessages(StackTraceElement[] trace)
Convert a stack trace to list of
StackTraceElement . |
String |
toString() |
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
private final String source
public ForeignException(String source, Throwable cause)
source
- cause
- public String getSource()
public boolean isRemote()
private static List<org.apache.hadoop.hbase.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage> toStackTraceElementMessages(StackTraceElement[] trace)
StackTraceElement
.trace
- the stack trace to convert to protobuf messagepublic static byte[] serialize(String source, Throwable t)
source
- the name of the external exception sourcet
- the "local" external exception (local)public static ForeignException deserialize(byte[] bytes) throws com.google.protobuf.InvalidProtocolBufferException
bytes
- com.google.protobuf.InvalidProtocolBufferException
- if there was deserialization problem this is thrown.private static StackTraceElement[] toStackTrace(List<org.apache.hadoop.hbase.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage> traceList)
ErrorHandlingProtos.StackTraceElementMessage
s to a
StackTraceElement
s.traceList
- list that was serializedCopyright © 2007–2019 The Apache Software Foundation. All rights reserved.