svn merge -c 1212004 from trunk for HADOOP-7897.
git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-0.23-PB@1230416 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1c078f46c1
commit
d16e2fdd71
|
@ -37,6 +37,9 @@ Release 0.23-PB - Unreleased
|
||||||
HADOOP-7833. Fix findbugs warnings in protobuf generated code.
|
HADOOP-7833. Fix findbugs warnings in protobuf generated code.
|
||||||
(John Lee via suresh)
|
(John Lee via suresh)
|
||||||
|
|
||||||
|
HADOOP-7897. ProtobufRpcEngine client side exception mechanism is not
|
||||||
|
consistent with WritableRpcEngine. (suresh)
|
||||||
|
|
||||||
Release 0.23.1 - Unreleased
|
Release 0.23.1 - Unreleased
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -33,14 +33,17 @@ public class ProtobufHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the RemoteException wrapped in ServiceException as cause.
|
* Return the IOException thrown by the remote server wrapped in
|
||||||
* @param se ServiceException that wraps RemoteException
|
* ServiceException as cause.
|
||||||
* @return RemoteException wrapped in ServiceException or
|
* @param se ServiceException that wraps IO exception thrown by the server
|
||||||
* a new IOException that wraps unexpected ServiceException.
|
* @return Exception wrapped in ServiceException or
|
||||||
|
* a new IOException that wraps the unexpected ServiceException.
|
||||||
*/
|
*/
|
||||||
public static IOException getRemoteException(ServiceException se) {
|
public static IOException getRemoteException(ServiceException se) {
|
||||||
Throwable e = se.getCause();
|
Throwable e = se.getCause();
|
||||||
return ((e instanceof RemoteException) ? (IOException) e :
|
if (e == null) {
|
||||||
new IOException(se));
|
return new IOException(se);
|
||||||
|
}
|
||||||
|
return e instanceof IOException ? (IOException) e : new IOException(se);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,9 +144,10 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
*
|
*
|
||||||
* ServiceException has the following causes:
|
* ServiceException has the following causes:
|
||||||
* <ol>
|
* <ol>
|
||||||
* <li>Exceptions encountered in this methods are thrown as
|
* <li>Exceptions encountered on the client side in this method are
|
||||||
* RpcClientException, wrapped in RemoteException</li>
|
* set as cause in ServiceException as is.</li>
|
||||||
* <li>Remote exceptions are thrown wrapped in RemoteException</li>
|
* <li>Exceptions from the server are wrapped in RemoteException and are
|
||||||
|
* set as cause in ServiceException</li>
|
||||||
* </ol>
|
* </ol>
|
||||||
*
|
*
|
||||||
* Note that the client calling protobuf RPC methods, must handle
|
* Note that the client calling protobuf RPC methods, must handle
|
||||||
|
@ -167,9 +168,8 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
try {
|
try {
|
||||||
val = (RpcResponseWritable) client.call(RpcKind.RPC_PROTOCOL_BUFFER,
|
val = (RpcResponseWritable) client.call(RpcKind.RPC_PROTOCOL_BUFFER,
|
||||||
new RpcRequestWritable(rpcRequest), remoteId);
|
new RpcRequestWritable(rpcRequest), remoteId);
|
||||||
} catch (Exception e) {
|
} catch (Throwable e) {
|
||||||
RpcClientException ce = new RpcClientException("Client exception", e);
|
throw new ServiceException(e);
|
||||||
throw new ServiceException(getRemoteException(ce));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
HadoopRpcResponseProto response = val.message;
|
HadoopRpcResponseProto response = val.message;
|
||||||
|
@ -197,9 +197,8 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
try {
|
try {
|
||||||
returnMessage = prototype.newBuilderForType()
|
returnMessage = prototype.newBuilderForType()
|
||||||
.mergeFrom(response.getResponse()).build();
|
.mergeFrom(response.getResponse()).build();
|
||||||
} catch (InvalidProtocolBufferException e) {
|
} catch (Throwable e) {
|
||||||
RpcClientException ce = new RpcClientException("Client exception", e);
|
throw new ServiceException(e);
|
||||||
throw new ServiceException(getRemoteException(ce));
|
|
||||||
}
|
}
|
||||||
return returnMessage;
|
return returnMessage;
|
||||||
}
|
}
|
||||||
|
@ -309,11 +308,6 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
numHandlers, numReaders, queueSizePerHandler, verbose, secretManager);
|
numHandlers, numReaders, queueSizePerHandler, verbose, secretManager);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RemoteException getRemoteException(Exception e) {
|
|
||||||
return new RemoteException(e.getClass().getName(),
|
|
||||||
StringUtils.stringifyException(e));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Server extends RPC.Server {
|
public static class Server extends RPC.Server {
|
||||||
/**
|
/**
|
||||||
* Construct an RPC server.
|
* Construct an RPC server.
|
||||||
|
@ -335,8 +329,8 @@ public class ProtobufRpcEngine implements RpcEngine {
|
||||||
numReaders, queueSizePerHandler, conf, classNameBase(protocolImpl
|
numReaders, queueSizePerHandler, conf, classNameBase(protocolImpl
|
||||||
.getClass().getName()), secretManager);
|
.getClass().getName()), secretManager);
|
||||||
this.verbose = verbose;
|
this.verbose = verbose;
|
||||||
registerProtocolAndImpl(RpcKind.RPC_PROTOCOL_BUFFER,
|
registerProtocolAndImpl(RpcKind.RPC_PROTOCOL_BUFFER, protocolClass,
|
||||||
protocolClass, protocolImpl);
|
protocolImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static RpcResponseWritable handleException(Throwable e) {
|
private static RpcResponseWritable handleException(Throwable e) {
|
||||||
|
|
Loading…
Reference in New Issue