From 9a8cf2b5a95d1a2a971664c540ee1c39a4c9013e Mon Sep 17 00:00:00 2001 From: Eli Collins Date: Tue, 15 May 2012 17:28:15 +0000 Subject: [PATCH] HADOOP-8398. svn merge -c 1338806 from trunk git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/branches/branch-2@1338807 13f79535-47bb-0310-9956-ffa450edef68 --- .../hadoop-common/CHANGES.txt | 2 ++ .../org/apache/hadoop/fs/BlockLocation.java | 36 ++++++++----------- .../main/java/org/apache/hadoop/net/Node.java | 1 + .../java/org/apache/hadoop/net/NodeBase.java | 2 +- 4 files changed, 19 insertions(+), 22 deletions(-) diff --git a/hadoop-common-project/hadoop-common/CHANGES.txt b/hadoop-common-project/hadoop-common/CHANGES.txt index 953f4a76338..9a63f6b1909 100644 --- a/hadoop-common-project/hadoop-common/CHANGES.txt +++ b/hadoop-common-project/hadoop-common/CHANGES.txt @@ -186,6 +186,8 @@ Release 2.0.0 - UNRELEASED HADOOP-8366 Use ProtoBuf for RpcResponseHeader (sanjay radia) + HADOOP-8398. Cleanup BlockLocation. (eli) + OPTIMIZATIONS BUG FIXES diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BlockLocation.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BlockLocation.java index 46989f2204c..cfe9ee8c660 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BlockLocation.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/BlockLocation.java @@ -17,29 +17,23 @@ */ package org.apache.hadoop.fs; -import java.io.DataInput; -import java.io.DataOutput; import java.io.IOException; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.classification.InterfaceStability; -import org.apache.hadoop.io.Text; -import org.apache.hadoop.io.Writable; -import org.apache.hadoop.io.WritableFactories; -import org.apache.hadoop.io.WritableFactory; -/* - * A BlockLocation lists hosts, offset and length - * of block. - * +/** + * Represents the network location of a block, information about the hosts + * that contain block replicas, and other block metadata (E.g. the file + * offset associated with the block, length, whether it is corrupt, etc). */ @InterfaceAudience.Public @InterfaceStability.Stable public class BlockLocation { - private String[] hosts; //hostnames of datanodes - private String[] names; //hostname:portNumber of datanodes - private String[] topologyPaths; // full path name in network topology - private long offset; //offset of the of the block in the file + private String[] hosts; // Datanode hostnames + private String[] names; // Datanode IP:xferPort for accessing the block + private String[] topologyPaths; // Full path name in network topology + private long offset; // Offset of the block in the file private long length; private boolean corrupt; @@ -105,7 +99,7 @@ public class BlockLocation { * Get the list of hosts (hostname) hosting this block */ public String[] getHosts() throws IOException { - if ((hosts == null) || (hosts.length == 0)) { + if (hosts == null || hosts.length == 0) { return new String[0]; } else { return hosts; @@ -113,25 +107,25 @@ public class BlockLocation { } /** - * Get the list of names (hostname:port) hosting this block + * Get the list of names (IP:xferPort) hosting this block */ public String[] getNames() throws IOException { - if ((names == null) || (names.length == 0)) { + if (names == null || names.length == 0) { return new String[0]; } else { - return this.names; + return names; } } /** * Get the list of network topology paths for each of the hosts. - * The last component of the path is the host. + * The last component of the path is the "name" (IP:xferPort). */ public String[] getTopologyPaths() throws IOException { - if ((topologyPaths == null) || (topologyPaths.length == 0)) { + if (topologyPaths == null || topologyPaths.length == 0) { return new String[0]; } else { - return this.topologyPaths; + return topologyPaths; } } diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/Node.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/Node.java index ac57ba4abcd..63ee0579dcf 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/Node.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/Node.java @@ -40,6 +40,7 @@ public interface Node { * @param location the location */ public void setNetworkLocation(String location); + /** @return this node's name */ public String getName(); diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java index a8f278176a0..a61054d3723 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/net/NodeBase.java @@ -110,7 +110,7 @@ public class NodeBase implements Node { * @return the path of a node */ public static String getPath(Node node) { - return node.getNetworkLocation()+PATH_SEPARATOR_STR+node.getName(); + return node.getNetworkLocation() + PATH_SEPARATOR_STR + node.getName(); } /** @return this node's path as its string representation */