@InterfaceAudience.Public @InterfaceStability.Stable public class BlockLocation extends Object implements Serializable
BlockLocation(offset: 0, length: BLOCK_SIZE, hosts: {"host1:9866", "host2:9866, host3:9866"})And if the file is erasure-coded, each BlockLocation represents a logical block groups. Value offset is the offset of a block group in the file and value length is the total length of a block group. Hosts of a BlockLocation are the datanodes that holding all the data blocks and parity blocks of a block group. Suppose we have a RS_3_2 coded file (3 data units and 2 parity units). A BlockLocation example will be like:
BlockLocation(offset: 0, length: 3 * BLOCK_SIZE, hosts: {"host1:9866", "host2:9866","host3:9866","host4:9866","host5:9866"})Please refer to
FileSystem.getFileBlockLocations(FileStatus, long, long)
or
FileContext.getFileBlockLocations(Path, long, long)
for more examples.Constructor and Description |
---|
BlockLocation()
Default Constructor.
|
BlockLocation(BlockLocation that)
Copy constructor.
|
BlockLocation(String[] names,
String[] hosts,
long offset,
long length)
Constructor with host, name, offset and length.
|
BlockLocation(String[] names,
String[] hosts,
long offset,
long length,
boolean corrupt)
Constructor with host, name, offset, length and corrupt flag.
|
BlockLocation(String[] names,
String[] hosts,
String[] topologyPaths,
long offset,
long length)
Constructor with host, name, network topology, offset and length.
|
BlockLocation(String[] names,
String[] hosts,
String[] topologyPaths,
long offset,
long length,
boolean corrupt)
Constructor with host, name, network topology, offset, length
and corrupt flag.
|
BlockLocation(String[] names,
String[] hosts,
String[] cachedHosts,
String[] topologyPaths,
long offset,
long length,
boolean corrupt) |
BlockLocation(String[] names,
String[] hosts,
String[] cachedHosts,
String[] topologyPaths,
String[] storageIds,
StorageType[] storageTypes,
long offset,
long length,
boolean corrupt) |
Modifier and Type | Method and Description |
---|---|
String[] |
getCachedHosts()
Get the list of hosts (hostname) hosting a cached replica of the block.
|
String[] |
getHosts()
Get the list of hosts (hostname) hosting this block.
|
long |
getLength()
Get the length of the block.
|
String[] |
getNames()
Get the list of names (IP:xferPort) hosting this block.
|
long |
getOffset()
Get the start offset of file associated with this block.
|
String[] |
getStorageIds()
Get the storageID of each replica of the block.
|
StorageType[] |
getStorageTypes()
Get the storage type of each replica of the block.
|
String[] |
getTopologyPaths()
Get the list of network topology paths for each of the hosts.
|
boolean |
isCorrupt()
Get the corrupt flag.
|
boolean |
isStriped()
Return true if the block is striped (erasure coded).
|
void |
setCachedHosts(String[] cachedHosts)
Set the hosts hosting a cached replica of this block.
|
void |
setCorrupt(boolean corrupt)
Set the corrupt flag.
|
void |
setHosts(String[] hosts)
Set the hosts hosting this block.
|
void |
setLength(long length)
Set the length of block.
|
void |
setNames(String[] names)
Set the names (host:port) hosting this block.
|
void |
setOffset(long offset)
Set the start offset of file associated with this block.
|
void |
setStorageIds(String[] storageIds) |
void |
setStorageTypes(StorageType[] storageTypes) |
void |
setTopologyPaths(String[] topologyPaths)
Set the network topology paths of the hosts.
|
String |
toString() |
public BlockLocation()
public BlockLocation(BlockLocation that)
that
- blocklocation.public BlockLocation(String[] names, String[] hosts, long offset, long length)
names
- names array.hosts
- host array.offset
- offset.length
- length.public BlockLocation(String[] names, String[] hosts, long offset, long length, boolean corrupt)
names
- names.hosts
- hosts.offset
- offset.length
- length.corrupt
- corrupt.public BlockLocation(String[] names, String[] hosts, String[] topologyPaths, long offset, long length)
names
- names.hosts
- hosts.topologyPaths
- topologyPaths.offset
- offset.length
- length.public BlockLocation(String[] names, String[] hosts, String[] topologyPaths, long offset, long length, boolean corrupt)
names
- names.hosts
- hosts.topologyPaths
- topologyPaths.offset
- offset.length
- length.corrupt
- corrupt.public BlockLocation(String[] names, String[] hosts, String[] cachedHosts, String[] topologyPaths, long offset, long length, boolean corrupt)
public String[] getHosts() throws IOException
IOException
- If an I/O error occurred.public String[] getCachedHosts()
public String[] getNames() throws IOException
IOException
- If an I/O error occurred.public String[] getTopologyPaths() throws IOException
IOException
- If an I/O error occurred.public String[] getStorageIds()
public StorageType[] getStorageTypes()
public long getOffset()
public long getLength()
public boolean isCorrupt()
public boolean isStriped()
public void setOffset(long offset)
offset
- start offset.public void setLength(long length)
length
- length of block.public void setCorrupt(boolean corrupt)
corrupt
- corrupt flag.public void setHosts(String[] hosts) throws IOException
hosts
- hosts array.IOException
- If an I/O error occurred.public void setCachedHosts(String[] cachedHosts)
cachedHosts
- cached hosts.public void setNames(String[] names) throws IOException
names
- names.IOException
- If an I/O error occurred.public void setTopologyPaths(String[] topologyPaths) throws IOException
topologyPaths
- topology paths.IOException
- If an I/O error occurred.public void setStorageIds(String[] storageIds)
public void setStorageTypes(StorageType[] storageTypes)
Copyright © 2023 Apache Software Foundation. All rights reserved.