duongkame commented on code in PR #3780:
URL: https://github.com/apache/ozone/pull/3780#discussion_r988525697


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java:
##########
@@ -363,10 +367,36 @@ public EncryptedKeyVersion run() throws IOException {
   public OmKeyInfo lookupKey(OmKeyArgs args, String clientAddress)
       throws IOException {
     Preconditions.checkNotNull(args);
+
+    OmKeyInfo value = captureLatencyNs(metrics.getLookupReadKeyInfoLatencyNs(),
+        () -> readKeyInfo(args));
+
+    // If operation is head, do not perform any additional steps based on 
flags.
+    // As head operation does not need any of those details.
+    if (!args.isHeadOp()) {
+
+      // add block token for read.
+      captureLatencyNs(metrics.getLookupGenerateBlockTokenLatencyNs(),
+          () -> addBlockToken4Read(value));
+
+      // Refresh container pipeline info from SCM
+      // based on OmKeyArgs.refreshPipeline flag
+      // value won't be null as the check is done inside try/catch block.
+      captureLatencyNs(metrics.getLookupRefreshLocationLatencyNs(),
+          () -> refresh(value));

Review Comment:
   Leveraging the cache also comes with a responsibility to maintain the cached 
data consistency. In this case, a container location cached in OM may be stale 
when a relevant datanode is down or the container is moved to another set of 
datanodes as a result of rebalancing. We've decided to put the responsibility 
of triggering cache invalidation to the clients when they detect errors reading 
data from datanodes. This is done by client retrying the new API `getKeyInfo` 
call with `forceUpdateContainerCacheFromSCM=true`. These interactions are 
detailed [in this 
chapter](https://docs.google.com/document/d/1-hVdA7mRBFiFOqr0J0Pg6-Ie5SOZaT7Z/edit#heading=h.4d34og8).
   
   For backward compatibility with previous client versions, we need to keep 
`lookupKey` as it is.
   
   



-- 
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]

Reply via email to