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

This commit is contained in:
Bharat Viswanadham 2019-07-22 15:11:10 -07:00 committed by Arpit Agarwal
parent c958eddcf4
commit 2ea71d953b
1 changed files with 8 additions and 35 deletions

View File

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