[
https://issues.apache.org/jira/browse/HDFS-5450?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13819181#comment-13819181
]
Colin Patrick McCabe commented on HDFS-5450:
--------------------------------------------
Looks like a good cleanup. I like the idea of using a shared empty array
rather than having "if null" sprinkled everywhere.
{code}
/**
+ * Set the hosts hosting a cached replica of this block
+ */
+ public void setCachedHosts(String[] cachedHosts) {
+ if (cachedHosts != null) {
+ this.cachedHosts = cachedHosts;
+ }
+ }
+
+ /**
* Set the names (host:port) hosting this block
*/
public void setNames(String[] names) throws IOException {
- if (names == null) {
- this.names = new String[0];
- } else {
+ if (names != null) {
this.names = names;
}
}
@@ -197,9 +222,7 @@ public void setNames(String[] names) throws IOException {
* Set the network topology paths of the hosts
*/
public void setTopologyPaths(String[] topologyPaths) throws IOException {
- if (topologyPaths == null) {
- this.topologyPaths = new String[0];
- } else {
+ if (topologyPaths != null) {
this.topologyPaths = topologyPaths;
}
}
{code}
This doesn't seem quite right. If someone sets one of these things to null,
surely we should interpret that as clearing the field, rather than ignoring it
altogether?
> better API for getting the cached blocks locations
> --------------------------------------------------
>
> Key: HDFS-5450
> URL: https://issues.apache.org/jira/browse/HDFS-5450
> Project: Hadoop HDFS
> Issue Type: Sub-task
> Components: hdfs-client
> Affects Versions: 3.0.0
> Reporter: Colin Patrick McCabe
> Assignee: Andrew Wang
> Priority: Minor
> Attachments: hdfs-5450-1.patch, hdfs-5450-2.patch
>
>
> Currently, we have to downcast the {{BlockLocation}] to {{HdfsBlockLocation}}
> to get information about whether a replica is cached. We should have this
> information in {{BlockLocation}} instead.
--
This message was sent by Atlassian JIRA
(v6.1#6144)