peterxcli commented on code in PR #11763:
URL: https://github.com/apache/ozone/pull/11763#discussion_r4476171128
##########
hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/protocolPB/GrpcOmTransport.java:
##########
@@ -243,30 +243,21 @@ private OMResponse submitRequestToHost(OMRequest payload,
String targetHost)
}
public static Exception unwrapException(Exception ex) {
- Exception grpcException = null;
- try {
- StatusRuntimeException srexp =
- (StatusRuntimeException)ex.getCause();
- Status status = srexp.getStatus();
- LOG.debug("GRPC exception wrapped: {}", status.getDescription());
- if (status.getCode() == Status.Code.INTERNAL) {
- // exception potentially generated by OzoneManagerServiceGrpc
- String description = status.getDescription();
- int colonIndex = description.indexOf(':');
- grpcException = new ServiceException(new
RemoteException(description.substring(0, colonIndex),
- description.substring(colonIndex + 2)));
- } else if ((status.getCode() == Status.Code.RESOURCE_EXHAUSTED) ||
- (status.getCode() == Status.Code.DATA_LOSS)) {
- grpcException = srexp;
- } else {
- // exception generated by connection failure, gRPC
- grpcException = ex;
+ StatusRuntimeException srexp = (StatusRuntimeException) ex.getCause();
+ Status status = srexp.getStatus();
+ LOG.debug("GRPC exception wrapped: {}", status.getDescription());
+ if (status.getCode() == Status.Code.INTERNAL) {
+ IOException omException = OMGrpcError.toOMException(srexp);
+ if (omException != null) {
+ // exception generated by OzoneManagerServiceGrpc
+ return new ServiceException(omException);
}
- } catch (Exception e) {
- grpcException = new IOException(e);
- LOG.error("error unwrapping exception from OMResponse {}");
+ } else if ((status.getCode() == Status.Code.RESOURCE_EXHAUSTED) ||
+ (status.getCode() == Status.Code.DATA_LOSS)) {
+ return srexp;
}
- return grpcException;
+ // exception generated by gRPC, e.g. a connection failure
+ return ex;
Review Comment:
because the description keeps the old class: message format. A new S3G with
an old OM still works too.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]