rakeshadr commented on a change in pull request #814: HDDS-3286. 
BasicOzoneFileSystem  support batchDelete and batchRename.
URL: https://github.com/apache/hadoop-ozone/pull/814#discussion_r407588198
 
 

 ##########
 File path: 
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyRenameRequest.java
 ##########
 @@ -127,112 +131,124 @@ public OMClientResponse 
validateAndUpdateCache(OzoneManager ozoneManager,
     OmKeyInfo fromKeyValue = null;
     String toKey = null, fromKey = null;
     Result result = null;
+    List<RenameInfo> renameInfoList = new ArrayList<>();
     try {
-      if (toKeyName.length() == 0 || fromKeyName.length() == 0) {
-        throw new OMException("Key name is empty",
-            OMException.ResultCodes.INVALID_KEY_NAME);
+      if (renameKeyMap.size() == 0) {
+        throw new OMException("Key not found " + fromKey, KEY_NOT_FOUND);
       }
-      // check Acls to see if user has access to perform delete operation on
-      // old key and create operation on new key
-      checkKeyAcls(ozoneManager, volumeName, bucketName, fromKeyName,
-          IAccessAuthorizer.ACLType.DELETE, OzoneObj.ResourceType.KEY);
-      checkKeyAcls(ozoneManager, volumeName, bucketName, toKeyName,
-          IAccessAuthorizer.ACLType.CREATE, OzoneObj.ResourceType.KEY);
-
       acquiredLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
-          volumeName, bucketName);
-
-      // Validate bucket and volume exists or not.
-      validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
-
-      // Check if toKey exists
-      fromKey = omMetadataManager.getOzoneKey(volumeName, bucketName,
-          fromKeyName);
-      toKey = omMetadataManager.getOzoneKey(volumeName, bucketName, toKeyName);
-      OmKeyInfo toKeyValue = omMetadataManager.getKeyTable().get(toKey);
-
-      if (toKeyValue != null) {
-
-        // Check if this transaction is a replay of ratis logs.
-        if (isReplay(ozoneManager, toKeyValue, trxnLogIndex)) {
-
-          // Check if fromKey is still in the DB and created before this
-          // replay.
-          // For example, lets say we have the following sequence of
-          // transactions.
-          //     Trxn 1 : Create Key1
-          //     Trnx 2 : Rename Key1 to Key2 -> Deletes Key1 and Creates Key2
-          // Now if these transactions are replayed:
-          //     Replay Trxn 1 : Creates Key1 again as Key1 does not exist in 
DB
-          //     Replay Trxn 2 : Key2 is not created as it exists in DB and the
-          //                     request would be deemed a replay. But Key1
-          //                     is still in the DB and needs to be deleted.
-          fromKeyValue = omMetadataManager.getKeyTable().get(fromKey);
-          if (fromKeyValue != null) {
-            // Check if this replay transaction was after the fromKey was
-            // created. If so, we have to delete the fromKey.
-            if (ozoneManager.isRatisEnabled() &&
-                trxnLogIndex > fromKeyValue.getUpdateID()) {
-              // Add to cache. Only fromKey should be deleted. ToKey already
-              // exists in DB as this transaction is a replay.
-              result = Result.DELETE_FROM_KEY_ONLY;
-              Table<String, OmKeyInfo> keyTable = omMetadataManager
-                  .getKeyTable();
-              keyTable.addCacheEntry(new CacheKey<>(fromKey),
-                  new CacheValue<>(Optional.absent(), trxnLogIndex));
+              volumeName, bucketName);
+      for (Map.Entry<String, String> renameKeyEntry : renameKeyMap.entrySet()) 
{
+        String fromKeyName = renameKeyEntry.getKey();
 
 Review comment:
   Above comment is applicable `renamekeys` as well.
   
   What if one of the key not found in the list of keys and assume there are 
10keys and the 5th key not found. What is the contract batch api provides 
`executes all or executes till first failure or none of them` ?

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