bharatviswa504 commented on a change in pull request #448: HDDS-2870. Handle 
replay of KeyCreate requests.
URL: https://github.com/apache/hadoop-ozone/pull/448#discussion_r370833839
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/response/key/OMKeyCreateResponse.java
 ##########
 @@ -38,26 +36,30 @@
   private OmKeyInfo omKeyInfo;
   private long openKeySessionID;
 
-  public OMKeyCreateResponse(@Nullable OmKeyInfo omKeyInfo,
-      long openKeySessionID, @Nonnull OMResponse omResponse) {
+  public OMKeyCreateResponse(@Nonnull OMResponse omResponse,
+      @Nonnull OmKeyInfo omKeyInfo, long openKeySessionID) {
     super(omResponse);
     this.omKeyInfo = omKeyInfo;
     this.openKeySessionID = openKeySessionID;
   }
 
+  /**
+   * For when the request is not successful or it is a replay transaction.
+   * For a successful request, the other constructor should be used.
+   */
+  public OMKeyCreateResponse(@Nonnull OMResponse omResponse) {
+    super(omResponse);
+    checkStatusNotOK();
+  }
+
   @Override
   public void addToDBBatch(OMMetadataManager omMetadataManager,
       BatchOperation batchOperation) throws IOException {
 
-    // For OmResponse with failure, this should do nothing. This method is
-    // not called in failure scenario in OM code.
-    if (getOMResponse().getStatus() == OzoneManagerProtocolProtos.Status.OK) {
-      String openKey = omMetadataManager.getOpenKey(omKeyInfo.getVolumeName(),
-          omKeyInfo.getBucketName(), omKeyInfo.getKeyName(),
-          openKeySessionID);
-      omMetadataManager.getOpenKeyTable().putWithBatch(batchOperation,
-          openKey, omKeyInfo);
-    }
+    String openKey = omMetadataManager.getOpenKey(omKeyInfo.getVolumeName(),
 
 Review comment:
   NIT: public -> protected. (In Base class addToBatch is protected)

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to