captainzmc commented on a change in pull request #814:
URL: https://github.com/apache/hadoop-ozone/pull/814#discussion_r427238283
##########
File path:
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/request/key/OMKeyDeleteRequest.java
##########
@@ -116,51 +119,53 @@ public OMClientResponse
validateAndUpdateCache(OzoneManager ozoneManager,
boolean acquiredLock = false;
OMClientResponse omClientResponse = null;
Result result = null;
+ List<OmKeyInfo> omKeyInfoList= new ArrayList<>();
try {
- // check Acl
- checkKeyAcls(ozoneManager, volumeName, bucketName, keyName,
- IAccessAuthorizer.ACLType.DELETE, OzoneObj.ResourceType.KEY);
-
- String objectKey = omMetadataManager.getOzoneKey(
- volumeName, bucketName, keyName);
-
+ if (keyNameList.size() ==0) {
+ throw new OMException("Key not found", KEY_NOT_FOUND);
+ }
acquiredLock = omMetadataManager.getLock().acquireWriteLock(BUCKET_LOCK,
- volumeName, bucketName);
-
+ volumeName, bucketName);
// Validate bucket and volume exists or not.
validateBucketAndVolume(omMetadataManager, volumeName, bucketName);
-
- OmKeyInfo omKeyInfo = omMetadataManager.getKeyTable().get(objectKey);
- if (omKeyInfo == null) {
- throw new OMException("Key not found", KEY_NOT_FOUND);
+ Table<String, OmKeyInfo> keyTable = omMetadataManager.getKeyTable();
+ for (String keyName : keyNameList) {
+ // check Acl
+ checkKeyAcls(ozoneManager, volumeName, bucketName, keyName,
+ IAccessAuthorizer.ACLType.DELETE, OzoneObj.ResourceType.KEY);
+ String objectKey = omMetadataManager.getOzoneKey(
+ volumeName, bucketName, keyName);
+ OmKeyInfo omKeyInfo = keyTable.get(objectKey);
+ if (omKeyInfo == null) {
Review comment:
> 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` ?
>
> Please consider `Check if this transaction is a replay of ratis logs.`
this validation check also or any other exception. As there is no strict
recommendations, I'm keeping this open for discussions:-).
When delete multiple keys, such as a directory, FS will get all the keys in
this directory first, so at this time the key exists. But if there are two
people delete a directory at the same time, this can cause problems, which can
also occur when a single key is deleted before.
So here we're executing till first failure. Let the user know that the key
he deleted has just been deleted by someone else. If any other error occurs, it
will break and throw the exception to the user.
----------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]