protected void setFailure(final String source, final Throwable cause) { setFailure(new RemoteProcedureException(source, cause)); }
@Override public String toString() { String className = getCause().getClass().getName(); return className + " via " + getSource() + ":" + getLocalizedMessage(); }
/** * Takes a series of bytes and tries to generate an RemoteProcedureException instance for it. * @param bytes * @return the ForeignExcpetion instance * @throws InvalidProtocolBufferException if there was deserialization problem this is thrown. */ public static RemoteProcedureException deserialize(byte[] bytes) throws IOException { return fromProto(ForeignExceptionMessage.parseFrom(bytes)); }
/** * This is a version of unwrapRemoteIOException that can do DoNotRetryIOE. * We need to throw DNRIOE to clients if a failed Procedure else they will * keep trying. The default proc.getException().unwrapRemoteException * doesn't have access to DNRIOE from the procedure2 module. */ public static IOException unwrapRemoteIOException(Procedure proc) { Exception e = proc.getException().unwrapRemoteException(); // Do not retry ProcedureExceptions! return (e instanceof ProcedureException)? new DoNotRetryIOException(e): proc.getException().unwrapRemoteIOException(); } }
public Exception unwrapRemoteException() { final Throwable cause = getCause(); if (cause instanceof RemoteException) { return ((RemoteException)cause).unwrapRemoteException(); } if (cause instanceof Exception) { return (Exception)cause; } return new Exception(cause); }
public static Throwable assertProcFailed(final Procedure<?> result) { assertEquals(true, result.isFailed()); LOG.info("procId=" + result.getProcId() + " exception: " + result.getException().getMessage()); return getExceptionCause(result); }
public IOException unwrapRemoteIOException() { final Exception cause = unwrapRemoteException(); if (cause instanceof IOException) { return (IOException)cause; } return new IOException(cause); }
public static byte[] waitForProcedureToComplete(ProcedureExecutor<MasterProcedureEnv> procExec, final long procId) throws IOException { while (!procExec.isFinished(procId) && procExec.isRunning()) { // TODO: add a config to make it tunable // Dev Consideration: are we waiting forever, or we can set up some timeout value? Threads.sleepWithoutInterrupt(250); } ProcedureInfo result = procExec.getResult(procId); if (result != null) { if (result.isFailed()) { // If the procedure fails, we should always have an exception captured. Throw it. throw RemoteProcedureException.fromProto( result.getForeignExceptionMessage()).unwrapRemoteException(); } return result.getResult(); } else { if (procExec.isRunning()) { throw new IOException("Procedure " + procId + "not found"); } else { throw new IOException("The Master is Aborting"); } } }
/** * Converts a RemoteProcedureException to an array of bytes. * @param source the name of the external exception source * @param t the "local" external exception (local) * @return protobuf serialized version of RemoteProcedureException */ public static byte[] serialize(String source, Throwable t) { return toProto(source, t).toByteArray(); }
out.print( new Date(proc.getLastUpdate()) ); out.write("</td>\n <td>"); out.print( escapeXml(proc.isFailed() ? proc.getException().unwrapRemoteIOException().getMessage() : "") ); out.write("</td>\n <td>"); out.print( escapeXml(ProcedureDescriber.describeParameters(proc)) );
/** * Helper to create the ProcedureInfo from Procedure. */ @InterfaceAudience.Private public static ProcedureInfo createProcedureInfo(final Procedure proc, final NonceKey nonceKey) { RemoteProcedureException exception = proc.hasException() ? proc.getException() : null; return new ProcedureInfo( proc.getProcId(), proc.toStringClass(), proc.getOwner(), proc.getState(), proc.hasParent() ? proc.getParentProcId() : -1, nonceKey, exception != null ? RemoteProcedureException.toProto(exception.getSource(), exception.getCause()) : null, proc.getLastUpdate(), proc.getStartTime(), proc.getResult()); }
public static Throwable getExceptionCause(final Procedure<?> procInfo) { assert procInfo.isFailed(); Throwable cause = procInfo.getException().getCause(); return cause == null ? procInfo.getException() : cause; }
private void assertProcFailed(long procId) { assertTrue("expected completed proc", procExecutor.isFinished(procId)); Procedure<?> result = procExecutor.getResult(procId); assertEquals(true, result.isFailed()); LOG.info(result.getException().getMessage()); }
boolean tableDeleted; if (proc.hasException()) { Exception procEx = proc.getException().unwrapRemoteException(); if (iProcTable.getTableOperationType() == TableOperationType.CREATE) {
/** * Converts a RemoteProcedureException to an array of bytes. * @param source the name of the external exception source * @param t the "local" external exception (local) * @return protobuf serialized version of RemoteProcedureException */ public static byte[] serialize(String source, Throwable t) { return toProto(source, t).toByteArray(); }
private void createRSGroupTable() throws IOException { Long procId = masterServices.createSystemTable(RSGROUP_TABLE_DESC); // wait for region to be online int tries = 600; while (!(masterServices.getMasterProcedureExecutor().isFinished(procId)) && masterServices.getMasterProcedureExecutor().isRunning() && tries > 0) { try { Thread.sleep(100); } catch (InterruptedException e) { throw new IOException("Wait interrupted ", e); } tries--; } if(tries <= 0) { throw new IOException("Failed to create group table in a given time."); } else { Procedure<?> result = masterServices.getMasterProcedureExecutor().getResult(procId); if (result != null && result.isFailed()) { throw new IOException("Failed to create group table. " + result.getException().unwrapRemoteIOException()); } } }