List of usage examples for org.apache.hadoop.ipc RemoteException unwrapRemoteException
public IOException unwrapRemoteException()
From source file:com.alibaba.wasp.client.WaspAdmin.java
License:Apache License
/** * Helper function called by other execute functions. *//*from www . j a va 2 s .co m*/ private <V> V executeCallable(Callable<V> function) throws IOException { try { return function.call(); } catch (RemoteException re) { throw re.unwrapRemoteException(); } catch (IOException e) { throw e; } catch (ServiceException se) { throw ProtobufUtil.getRemoteException(se); } catch (Exception e) { // This should not happen... throw new IOException("Unexpected exception when calling master", e); } }
From source file:com.alibaba.wasp.ipc.NettyTransceiver.java
License:Apache License
private Message processResponse(List<ByteBuffer> res, Class<? extends VersionedProtocol> protocol, RpcRequestBody param) throws IOException { ByteBufferInputStream in = new ByteBufferInputStream(res); try {/*from w ww .j av a 2 s . c om*/ // See NettyServer.prepareResponse for where we write out the response. // It writes the call.id (int), a boolean signifying any error (and if // so the exception name/trace), and the response bytes // Read the call id. RpcResponseHeader response = RpcResponseHeader.parseDelimitedFrom(in); if (response == null) { // When the stream is closed, protobuf doesn't raise an EOFException, // instead, it returns a null message object. throw new EOFException(); } Status status = response.getStatus(); if (status == Status.SUCCESS) { Message rpcResponseType; try { rpcResponseType = ProtobufRpcEngine.Invoker.getReturnProtoType( ProtobufRpcEngine.Server.getMethod(protocol, param.getMethodName())); } catch (Exception e) { throw new RuntimeException(e); // local exception } Builder builder = rpcResponseType.newBuilderForType(); builder.mergeDelimitedFrom(in); Message value = builder.build(); return value; } else if (status == Status.ERROR) { RpcException exceptionResponse = RpcException.parseDelimitedFrom(in); RemoteException remoteException = new RemoteException(exceptionResponse.getExceptionName(), exceptionResponse.getStackTrace()); throw remoteException.unwrapRemoteException(); } else if (status == Status.FATAL) { RpcException exceptionResponse = RpcException.parseDelimitedFrom(in); // Close the connection LOG.error("Fatal Exception.", exceptionResponse); RemoteException remoteException = new RemoteException(exceptionResponse.getExceptionName(), exceptionResponse.getStackTrace()); throw remoteException.unwrapRemoteException(); } else { throw new IOException("What happened?"); } } catch (Exception e) { if (e instanceof RemoteException) { ((RemoteException) e).unwrapRemoteException(); } if (e instanceof IOException) { throw (IOException) e; } else { throw new IOException(e); } } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
/** * Create one snapshot.// w ww . j a v a 2 s.c om * * @param snapshotRoot * The directory where the snapshot is to be taken * @param snapshotName * Name of the snapshot * @return the snapshot path. * @see ClientProtocol#createSnapshot(String, String) */ public String createSnapshot(String snapshotRoot, String snapshotName) throws IOException { checkOpen(); TraceScope scope = Trace.startSpan("createSnapshot", traceSampler); try { return namenode.createSnapshot(snapshotRoot, snapshotName); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
/** * Delete a snapshot of a snapshottable directory. * //from www . j a v a 2 s . c o m * @param snapshotRoot * The snapshottable directory that the * to-be-deleted snapshot belongs to * @param snapshotName * The name of the to-be-deleted snapshot * @throws IOException * @see ClientProtocol#deleteSnapshot(String, String) */ public void deleteSnapshot(String snapshotRoot, String snapshotName) throws IOException { checkOpen(); TraceScope scope = Trace.startSpan("deleteSnapshot", traceSampler); try { namenode.deleteSnapshot(snapshotRoot, snapshotName); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
/** * Rename a snapshot.// w w w .j av a 2 s . c o m * * @param snapshotDir * The directory path where the snapshot was taken * @param snapshotOldName * Old name of the snapshot * @param snapshotNewName * New name of the snapshot * @throws IOException * @see ClientProtocol#renameSnapshot(String, String, String) */ public void renameSnapshot(String snapshotDir, String snapshotOldName, String snapshotNewName) throws IOException { checkOpen(); TraceScope scope = Trace.startSpan("renameSnapshot", traceSampler); try { namenode.renameSnapshot(snapshotDir, snapshotOldName, snapshotNewName); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
/** * Get all the current snapshottable directories. * //from ww w .jav a 2s . com * @return All the current snapshottable directories * @throws IOException * @see ClientProtocol#getSnapshottableDirListing() */ public SnapshottableDirectoryStatus[] getSnapshottableDirListing() throws IOException { checkOpen(); TraceScope scope = Trace.startSpan("getSnapshottableDirListing", traceSampler); try { return namenode.getSnapshottableDirListing(); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
/** * Allow snapshot on a directory.//from ww w. j av a 2 s . c o m * * @see ClientProtocol#allowSnapshot(String snapshotRoot) */ public void allowSnapshot(String snapshotRoot) throws IOException { checkOpen(); TraceScope scope = Trace.startSpan("allowSnapshot", traceSampler); try { namenode.allowSnapshot(snapshotRoot); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
/** * Disallow snapshot on a directory./*from w w w .j ava 2 s . c o m*/ * * @see ClientProtocol#disallowSnapshot(String snapshotRoot) */ public void disallowSnapshot(String snapshotRoot) throws IOException { checkOpen(); TraceScope scope = Trace.startSpan("disallowSnapshot", traceSampler); try { namenode.disallowSnapshot(snapshotRoot); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
/** * Get the difference between two snapshots, or between a snapshot and the * current tree of a directory./*www .j a v a 2 s . com*/ * * @see ClientProtocol#getSnapshotDiffReport(String, String, String) */ public SnapshotDiffReport getSnapshotDiffReport(String snapshotDir, String fromSnapshot, String toSnapshot) throws IOException { checkOpen(); TraceScope scope = Trace.startSpan("getSnapshotDiffReport", traceSampler); try { return namenode.getSnapshotDiffReport(snapshotDir, fromSnapshot, toSnapshot); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }
From source file:com.mellanox.r4h.DFSClient.java
License:Apache License
public long addCacheDirective(CacheDirectiveInfo info, EnumSet<CacheFlag> flags) throws IOException { checkOpen();//from www . j a v a 2 s. c om TraceScope scope = Trace.startSpan("addCacheDirective", traceSampler); try { return namenode.addCacheDirective(info, flags); } catch (RemoteException re) { throw re.unwrapRemoteException(); } finally { scope.close(); } }