Quellcode durchsuchen

HADOOP-324. Fix datanode to not exit when a disk is full, but simply to fail writes. Contributed by Wendy Chien.

git-svn-id: https://svn.apache.org/repos/asf/lucene/hadoop/trunk@430085 13f79535-47bb-0310-9956-ffa450edef68
Doug Cutting vor 19 Jahren
Ursprung
Commit
e2abfbeac1

+ 3 - 0
CHANGES.txt

@@ -16,6 +16,9 @@ Trunk (unreleased changes)
     available).  Also, tasks are better load-balanced among nodes.
     available).  Also, tasks are better load-balanced among nodes.
     (omalley via cutting)
     (omalley via cutting)
 
 
+ 4. HADOOP-324.  Fix datanode to not exit when a disk is full, but
+    rather simply to fail writes.  (Wendy Chien via cutting)
+
 
 
 Release 0.5.0 - 2006-08-04
 Release 0.5.0 - 2006-08-04
 
 

+ 7 - 2
src/java/org/apache/hadoop/dfs/DataNode.java

@@ -22,6 +22,7 @@ import org.apache.hadoop.conf.*;
 import org.apache.hadoop.metrics.Metrics;
 import org.apache.hadoop.metrics.Metrics;
 import org.apache.hadoop.util.*;
 import org.apache.hadoop.util.*;
 import org.apache.hadoop.util.DiskChecker.DiskErrorException;
 import org.apache.hadoop.util.DiskChecker.DiskErrorException;
+import org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException;
 import org.apache.hadoop.mapred.StatusHttpServer;
 import org.apache.hadoop.mapred.StatusHttpServer;
 
 
 import java.io.*;
 import java.io.*;
@@ -726,8 +727,12 @@ public class DataNode implements FSConstants, Runnable {
                       out.write(buf, 0, bytesRead);
                       out.write(buf, 0, bytesRead);
                       myMetrics.wroteBytes(bytesRead);
                       myMetrics.wroteBytes(bytesRead);
                     } catch (IOException iex) {
                     } catch (IOException iex) {
-                      shutdown();
-                      throw iex;
+                      if (iex.getMessage().startsWith("No space left on device")) {
+                    	  throw new DiskOutOfSpaceException("No space left on device");
+                      } else {
+                        shutdown();
+                        throw iex;
+                      }
                     }
                     }
                     if (out2 != null) {
                     if (out2 != null) {
                       try {
                       try {

+ 2 - 1
src/java/org/apache/hadoop/dfs/FSDataset.java

@@ -21,6 +21,7 @@ import java.util.*;
 import org.apache.hadoop.fs.*;
 import org.apache.hadoop.fs.*;
 import org.apache.hadoop.util.DiskChecker;
 import org.apache.hadoop.util.DiskChecker;
 import org.apache.hadoop.util.DiskChecker.DiskErrorException;
 import org.apache.hadoop.util.DiskChecker.DiskErrorException;
+import org.apache.hadoop.util.DiskChecker.DiskOutOfSpaceException;
 import org.apache.hadoop.conf.*;
 import org.apache.hadoop.conf.*;
 
 
 /**************************************************
 /**************************************************
@@ -302,7 +303,7 @@ class FSDataset implements FSConstants {
             // Check if we have too little space
             // Check if we have too little space
             //
             //
             if (getRemaining() < blockSize) {
             if (getRemaining() < blockSize) {
-                throw new IOException("Insufficient space for an additional block");
+                throw new DiskOutOfSpaceException("Insufficient space for an additional block");
             }
             }
 
 
             //
             //

+ 6 - 0
src/java/org/apache/hadoop/util/DiskChecker.java

@@ -16,6 +16,12 @@ public class DiskChecker {
       }
       }
     }
     }
     
     
+    public static class DiskOutOfSpaceException extends IOException {
+        public DiskOutOfSpaceException(String msg) {
+          super(msg);
+        }
+      }
+      
     public static void checkDir( File dir ) throws DiskErrorException {
     public static void checkDir( File dir ) throws DiskErrorException {
         if( !dir.exists() && !dir.mkdirs() )
         if( !dir.exists() && !dir.mkdirs() )
             throw new DiskErrorException( "can not create directory: " 
             throw new DiskErrorException( "can not create directory: "