szetszwo commented on code in PR #7329:
URL: https://github.com/apache/ozone/pull/7329#discussion_r1809673287
##########
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());
Review Comment:
Let's refactor the code to get/check ClientId and callId in
`OzoneManagerRatisServer`.
```java
//OzoneManagerRatisServer
private ClientId getClientId() {
final byte[] clientIdBytes = Server.getClientId();
if (!ozoneManager.isTestSecureOmFlag()) {
Preconditions.checkArgument(clientIdBytes != DUMMY_CLIENT_ID);
}
return ClientId.valueOf(UUID.nameUUIDFromBytes(clientIdBytes));
}
private long getCallId() {
final long callId = Server.getCallId();
if (!ozoneManager.isTestSecureOmFlag()) {
Preconditions.checkArgument(callId != INVALID_CALL_ID);
}
return callId;
}
```
##########
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);
Review Comment:
The we can move the whole thing to `OzoneManagerRatisServer`. It should
check retry before creating `omClientRequest`.
```java
//OzoneManagerRatisServer
public OMResponse checkRetryCache() throws ServiceException {
final ClientInvocationId invocationId =
ClientInvocationId.valueOf(getClientId(), getCallId());
final RetryCache.Entry cacheEntry =
getServerDivision().getRetryCache().getIfPresent(invocationId);
if (cacheEntry == null) {
return null; //cache miss
}
//cache hit
try {
return getOMResponse(cacheEntry.getReplyFuture().get());
} catch (ExecutionException ex) {
throw new ServiceException(ex.getMessage(), ex);
} catch (InterruptedException ex) {
Thread.currentThread().interrupt();
throw new ServiceException(ex.getMessage(), ex);
}
}
```
--
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]