@InterfaceAudience.Private public class HDFSBlocksDistribution extends Object
Modifier and Type | Class and Description |
---|---|
static class |
HDFSBlocksDistribution.HostAndWeight
Stores the hostname and weight for that hostname.
|
static interface |
HDFSBlocksDistribution.Visitor
Implementations 'visit' hostAndWeight.
|
Modifier and Type | Field and Description |
---|---|
private Map<String,HDFSBlocksDistribution.HostAndWeight> |
hostAndWeights |
private long |
uniqueBlocksTotalWeight |
Constructor and Description |
---|
HDFSBlocksDistribution() |
Modifier and Type | Method and Description |
---|---|
void |
add(HDFSBlocksDistribution otherBlocksDistribution)
This will add the distribution from input to this object
|
private void |
addHostAndBlockWeight(String host,
long weight,
long weightForSsd)
add some weight to a specific host
|
void |
addHostsAndBlockWeight(String[] hosts,
long weight)
add some weight to a list of hosts, update the value of unique block weight
|
void |
addHostsAndBlockWeight(String[] hosts,
long weight,
org.apache.hadoop.fs.StorageType[] storageTypes)
add some weight to a list of hosts, update the value of unique block weight
|
private void |
addUniqueWeight(long weight)
add some weight to the total unique weight
|
float |
getBlockLocalityIndex(String host)
Get the block locality index for a given host
|
float |
getBlockLocalityIndexForSsd(String host)
Get the block locality index for a ssd for a given host
|
private long |
getBlocksLocalityWeightInternal(String host,
HDFSBlocksDistribution.Visitor visitor) |
long |
getBlocksLocalWeight(String host)
Get the blocks local weight for a given host
|
long |
getBlocksLocalWithSsdWeight(String host)
Get the blocks local weight with ssd for a given host
|
Map<String,HDFSBlocksDistribution.HostAndWeight> |
getHostAndWeights()
Returns the hosts and their weights
|
List<String> |
getTopHosts()
Return the sorted list of hosts in terms of their weights
|
HDFSBlocksDistribution.HostAndWeight[] |
getTopHostsWithWeights()
Return the sorted list of hosts in terms of their weights
|
long |
getUniqueBlocksTotalWeight()
Returns the sum of all unique blocks' weight
|
long |
getWeight(String host)
return the weight for a specific host, that will be the total bytes of all blocks on the host
|
String |
toString() |
private Map<String,HDFSBlocksDistribution.HostAndWeight> hostAndWeights
private long uniqueBlocksTotalWeight
public HDFSBlocksDistribution()
public void addHostsAndBlockWeight(String[] hosts, long weight)
hosts
- the list of the hostweight
- the weightpublic void addHostsAndBlockWeight(String[] hosts, long weight, org.apache.hadoop.fs.StorageType[] storageTypes)
hosts
- the list of the hostweight
- the weightprivate void addUniqueWeight(long weight)
weight
- the weightprivate void addHostAndBlockWeight(String host, long weight, long weightForSsd)
host
- the host nameweight
- the weightweightForSsd
- the weight for ssdpublic Map<String,HDFSBlocksDistribution.HostAndWeight> getHostAndWeights()
public long getWeight(String host)
host
- the host namepublic long getUniqueBlocksTotalWeight()
public float getBlockLocalityIndex(String host)
host
- the host namepublic float getBlockLocalityIndexForSsd(String host)
host
- the host namepublic long getBlocksLocalWeight(String host)
host
- the host namepublic long getBlocksLocalWithSsdWeight(String host)
host
- the host nameprivate long getBlocksLocalityWeightInternal(String host, HDFSBlocksDistribution.Visitor visitor)
public void add(HDFSBlocksDistribution otherBlocksDistribution)
otherBlocksDistribution
- the other hdfs blocks distributionpublic List<String> getTopHosts()
public HDFSBlocksDistribution.HostAndWeight[] getTopHostsWithWeights()
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.