[ 
https://issues.apache.org/jira/browse/HDFS-7829?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14349476#comment-14349476
 ] 

Jing Zhao commented on HDFS-7829:
---------------------------------

Thanks for the update, [~tasanuma0829]!

The current builder implementation looks good to me in general. The plan also 
sounds good to me. Some comments on the builder:
# "this.cachedLocs" should be changed to "this.locs"?
{code}
+    public Builder setStorages(DatanodeStorageInfo[] storages) {
+      this.cachedLocs = DatanodeStorageInfo.toDatanodeInfos(storages);
+      this.storageIDs = DatanodeStorageInfo.toStorageIDs(storages);
+      this.storageTypes = DatanodeStorageInfo.toStorageTypes(storages);
+      return this;
+    }
{code}
# Looking into the current constructors, seems we're mainly handling two 
scenarios:
1) The caller passes in a "DatanodeStorageInfo[]" which is used to set 
{{locs}}, {{storageIDs}}, and {{storageTypes}}.
2) The caller passes in a "DatanodeInfo[]" which is used to set {{locs}}, while 
{{storageIDs}} and {{storageTypes}} are left as null.
Thus it may be better to reflect this dependency in the builder. More 
specifically, I think we don't need {{setStrageIDs}} and {{setStorageTypes}} in 
the builder.

> Code clean up for LocatedBlock
> ------------------------------
>
>                 Key: HDFS-7829
>                 URL: https://issues.apache.org/jira/browse/HDFS-7829
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>            Reporter: Jing Zhao
>            Assignee: Takanobu Asanuma
>            Priority: Minor
>         Attachments: HDFS-7829.1.patch
>
>
> We can do some code cleanup for {{LocatedBlock}}, including:
> # Using a simple Builder pattern to avoid multiple constructors
> # Setting data fields like {{corrupt}} and {{offset}} to final



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to