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(And also I feel, if I use super.clone it will make 
shallow copy, and then I need to change few fields, so I think it will be 
double work in cloning). 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:
us...@infra.apache.org


With regards,
Apache Git Services

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

Reply via email to