/** * Create RemoteException from attributes * @param attrs may not be null */ public static RemoteException valueOf(Attributes attrs) { return new RemoteException(attrs.getValue("class"), attrs.getValue("message")); }
private static void readStatus(DataInputStream inStream) throws IOException { int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }
@Override public FSDataInputStream open(Path f, final int bufferSize) throws IOException { throw new RemoteException(FileNotFoundException.class.getName(), ""); } @Override
public ByteBuffer readResponse() throws IOException { int length = in.readInt(); if (firstResponse) { firstResponse = false; // pre-rpcv9 exception, almost certainly a version mismatch. if (length == -1) { in.readInt(); // ignore fatal/error status, it's fatal for us. throw new RemoteException(WritableUtils.readString(in), WritableUtils.readString(in)); } } if (length <= 0) { throw new RpcException("RPC response has invalid length"); } if (maxResponseLength > 0 && length > maxResponseLength) { throw new RpcException("RPC response exceeds maximum data length"); } ByteBuffer bb = ByteBuffer.allocate(length); in.readFully(bb.array()); return bb; }
String msg = in.toString(offset + classLen + 8, msgLen, HConstants.UTF8_CHARSET); in.readerIndex(offset + totalLen); throw new RemoteException(className, msg);
@Override public ExecuteProceduresResponse sendRequest(ServerName server, ExecuteProceduresRequest req) throws IOException { switch (rand.nextInt(5)) { case 0: throw new ServerNotRunningYetException("wait on server startup"); case 1: throw new SocketTimeoutException("simulate socket timeout"); case 2: throw new RemoteException("java.io.IOException", "unexpected exception"); default: // fall out } return super.sendRequest(server, req); }
LOG.warn("Detailed error code not set by server on rpc error"); RemoteException re = new RemoteException(exceptionClassName, errorMsg, erCode); if (status == RpcStatusProto.ERROR) { final Call call = calls.remove(callId);
private static void readStatus(DataInputStream inStream) throws IOException { int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }
/** * Disallow snapshot on a directory. * Usage: hdfs dfsadmin -disallowSnapshot snapshotDir * @param argv List of of command line parameters. * @exception IOException */ public void disallowSnapshot(String[] argv) throws IOException { Path p = new Path(argv[1]); final DistributedFileSystem dfs = AdminHelper.getDFS(p.toUri(), getConf()); try { dfs.disallowSnapshot(p); } catch (SnapshotException e) { throw new RemoteException(e.getClass().getName(), e.getMessage()); } System.out.println("Disallowing snapshot on " + argv[1] + " succeeded"); }
/** * Allow snapshot on a directory. * Usage: hdfs dfsadmin -allowSnapshot snapshotDir * @param argv List of of command line parameters. * @exception IOException */ public void allowSnapshot(String[] argv) throws IOException { Path p = new Path(argv[1]); final DistributedFileSystem dfs = AdminHelper.getDFS(p.toUri(), getConf()); try { dfs.allowSnapshot(p); } catch (SnapshotException e) { throw new RemoteException(e.getClass().getName(), e.getMessage()); } System.out.println("Allowing snapshot on " + argv[1] + " succeeded"); }
case ERROR: // might get a RPC error during case FATAL: throw new RemoteException(header.getExceptionClassName(), header.getErrorMsg()); default: break;
String msg = in.toString(offset + classLen + 8, msgLen, HConstants.UTF8_CHARSET); in.readerIndex(offset + totalLen); throw new RemoteException(className, msg);
/** Create RemoteException from attributes */ public static RemoteException valueOf(Attributes attrs) { return new RemoteException(attrs.getValue("class"), attrs.getValue("message")); } }
/** Convert a Json map to a RemoteException. */ public static RemoteException toRemoteException(final Map<?, ?> json) { final Map<?, ?> m = (Map<?, ?>)json.get(RemoteException.class.getSimpleName()); final String message = (String)m.get("message"); final String javaClassName = (String)m.get("javaClassName"); return new RemoteException(javaClassName, message); }
/** Convert a Json map to a RemoteException. */ static RemoteException toRemoteException(final Map<?, ?> json) { final Map<?, ?> m = (Map<?, ?>)json.get( RemoteException.class.getSimpleName()); final String message = (String)m.get("message"); final String javaClassName = (String)m.get("javaClassName"); if (UNSUPPPORTED_EXCEPTION_STR.equals(javaClassName)) { throw new UnsupportedOperationException(message); } return new RemoteException(javaClassName, message); }
private static void readStatus(DataInputStream inStream) throws IOException { int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }
@Override public FSDataInputStream open(Path f, final int bufferSize) throws IOException { throw new RemoteException(FileNotFoundException.class.getName(), ""); } @Override
private static void readStatus(DataInputStream inStream) throws IOException { int status = inStream.readInt(); // read status if (status != SaslStatus.SUCCESS.state) { throw new RemoteException(WritableUtils.readString(inStream), WritableUtils.readString(inStream)); } }
@Override public ExecuteProceduresResponse sendRequest(ServerName server, ExecuteProceduresRequest req) throws IOException { switch (rand.nextInt(5)) { case 0: throw new ServerNotRunningYetException("wait on server startup"); case 1: throw new SocketTimeoutException("simulate socket timeout"); case 2: throw new RemoteException("java.io.IOException", "unexpected exception"); default: // fall out } return super.sendRequest(server, req); }
@Test public void testCatchingRemoteException() throws IOException { FileSystem mockedFileSystem = Mockito.mock(FileSystem.class); RemoteException thrownException = new RemoteException(AlreadyBeingCreatedException.class.getName(), "Failed to CREATE_FILE"); Mockito.when(mockedFileSystem.createNewFile(Mockito.any())).thenThrow(thrownException); HDFSSynchronization synchronization = new HDFSSynchronization("someDir", (conf) -> mockedFileSystem); assertFalse(synchronization.tryAcquireJobLock(configuration)); }