YARN-10697. Resources are displayed in bytes in UI for schedulers other than capacity. Contributed by Bilwa S T.
This commit is contained in:
parent
714427c414
commit
174f3a96b1
@ -31,6 +31,7 @@
|
|||||||
import org.apache.hadoop.classification.InterfaceStability.Evolving;
|
import org.apache.hadoop.classification.InterfaceStability.Evolving;
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Stable;
|
import org.apache.hadoop.classification.InterfaceStability.Stable;
|
||||||
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
import org.apache.hadoop.classification.InterfaceStability.Unstable;
|
||||||
|
import org.apache.hadoop.util.StringUtils;
|
||||||
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
|
import org.apache.hadoop.yarn.api.ApplicationMasterProtocol;
|
||||||
import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
|
import org.apache.hadoop.yarn.api.protocolrecords.ResourceTypes;
|
||||||
import org.apache.hadoop.yarn.api.records.impl.LightWeightResource;
|
import org.apache.hadoop.yarn.api.records.impl.LightWeightResource;
|
||||||
@ -465,9 +466,13 @@ public int compareTo(Resource other) {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
|
return getFormattedString(String.valueOf(getMemorySize()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getFormattedString(String memory) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append("<memory:").append(getMemorySize()).append(", vCores:")
|
sb.append("<memory:").append(memory).append(", vCores:")
|
||||||
.append(getVirtualCores());
|
.append(getVirtualCores());
|
||||||
|
|
||||||
for (int i = 2; i < resources.length; i++) {
|
for (int i = 2; i < resources.length; i++) {
|
||||||
@ -485,6 +490,15 @@ public String toString() {
|
|||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is to get memory in terms of KB|MB|GB.
|
||||||
|
* @return string containing all resources
|
||||||
|
*/
|
||||||
|
public String getFormattedString() {
|
||||||
|
return getFormattedString(
|
||||||
|
StringUtils.byteDesc(getMemorySize() * 1024 * 1024));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 47;
|
final int prime = 47;
|
||||||
|
@ -83,13 +83,13 @@ protected void render(Block html) {
|
|||||||
} else {
|
} else {
|
||||||
allocatedContainers = clusterMetrics.getContainersAllocated();
|
allocatedContainers = clusterMetrics.getContainersAllocated();
|
||||||
usedResources = Resource.newInstance(
|
usedResources = Resource.newInstance(
|
||||||
clusterMetrics.getAllocatedMB() * BYTES_IN_MB,
|
clusterMetrics.getAllocatedMB(),
|
||||||
(int) clusterMetrics.getAllocatedVirtualCores());
|
(int) clusterMetrics.getAllocatedVirtualCores());
|
||||||
totalResources = Resource.newInstance(
|
totalResources = Resource.newInstance(
|
||||||
clusterMetrics.getTotalMB() * BYTES_IN_MB,
|
clusterMetrics.getTotalMB(),
|
||||||
(int) clusterMetrics.getTotalVirtualCores());
|
(int) clusterMetrics.getTotalVirtualCores());
|
||||||
reservedResources = Resource.newInstance(
|
reservedResources = Resource.newInstance(
|
||||||
clusterMetrics.getReservedMB() * BYTES_IN_MB,
|
clusterMetrics.getReservedMB(),
|
||||||
(int) clusterMetrics.getReservedVirtualCores());
|
(int) clusterMetrics.getReservedVirtualCores());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,9 +121,9 @@ protected void render(Block html) {
|
|||||||
)
|
)
|
||||||
).
|
).
|
||||||
td(String.valueOf(allocatedContainers)).
|
td(String.valueOf(allocatedContainers)).
|
||||||
td(usedResources.toString()).
|
td(usedResources.getFormattedString()).
|
||||||
td(totalResources.toString()).
|
td(totalResources.getFormattedString()).
|
||||||
td(reservedResources.toString()).
|
td(reservedResources.getFormattedString()).
|
||||||
td(String.valueOf(clusterMetrics.getUtilizedMBPercent())).
|
td(String.valueOf(clusterMetrics.getUtilizedMBPercent())).
|
||||||
td(String.valueOf(clusterMetrics.getUtilizedVirtualCoresPercent())).
|
td(String.valueOf(clusterMetrics.getUtilizedVirtualCoresPercent())).
|
||||||
__().
|
__().
|
||||||
|
Loading…
Reference in New Issue
Block a user