HBASE-16378 Procedure v2 - Make ProcedureException extend HBaseException
This commit is contained in:
parent
7999bb9bd3
commit
e637a61e26
|
@ -18,6 +18,7 @@
|
|||
package org.apache.hadoop.hbase.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -37,6 +38,24 @@ import org.apache.hadoop.hbase.protobuf.generated.ErrorHandlingProtos.StackTrace
|
|||
public final class ForeignExceptionUtil {
|
||||
private ForeignExceptionUtil() { }
|
||||
|
||||
public static Exception toException(final ForeignExceptionMessage eem) {
|
||||
final GenericExceptionMessage gem = eem.getGenericException();
|
||||
final StackTraceElement[] trace = toStackTrace(gem.getTraceList());
|
||||
try {
|
||||
Class<?> realClass = Class.forName(gem.getClassName());
|
||||
Class<? extends Exception> cls = realClass.asSubclass(Exception.class);
|
||||
Constructor<? extends Exception> cn = cls.getConstructor(String.class);
|
||||
cn.setAccessible(true);
|
||||
Exception re = cn.newInstance(gem.getMessage());
|
||||
re.setStackTrace(trace);
|
||||
return re;
|
||||
} catch (Throwable e) {
|
||||
Exception re = new Exception(gem.getMessage());
|
||||
re.setStackTrace(trace);
|
||||
return re;
|
||||
}
|
||||
}
|
||||
|
||||
public static IOException toIOException(final ForeignExceptionMessage eem) {
|
||||
GenericExceptionMessage gem = eem.getGenericException();
|
||||
StackTraceElement[] trace = toStackTrace(gem.getTraceList());
|
||||
|
|
|
@ -18,14 +18,13 @@
|
|||
|
||||
package org.apache.hadoop.hbase.procedure2;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.hadoop.hbase.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.exceptions.HBaseException;
|
||||
|
||||
@InterfaceAudience.Private
|
||||
@InterfaceStability.Stable
|
||||
public class ProcedureException extends IOException {
|
||||
public class ProcedureException extends HBaseException {
|
||||
/** default constructor */
|
||||
public ProcedureException() {
|
||||
super();
|
||||
|
|
|
@ -111,6 +111,6 @@ public class RemoteProcedureException extends ProcedureException {
|
|||
}
|
||||
|
||||
public static RemoteProcedureException fromProto(final ForeignExceptionMessage eem) {
|
||||
return new RemoteProcedureException(eem.getSource(), ForeignExceptionUtil.toIOException(eem));
|
||||
return new RemoteProcedureException(eem.getSource(), ForeignExceptionUtil.toException(eem));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -300,10 +300,6 @@ implements ServerProcedureInterface {
|
|||
default:
|
||||
throw new UnsupportedOperationException("unhandled state=" + state);
|
||||
}
|
||||
} catch (ProcedureYieldException e) {
|
||||
LOG.warn("Failed serverName=" + this.serverName + ", state=" + state + "; retry "
|
||||
+ e.getMessage());
|
||||
throw e;
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Failed serverName=" + this.serverName + ", state=" + state + "; retry", e);
|
||||
} catch (InterruptedException e) {
|
||||
|
|
Loading…
Reference in New Issue