ChenSammi commented on code in PR #12038:
URL: https://github.com/apache/ozone/pull/12038#discussion_r4677129499


##########
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/execution/OMExecutionFlow.java:
##########
@@ -100,12 +95,55 @@ private OMResponse submitExecutionToRatis(OMRequest 
request, boolean isWrite) th
 
     // 2. submit request to ratis
     OMResponse response = 
ozoneManager.getOmRatisServer().submitRequest(requestToSubmit, isWrite);
-    if (!response.getSuccess() && omClientRequest != null) {
-      omClientRequest.handleRequestFailure(ozoneManager);
+    if (omClientRequest != null) {
+      if (!response.getSuccess()) {
+        omClientRequest.handleRequestFailure(ozoneManager);
+      } else {
+        return postExecute(omClientRequest, request, response);
+      }
     }
     return response;
   }
 
+  /**
+   * Runs post-execute steps on a successful write response served from the 
Ratis retry cache.
+   */
+  public OMResponse postExecute(OMRequest request, OMResponse response) {
+    final OMClientRequest omClientRequest;
+    try {
+      omClientRequest = createClientRequest(request);

Review Comment:
   It's better we only create the OMClientRequest for those override the 
postExecute() function. 
   
   Some example code by Gemini
   
   ```
   private static final Set<Type> POST_EXECUTE_COMMANDS =
       Collections.unmodifiableSet(EnumSet.of(
           Type.RecoverLease
           // Add future commands here if they override postExecute()
       ));
   
   public static boolean hasPostExecute(Type cmdType) {
     return POST_EXECUTE_COMMANDS.contains(cmdType);
   }
   ```
   
   And a test to warn future contributors if they forget to update the Set. 
   
   ```
   @Test
   public void testPostExecuteCommandsRegistered() throws Exception {
     for (Type cmdType : Type.values()) {
       OMRequest dummyReq = OMRequest.newBuilder()
           .setCmdType(cmdType)
           .setClientId("test-client")
           .build();
       try {
         OMClientRequest req = OMRequestFactory.createRequest(dummyReq);
         Method m = req.getClass().getMethod(
             "postExecute", OMRequest.class, OMResponse.class);
         boolean overridden = 
!m.getDeclaringClass().equals(OMClientRequest.class);
         assertEquals(overridden, OMRequestFactory.hasPostExecute(cmdType),
             "Mismatch in POST_EXECUTE_COMMANDS for " + cmdType);
       } catch (Exception ignored) {
         // Skip CmdTypes that require specific sub-fields in constructor or 
are read-only
       }
     }
   }
   ```



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