Class ForeignException
java.lang.Object
java.lang.Throwable
java.lang.Exception
java.io.IOException
org.apache.hadoop.hbase.errorhandling.ForeignException
- All Implemented Interfaces:
Serializable
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionprivate static class
This is a Proxy Throwable that contains the information of the original remote exception -
Field Summary
-
Constructor Summary
ConstructorDescriptionForeignException
(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
Modifier and TypeMethodDescriptionstatic ForeignException
deserialize
(byte[] bytes) Takes a series of bytes and tries to generate an ForeignException instance for it.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[]
Converts a ForeignException to an array of bytes.private static StackTraceElement[]
toStackTrace
(List<org.apache.hadoop.hbase.shaded.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage> traceList) Unwind a serialized array ofErrorHandlingProtos.StackTraceElementMessage
s to aStackTraceElement
s.private static List<org.apache.hadoop.hbase.shaded.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage>
Convert a stack trace to list ofStackTraceElement
.toString()
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace
-
Field Details
-
source
Name of the throwable's source such as a host or thread name. Must be non-null.
-
-
Constructor Details
-
ForeignException
Create a new ForeignException that can be serialized. It is assumed that this came form a local source. -
ForeignException
Create a new ForeignException that can be serialized. It is assumed that this is locally generated.
-
-
Method Details
-
getSource
-
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
-
toStackTraceElementMessages
private static List<org.apache.hadoop.hbase.shaded.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage> toStackTraceElementMessages(StackTraceElement[] trace) Convert a stack trace to list ofStackTraceElement
.- Parameters:
trace
- the stack trace to convert to protobuf message- Returns:
- null if the passed stack is null.
-
serialize
Converts a ForeignException to an array of bytes.- Parameters:
source
- the name of the external exception sourcet
- the "local" external exception (local)- Returns:
- protobuf serialized version of ForeignException
-
deserialize
Takes a series of bytes and tries to generate an ForeignException instance for it.- Returns:
- the ForeignExcpetion instance
- Throws:
InvalidProtocolBufferException
- if there was deserialization problem this is thrown.IOException
-
toStackTrace
private static StackTraceElement[] toStackTrace(List<org.apache.hadoop.hbase.shaded.protobuf.generated.ErrorHandlingProtos.StackTraceElementMessage> traceList) Unwind a serialized array ofErrorHandlingProtos.StackTraceElementMessage
s to aStackTraceElement
s.- Parameters:
traceList
- list that was serialized- Returns:
- the deserialized list or null if it couldn't be unwound (e.g. wasn't set on the sender).
-