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
This commit is contained in:
Eli Collins 2012-05-15 17:28:15 +00:00
parent 053f50f713
commit 9a8cf2b5a9
4 changed files with 19 additions and 22 deletions

View File

@ -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

View File

@ -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;
}
}

View File

@ -40,6 +40,7 @@ public interface Node {
* @param location the location
*/
public void setNetworkLocation(String location);
/** @return this node's name */
public String getName();

View File

@ -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 */