[
https://issues.apache.org/jira/browse/HDFS-14862?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
David Mollitor updated HDFS-14862:
----------------------------------
Attachment: HDFS-14862.1.patch
> 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
> Priority: Minor
> 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: [email protected]
For additional commands, e-mail: [email protected]