You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by GitBox <gi...@apache.org> on 2019/10/23 06:00:46 UTC

[GitHub] [hadoop-ozone] bharatviswa504 commented on a change in pull request #71: HDDS-2344. Add immutable entries in to the DoubleBuffer for Volume requests.

bharatviswa504 commented on a change in pull request #71: HDDS-2344. Add immutable entries in to the DoubleBuffer for Volume requests.
URL: https://github.com/apache/hadoop-ozone/pull/71#discussion_r337861523
 
 

 ##########
 File path: hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/om/helpers/OmOzoneAclMap.java
 ##########
 @@ -298,4 +303,27 @@ public static OmOzoneAclMap ozoneAclGetFromProtobuf(
   public List<OzoneAclInfo> getDefaultAclList() {
     return defaultAclList;
   }
+
+  @Override
+  public Object clone() {
+    ArrayList<Map<String, BitSet>> accessMap = new ArrayList<>();
+
+    // Initialize.
+    for (OzoneAclType aclType : OzoneAclType.values()) {
+      accessMap.add(aclType.ordinal(), new HashMap<>());
+    }
+
+    // Add from original accessAclMap to accessMap.
+    for (OzoneAclType aclType : OzoneAclType.values()) {
+      final int ordinal = aclType.ordinal();
+      accessAclMap.get(ordinal).forEach((k, v) ->
+          accessMap.get(ordinal).put(k, (BitSet) v.clone()));
+    }
+
+    // We can do shallow copy here, as OzoneAclInfo is immutable structure.
+    ArrayList<OzoneAclInfo> defaultList = new ArrayList<>();
+    defaultList.addAll(defaultAclList);
+
+    return new OmOzoneAclMap(defaultList, accessMap);
+  }
 
 Review comment:
   I thought it is the final class and did like that. I think this should be marked as final like other classes like OMVolumeArgs. (As these classes represent proto structure data). And also as for few parameters, I need a deep copy, so I changed like this. Let me know what do you think.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-dev-unsubscribe@hadoop.apache.org
For additional commands, e-mail: hdfs-dev-help@hadoop.apache.org