David Mollitor created HDFS-14862: ------------------------------------- Summary: Review of MovedBlocks Key: HDFS-14862 URL: https://issues.apache.org/jira/browse/HDFS-14862 Project: Hadoop HDFS Issue Type: Improvement Components: balancer & mover Affects Versions: 3.2.0 Reporter: David Mollitor Assignee: David Mollitor Attachments: HDFS-14862.1.patch
Internal data structure needs to be protected (synchronized) but is scoped as {{protected}} so any sub-class could modify without a lock. Synchronize the collection itself for protection. It also returns the internal data structure in {{getLocations}} so the structure could be modified outside of the lock. Create a copy instead. {code:java} /** The locations of the replicas of the block. */ protected final List<L> locations = new ArrayList<L>(3); public Locations(Block block) { this.block = block; } /** clean block locations */ public synchronized void clearLocations() { locations.clear(); } ... /** @return its locations */ public synchronized List<L> getLocations() { return locations; } {code} [https://github.com/apache/hadoop/blob/trunk/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/balancer/MovedBlocks.java#L43] Also, remove a bunch of superfluous and complicated code. -- This message was sent by Atlassian Jira (v8.3.4#803005) --------------------------------------------------------------------- To unsubscribe, e-mail: hdfs-dev-unsubscr...@hadoop.apache.org For additional commands, e-mail: hdfs-dev-h...@hadoop.apache.org