adoroszlai commented on code in PR #7329:
URL: https://github.com/apache/ozone/pull/7329#discussion_r1808118835
##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/protocolPB/OzoneManagerProtocolServerSideTranslatorPB.java:
##########
@@ -215,6 +222,28 @@ private OMResponse internalProcessRequest(OMRequest
request) throws
// Added the assertion.
assert (omClientRequest != null);
OMClientRequest finalOmClientRequest = omClientRequest;
+
+ ClientInvocationId clientInvocationId = ClientInvocationId.valueOf(
+
ClientId.valueOf(UUID.nameUUIDFromBytes(ProtobufRpcEngine.Server.getClientId())),
+ ProtobufRpcEngine.Server.getCallId());
+ RetryCache.Entry cacheEntry =
+
omRatisServer.getServerDivision().getRetryCache().getIfPresent(clientInvocationId);
+ // if this request has been executed before, return the cached result.
+ if (cacheEntry != null) {
+ if (cacheEntry.getReplyFuture().isDone()) {
+ RaftClientReply raftClientReply;
+ try {
+ raftClientReply = cacheEntry.getReplyFuture().get();
+ } catch (ExecutionException ex) {
+ throw new ServiceException(ex.getMessage(), ex);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ throw new ServiceException(ex.getMessage(), ex);
+ }
+ return
OMRatisHelper.getOMResponseFromRaftClientReply(raftClientReply);
+ }
+ }
Review Comment:
Assuming it is needed and is specific to OM: please extract to a method to
keep the level of abstraction in `internalProcessRequest` more consistent.
Something like:
```java
RaftClientReply raftClientReply = getCachedReply(...);
if (raftClientReply != null) {
return OMRatisHelper.getOMResponseFromRaftClientReply(raftClientReply);
}
```
--
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]