hadoop-common-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a.@apache.org
Subject svn commit: r396706 - /lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSck.java
Date Mon, 24 Apr 2006 22:46:29 GMT
Author: ab
Date: Mon Apr 24 15:46:26 2006
New Revision: 396706

URL: http://svn.apache.org/viewcvs?rev=396706&view=rev
Log:
Fix for HADOOP-154 (fixed in other relevant places, too).

Modified:
    lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSck.java

Modified: lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSck.java
URL: http://svn.apache.org/viewcvs/lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSck.java?rev=396706&r1=396705&r2=396706&view=diff
==============================================================================
--- lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSck.java (original)
+++ lucene/hadoop/trunk/src/java/org/apache/hadoop/dfs/DFSck.java Mon Apr 24 15:46:26 2006
@@ -20,7 +20,6 @@
 import java.io.DataInputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
-import java.lang.reflect.Method;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.util.ArrayList;
@@ -495,7 +494,9 @@
 
     /** Return the actual replication factor. */
     public float getReplicationFactor() {
-      return (float)(totalBlocks * replication + overReplicatedBlocks - underReplicatedBlocks)
/ (float)totalBlocks;
+      if (totalBlocks != 0)
+        return (float)(totalBlocks * replication + overReplicatedBlocks - underReplicatedBlocks)
/ (float)totalBlocks;
+      else return 0.0f;
     }
 
     /** Return the number of under-replicated blocks. Note: missing blocks are not counted
here.*/
@@ -560,7 +561,8 @@
       StringBuffer res = new StringBuffer();
       res.append("Status: " + (isHealthy() ? "HEALTHY" : "CORRUPT"));
       res.append("\n Total size:\t" + totalSize + " B");
-      res.append("\n Total blocks:\t" + totalBlocks + " (avg. block size "
+      res.append("\n Total blocks:\t" + totalBlocks);
+      if (totalBlocks > 0) res.append(" (avg. block size "
               + (totalSize / totalBlocks) + " B)");
       res.append("\n Total dirs:\t" + totalDirs);
       res.append("\n Total files:\t" + totalFiles);
@@ -571,11 +573,13 @@
         res.append("\n  MISSING SIZE:\t\t" + missingSize + " B");
         res.append("\n  ********************************");
       }
-      res.append("\n Over-replicated blocks:\t" + overReplicatedBlocks
-              + " (" + ((float)(overReplicatedBlocks * 100) / (float)totalBlocks)
+      res.append("\n Over-replicated blocks:\t" + overReplicatedBlocks);
+      if (totalBlocks > 0) res.append(" ("
+              + ((float)(overReplicatedBlocks * 100) / (float)totalBlocks)
               + " %)");
-      res.append("\n Under-replicated blocks:\t" + underReplicatedBlocks
-              + " (" + ((float)(underReplicatedBlocks * 100) / (float)totalBlocks)
+      res.append("\n Under-replicated blocks:\t" + underReplicatedBlocks);
+      if (totalBlocks > 0) res.append(" ("
+              + ((float)(underReplicatedBlocks * 100) / (float)totalBlocks)
               + " %)");
       res.append("\n Target replication factor:\t" + replication);
       res.append("\n Real replication factor:\t" + getReplicationFactor());



Mime
View raw message