java.io.Serializable@Public
@Stable
public class BlockLocation
extends java.lang.Object
implements java.io.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 | Description |
|---|---|
BlockLocation() |
Default Constructor.
|
BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
long offset,
long length) |
Constructor with host, name, offset and length.
|
BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
long offset,
long length,
boolean corrupt) |
Constructor with host, name, offset, length and corrupt flag.
|
BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] topologyPaths,
long offset,
long length) |
Constructor with host, name, network topology, offset and length.
|
BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] topologyPaths,
long offset,
long length,
boolean corrupt) |
Constructor with host, name, network topology, offset, length
and corrupt flag.
|
BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] cachedHosts,
java.lang.String[] topologyPaths,
long offset,
long length,
boolean corrupt) |
|
BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] cachedHosts,
java.lang.String[] topologyPaths,
java.lang.String[] storageIds,
StorageType[] storageTypes,
long offset,
long length,
boolean corrupt) |
|
BlockLocation(BlockLocation that) |
Copy constructor.
|
| Modifier and Type | Method | Description |
|---|---|---|
java.lang.String[] |
getCachedHosts() |
Get the list of hosts (hostname) hosting a cached replica of the block.
|
java.lang.String[] |
getHosts() |
Get the list of hosts (hostname) hosting this block.
|
long |
getLength() |
Get the length of the block.
|
java.lang.String[] |
getNames() |
Get the list of names (IP:xferPort) hosting this block.
|
long |
getOffset() |
Get the start offset of file associated with this block.
|
java.lang.String[] |
getStorageIds() |
Get the storageID of each replica of the block.
|
StorageType[] |
getStorageTypes() |
Get the storage type of each replica of the block.
|
java.lang.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(java.lang.String[] cachedHosts) |
Set the hosts hosting a cached replica of this block.
|
void |
setCorrupt(boolean corrupt) |
Set the corrupt flag.
|
void |
setHosts(java.lang.String[] hosts) |
Set the hosts hosting this block.
|
void |
setLength(long length) |
Set the length of block.
|
void |
setNames(java.lang.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(java.lang.String[] storageIds) |
|
void |
setStorageTypes(StorageType[] storageTypes) |
|
void |
setTopologyPaths(java.lang.String[] topologyPaths) |
Set the network topology paths of the hosts.
|
java.lang.String |
toString() |
public BlockLocation()
public BlockLocation(BlockLocation that)
that - blocklocation.public BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
long offset,
long length)
names - names array.hosts - host array.offset - offset.length - length.public BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
long offset,
long length,
boolean corrupt)
names - names.hosts - hosts.offset - offset.length - length.corrupt - corrupt.public BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] topologyPaths,
long offset,
long length)
names - names.hosts - hosts.topologyPaths - topologyPaths.offset - offset.length - length.public BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] topologyPaths,
long offset,
long length,
boolean corrupt)
names - names.hosts - hosts.topologyPaths - topologyPaths.offset - offset.length - length.corrupt - corrupt.public BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] cachedHosts,
java.lang.String[] topologyPaths,
long offset,
long length,
boolean corrupt)
public BlockLocation(java.lang.String[] names,
java.lang.String[] hosts,
java.lang.String[] cachedHosts,
java.lang.String[] topologyPaths,
java.lang.String[] storageIds,
StorageType[] storageTypes,
long offset,
long length,
boolean corrupt)
public java.lang.String[] getHosts()
throws java.io.IOException
java.io.IOException - If an I/O error occurred.public java.lang.String[] getCachedHosts()
public java.lang.String[] getNames()
throws java.io.IOException
java.io.IOException - If an I/O error occurred.public java.lang.String[] getTopologyPaths()
throws java.io.IOException
java.io.IOException - If an I/O error occurred.public java.lang.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(java.lang.String[] hosts)
throws java.io.IOException
hosts - hosts array.java.io.IOException - If an I/O error occurred.public void setCachedHosts(java.lang.String[] cachedHosts)
cachedHosts - cached hosts.public void setNames(java.lang.String[] names)
throws java.io.IOException
names - names.java.io.IOException - If an I/O error occurred.public void setTopologyPaths(java.lang.String[] topologyPaths)
throws java.io.IOException
topologyPaths - topology paths.java.io.IOException - If an I/O error occurred.public void setStorageIds(java.lang.String[] storageIds)
public void setStorageTypes(StorageType[] storageTypes)
public java.lang.String toString()
toString in class java.lang.ObjectCopyright © 2008–2025 Apache Software Foundation. All rights reserved.