Browse Source

HDDS-1686. Remove check to get from openKeyTable in acl implementatio… (#966)

Bharat Viswanadham 5 years ago
parent
commit
2ea71d953b

+ 8 - 35
hadoop-ozone/ozone-manager/src/main/java/org/apache/hadoop/ozone/om/KeyManagerImpl.java

@@ -1396,17 +1396,10 @@ public class KeyManagerImpl implements KeyManager {
       validateBucket(volume, bucket);
       String objectKey = metadataManager.getOzoneKey(volume, bucket, keyName);
       OmKeyInfo keyInfo = metadataManager.getKeyTable().get(objectKey);
-      Table keyTable;
       if (keyInfo == null) {
-        keyInfo = metadataManager.getOpenKeyTable().get(objectKey);
-        if (keyInfo == null) {
-          throw new OMException("Key not found. Key:" +
-              objectKey, KEY_NOT_FOUND);
-        }
-        keyTable = metadataManager.getOpenKeyTable();
-      } else {
-        keyTable = metadataManager.getKeyTable();
+        throw new OMException("Key not found. Key:" + objectKey, KEY_NOT_FOUND);
       }
+
       List<OzoneAclInfo> newAcls = new ArrayList<>(keyInfo.getAcls());
       OzoneAclInfo newAcl = null;
       for(OzoneAclInfo a: keyInfo.getAcls()) {
@@ -1442,7 +1435,7 @@ public class KeyManagerImpl implements KeyManager {
           .setDataSize(keyInfo.getDataSize())
           .setFileEncryptionInfo(keyInfo.getFileEncryptionInfo())
           .build();
-      keyTable.put(objectKey, newObj);
+      metadataManager.getKeyTable().put(objectKey, newObj);
     } catch (IOException ex) {
       if (!(ex instanceof OMException)) {
         LOG.error("Add acl operation failed for key:{}/{}/{}", volume,
@@ -1475,16 +1468,8 @@ public class KeyManagerImpl implements KeyManager {
       validateBucket(volume, bucket);
       String objectKey = metadataManager.getOzoneKey(volume, bucket, keyName);
       OmKeyInfo keyInfo = metadataManager.getKeyTable().get(objectKey);
-      Table keyTable;
       if (keyInfo == null) {
-        keyInfo = metadataManager.getOpenKeyTable().get(objectKey);
-        if (keyInfo == null) {
-          throw new OMException("Key not found. Key:" +
-              objectKey, KEY_NOT_FOUND);
-        }
-        keyTable = metadataManager.getOpenKeyTable();
-      } else {
-        keyTable = metadataManager.getKeyTable();
+        throw new OMException("Key not found. Key:" + objectKey, KEY_NOT_FOUND);
       }
 
       List<OzoneAclInfo> newAcls = new ArrayList<>(keyInfo.getAcls());
@@ -1529,7 +1514,7 @@ public class KeyManagerImpl implements KeyManager {
           .setFileEncryptionInfo(keyInfo.getFileEncryptionInfo())
           .build();
 
-      keyTable.put(objectKey, newObj);
+      metadataManager.getKeyTable().put(objectKey, newObj);
     } catch (IOException ex) {
       if (!(ex instanceof OMException)) {
         LOG.error("Remove acl operation failed for key:{}/{}/{}", volume,
@@ -1562,16 +1547,8 @@ public class KeyManagerImpl implements KeyManager {
       validateBucket(volume, bucket);
       String objectKey = metadataManager.getOzoneKey(volume, bucket, keyName);
       OmKeyInfo keyInfo = metadataManager.getKeyTable().get(objectKey);
-      Table keyTable;
       if (keyInfo == null) {
-        keyInfo = metadataManager.getOpenKeyTable().get(objectKey);
-        if (keyInfo == null) {
-          throw new OMException("Key not found. Key:" +
-              objectKey, KEY_NOT_FOUND);
-        }
-        keyTable = metadataManager.getOpenKeyTable();
-      } else {
-        keyTable = metadataManager.getKeyTable();
+        throw new OMException("Key not found. Key:" + objectKey, KEY_NOT_FOUND);
       }
 
       List<OzoneAclInfo> newAcls = new ArrayList<>();
@@ -1592,7 +1569,7 @@ public class KeyManagerImpl implements KeyManager {
           .setFileEncryptionInfo(keyInfo.getFileEncryptionInfo())
           .build();
 
-      keyTable.put(objectKey, newObj);
+      metadataManager.getKeyTable().put(objectKey, newObj);
     } catch (IOException ex) {
       if (!(ex instanceof OMException)) {
         LOG.error("Set acl operation failed for key:{}/{}/{}", volume,
@@ -1624,11 +1601,7 @@ public class KeyManagerImpl implements KeyManager {
       String objectKey = metadataManager.getOzoneKey(volume, bucket, keyName);
       OmKeyInfo keyInfo = metadataManager.getKeyTable().get(objectKey);
       if (keyInfo == null) {
-        keyInfo = metadataManager.getOpenKeyTable().get(objectKey);
-        if (keyInfo == null) {
-          throw new OMException("Key not found. Key:" +
-              objectKey, KEY_NOT_FOUND);
-        }
+        throw new OMException("Key not found. Key:" + objectKey, KEY_NOT_FOUND);
       }
 
       List<OzoneAcl> acls = new ArrayList<>();