HDFS-2238. In NamenodeFsck.toString(), uses StringBuilder.(..) instead of string concatenation. Contributed by Uma Maheswara Rao G

git-svn-id: https://svn.apache.org/repos/asf/hadoop/common/trunk@1154973 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Tsz-wo Sze 2011-08-08 14:27:53 +00:00
parent 371f4a5905
commit 498e290103
2 changed files with 68 additions and 34 deletions

View File

@ -644,6 +644,9 @@ Trunk (unreleased changes)
HDFS-2228. Move block and datanode code from FSNamesystem to HDFS-2228. Move block and datanode code from FSNamesystem to
BlockManager and DatanodeManager. (szetszwo) BlockManager and DatanodeManager. (szetszwo)
HDFS-2238. In NamenodeFsck.toString(), uses StringBuilder.(..) instead of
string concatenation. (Uma Maheswara Rao G via szetszwo)
OPTIMIZATIONS OPTIMIZATIONS
HDFS-1458. Improve checkpoint performance by avoiding unnecessary image HDFS-1458. Improve checkpoint performance by avoiding unnecessary image

View File

@ -646,46 +646,77 @@ float getReplicationFactor() {
/** {@inheritDoc} */ /** {@inheritDoc} */
public String toString() { public String toString() {
StringBuilder res = new StringBuilder(); StringBuilder res = new StringBuilder();
res.append("Status: " + (isHealthy() ? "HEALTHY" : "CORRUPT")); res.append("Status: ").append((isHealthy() ? "HEALTHY" : "CORRUPT"))
res.append("\n Total size:\t" + totalSize + " B"); .append("\n Total size:\t").append(totalSize).append(" B");
if (totalOpenFilesSize != 0) if (totalOpenFilesSize != 0) {
res.append(" (Total open files size: " + totalOpenFilesSize + " B)"); res.append(" (Total open files size: ").append(totalOpenFilesSize)
res.append("\n Total dirs:\t" + totalDirs); .append(" B)");
res.append("\n Total files:\t" + totalFiles); }
if (totalOpenFiles != 0) res.append("\n Total dirs:\t").append(totalDirs).append(
res.append(" (Files currently being written: " + "\n Total files:\t").append(totalFiles);
totalOpenFiles + ")"); if (totalOpenFiles != 0) {
res.append("\n Total blocks (validated):\t" + totalBlocks); res.append(" (Files currently being written: ").append(totalOpenFiles)
if (totalBlocks > 0) res.append(" (avg. block size " .append(")");
+ (totalSize / totalBlocks) + " B)"); }
if (totalOpenFilesBlocks != 0) res.append("\n Total blocks (validated):\t").append(totalBlocks);
res.append(" (Total open file blocks (not validated): " + if (totalBlocks > 0) {
totalOpenFilesBlocks + ")"); res.append(" (avg. block size ").append((totalSize / totalBlocks))
if (corruptFiles > 0) { .append(" B)");
res.append("\n ********************************"); }
res.append("\n CORRUPT FILES:\t" + corruptFiles); if (totalOpenFilesBlocks != 0) {
res.append(" (Total open file blocks (not validated): ").append(
totalOpenFilesBlocks).append(")");
}
if (corruptFiles > 0) {
res.append("\n ********************************").append(
"\n CORRUPT FILES:\t").append(corruptFiles);
if (missingSize > 0) { if (missingSize > 0) {
res.append("\n MISSING BLOCKS:\t" + missingIds.size()); res.append("\n MISSING BLOCKS:\t").append(missingIds.size()).append(
res.append("\n MISSING SIZE:\t\t" + missingSize + " B"); "\n MISSING SIZE:\t\t").append(missingSize).append(" B");
} }
if (corruptBlocks > 0) { if (corruptBlocks > 0) {
res.append("\n CORRUPT BLOCKS: \t" + corruptBlocks); res.append("\n CORRUPT BLOCKS: \t").append(corruptBlocks);
} }
res.append("\n ********************************"); res.append("\n ********************************");
} }
res.append("\n Minimally replicated blocks:\t" + numMinReplicatedBlocks); res.append("\n Minimally replicated blocks:\t").append(
if (totalBlocks > 0) res.append(" (" + ((float) (numMinReplicatedBlocks * 100) / (float) totalBlocks) + " %)"); numMinReplicatedBlocks);
res.append("\n Over-replicated blocks:\t" + numOverReplicatedBlocks); if (totalBlocks > 0) {
if (totalBlocks > 0) res.append(" (" + ((float) (numOverReplicatedBlocks * 100) / (float) totalBlocks) + " %)"); res.append(" (").append(
res.append("\n Under-replicated blocks:\t" + numUnderReplicatedBlocks); ((float) (numMinReplicatedBlocks * 100) / (float) totalBlocks))
if (totalBlocks > 0) res.append(" (" + ((float) (numUnderReplicatedBlocks * 100) / (float) totalBlocks) + " %)"); .append(" %)");
res.append("\n Mis-replicated blocks:\t\t" + numMisReplicatedBlocks); }
if (totalBlocks > 0) res.append(" (" + ((float) (numMisReplicatedBlocks * 100) / (float) totalBlocks) + " %)"); res.append("\n Over-replicated blocks:\t")
res.append("\n Default replication factor:\t" + replication); .append(numOverReplicatedBlocks);
res.append("\n Average block replication:\t" + getReplicationFactor()); if (totalBlocks > 0) {
res.append("\n Corrupt blocks:\t\t" + corruptBlocks); res.append(" (").append(
res.append("\n Missing replicas:\t\t" + missingReplicas); ((float) (numOverReplicatedBlocks * 100) / (float) totalBlocks))
if (totalReplicas > 0) res.append(" (" + ((float) (missingReplicas * 100) / (float) totalReplicas) + " %)"); .append(" %)");
}
res.append("\n Under-replicated blocks:\t").append(
numUnderReplicatedBlocks);
if (totalBlocks > 0) {
res.append(" (").append(
((float) (numUnderReplicatedBlocks * 100) / (float) totalBlocks))
.append(" %)");
}
res.append("\n Mis-replicated blocks:\t\t")
.append(numMisReplicatedBlocks);
if (totalBlocks > 0) {
res.append(" (").append(
((float) (numMisReplicatedBlocks * 100) / (float) totalBlocks))
.append(" %)");
}
res.append("\n Default replication factor:\t").append(replication)
.append("\n Average block replication:\t").append(
getReplicationFactor()).append("\n Corrupt blocks:\t\t").append(
corruptBlocks).append("\n Missing replicas:\t\t").append(
missingReplicas);
if (totalReplicas > 0) {
res.append(" (").append(
((float) (missingReplicas * 100) / (float) totalReplicas)).append(
" %)");
}
return res.toString(); return res.toString();
} }
} }