cchung100m commented on code in PR #8990:
URL: https://github.com/apache/ozone/pull/8990#discussion_r2591837652
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/container/states/ContainerEntry.java:
##########
@@ -42,14 +43,22 @@ public ContainerInfo getInfo() {
}
public Set<ContainerReplica> getReplicas() {
- return new HashSet<>(replicas.values());
+ return Collections.unmodifiableSet(replicas.keySet());
}
public ContainerReplica put(ContainerReplica r) {
- return replicas.put(r.getDatanodeDetails().getID(), r);
+ // Modifications are rare compared to reads, so to optimize for read we
return and unmodifable view of the
+ // map in getReplicas. That means for any modification we need to copy the
map.
+ Map<ContainerReplica, ContainerReplica> map = new HashMap<>(8);
+ map.putAll(this.replicas);
+ replicas = map;
+ return replicas.put(r, r);
}
public ContainerReplica removeReplica(DatanodeID datanodeID) {
+ Map<ContainerReplica, ContainerReplica> map = new HashMap<>(8);
+ map.putAll(this.replicas);
+ replicas = map;
return replicas.remove(datanodeID);
Review Comment:
Hi @adoroszlai
Thanks for the reminder. I have updated the part you mentioned.
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]